From 744cb4d2c908a025204d9d5d0d1c038acd51db11 Mon Sep 17 00:00:00 2001 From: Mike Pennisi <mike@mikepennisi.com> Date: Thu, 2 Jun 2016 14:30:33 -0400 Subject: [PATCH 1/8] Add templates for destructuring with dflt params --- .../default/arrow-function-dflt.template | 48 ++++++++++++ .../default/cls-decl-gen-meth-dflt.template | 71 ++++++++++++++++++ .../cls-decl-gen-meth-static-dflt.template | 71 ++++++++++++++++++ .../default/cls-decl-meth-dflt.template | 69 ++++++++++++++++++ .../cls-decl-meth-static-dflt.template | 69 ++++++++++++++++++ .../default/cls-expr-gen-meth-dflt.template | 73 +++++++++++++++++++ .../cls-expr-gen-meth-static-dflt.template | 73 +++++++++++++++++++ .../default/cls-expr-meth-dflt.template | 70 ++++++++++++++++++ .../cls-expr-meth-static-dflt.template | 70 ++++++++++++++++++ .../default/func-decl-dflt.template | 48 ++++++++++++ .../default/func-expr-dflt.template | 49 +++++++++++++ .../default/gen-func-decl-dflt.template | 47 ++++++++++++ .../default/gen-func-expr-dflt.template | 49 +++++++++++++ .../default/gen-method-dflt.template | 55 ++++++++++++++ src/dstr-binding/default/meth-dflt.template | 52 +++++++++++++ .../error/arrow-function-dflt.template | 44 +++++++++++ .../error/cls-decl-gen-meth-dflt.template | 69 ++++++++++++++++++ .../cls-decl-gen-meth-static-dflt.template | 68 +++++++++++++++++ .../error/cls-decl-meth-dflt.template | 68 +++++++++++++++++ .../error/cls-decl-meth-static-dflt.template | 66 +++++++++++++++++ .../error/cls-expr-gen-meth-dflt.template | 71 ++++++++++++++++++ .../cls-expr-gen-meth-static-dflt.template | 70 ++++++++++++++++++ .../error/cls-expr-meth-dflt.template | 69 ++++++++++++++++++ .../error/cls-expr-meth-static-dflt.template | 67 +++++++++++++++++ .../error/func-decl-dflt.template | 46 ++++++++++++ .../error/func-expr-dflt.template | 45 ++++++++++++ .../error/gen-func-decl-dflt.template | 45 ++++++++++++ .../error/gen-func-expr-dflt.template | 45 ++++++++++++ src/dstr-binding/error/gen-meth-dflt.template | 52 +++++++++++++ src/dstr-binding/error/meth-dflt.template | 49 +++++++++++++ 30 files changed, 1788 insertions(+) create mode 100644 src/dstr-binding/default/arrow-function-dflt.template create mode 100644 src/dstr-binding/default/cls-decl-gen-meth-dflt.template create mode 100644 src/dstr-binding/default/cls-decl-gen-meth-static-dflt.template create mode 100644 src/dstr-binding/default/cls-decl-meth-dflt.template create mode 100644 src/dstr-binding/default/cls-decl-meth-static-dflt.template create mode 100644 src/dstr-binding/default/cls-expr-gen-meth-dflt.template create mode 100644 src/dstr-binding/default/cls-expr-gen-meth-static-dflt.template create mode 100644 src/dstr-binding/default/cls-expr-meth-dflt.template create mode 100644 src/dstr-binding/default/cls-expr-meth-static-dflt.template create mode 100644 src/dstr-binding/default/func-decl-dflt.template create mode 100644 src/dstr-binding/default/func-expr-dflt.template create mode 100644 src/dstr-binding/default/gen-func-decl-dflt.template create mode 100644 src/dstr-binding/default/gen-func-expr-dflt.template create mode 100644 src/dstr-binding/default/gen-method-dflt.template create mode 100644 src/dstr-binding/default/meth-dflt.template create mode 100644 src/dstr-binding/error/arrow-function-dflt.template create mode 100644 src/dstr-binding/error/cls-decl-gen-meth-dflt.template create mode 100644 src/dstr-binding/error/cls-decl-gen-meth-static-dflt.template create mode 100644 src/dstr-binding/error/cls-decl-meth-dflt.template create mode 100644 src/dstr-binding/error/cls-decl-meth-static-dflt.template create mode 100644 src/dstr-binding/error/cls-expr-gen-meth-dflt.template create mode 100644 src/dstr-binding/error/cls-expr-gen-meth-static-dflt.template create mode 100644 src/dstr-binding/error/cls-expr-meth-dflt.template create mode 100644 src/dstr-binding/error/cls-expr-meth-static-dflt.template create mode 100644 src/dstr-binding/error/func-decl-dflt.template create mode 100644 src/dstr-binding/error/func-expr-dflt.template create mode 100644 src/dstr-binding/error/gen-func-decl-dflt.template create mode 100644 src/dstr-binding/error/gen-func-expr-dflt.template create mode 100644 src/dstr-binding/error/gen-meth-dflt.template create mode 100644 src/dstr-binding/error/meth-dflt.template diff --git a/src/dstr-binding/default/arrow-function-dflt.template b/src/dstr-binding/default/arrow-function-dflt.template new file mode 100644 index 0000000000..b6e0eabd9b --- /dev/null +++ b/src/dstr-binding/default/arrow-function-dflt.template @@ -0,0 +1,48 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/expressions/arrow-function/dstr-dflt- +name: arrow function expression (default parameter) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +es6id: 14.2.16 +features: [destructuring-binding, default-parameters] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +var callCount = 0; +var f; +f = (/*{ elems }*/ = /*{ vals }*/) => { + /*{ body }*/ + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); diff --git a/src/dstr-binding/default/cls-decl-gen-meth-dflt.template b/src/dstr-binding/default/cls-decl-gen-meth-dflt.template new file mode 100644 index 0000000000..3523cd63b9 --- /dev/null +++ b/src/dstr-binding/default/cls-decl-gen-meth-dflt.template @@ -0,0 +1,71 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/statements/class/dstr-gen-meth-dflt- +name: class expression method (default parameters) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +var callCount = 0; +class C { + *method(/*{ elems }*/ = /*{ vals }*/) { + /*{ body }*/ + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/src/dstr-binding/default/cls-decl-gen-meth-static-dflt.template b/src/dstr-binding/default/cls-decl-gen-meth-static-dflt.template new file mode 100644 index 0000000000..bb257929b9 --- /dev/null +++ b/src/dstr-binding/default/cls-decl-gen-meth-static-dflt.template @@ -0,0 +1,71 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/statements/class/dstr-gen-meth-static-dflt- +name: static class expression generator method (default parameter) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +var callCount = 0; +class C { + static *method(/*{ elems }*/ = /*{ vals }*/) { + /*{ body }*/ + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/src/dstr-binding/default/cls-decl-meth-dflt.template b/src/dstr-binding/default/cls-decl-meth-dflt.template new file mode 100644 index 0000000000..9a073c5b74 --- /dev/null +++ b/src/dstr-binding/default/cls-decl-meth-dflt.template @@ -0,0 +1,69 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/statements/class/dstr-meth-dflt- +name: class expression method (default parameter) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +var callCount = 0; +class C { + method(/*{ elems }*/ = /*{ vals }*/) { + /*{ body }*/ + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/src/dstr-binding/default/cls-decl-meth-static-dflt.template b/src/dstr-binding/default/cls-decl-meth-static-dflt.template new file mode 100644 index 0000000000..07f25960ab --- /dev/null +++ b/src/dstr-binding/default/cls-decl-meth-static-dflt.template @@ -0,0 +1,69 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/statements/class/dstr-meth-static-dflt- +name: static class expression method (default parameter) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +var callCount = 0; +class C { + static method(/*{ elems }*/ = /*{ vals }*/) { + /*{ body }*/ + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/src/dstr-binding/default/cls-expr-gen-meth-dflt.template b/src/dstr-binding/default/cls-expr-gen-meth-dflt.template new file mode 100644 index 0000000000..b8963fdc05 --- /dev/null +++ b/src/dstr-binding/default/cls-expr-gen-meth-dflt.template @@ -0,0 +1,73 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/expressions/class/dstr-gen-meth-dflt- +name: class expression method (default parameter) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +var callCount = 0; +var C = class { + *method(/*{ elems }*/ = /*{ vals }*/) { + /*{ body }*/ + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/src/dstr-binding/default/cls-expr-gen-meth-static-dflt.template b/src/dstr-binding/default/cls-expr-gen-meth-static-dflt.template new file mode 100644 index 0000000000..fd512fc015 --- /dev/null +++ b/src/dstr-binding/default/cls-expr-gen-meth-static-dflt.template @@ -0,0 +1,73 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/expressions/class/dstr-gen-meth-static-dflt- +name: static class expression generator method (default parameter) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +var callCount = 0; +var C = class { + static *method(/*{ elems }*/ = /*{ vals }*/) { + /*{ body }*/ + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/src/dstr-binding/default/cls-expr-meth-dflt.template b/src/dstr-binding/default/cls-expr-meth-dflt.template new file mode 100644 index 0000000000..c2a5f0e4ad --- /dev/null +++ b/src/dstr-binding/default/cls-expr-meth-dflt.template @@ -0,0 +1,70 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/expressions/class/dstr-meth-dflt- +name: class expression method (default parameter) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +var callCount = 0; +var C = class { + method(/*{ elems }*/ = /*{ vals }*/) { + /*{ body }*/ + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/src/dstr-binding/default/cls-expr-meth-static-dflt.template b/src/dstr-binding/default/cls-expr-meth-static-dflt.template new file mode 100644 index 0000000000..831d74e41a --- /dev/null +++ b/src/dstr-binding/default/cls-expr-meth-static-dflt.template @@ -0,0 +1,70 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/expressions/class/dstr-meth-static-dflt- +name: static class expression method (default parameter) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +var callCount = 0; +var C = class { + static method(/*{ elems }*/ = /*{ vals }*/) { + /*{ body }*/ + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/src/dstr-binding/default/func-decl-dflt.template b/src/dstr-binding/default/func-decl-dflt.template new file mode 100644 index 0000000000..9b58d5a198 --- /dev/null +++ b/src/dstr-binding/default/func-decl-dflt.template @@ -0,0 +1,48 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/statements/function/dstr-dflt- +name: function declaration (default parameter) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.1.19 +features: [destructuring-binding, default-parameters] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +var callCount = 0; +function f(/*{ elems }*/ = /*{ vals }*/) { + /*{ body }*/ + callCount = callCount + 1; +}; +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/src/dstr-binding/default/func-expr-dflt.template b/src/dstr-binding/default/func-expr-dflt.template new file mode 100644 index 0000000000..bee2b4aa22 --- /dev/null +++ b/src/dstr-binding/default/func-expr-dflt.template @@ -0,0 +1,49 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/expressions/function/dstr-dflt- +name: function expression (default parameter) +esid: sec-function-definitions-runtime-semantics-evaluation +es6id: 14.1.20 +features: [destructuring-binding, default-parameters] +info: | + FunctionExpression : function ( FormalParameters ) { FunctionBody } + + [...] + 3. Let closure be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +var callCount = 0; +var f; +f = function(/*{ elems }*/ = /*{ vals }*/) { + /*{ body }*/ + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/src/dstr-binding/default/gen-func-decl-dflt.template b/src/dstr-binding/default/gen-func-decl-dflt.template new file mode 100644 index 0000000000..a5eb965ab0 --- /dev/null +++ b/src/dstr-binding/default/gen-func-decl-dflt.template @@ -0,0 +1,47 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/statements/generators/dstr-dflt- +name: generator function declaration (default parameter) +esid: sec-generator-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.4.12 +features: [destructuring-binding, default-parameters] +info: | + GeneratorDeclaration : function * ( FormalParameters ) { GeneratorBody } + + [...] + 2. Let F be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +var callCount = 0; +function* f(/*{ elems }*/ = /*{ vals }*/) { + /*{ body }*/ + callCount = callCount + 1; +}; +f().next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/src/dstr-binding/default/gen-func-expr-dflt.template b/src/dstr-binding/default/gen-func-expr-dflt.template new file mode 100644 index 0000000000..f3f16ae6d8 --- /dev/null +++ b/src/dstr-binding/default/gen-func-expr-dflt.template @@ -0,0 +1,49 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/expressions/generators/dstr-dflt- +name: generator function expression (default parameter) +esid: sec-generator-function-definitions-runtime-semantics-evaluation +es6id: 14.4.14 +features: [destructuring-binding, default-parameters] +info: | + GeneratorExpression : function * ( FormalParameters ) { GeneratorBody } + + [...] + 3. Let closure be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +var callCount = 0; +var f; +f = function*(/*{ elems }*/ = /*{ vals }*/) { + /*{ body }*/ + callCount = callCount + 1; +}; + +f().next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/src/dstr-binding/default/gen-method-dflt.template b/src/dstr-binding/default/gen-method-dflt.template new file mode 100644 index 0000000000..0a75534c61 --- /dev/null +++ b/src/dstr-binding/default/gen-method-dflt.template @@ -0,0 +1,55 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/expressions/object/dstr-gen-meth-dflt- +name: generator method (default parameter) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +es6id: 14.4.13 +features: [destructuring-binding, default-parameters] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +var callCount = 0; +var obj = { + *method(/*{ elems }*/ = /*{ vals }*/) { + /*{ body }*/ + callCount = callCount + 1; + } +}; + +obj.method().next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); diff --git a/src/dstr-binding/default/meth-dflt.template b/src/dstr-binding/default/meth-dflt.template new file mode 100644 index 0000000000..3a8b825e7e --- /dev/null +++ b/src/dstr-binding/default/meth-dflt.template @@ -0,0 +1,52 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/expressions/object/dstr-meth-dflt- +name: method (default parameter) +esid: sec-runtime-semantics-definemethod +es6id: 14.3.8 +features: [destructuring-binding, default-parameters] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +var callCount = 0; +var obj = { + method(/*{ elems }*/ = /*{ vals }*/) { + /*{ body }*/ + callCount = callCount + 1; + } +}; + +obj.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/src/dstr-binding/error/arrow-function-dflt.template b/src/dstr-binding/error/arrow-function-dflt.template new file mode 100644 index 0000000000..268fbe58b8 --- /dev/null +++ b/src/dstr-binding/error/arrow-function-dflt.template @@ -0,0 +1,44 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/expressions/arrow-function/dstr-dflt- +name: arrow function expression (default parameter) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +es6id: 14.2.16 +features: [destructuring-binding, default-parameters] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +var f = (/*{ elems }*/ = /*{ vals }*/) => {}; + +assert.throws(/*{ error }*/, function() { + f(); +}); diff --git a/src/dstr-binding/error/cls-decl-gen-meth-dflt.template b/src/dstr-binding/error/cls-decl-gen-meth-dflt.template new file mode 100644 index 0000000000..48479af1b1 --- /dev/null +++ b/src/dstr-binding/error/cls-decl-gen-meth-dflt.template @@ -0,0 +1,69 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/statements/class/dstr-gen-meth-dflt- +name: class expression method (default parameter) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +class C { + *method(/*{ elems }*/ = /*{ vals }*/) {} +}; +var c = new C(); + +assert.throws(/*{ error }*/, function() { + c.method(); +}); diff --git a/src/dstr-binding/error/cls-decl-gen-meth-static-dflt.template b/src/dstr-binding/error/cls-decl-gen-meth-static-dflt.template new file mode 100644 index 0000000000..ba0ee63759 --- /dev/null +++ b/src/dstr-binding/error/cls-decl-gen-meth-static-dflt.template @@ -0,0 +1,68 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/statements/class/dstr-gen-meth-static-dflt- +name: static class expression generator method (default parameter) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +class C { + static *method(/*{ elems }*/ = /*{ vals }*/) {} +}; + +assert.throws(/*{ error }*/, function() { + C.method(); +}); diff --git a/src/dstr-binding/error/cls-decl-meth-dflt.template b/src/dstr-binding/error/cls-decl-meth-dflt.template new file mode 100644 index 0000000000..6824a0a039 --- /dev/null +++ b/src/dstr-binding/error/cls-decl-meth-dflt.template @@ -0,0 +1,68 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/statements/class/dstr-meth-dflt- +name: class expression method (default parameter) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +class C { + method(/*{ elems }*/ = /*{ vals }*/) {} +}; + +var c = new C(); + +assert.throws(/*{ error }*/, function() { + c.method(); +}); diff --git a/src/dstr-binding/error/cls-decl-meth-static-dflt.template b/src/dstr-binding/error/cls-decl-meth-static-dflt.template new file mode 100644 index 0000000000..7c86010dbf --- /dev/null +++ b/src/dstr-binding/error/cls-decl-meth-static-dflt.template @@ -0,0 +1,66 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/statements/class/dstr-meth-static-dflt- +name: static class expression method (default parameter) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +class C { + static method(/*{ elems }*/ = /*{ vals }*/) {} +}; + +assert.throws(/*{ error }*/, function() { + C.method(); +}); diff --git a/src/dstr-binding/error/cls-expr-gen-meth-dflt.template b/src/dstr-binding/error/cls-expr-gen-meth-dflt.template new file mode 100644 index 0000000000..e6bdc24765 --- /dev/null +++ b/src/dstr-binding/error/cls-expr-gen-meth-dflt.template @@ -0,0 +1,71 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/expressions/class/dstr-gen-meth-dflt- +name: class expression method (default parameter) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +var C = class { + *method(/*{ elems }*/ = /*{ vals }*/) {} +}; +var c = new C(); + +assert.throws(/*{ error }*/, function() { + c.method(); +}); diff --git a/src/dstr-binding/error/cls-expr-gen-meth-static-dflt.template b/src/dstr-binding/error/cls-expr-gen-meth-static-dflt.template new file mode 100644 index 0000000000..75cd41fe88 --- /dev/null +++ b/src/dstr-binding/error/cls-expr-gen-meth-static-dflt.template @@ -0,0 +1,70 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/expressions/class/dstr-gen-meth-static-dflt- +name: static class expression generator method (default parameter) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +var C = class { + static *method(/*{ elems }*/ = /*{ vals }*/) {} +}; + +assert.throws(/*{ error }*/, function() { + C.method(); +}); diff --git a/src/dstr-binding/error/cls-expr-meth-dflt.template b/src/dstr-binding/error/cls-expr-meth-dflt.template new file mode 100644 index 0000000000..0f1465a2b1 --- /dev/null +++ b/src/dstr-binding/error/cls-expr-meth-dflt.template @@ -0,0 +1,69 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/expressions/class/dstr-meth-dflt- +name: class expression method (default parameter) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +var C = class { + method(/*{ elems }*/ = /*{ vals }*/) {} +}; + +var c = new C(); + +assert.throws(/*{ error }*/, function() { + c.method(); +}); diff --git a/src/dstr-binding/error/cls-expr-meth-static-dflt.template b/src/dstr-binding/error/cls-expr-meth-static-dflt.template new file mode 100644 index 0000000000..e623115df5 --- /dev/null +++ b/src/dstr-binding/error/cls-expr-meth-static-dflt.template @@ -0,0 +1,67 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/expressions/class/dstr-meth-static-dflt- +name: static class expression method (default parameter) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +var C = class { + static method(/*{ elems }*/ = /*{ vals }*/) {} +}; + +assert.throws(/*{ error }*/, function() { + C.method(); +}); diff --git a/src/dstr-binding/error/func-decl-dflt.template b/src/dstr-binding/error/func-decl-dflt.template new file mode 100644 index 0000000000..ebadbe395e --- /dev/null +++ b/src/dstr-binding/error/func-decl-dflt.template @@ -0,0 +1,46 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/statements/function/dstr-dflt- +name: function declaration (default parameter) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.1.19 +features: [destructuring-binding, default-parameters] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +function f(/*{ elems }*/ = /*{ vals }*/) {} + +assert.throws(/*{ error }*/, function() { + f(); +}); diff --git a/src/dstr-binding/error/func-expr-dflt.template b/src/dstr-binding/error/func-expr-dflt.template new file mode 100644 index 0000000000..29c03f558e --- /dev/null +++ b/src/dstr-binding/error/func-expr-dflt.template @@ -0,0 +1,45 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/expressions/function/dstr-dflt- +name: function expression (default parameter) +esid: sec-function-definitions-runtime-semantics-evaluation +es6id: 14.1.20 +features: [destructuring-binding, default-parameters] +info: | + FunctionExpression : function ( FormalParameters ) { FunctionBody } + + [...] + 3. Let closure be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +var f = function(/*{ elems }*/ = /*{ vals }*/) {}; + +assert.throws(/*{ error }*/, function() { + f(); +}); diff --git a/src/dstr-binding/error/gen-func-decl-dflt.template b/src/dstr-binding/error/gen-func-decl-dflt.template new file mode 100644 index 0000000000..523836662b --- /dev/null +++ b/src/dstr-binding/error/gen-func-decl-dflt.template @@ -0,0 +1,45 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/statements/generators/dstr-dflt- +name: generator function declaration (default parameter) +esid: sec-generator-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.4.12 +features: [destructuring-binding, default-parameters] +info: | + GeneratorDeclaration : function * ( FormalParameters ) { GeneratorBody } + + [...] + 2. Let F be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +function* f(/*{ elems }*/ = /*{ vals }*/) {} + +assert.throws(/*{ error }*/, function() { + f(); +}); diff --git a/src/dstr-binding/error/gen-func-expr-dflt.template b/src/dstr-binding/error/gen-func-expr-dflt.template new file mode 100644 index 0000000000..2689749a29 --- /dev/null +++ b/src/dstr-binding/error/gen-func-expr-dflt.template @@ -0,0 +1,45 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/expressions/generators/dstr-dflt- +name: generator function expression (default parameter) +esid: sec-generator-function-definitions-runtime-semantics-evaluation +es6id: 14.4.14 +features: [destructuring-binding, default-parameters] +info: | + GeneratorExpression : function * ( FormalParameters ) { GeneratorBody } + + [...] + 3. Let closure be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +var f = function*(/*{ elems }*/ = /*{ vals }*/) {}; + +assert.throws(/*{ error }*/, function() { + f(); +}); diff --git a/src/dstr-binding/error/gen-meth-dflt.template b/src/dstr-binding/error/gen-meth-dflt.template new file mode 100644 index 0000000000..d738d6b2d3 --- /dev/null +++ b/src/dstr-binding/error/gen-meth-dflt.template @@ -0,0 +1,52 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/expressions/object/dstr-gen-meth-dflt- +name: generator method (default parameter) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +es6id: 14.4.13 +features: [destructuring-binding, default-parameters] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +var obj = { + *method(/*{ elems }*/ = /*{ vals }*/) {} +}; + +assert.throws(/*{ error }*/, function() { + obj.method(); +}); diff --git a/src/dstr-binding/error/meth-dflt.template b/src/dstr-binding/error/meth-dflt.template new file mode 100644 index 0000000000..e56ffd0b2c --- /dev/null +++ b/src/dstr-binding/error/meth-dflt.template @@ -0,0 +1,49 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/expressions/object/dstr-meth-dflt- +name: method (default parameter) +esid: sec-runtime-semantics-definemethod +es6id: 14.3.8 +features: [destructuring-binding, default-parameters] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +var obj = { + method(/*{ elems }*/ = /*{ vals }*/) {} +}; + +assert.throws(/*{ error }*/, function() { + obj.method(); +}); -- GitLab From a969e853e7d8a43f2f1c7579d5a3e4fc1aa2a2fc Mon Sep 17 00:00:00 2001 From: Mike Pennisi <mike@mikepennisi.com> Date: Thu, 2 Jun 2016 14:51:51 -0400 Subject: [PATCH 2/8] Generate tests --- .../dstr-dflt-ary-init-iter-close.js | 72 +++++++++++ .../dstr-dflt-ary-init-iter-get-err.js | 57 +++++++++ .../dstr-dflt-ary-init-iter-no-close.js | 72 +++++++++++ .../dstr-dflt-ary-name-iter-val.js | 71 +++++++++++ .../dstr-dflt-ary-ptrn-elem-ary-elem-init.js | 63 ++++++++++ .../dstr-dflt-ary-ptrn-elem-ary-elem-iter.js | 64 ++++++++++ ...str-dflt-ary-ptrn-elem-ary-elision-init.js | 70 +++++++++++ ...str-dflt-ary-ptrn-elem-ary-elision-iter.js | 67 ++++++++++ .../dstr-dflt-ary-ptrn-elem-ary-empty-init.js | 65 ++++++++++ .../dstr-dflt-ary-ptrn-elem-ary-empty-iter.js | 63 ++++++++++ .../dstr-dflt-ary-ptrn-elem-ary-rest-init.js | 67 ++++++++++ .../dstr-dflt-ary-ptrn-elem-ary-rest-iter.js | 70 +++++++++++ .../dstr-dflt-ary-ptrn-elem-ary-val-null.js | 64 ++++++++++ ...tr-dflt-ary-ptrn-elem-id-init-exhausted.js | 62 ++++++++++ ...flt-ary-ptrn-elem-id-init-fn-name-arrow.js | 63 ++++++++++ ...flt-ary-ptrn-elem-id-init-fn-name-class.js | 64 ++++++++++ ...flt-ary-ptrn-elem-id-init-fn-name-cover.js | 64 ++++++++++ ...r-dflt-ary-ptrn-elem-id-init-fn-name-fn.js | 64 ++++++++++ ...-dflt-ary-ptrn-elem-id-init-fn-name-gen.js | 64 ++++++++++ .../dstr-dflt-ary-ptrn-elem-id-init-hole.js | 58 +++++++++ ...dstr-dflt-ary-ptrn-elem-id-init-skipped.js | 67 ++++++++++ .../dstr-dflt-ary-ptrn-elem-id-init-throws.js | 55 +++++++++ .../dstr-dflt-ary-ptrn-elem-id-init-undef.js | 61 ++++++++++ ...dflt-ary-ptrn-elem-id-init-unresolvable.js | 62 ++++++++++ ...str-dflt-ary-ptrn-elem-id-iter-complete.js | 65 ++++++++++ .../dstr-dflt-ary-ptrn-elem-id-iter-done.js | 60 +++++++++ ...str-dflt-ary-ptrn-elem-id-iter-step-err.js | 63 ++++++++++ ...dstr-dflt-ary-ptrn-elem-id-iter-val-err.js | 74 +++++++++++ .../dstr-dflt-ary-ptrn-elem-id-iter-val.js | 71 +++++++++++ .../dstr-dflt-ary-ptrn-elem-obj-id-init.js | 63 ++++++++++ .../dstr-dflt-ary-ptrn-elem-obj-id.js | 63 ++++++++++ ...str-dflt-ary-ptrn-elem-obj-prop-id-init.js | 73 +++++++++++ .../dstr-dflt-ary-ptrn-elem-obj-prop-id.js | 73 +++++++++++ .../dstr-dflt-ary-ptrn-elem-obj-val-null.js | 64 ++++++++++ .../dstr-dflt-ary-ptrn-elem-obj-val-undef.js | 64 ++++++++++ .../dstr-dflt-ary-ptrn-elision-exhausted.js | 68 +++++++++++ .../dstr-dflt-ary-ptrn-elision-step-err.js | 71 +++++++++++ .../dstr-dflt-ary-ptrn-elision.js | 77 ++++++++++++ .../dstr-dflt-ary-ptrn-empty.js | 60 +++++++++ .../dstr-dflt-ary-ptrn-rest-ary-elem.js | 84 +++++++++++++ .../dstr-dflt-ary-ptrn-rest-ary-elision.js | 90 ++++++++++++++ .../dstr-dflt-ary-ptrn-rest-ary-empty.js | 73 +++++++++++ .../dstr-dflt-ary-ptrn-rest-ary-rest.js | 69 +++++++++++ ...-dflt-ary-ptrn-rest-id-elision-next-err.js | 57 +++++++++ .../dstr-dflt-ary-ptrn-rest-id-elision.js | 65 ++++++++++ .../dstr-dflt-ary-ptrn-rest-id-exhausted.js | 61 ++++++++++ ...str-dflt-ary-ptrn-rest-id-iter-step-err.js | 68 +++++++++++ ...dstr-dflt-ary-ptrn-rest-id-iter-val-err.js | 70 +++++++++++ .../dstr-dflt-ary-ptrn-rest-id.js | 62 ++++++++++ .../dstr-dflt-ary-ptrn-rest-init-ary.js | 56 +++++++++ .../dstr-dflt-ary-ptrn-rest-init-id.js | 56 +++++++++ .../dstr-dflt-ary-ptrn-rest-init-obj.js | 56 +++++++++ .../dstr-dflt-ary-ptrn-rest-not-final-ary.js | 56 +++++++++ .../dstr-dflt-ary-ptrn-rest-not-final-id.js | 56 +++++++++ .../dstr-dflt-ary-ptrn-rest-not-final-obj.js | 56 +++++++++ .../dstr-dflt-ary-ptrn-rest-obj-id.js | 62 ++++++++++ .../dstr-dflt-ary-ptrn-rest-obj-prop-id.js | 70 +++++++++++ .../arrow-function/dstr-dflt-obj-init-null.js | 51 ++++++++ .../dstr-dflt-obj-init-undefined.js | 51 ++++++++ .../dstr-dflt-obj-ptrn-empty.js | 61 ++++++++++ .../dstr-dflt-obj-ptrn-id-get-value-err.js | 58 +++++++++ ...str-dflt-obj-ptrn-id-init-fn-name-arrow.js | 62 ++++++++++ ...str-dflt-obj-ptrn-id-init-fn-name-class.js | 63 ++++++++++ ...str-dflt-obj-ptrn-id-init-fn-name-cover.js | 63 ++++++++++ .../dstr-dflt-obj-ptrn-id-init-fn-name-fn.js | 63 ++++++++++ .../dstr-dflt-obj-ptrn-id-init-fn-name-gen.js | 63 ++++++++++ .../dstr-dflt-obj-ptrn-id-init-skipped.js | 66 ++++++++++ .../dstr-dflt-obj-ptrn-id-init-throws.js | 58 +++++++++ ...dstr-dflt-obj-ptrn-id-init-unresolvable.js | 62 ++++++++++ .../dstr-dflt-obj-ptrn-id-trailing-comma.js | 56 +++++++++ .../dstr-dflt-obj-ptrn-list-err.js | 59 +++++++++ .../dstr-dflt-obj-ptrn-prop-ary-init.js | 65 ++++++++++ ...r-dflt-obj-ptrn-prop-ary-trailing-comma.js | 56 +++++++++ .../dstr-dflt-obj-ptrn-prop-ary-value-null.js | 53 ++++++++ .../dstr-dflt-obj-ptrn-prop-ary.js | 63 ++++++++++ .../dstr-dflt-obj-ptrn-prop-eval-err.js | 55 +++++++++ ...str-dflt-obj-ptrn-prop-id-get-value-err.js | 60 +++++++++ ...dstr-dflt-obj-ptrn-prop-id-init-skipped.js | 78 ++++++++++++ .../dstr-dflt-obj-ptrn-prop-id-init-throws.js | 58 +++++++++ ...dflt-obj-ptrn-prop-id-init-unresolvable.js | 62 ++++++++++ .../dstr-dflt-obj-ptrn-prop-id-init.js | 59 +++++++++ ...tr-dflt-obj-ptrn-prop-id-trailing-comma.js | 60 +++++++++ .../dstr-dflt-obj-ptrn-prop-id.js | 59 +++++++++ .../dstr-dflt-obj-ptrn-prop-obj-init.js | 65 ++++++++++ .../dstr-dflt-obj-ptrn-prop-obj-value-null.js | 53 ++++++++ ...dstr-dflt-obj-ptrn-prop-obj-value-undef.js | 53 ++++++++ .../dstr-dflt-obj-ptrn-prop-obj.js | 63 ++++++++++ .../dstr-gen-meth-dflt-ary-init-iter-close.js | 97 +++++++++++++++ ...str-gen-meth-dflt-ary-init-iter-get-err.js | 84 +++++++++++++ ...tr-gen-meth-dflt-ary-init-iter-no-close.js | 97 +++++++++++++++ .../dstr-gen-meth-dflt-ary-name-iter-val.js | 96 +++++++++++++++ ...n-meth-dflt-ary-ptrn-elem-ary-elem-init.js | 88 ++++++++++++++ ...n-meth-dflt-ary-ptrn-elem-ary-elem-iter.js | 89 ++++++++++++++ ...eth-dflt-ary-ptrn-elem-ary-elision-init.js | 95 +++++++++++++++ ...eth-dflt-ary-ptrn-elem-ary-elision-iter.js | 92 ++++++++++++++ ...-meth-dflt-ary-ptrn-elem-ary-empty-init.js | 90 ++++++++++++++ ...-meth-dflt-ary-ptrn-elem-ary-empty-iter.js | 88 ++++++++++++++ ...n-meth-dflt-ary-ptrn-elem-ary-rest-init.js | 92 ++++++++++++++ ...n-meth-dflt-ary-ptrn-elem-ary-rest-iter.js | 95 +++++++++++++++ ...en-meth-dflt-ary-ptrn-elem-ary-val-null.js | 91 ++++++++++++++ ...th-dflt-ary-ptrn-elem-id-init-exhausted.js | 87 +++++++++++++ ...flt-ary-ptrn-elem-id-init-fn-name-arrow.js | 88 ++++++++++++++ ...flt-ary-ptrn-elem-id-init-fn-name-class.js | 89 ++++++++++++++ ...flt-ary-ptrn-elem-id-init-fn-name-cover.js | 89 ++++++++++++++ ...h-dflt-ary-ptrn-elem-id-init-fn-name-fn.js | 89 ++++++++++++++ ...-dflt-ary-ptrn-elem-id-init-fn-name-gen.js | 89 ++++++++++++++ ...en-meth-dflt-ary-ptrn-elem-id-init-hole.js | 83 +++++++++++++ ...meth-dflt-ary-ptrn-elem-id-init-skipped.js | 92 ++++++++++++++ ...-meth-dflt-ary-ptrn-elem-id-init-throws.js | 82 +++++++++++++ ...n-meth-dflt-ary-ptrn-elem-id-init-undef.js | 86 +++++++++++++ ...dflt-ary-ptrn-elem-id-init-unresolvable.js | 89 ++++++++++++++ ...eth-dflt-ary-ptrn-elem-id-iter-complete.js | 90 ++++++++++++++ ...en-meth-dflt-ary-ptrn-elem-id-iter-done.js | 85 +++++++++++++ ...eth-dflt-ary-ptrn-elem-id-iter-step-err.js | 90 ++++++++++++++ ...meth-dflt-ary-ptrn-elem-id-iter-val-err.js | 101 +++++++++++++++ ...gen-meth-dflt-ary-ptrn-elem-id-iter-val.js | 96 +++++++++++++++ ...gen-meth-dflt-ary-ptrn-elem-obj-id-init.js | 88 ++++++++++++++ ...dstr-gen-meth-dflt-ary-ptrn-elem-obj-id.js | 88 ++++++++++++++ ...eth-dflt-ary-ptrn-elem-obj-prop-id-init.js | 98 +++++++++++++++ ...gen-meth-dflt-ary-ptrn-elem-obj-prop-id.js | 98 +++++++++++++++ ...en-meth-dflt-ary-ptrn-elem-obj-val-null.js | 91 ++++++++++++++ ...n-meth-dflt-ary-ptrn-elem-obj-val-undef.js | 91 ++++++++++++++ ...en-meth-dflt-ary-ptrn-elision-exhausted.js | 93 ++++++++++++++ ...gen-meth-dflt-ary-ptrn-elision-step-err.js | 98 +++++++++++++++ .../dstr-gen-meth-dflt-ary-ptrn-elision.js | 102 ++++++++++++++++ .../dstr-gen-meth-dflt-ary-ptrn-empty.js | 85 +++++++++++++ ...tr-gen-meth-dflt-ary-ptrn-rest-ary-elem.js | 109 +++++++++++++++++ ...gen-meth-dflt-ary-ptrn-rest-ary-elision.js | 115 ++++++++++++++++++ ...r-gen-meth-dflt-ary-ptrn-rest-ary-empty.js | 98 +++++++++++++++ ...tr-gen-meth-dflt-ary-ptrn-rest-ary-rest.js | 94 ++++++++++++++ ...-dflt-ary-ptrn-rest-id-elision-next-err.js | 84 +++++++++++++ ...-gen-meth-dflt-ary-ptrn-rest-id-elision.js | 90 ++++++++++++++ ...en-meth-dflt-ary-ptrn-rest-id-exhausted.js | 86 +++++++++++++ ...eth-dflt-ary-ptrn-rest-id-iter-step-err.js | 95 +++++++++++++++ ...meth-dflt-ary-ptrn-rest-id-iter-val-err.js | 97 +++++++++++++++ .../dstr-gen-meth-dflt-ary-ptrn-rest-id.js | 87 +++++++++++++ ...tr-gen-meth-dflt-ary-ptrn-rest-init-ary.js | 81 ++++++++++++ ...str-gen-meth-dflt-ary-ptrn-rest-init-id.js | 81 ++++++++++++ ...tr-gen-meth-dflt-ary-ptrn-rest-init-obj.js | 81 ++++++++++++ ...n-meth-dflt-ary-ptrn-rest-not-final-ary.js | 81 ++++++++++++ ...en-meth-dflt-ary-ptrn-rest-not-final-id.js | 81 ++++++++++++ ...n-meth-dflt-ary-ptrn-rest-not-final-obj.js | 81 ++++++++++++ ...dstr-gen-meth-dflt-ary-ptrn-rest-obj-id.js | 87 +++++++++++++ ...gen-meth-dflt-ary-ptrn-rest-obj-prop-id.js | 95 +++++++++++++++ .../class/dstr-gen-meth-dflt-obj-init-null.js | 78 ++++++++++++ .../dstr-gen-meth-dflt-obj-init-undefined.js | 78 ++++++++++++ .../dstr-gen-meth-dflt-obj-ptrn-empty.js | 86 +++++++++++++ ...gen-meth-dflt-obj-ptrn-id-get-value-err.js | 85 +++++++++++++ ...eth-dflt-obj-ptrn-id-init-fn-name-arrow.js | 87 +++++++++++++ ...eth-dflt-obj-ptrn-id-init-fn-name-class.js | 88 ++++++++++++++ ...eth-dflt-obj-ptrn-id-init-fn-name-cover.js | 88 ++++++++++++++ ...n-meth-dflt-obj-ptrn-id-init-fn-name-fn.js | 88 ++++++++++++++ ...-meth-dflt-obj-ptrn-id-init-fn-name-gen.js | 88 ++++++++++++++ ...-gen-meth-dflt-obj-ptrn-id-init-skipped.js | 91 ++++++++++++++ ...r-gen-meth-dflt-obj-ptrn-id-init-throws.js | 85 +++++++++++++ ...meth-dflt-obj-ptrn-id-init-unresolvable.js | 89 ++++++++++++++ ...en-meth-dflt-obj-ptrn-id-trailing-comma.js | 81 ++++++++++++ .../dstr-gen-meth-dflt-obj-ptrn-list-err.js | 86 +++++++++++++ ...tr-gen-meth-dflt-obj-ptrn-prop-ary-init.js | 90 ++++++++++++++ ...h-dflt-obj-ptrn-prop-ary-trailing-comma.js | 81 ++++++++++++ ...-meth-dflt-obj-ptrn-prop-ary-value-null.js | 80 ++++++++++++ .../dstr-gen-meth-dflt-obj-ptrn-prop-ary.js | 88 ++++++++++++++ ...tr-gen-meth-dflt-obj-ptrn-prop-eval-err.js | 82 +++++++++++++ ...eth-dflt-obj-ptrn-prop-id-get-value-err.js | 87 +++++++++++++ ...meth-dflt-obj-ptrn-prop-id-init-skipped.js | 103 ++++++++++++++++ ...-meth-dflt-obj-ptrn-prop-id-init-throws.js | 85 +++++++++++++ ...dflt-obj-ptrn-prop-id-init-unresolvable.js | 89 ++++++++++++++ ...str-gen-meth-dflt-obj-ptrn-prop-id-init.js | 84 +++++++++++++ ...th-dflt-obj-ptrn-prop-id-trailing-comma.js | 85 +++++++++++++ .../dstr-gen-meth-dflt-obj-ptrn-prop-id.js | 84 +++++++++++++ ...tr-gen-meth-dflt-obj-ptrn-prop-obj-init.js | 90 ++++++++++++++ ...-meth-dflt-obj-ptrn-prop-obj-value-null.js | 80 ++++++++++++ ...meth-dflt-obj-ptrn-prop-obj-value-undef.js | 80 ++++++++++++ .../dstr-gen-meth-dflt-obj-ptrn-prop-obj.js | 88 ++++++++++++++ ...en-meth-static-dflt-ary-init-iter-close.js | 97 +++++++++++++++ ...-meth-static-dflt-ary-init-iter-get-err.js | 83 +++++++++++++ ...meth-static-dflt-ary-init-iter-no-close.js | 97 +++++++++++++++ ...-gen-meth-static-dflt-ary-name-iter-val.js | 96 +++++++++++++++ ...static-dflt-ary-ptrn-elem-ary-elem-init.js | 88 ++++++++++++++ ...static-dflt-ary-ptrn-elem-ary-elem-iter.js | 89 ++++++++++++++ ...tic-dflt-ary-ptrn-elem-ary-elision-init.js | 95 +++++++++++++++ ...tic-dflt-ary-ptrn-elem-ary-elision-iter.js | 92 ++++++++++++++ ...tatic-dflt-ary-ptrn-elem-ary-empty-init.js | 90 ++++++++++++++ ...tatic-dflt-ary-ptrn-elem-ary-empty-iter.js | 88 ++++++++++++++ ...static-dflt-ary-ptrn-elem-ary-rest-init.js | 92 ++++++++++++++ ...static-dflt-ary-ptrn-elem-ary-rest-iter.js | 95 +++++++++++++++ ...-static-dflt-ary-ptrn-elem-ary-val-null.js | 90 ++++++++++++++ ...ic-dflt-ary-ptrn-elem-id-init-exhausted.js | 87 +++++++++++++ ...flt-ary-ptrn-elem-id-init-fn-name-arrow.js | 88 ++++++++++++++ ...flt-ary-ptrn-elem-id-init-fn-name-class.js | 89 ++++++++++++++ ...flt-ary-ptrn-elem-id-init-fn-name-cover.js | 89 ++++++++++++++ ...c-dflt-ary-ptrn-elem-id-init-fn-name-fn.js | 89 ++++++++++++++ ...-dflt-ary-ptrn-elem-id-init-fn-name-gen.js | 89 ++++++++++++++ ...-static-dflt-ary-ptrn-elem-id-init-hole.js | 83 +++++++++++++ ...atic-dflt-ary-ptrn-elem-id-init-skipped.js | 92 ++++++++++++++ ...tatic-dflt-ary-ptrn-elem-id-init-throws.js | 81 ++++++++++++ ...static-dflt-ary-ptrn-elem-id-init-undef.js | 86 +++++++++++++ ...dflt-ary-ptrn-elem-id-init-unresolvable.js | 88 ++++++++++++++ ...tic-dflt-ary-ptrn-elem-id-iter-complete.js | 90 ++++++++++++++ ...-static-dflt-ary-ptrn-elem-id-iter-done.js | 85 +++++++++++++ ...tic-dflt-ary-ptrn-elem-id-iter-step-err.js | 89 ++++++++++++++ ...atic-dflt-ary-ptrn-elem-id-iter-val-err.js | 100 +++++++++++++++ ...h-static-dflt-ary-ptrn-elem-id-iter-val.js | 96 +++++++++++++++ ...h-static-dflt-ary-ptrn-elem-obj-id-init.js | 88 ++++++++++++++ ...n-meth-static-dflt-ary-ptrn-elem-obj-id.js | 88 ++++++++++++++ ...tic-dflt-ary-ptrn-elem-obj-prop-id-init.js | 98 +++++++++++++++ ...h-static-dflt-ary-ptrn-elem-obj-prop-id.js | 98 +++++++++++++++ ...-static-dflt-ary-ptrn-elem-obj-val-null.js | 90 ++++++++++++++ ...static-dflt-ary-ptrn-elem-obj-val-undef.js | 90 ++++++++++++++ ...-static-dflt-ary-ptrn-elision-exhausted.js | 93 ++++++++++++++ ...h-static-dflt-ary-ptrn-elision-step-err.js | 97 +++++++++++++++ ...r-gen-meth-static-dflt-ary-ptrn-elision.js | 102 ++++++++++++++++ ...str-gen-meth-static-dflt-ary-ptrn-empty.js | 85 +++++++++++++ ...meth-static-dflt-ary-ptrn-rest-ary-elem.js | 109 +++++++++++++++++ ...h-static-dflt-ary-ptrn-rest-ary-elision.js | 115 ++++++++++++++++++ ...eth-static-dflt-ary-ptrn-rest-ary-empty.js | 98 +++++++++++++++ ...meth-static-dflt-ary-ptrn-rest-ary-rest.js | 94 ++++++++++++++ ...-dflt-ary-ptrn-rest-id-elision-next-err.js | 83 +++++++++++++ ...th-static-dflt-ary-ptrn-rest-id-elision.js | 90 ++++++++++++++ ...-static-dflt-ary-ptrn-rest-id-exhausted.js | 86 +++++++++++++ ...tic-dflt-ary-ptrn-rest-id-iter-step-err.js | 94 ++++++++++++++ ...atic-dflt-ary-ptrn-rest-id-iter-val-err.js | 96 +++++++++++++++ ...r-gen-meth-static-dflt-ary-ptrn-rest-id.js | 87 +++++++++++++ ...meth-static-dflt-ary-ptrn-rest-init-ary.js | 81 ++++++++++++ ...-meth-static-dflt-ary-ptrn-rest-init-id.js | 81 ++++++++++++ ...meth-static-dflt-ary-ptrn-rest-init-obj.js | 81 ++++++++++++ ...static-dflt-ary-ptrn-rest-not-final-ary.js | 81 ++++++++++++ ...-static-dflt-ary-ptrn-rest-not-final-id.js | 81 ++++++++++++ ...static-dflt-ary-ptrn-rest-not-final-obj.js | 81 ++++++++++++ ...n-meth-static-dflt-ary-ptrn-rest-obj-id.js | 87 +++++++++++++ ...h-static-dflt-ary-ptrn-rest-obj-prop-id.js | 95 +++++++++++++++ ...dstr-gen-meth-static-dflt-obj-init-null.js | 77 ++++++++++++ ...gen-meth-static-dflt-obj-init-undefined.js | 77 ++++++++++++ ...str-gen-meth-static-dflt-obj-ptrn-empty.js | 86 +++++++++++++ ...h-static-dflt-obj-ptrn-id-get-value-err.js | 84 +++++++++++++ ...tic-dflt-obj-ptrn-id-init-fn-name-arrow.js | 87 +++++++++++++ ...tic-dflt-obj-ptrn-id-init-fn-name-class.js | 88 ++++++++++++++ ...tic-dflt-obj-ptrn-id-init-fn-name-cover.js | 88 ++++++++++++++ ...static-dflt-obj-ptrn-id-init-fn-name-fn.js | 88 ++++++++++++++ ...tatic-dflt-obj-ptrn-id-init-fn-name-gen.js | 88 ++++++++++++++ ...th-static-dflt-obj-ptrn-id-init-skipped.js | 91 ++++++++++++++ ...eth-static-dflt-obj-ptrn-id-init-throws.js | 84 +++++++++++++ ...atic-dflt-obj-ptrn-id-init-unresolvable.js | 88 ++++++++++++++ ...-static-dflt-obj-ptrn-id-trailing-comma.js | 81 ++++++++++++ ...-gen-meth-static-dflt-obj-ptrn-list-err.js | 85 +++++++++++++ ...meth-static-dflt-obj-ptrn-prop-ary-init.js | 90 ++++++++++++++ ...c-dflt-obj-ptrn-prop-ary-trailing-comma.js | 81 ++++++++++++ ...tatic-dflt-obj-ptrn-prop-ary-value-null.js | 79 ++++++++++++ ...-gen-meth-static-dflt-obj-ptrn-prop-ary.js | 88 ++++++++++++++ ...meth-static-dflt-obj-ptrn-prop-eval-err.js | 81 ++++++++++++ ...tic-dflt-obj-ptrn-prop-id-get-value-err.js | 86 +++++++++++++ ...atic-dflt-obj-ptrn-prop-id-init-skipped.js | 103 ++++++++++++++++ ...tatic-dflt-obj-ptrn-prop-id-init-throws.js | 84 +++++++++++++ ...dflt-obj-ptrn-prop-id-init-unresolvable.js | 88 ++++++++++++++ ...-meth-static-dflt-obj-ptrn-prop-id-init.js | 84 +++++++++++++ ...ic-dflt-obj-ptrn-prop-id-trailing-comma.js | 85 +++++++++++++ ...r-gen-meth-static-dflt-obj-ptrn-prop-id.js | 84 +++++++++++++ ...meth-static-dflt-obj-ptrn-prop-obj-init.js | 90 ++++++++++++++ ...tatic-dflt-obj-ptrn-prop-obj-value-null.js | 79 ++++++++++++ ...atic-dflt-obj-ptrn-prop-obj-value-undef.js | 79 ++++++++++++ ...-gen-meth-static-dflt-obj-ptrn-prop-obj.js | 88 ++++++++++++++ .../dstr-meth-dflt-ary-init-iter-close.js | 94 ++++++++++++++ .../dstr-meth-dflt-ary-init-iter-get-err.js | 82 +++++++++++++ .../dstr-meth-dflt-ary-init-iter-no-close.js | 94 ++++++++++++++ .../class/dstr-meth-dflt-ary-name-iter-val.js | 93 ++++++++++++++ ...r-meth-dflt-ary-ptrn-elem-ary-elem-init.js | 85 +++++++++++++ ...r-meth-dflt-ary-ptrn-elem-ary-elem-iter.js | 86 +++++++++++++ ...eth-dflt-ary-ptrn-elem-ary-elision-init.js | 92 ++++++++++++++ ...eth-dflt-ary-ptrn-elem-ary-elision-iter.js | 89 ++++++++++++++ ...-meth-dflt-ary-ptrn-elem-ary-empty-init.js | 87 +++++++++++++ ...-meth-dflt-ary-ptrn-elem-ary-empty-iter.js | 85 +++++++++++++ ...r-meth-dflt-ary-ptrn-elem-ary-rest-init.js | 89 ++++++++++++++ ...r-meth-dflt-ary-ptrn-elem-ary-rest-iter.js | 92 ++++++++++++++ ...tr-meth-dflt-ary-ptrn-elem-ary-val-null.js | 89 ++++++++++++++ ...th-dflt-ary-ptrn-elem-id-init-exhausted.js | 84 +++++++++++++ ...flt-ary-ptrn-elem-id-init-fn-name-arrow.js | 85 +++++++++++++ ...flt-ary-ptrn-elem-id-init-fn-name-class.js | 86 +++++++++++++ ...flt-ary-ptrn-elem-id-init-fn-name-cover.js | 86 +++++++++++++ ...h-dflt-ary-ptrn-elem-id-init-fn-name-fn.js | 86 +++++++++++++ ...-dflt-ary-ptrn-elem-id-init-fn-name-gen.js | 86 +++++++++++++ ...tr-meth-dflt-ary-ptrn-elem-id-init-hole.js | 80 ++++++++++++ ...meth-dflt-ary-ptrn-elem-id-init-skipped.js | 89 ++++++++++++++ ...-meth-dflt-ary-ptrn-elem-id-init-throws.js | 80 ++++++++++++ ...r-meth-dflt-ary-ptrn-elem-id-init-undef.js | 83 +++++++++++++ ...dflt-ary-ptrn-elem-id-init-unresolvable.js | 87 +++++++++++++ ...eth-dflt-ary-ptrn-elem-id-iter-complete.js | 87 +++++++++++++ ...tr-meth-dflt-ary-ptrn-elem-id-iter-done.js | 82 +++++++++++++ ...eth-dflt-ary-ptrn-elem-id-iter-step-err.js | 88 ++++++++++++++ ...meth-dflt-ary-ptrn-elem-id-iter-val-err.js | 99 +++++++++++++++ ...str-meth-dflt-ary-ptrn-elem-id-iter-val.js | 93 ++++++++++++++ ...str-meth-dflt-ary-ptrn-elem-obj-id-init.js | 85 +++++++++++++ .../dstr-meth-dflt-ary-ptrn-elem-obj-id.js | 85 +++++++++++++ ...eth-dflt-ary-ptrn-elem-obj-prop-id-init.js | 95 +++++++++++++++ ...str-meth-dflt-ary-ptrn-elem-obj-prop-id.js | 95 +++++++++++++++ ...tr-meth-dflt-ary-ptrn-elem-obj-val-null.js | 89 ++++++++++++++ ...r-meth-dflt-ary-ptrn-elem-obj-val-undef.js | 89 ++++++++++++++ ...tr-meth-dflt-ary-ptrn-elision-exhausted.js | 90 ++++++++++++++ ...str-meth-dflt-ary-ptrn-elision-step-err.js | 96 +++++++++++++++ .../class/dstr-meth-dflt-ary-ptrn-elision.js | 99 +++++++++++++++ .../class/dstr-meth-dflt-ary-ptrn-empty.js | 82 +++++++++++++ .../dstr-meth-dflt-ary-ptrn-rest-ary-elem.js | 106 ++++++++++++++++ ...str-meth-dflt-ary-ptrn-rest-ary-elision.js | 112 +++++++++++++++++ .../dstr-meth-dflt-ary-ptrn-rest-ary-empty.js | 95 +++++++++++++++ .../dstr-meth-dflt-ary-ptrn-rest-ary-rest.js | 91 ++++++++++++++ ...-dflt-ary-ptrn-rest-id-elision-next-err.js | 82 +++++++++++++ ...dstr-meth-dflt-ary-ptrn-rest-id-elision.js | 87 +++++++++++++ ...tr-meth-dflt-ary-ptrn-rest-id-exhausted.js | 83 +++++++++++++ ...eth-dflt-ary-ptrn-rest-id-iter-step-err.js | 93 ++++++++++++++ ...meth-dflt-ary-ptrn-rest-id-iter-val-err.js | 95 +++++++++++++++ .../class/dstr-meth-dflt-ary-ptrn-rest-id.js | 84 +++++++++++++ .../dstr-meth-dflt-ary-ptrn-rest-init-ary.js | 78 ++++++++++++ .../dstr-meth-dflt-ary-ptrn-rest-init-id.js | 78 ++++++++++++ .../dstr-meth-dflt-ary-ptrn-rest-init-obj.js | 78 ++++++++++++ ...r-meth-dflt-ary-ptrn-rest-not-final-ary.js | 78 ++++++++++++ ...tr-meth-dflt-ary-ptrn-rest-not-final-id.js | 78 ++++++++++++ ...r-meth-dflt-ary-ptrn-rest-not-final-obj.js | 78 ++++++++++++ .../dstr-meth-dflt-ary-ptrn-rest-obj-id.js | 84 +++++++++++++ ...str-meth-dflt-ary-ptrn-rest-obj-prop-id.js | 92 ++++++++++++++ .../class/dstr-meth-dflt-obj-init-null.js | 76 ++++++++++++ .../dstr-meth-dflt-obj-init-undefined.js | 76 ++++++++++++ .../class/dstr-meth-dflt-obj-ptrn-empty.js | 83 +++++++++++++ ...str-meth-dflt-obj-ptrn-id-get-value-err.js | 83 +++++++++++++ ...eth-dflt-obj-ptrn-id-init-fn-name-arrow.js | 84 +++++++++++++ ...eth-dflt-obj-ptrn-id-init-fn-name-class.js | 85 +++++++++++++ ...eth-dflt-obj-ptrn-id-init-fn-name-cover.js | 85 +++++++++++++ ...r-meth-dflt-obj-ptrn-id-init-fn-name-fn.js | 85 +++++++++++++ ...-meth-dflt-obj-ptrn-id-init-fn-name-gen.js | 85 +++++++++++++ ...dstr-meth-dflt-obj-ptrn-id-init-skipped.js | 88 ++++++++++++++ .../dstr-meth-dflt-obj-ptrn-id-init-throws.js | 83 +++++++++++++ ...meth-dflt-obj-ptrn-id-init-unresolvable.js | 87 +++++++++++++ ...tr-meth-dflt-obj-ptrn-id-trailing-comma.js | 78 ++++++++++++ .../class/dstr-meth-dflt-obj-ptrn-list-err.js | 84 +++++++++++++ .../dstr-meth-dflt-obj-ptrn-prop-ary-init.js | 87 +++++++++++++ ...h-dflt-obj-ptrn-prop-ary-trailing-comma.js | 78 ++++++++++++ ...-meth-dflt-obj-ptrn-prop-ary-value-null.js | 78 ++++++++++++ .../class/dstr-meth-dflt-obj-ptrn-prop-ary.js | 85 +++++++++++++ .../dstr-meth-dflt-obj-ptrn-prop-eval-err.js | 80 ++++++++++++ ...eth-dflt-obj-ptrn-prop-id-get-value-err.js | 85 +++++++++++++ ...meth-dflt-obj-ptrn-prop-id-init-skipped.js | 100 +++++++++++++++ ...-meth-dflt-obj-ptrn-prop-id-init-throws.js | 83 +++++++++++++ ...dflt-obj-ptrn-prop-id-init-unresolvable.js | 87 +++++++++++++ .../dstr-meth-dflt-obj-ptrn-prop-id-init.js | 81 ++++++++++++ ...th-dflt-obj-ptrn-prop-id-trailing-comma.js | 82 +++++++++++++ .../class/dstr-meth-dflt-obj-ptrn-prop-id.js | 81 ++++++++++++ .../dstr-meth-dflt-obj-ptrn-prop-obj-init.js | 87 +++++++++++++ ...-meth-dflt-obj-ptrn-prop-obj-value-null.js | 78 ++++++++++++ ...meth-dflt-obj-ptrn-prop-obj-value-undef.js | 78 ++++++++++++ .../class/dstr-meth-dflt-obj-ptrn-prop-obj.js | 85 +++++++++++++ ...tr-meth-static-dflt-ary-init-iter-close.js | 94 ++++++++++++++ ...-meth-static-dflt-ary-init-iter-get-err.js | 80 ++++++++++++ ...meth-static-dflt-ary-init-iter-no-close.js | 94 ++++++++++++++ ...dstr-meth-static-dflt-ary-name-iter-val.js | 93 ++++++++++++++ ...static-dflt-ary-ptrn-elem-ary-elem-init.js | 85 +++++++++++++ ...static-dflt-ary-ptrn-elem-ary-elem-iter.js | 86 +++++++++++++ ...tic-dflt-ary-ptrn-elem-ary-elision-init.js | 92 ++++++++++++++ ...tic-dflt-ary-ptrn-elem-ary-elision-iter.js | 89 ++++++++++++++ ...tatic-dflt-ary-ptrn-elem-ary-empty-init.js | 87 +++++++++++++ ...tatic-dflt-ary-ptrn-elem-ary-empty-iter.js | 85 +++++++++++++ ...static-dflt-ary-ptrn-elem-ary-rest-init.js | 89 ++++++++++++++ ...static-dflt-ary-ptrn-elem-ary-rest-iter.js | 92 ++++++++++++++ ...-static-dflt-ary-ptrn-elem-ary-val-null.js | 87 +++++++++++++ ...ic-dflt-ary-ptrn-elem-id-init-exhausted.js | 84 +++++++++++++ ...flt-ary-ptrn-elem-id-init-fn-name-arrow.js | 85 +++++++++++++ ...flt-ary-ptrn-elem-id-init-fn-name-class.js | 86 +++++++++++++ ...flt-ary-ptrn-elem-id-init-fn-name-cover.js | 86 +++++++++++++ ...c-dflt-ary-ptrn-elem-id-init-fn-name-fn.js | 86 +++++++++++++ ...-dflt-ary-ptrn-elem-id-init-fn-name-gen.js | 86 +++++++++++++ ...-static-dflt-ary-ptrn-elem-id-init-hole.js | 80 ++++++++++++ ...atic-dflt-ary-ptrn-elem-id-init-skipped.js | 89 ++++++++++++++ ...tatic-dflt-ary-ptrn-elem-id-init-throws.js | 78 ++++++++++++ ...static-dflt-ary-ptrn-elem-id-init-undef.js | 83 +++++++++++++ ...dflt-ary-ptrn-elem-id-init-unresolvable.js | 85 +++++++++++++ ...tic-dflt-ary-ptrn-elem-id-iter-complete.js | 87 +++++++++++++ ...-static-dflt-ary-ptrn-elem-id-iter-done.js | 82 +++++++++++++ ...tic-dflt-ary-ptrn-elem-id-iter-step-err.js | 86 +++++++++++++ ...atic-dflt-ary-ptrn-elem-id-iter-val-err.js | 97 +++++++++++++++ ...h-static-dflt-ary-ptrn-elem-id-iter-val.js | 93 ++++++++++++++ ...h-static-dflt-ary-ptrn-elem-obj-id-init.js | 85 +++++++++++++ ...r-meth-static-dflt-ary-ptrn-elem-obj-id.js | 85 +++++++++++++ ...tic-dflt-ary-ptrn-elem-obj-prop-id-init.js | 95 +++++++++++++++ ...h-static-dflt-ary-ptrn-elem-obj-prop-id.js | 95 +++++++++++++++ ...-static-dflt-ary-ptrn-elem-obj-val-null.js | 87 +++++++++++++ ...static-dflt-ary-ptrn-elem-obj-val-undef.js | 87 +++++++++++++ ...-static-dflt-ary-ptrn-elision-exhausted.js | 90 ++++++++++++++ ...h-static-dflt-ary-ptrn-elision-step-err.js | 94 ++++++++++++++ .../dstr-meth-static-dflt-ary-ptrn-elision.js | 99 +++++++++++++++ .../dstr-meth-static-dflt-ary-ptrn-empty.js | 82 +++++++++++++ ...meth-static-dflt-ary-ptrn-rest-ary-elem.js | 106 ++++++++++++++++ ...h-static-dflt-ary-ptrn-rest-ary-elision.js | 112 +++++++++++++++++ ...eth-static-dflt-ary-ptrn-rest-ary-empty.js | 95 +++++++++++++++ ...meth-static-dflt-ary-ptrn-rest-ary-rest.js | 91 ++++++++++++++ ...-dflt-ary-ptrn-rest-id-elision-next-err.js | 80 ++++++++++++ ...th-static-dflt-ary-ptrn-rest-id-elision.js | 87 +++++++++++++ ...-static-dflt-ary-ptrn-rest-id-exhausted.js | 83 +++++++++++++ ...tic-dflt-ary-ptrn-rest-id-iter-step-err.js | 91 ++++++++++++++ ...atic-dflt-ary-ptrn-rest-id-iter-val-err.js | 93 ++++++++++++++ .../dstr-meth-static-dflt-ary-ptrn-rest-id.js | 84 +++++++++++++ ...meth-static-dflt-ary-ptrn-rest-init-ary.js | 78 ++++++++++++ ...-meth-static-dflt-ary-ptrn-rest-init-id.js | 78 ++++++++++++ ...meth-static-dflt-ary-ptrn-rest-init-obj.js | 78 ++++++++++++ ...static-dflt-ary-ptrn-rest-not-final-ary.js | 78 ++++++++++++ ...-static-dflt-ary-ptrn-rest-not-final-id.js | 78 ++++++++++++ ...static-dflt-ary-ptrn-rest-not-final-obj.js | 78 ++++++++++++ ...r-meth-static-dflt-ary-ptrn-rest-obj-id.js | 84 +++++++++++++ ...h-static-dflt-ary-ptrn-rest-obj-prop-id.js | 92 ++++++++++++++ .../dstr-meth-static-dflt-obj-init-null.js | 74 +++++++++++ ...str-meth-static-dflt-obj-init-undefined.js | 74 +++++++++++ .../dstr-meth-static-dflt-obj-ptrn-empty.js | 83 +++++++++++++ ...h-static-dflt-obj-ptrn-id-get-value-err.js | 81 ++++++++++++ ...tic-dflt-obj-ptrn-id-init-fn-name-arrow.js | 84 +++++++++++++ ...tic-dflt-obj-ptrn-id-init-fn-name-class.js | 85 +++++++++++++ ...tic-dflt-obj-ptrn-id-init-fn-name-cover.js | 85 +++++++++++++ ...static-dflt-obj-ptrn-id-init-fn-name-fn.js | 85 +++++++++++++ ...tatic-dflt-obj-ptrn-id-init-fn-name-gen.js | 85 +++++++++++++ ...th-static-dflt-obj-ptrn-id-init-skipped.js | 88 ++++++++++++++ ...eth-static-dflt-obj-ptrn-id-init-throws.js | 81 ++++++++++++ ...atic-dflt-obj-ptrn-id-init-unresolvable.js | 85 +++++++++++++ ...-static-dflt-obj-ptrn-id-trailing-comma.js | 78 ++++++++++++ ...dstr-meth-static-dflt-obj-ptrn-list-err.js | 82 +++++++++++++ ...meth-static-dflt-obj-ptrn-prop-ary-init.js | 87 +++++++++++++ ...c-dflt-obj-ptrn-prop-ary-trailing-comma.js | 78 ++++++++++++ ...tatic-dflt-obj-ptrn-prop-ary-value-null.js | 76 ++++++++++++ ...dstr-meth-static-dflt-obj-ptrn-prop-ary.js | 85 +++++++++++++ ...meth-static-dflt-obj-ptrn-prop-eval-err.js | 78 ++++++++++++ ...tic-dflt-obj-ptrn-prop-id-get-value-err.js | 83 +++++++++++++ ...atic-dflt-obj-ptrn-prop-id-init-skipped.js | 100 +++++++++++++++ ...tatic-dflt-obj-ptrn-prop-id-init-throws.js | 81 ++++++++++++ ...dflt-obj-ptrn-prop-id-init-unresolvable.js | 85 +++++++++++++ ...-meth-static-dflt-obj-ptrn-prop-id-init.js | 81 ++++++++++++ ...ic-dflt-obj-ptrn-prop-id-trailing-comma.js | 82 +++++++++++++ .../dstr-meth-static-dflt-obj-ptrn-prop-id.js | 81 ++++++++++++ ...meth-static-dflt-obj-ptrn-prop-obj-init.js | 87 +++++++++++++ ...tatic-dflt-obj-ptrn-prop-obj-value-null.js | 76 ++++++++++++ ...atic-dflt-obj-ptrn-prop-obj-value-undef.js | 76 ++++++++++++ ...dstr-meth-static-dflt-obj-ptrn-prop-obj.js | 85 +++++++++++++ .../function/dstr-dflt-ary-init-iter-close.js | 73 +++++++++++ .../dstr-dflt-ary-init-iter-get-err.js | 58 +++++++++ .../dstr-dflt-ary-init-iter-no-close.js | 73 +++++++++++ .../function/dstr-dflt-ary-name-iter-val.js | 72 +++++++++++ .../dstr-dflt-ary-ptrn-elem-ary-elem-init.js | 64 ++++++++++ .../dstr-dflt-ary-ptrn-elem-ary-elem-iter.js | 65 ++++++++++ ...str-dflt-ary-ptrn-elem-ary-elision-init.js | 71 +++++++++++ ...str-dflt-ary-ptrn-elem-ary-elision-iter.js | 68 +++++++++++ .../dstr-dflt-ary-ptrn-elem-ary-empty-init.js | 66 ++++++++++ .../dstr-dflt-ary-ptrn-elem-ary-empty-iter.js | 64 ++++++++++ .../dstr-dflt-ary-ptrn-elem-ary-rest-init.js | 68 +++++++++++ .../dstr-dflt-ary-ptrn-elem-ary-rest-iter.js | 71 +++++++++++ .../dstr-dflt-ary-ptrn-elem-ary-val-null.js | 65 ++++++++++ ...tr-dflt-ary-ptrn-elem-id-init-exhausted.js | 63 ++++++++++ ...flt-ary-ptrn-elem-id-init-fn-name-arrow.js | 64 ++++++++++ ...flt-ary-ptrn-elem-id-init-fn-name-class.js | 65 ++++++++++ ...flt-ary-ptrn-elem-id-init-fn-name-cover.js | 65 ++++++++++ ...r-dflt-ary-ptrn-elem-id-init-fn-name-fn.js | 65 ++++++++++ ...-dflt-ary-ptrn-elem-id-init-fn-name-gen.js | 65 ++++++++++ .../dstr-dflt-ary-ptrn-elem-id-init-hole.js | 59 +++++++++ ...dstr-dflt-ary-ptrn-elem-id-init-skipped.js | 68 +++++++++++ .../dstr-dflt-ary-ptrn-elem-id-init-throws.js | 56 +++++++++ .../dstr-dflt-ary-ptrn-elem-id-init-undef.js | 62 ++++++++++ ...dflt-ary-ptrn-elem-id-init-unresolvable.js | 63 ++++++++++ ...str-dflt-ary-ptrn-elem-id-iter-complete.js | 66 ++++++++++ .../dstr-dflt-ary-ptrn-elem-id-iter-done.js | 61 ++++++++++ ...str-dflt-ary-ptrn-elem-id-iter-step-err.js | 64 ++++++++++ ...dstr-dflt-ary-ptrn-elem-id-iter-val-err.js | 75 ++++++++++++ .../dstr-dflt-ary-ptrn-elem-id-iter-val.js | 72 +++++++++++ .../dstr-dflt-ary-ptrn-elem-obj-id-init.js | 64 ++++++++++ .../dstr-dflt-ary-ptrn-elem-obj-id.js | 64 ++++++++++ ...str-dflt-ary-ptrn-elem-obj-prop-id-init.js | 74 +++++++++++ .../dstr-dflt-ary-ptrn-elem-obj-prop-id.js | 74 +++++++++++ .../dstr-dflt-ary-ptrn-elem-obj-val-null.js | 65 ++++++++++ .../dstr-dflt-ary-ptrn-elem-obj-val-undef.js | 65 ++++++++++ .../dstr-dflt-ary-ptrn-elision-exhausted.js | 69 +++++++++++ .../dstr-dflt-ary-ptrn-elision-step-err.js | 72 +++++++++++ .../function/dstr-dflt-ary-ptrn-elision.js | 78 ++++++++++++ .../function/dstr-dflt-ary-ptrn-empty.js | 61 ++++++++++ .../dstr-dflt-ary-ptrn-rest-ary-elem.js | 85 +++++++++++++ .../dstr-dflt-ary-ptrn-rest-ary-elision.js | 91 ++++++++++++++ .../dstr-dflt-ary-ptrn-rest-ary-empty.js | 74 +++++++++++ .../dstr-dflt-ary-ptrn-rest-ary-rest.js | 70 +++++++++++ ...-dflt-ary-ptrn-rest-id-elision-next-err.js | 58 +++++++++ .../dstr-dflt-ary-ptrn-rest-id-elision.js | 66 ++++++++++ .../dstr-dflt-ary-ptrn-rest-id-exhausted.js | 62 ++++++++++ ...str-dflt-ary-ptrn-rest-id-iter-step-err.js | 69 +++++++++++ ...dstr-dflt-ary-ptrn-rest-id-iter-val-err.js | 71 +++++++++++ .../function/dstr-dflt-ary-ptrn-rest-id.js | 63 ++++++++++ .../dstr-dflt-ary-ptrn-rest-init-ary.js | 57 +++++++++ .../dstr-dflt-ary-ptrn-rest-init-id.js | 57 +++++++++ .../dstr-dflt-ary-ptrn-rest-init-obj.js | 57 +++++++++ .../dstr-dflt-ary-ptrn-rest-not-final-ary.js | 57 +++++++++ .../dstr-dflt-ary-ptrn-rest-not-final-id.js | 57 +++++++++ .../dstr-dflt-ary-ptrn-rest-not-final-obj.js | 57 +++++++++ .../dstr-dflt-ary-ptrn-rest-obj-id.js | 63 ++++++++++ .../dstr-dflt-ary-ptrn-rest-obj-prop-id.js | 71 +++++++++++ .../function/dstr-dflt-obj-init-null.js | 52 ++++++++ .../function/dstr-dflt-obj-init-undefined.js | 52 ++++++++ .../function/dstr-dflt-obj-ptrn-empty.js | 62 ++++++++++ .../dstr-dflt-obj-ptrn-id-get-value-err.js | 59 +++++++++ ...str-dflt-obj-ptrn-id-init-fn-name-arrow.js | 63 ++++++++++ ...str-dflt-obj-ptrn-id-init-fn-name-class.js | 64 ++++++++++ ...str-dflt-obj-ptrn-id-init-fn-name-cover.js | 64 ++++++++++ .../dstr-dflt-obj-ptrn-id-init-fn-name-fn.js | 64 ++++++++++ .../dstr-dflt-obj-ptrn-id-init-fn-name-gen.js | 64 ++++++++++ .../dstr-dflt-obj-ptrn-id-init-skipped.js | 67 ++++++++++ .../dstr-dflt-obj-ptrn-id-init-throws.js | 59 +++++++++ ...dstr-dflt-obj-ptrn-id-init-unresolvable.js | 63 ++++++++++ .../dstr-dflt-obj-ptrn-id-trailing-comma.js | 57 +++++++++ .../function/dstr-dflt-obj-ptrn-list-err.js | 60 +++++++++ .../dstr-dflt-obj-ptrn-prop-ary-init.js | 66 ++++++++++ ...r-dflt-obj-ptrn-prop-ary-trailing-comma.js | 57 +++++++++ .../dstr-dflt-obj-ptrn-prop-ary-value-null.js | 54 ++++++++ .../function/dstr-dflt-obj-ptrn-prop-ary.js | 64 ++++++++++ .../dstr-dflt-obj-ptrn-prop-eval-err.js | 56 +++++++++ ...str-dflt-obj-ptrn-prop-id-get-value-err.js | 61 ++++++++++ ...dstr-dflt-obj-ptrn-prop-id-init-skipped.js | 79 ++++++++++++ .../dstr-dflt-obj-ptrn-prop-id-init-throws.js | 59 +++++++++ ...dflt-obj-ptrn-prop-id-init-unresolvable.js | 63 ++++++++++ .../dstr-dflt-obj-ptrn-prop-id-init.js | 60 +++++++++ ...tr-dflt-obj-ptrn-prop-id-trailing-comma.js | 61 ++++++++++ .../function/dstr-dflt-obj-ptrn-prop-id.js | 60 +++++++++ .../dstr-dflt-obj-ptrn-prop-obj-init.js | 66 ++++++++++ .../dstr-dflt-obj-ptrn-prop-obj-value-null.js | 54 ++++++++ ...dstr-dflt-obj-ptrn-prop-obj-value-undef.js | 54 ++++++++ .../function/dstr-dflt-obj-ptrn-prop-obj.js | 64 ++++++++++ .../dstr-dflt-ary-init-iter-close.js | 73 +++++++++++ .../dstr-dflt-ary-init-iter-get-err.js | 58 +++++++++ .../dstr-dflt-ary-init-iter-no-close.js | 73 +++++++++++ .../generators/dstr-dflt-ary-name-iter-val.js | 72 +++++++++++ .../dstr-dflt-ary-ptrn-elem-ary-elem-init.js | 64 ++++++++++ .../dstr-dflt-ary-ptrn-elem-ary-elem-iter.js | 65 ++++++++++ ...str-dflt-ary-ptrn-elem-ary-elision-init.js | 71 +++++++++++ ...str-dflt-ary-ptrn-elem-ary-elision-iter.js | 68 +++++++++++ .../dstr-dflt-ary-ptrn-elem-ary-empty-init.js | 66 ++++++++++ .../dstr-dflt-ary-ptrn-elem-ary-empty-iter.js | 64 ++++++++++ .../dstr-dflt-ary-ptrn-elem-ary-rest-init.js | 68 +++++++++++ .../dstr-dflt-ary-ptrn-elem-ary-rest-iter.js | 71 +++++++++++ .../dstr-dflt-ary-ptrn-elem-ary-val-null.js | 65 ++++++++++ ...tr-dflt-ary-ptrn-elem-id-init-exhausted.js | 63 ++++++++++ ...flt-ary-ptrn-elem-id-init-fn-name-arrow.js | 64 ++++++++++ ...flt-ary-ptrn-elem-id-init-fn-name-class.js | 65 ++++++++++ ...flt-ary-ptrn-elem-id-init-fn-name-cover.js | 65 ++++++++++ ...r-dflt-ary-ptrn-elem-id-init-fn-name-fn.js | 65 ++++++++++ ...-dflt-ary-ptrn-elem-id-init-fn-name-gen.js | 65 ++++++++++ .../dstr-dflt-ary-ptrn-elem-id-init-hole.js | 59 +++++++++ ...dstr-dflt-ary-ptrn-elem-id-init-skipped.js | 68 +++++++++++ .../dstr-dflt-ary-ptrn-elem-id-init-throws.js | 56 +++++++++ .../dstr-dflt-ary-ptrn-elem-id-init-undef.js | 62 ++++++++++ ...dflt-ary-ptrn-elem-id-init-unresolvable.js | 63 ++++++++++ ...str-dflt-ary-ptrn-elem-id-iter-complete.js | 66 ++++++++++ .../dstr-dflt-ary-ptrn-elem-id-iter-done.js | 61 ++++++++++ ...str-dflt-ary-ptrn-elem-id-iter-step-err.js | 64 ++++++++++ ...dstr-dflt-ary-ptrn-elem-id-iter-val-err.js | 75 ++++++++++++ .../dstr-dflt-ary-ptrn-elem-id-iter-val.js | 72 +++++++++++ .../dstr-dflt-ary-ptrn-elem-obj-id-init.js | 64 ++++++++++ .../dstr-dflt-ary-ptrn-elem-obj-id.js | 64 ++++++++++ ...str-dflt-ary-ptrn-elem-obj-prop-id-init.js | 74 +++++++++++ .../dstr-dflt-ary-ptrn-elem-obj-prop-id.js | 74 +++++++++++ .../dstr-dflt-ary-ptrn-elem-obj-val-null.js | 65 ++++++++++ .../dstr-dflt-ary-ptrn-elem-obj-val-undef.js | 65 ++++++++++ .../dstr-dflt-ary-ptrn-elision-exhausted.js | 69 +++++++++++ .../dstr-dflt-ary-ptrn-elision-step-err.js | 72 +++++++++++ .../generators/dstr-dflt-ary-ptrn-elision.js | 78 ++++++++++++ .../generators/dstr-dflt-ary-ptrn-empty.js | 61 ++++++++++ .../dstr-dflt-ary-ptrn-rest-ary-elem.js | 85 +++++++++++++ .../dstr-dflt-ary-ptrn-rest-ary-elision.js | 91 ++++++++++++++ .../dstr-dflt-ary-ptrn-rest-ary-empty.js | 74 +++++++++++ .../dstr-dflt-ary-ptrn-rest-ary-rest.js | 70 +++++++++++ ...-dflt-ary-ptrn-rest-id-elision-next-err.js | 58 +++++++++ .../dstr-dflt-ary-ptrn-rest-id-elision.js | 66 ++++++++++ .../dstr-dflt-ary-ptrn-rest-id-exhausted.js | 62 ++++++++++ ...str-dflt-ary-ptrn-rest-id-iter-step-err.js | 69 +++++++++++ ...dstr-dflt-ary-ptrn-rest-id-iter-val-err.js | 71 +++++++++++ .../generators/dstr-dflt-ary-ptrn-rest-id.js | 63 ++++++++++ .../dstr-dflt-ary-ptrn-rest-init-ary.js | 57 +++++++++ .../dstr-dflt-ary-ptrn-rest-init-id.js | 57 +++++++++ .../dstr-dflt-ary-ptrn-rest-init-obj.js | 57 +++++++++ .../dstr-dflt-ary-ptrn-rest-not-final-ary.js | 57 +++++++++ .../dstr-dflt-ary-ptrn-rest-not-final-id.js | 57 +++++++++ .../dstr-dflt-ary-ptrn-rest-not-final-obj.js | 57 +++++++++ .../dstr-dflt-ary-ptrn-rest-obj-id.js | 63 ++++++++++ .../dstr-dflt-ary-ptrn-rest-obj-prop-id.js | 71 +++++++++++ .../generators/dstr-dflt-obj-init-null.js | 52 ++++++++ .../dstr-dflt-obj-init-undefined.js | 52 ++++++++ .../generators/dstr-dflt-obj-ptrn-empty.js | 62 ++++++++++ .../dstr-dflt-obj-ptrn-id-get-value-err.js | 59 +++++++++ ...str-dflt-obj-ptrn-id-init-fn-name-arrow.js | 63 ++++++++++ ...str-dflt-obj-ptrn-id-init-fn-name-class.js | 64 ++++++++++ ...str-dflt-obj-ptrn-id-init-fn-name-cover.js | 64 ++++++++++ .../dstr-dflt-obj-ptrn-id-init-fn-name-fn.js | 64 ++++++++++ .../dstr-dflt-obj-ptrn-id-init-fn-name-gen.js | 64 ++++++++++ .../dstr-dflt-obj-ptrn-id-init-skipped.js | 67 ++++++++++ .../dstr-dflt-obj-ptrn-id-init-throws.js | 59 +++++++++ ...dstr-dflt-obj-ptrn-id-init-unresolvable.js | 63 ++++++++++ .../dstr-dflt-obj-ptrn-id-trailing-comma.js | 57 +++++++++ .../generators/dstr-dflt-obj-ptrn-list-err.js | 60 +++++++++ .../dstr-dflt-obj-ptrn-prop-ary-init.js | 66 ++++++++++ ...r-dflt-obj-ptrn-prop-ary-trailing-comma.js | 57 +++++++++ .../dstr-dflt-obj-ptrn-prop-ary-value-null.js | 54 ++++++++ .../generators/dstr-dflt-obj-ptrn-prop-ary.js | 64 ++++++++++ .../dstr-dflt-obj-ptrn-prop-eval-err.js | 56 +++++++++ ...str-dflt-obj-ptrn-prop-id-get-value-err.js | 61 ++++++++++ ...dstr-dflt-obj-ptrn-prop-id-init-skipped.js | 79 ++++++++++++ .../dstr-dflt-obj-ptrn-prop-id-init-throws.js | 59 +++++++++ ...dflt-obj-ptrn-prop-id-init-unresolvable.js | 63 ++++++++++ .../dstr-dflt-obj-ptrn-prop-id-init.js | 60 +++++++++ ...tr-dflt-obj-ptrn-prop-id-trailing-comma.js | 61 ++++++++++ .../generators/dstr-dflt-obj-ptrn-prop-id.js | 60 +++++++++ .../dstr-dflt-obj-ptrn-prop-obj-init.js | 66 ++++++++++ .../dstr-dflt-obj-ptrn-prop-obj-value-null.js | 54 ++++++++ ...dstr-dflt-obj-ptrn-prop-obj-value-undef.js | 54 ++++++++ .../generators/dstr-dflt-obj-ptrn-prop-obj.js | 64 ++++++++++ .../dstr-gen-meth-dflt-ary-init-iter-close.js | 79 ++++++++++++ ...str-gen-meth-dflt-ary-init-iter-get-err.js | 65 ++++++++++ ...tr-gen-meth-dflt-ary-init-iter-no-close.js | 79 ++++++++++++ .../dstr-gen-meth-dflt-ary-name-iter-val.js | 78 ++++++++++++ ...n-meth-dflt-ary-ptrn-elem-ary-elem-init.js | 70 +++++++++++ ...n-meth-dflt-ary-ptrn-elem-ary-elem-iter.js | 71 +++++++++++ ...eth-dflt-ary-ptrn-elem-ary-elision-init.js | 77 ++++++++++++ ...eth-dflt-ary-ptrn-elem-ary-elision-iter.js | 74 +++++++++++ ...-meth-dflt-ary-ptrn-elem-ary-empty-init.js | 72 +++++++++++ ...-meth-dflt-ary-ptrn-elem-ary-empty-iter.js | 70 +++++++++++ ...n-meth-dflt-ary-ptrn-elem-ary-rest-init.js | 74 +++++++++++ ...n-meth-dflt-ary-ptrn-elem-ary-rest-iter.js | 77 ++++++++++++ ...en-meth-dflt-ary-ptrn-elem-ary-val-null.js | 72 +++++++++++ ...th-dflt-ary-ptrn-elem-id-init-exhausted.js | 69 +++++++++++ ...flt-ary-ptrn-elem-id-init-fn-name-arrow.js | 70 +++++++++++ ...flt-ary-ptrn-elem-id-init-fn-name-class.js | 71 +++++++++++ ...flt-ary-ptrn-elem-id-init-fn-name-cover.js | 71 +++++++++++ ...h-dflt-ary-ptrn-elem-id-init-fn-name-fn.js | 71 +++++++++++ ...-dflt-ary-ptrn-elem-id-init-fn-name-gen.js | 71 +++++++++++ ...en-meth-dflt-ary-ptrn-elem-id-init-hole.js | 65 ++++++++++ ...meth-dflt-ary-ptrn-elem-id-init-skipped.js | 74 +++++++++++ ...-meth-dflt-ary-ptrn-elem-id-init-throws.js | 63 ++++++++++ ...n-meth-dflt-ary-ptrn-elem-id-init-undef.js | 68 +++++++++++ ...dflt-ary-ptrn-elem-id-init-unresolvable.js | 70 +++++++++++ ...eth-dflt-ary-ptrn-elem-id-iter-complete.js | 72 +++++++++++ ...en-meth-dflt-ary-ptrn-elem-id-iter-done.js | 67 ++++++++++ ...eth-dflt-ary-ptrn-elem-id-iter-step-err.js | 71 +++++++++++ ...meth-dflt-ary-ptrn-elem-id-iter-val-err.js | 82 +++++++++++++ ...gen-meth-dflt-ary-ptrn-elem-id-iter-val.js | 78 ++++++++++++ ...gen-meth-dflt-ary-ptrn-elem-obj-id-init.js | 70 +++++++++++ ...dstr-gen-meth-dflt-ary-ptrn-elem-obj-id.js | 70 +++++++++++ ...eth-dflt-ary-ptrn-elem-obj-prop-id-init.js | 80 ++++++++++++ ...gen-meth-dflt-ary-ptrn-elem-obj-prop-id.js | 80 ++++++++++++ ...en-meth-dflt-ary-ptrn-elem-obj-val-null.js | 72 +++++++++++ ...n-meth-dflt-ary-ptrn-elem-obj-val-undef.js | 72 +++++++++++ ...en-meth-dflt-ary-ptrn-elision-exhausted.js | 75 ++++++++++++ ...gen-meth-dflt-ary-ptrn-elision-step-err.js | 79 ++++++++++++ .../dstr-gen-meth-dflt-ary-ptrn-elision.js | 84 +++++++++++++ .../dstr-gen-meth-dflt-ary-ptrn-empty.js | 67 ++++++++++ ...tr-gen-meth-dflt-ary-ptrn-rest-ary-elem.js | 91 ++++++++++++++ ...gen-meth-dflt-ary-ptrn-rest-ary-elision.js | 97 +++++++++++++++ ...r-gen-meth-dflt-ary-ptrn-rest-ary-empty.js | 80 ++++++++++++ ...tr-gen-meth-dflt-ary-ptrn-rest-ary-rest.js | 76 ++++++++++++ ...-dflt-ary-ptrn-rest-id-elision-next-err.js | 65 ++++++++++ ...-gen-meth-dflt-ary-ptrn-rest-id-elision.js | 72 +++++++++++ ...en-meth-dflt-ary-ptrn-rest-id-exhausted.js | 68 +++++++++++ ...eth-dflt-ary-ptrn-rest-id-iter-step-err.js | 76 ++++++++++++ ...meth-dflt-ary-ptrn-rest-id-iter-val-err.js | 78 ++++++++++++ .../dstr-gen-meth-dflt-ary-ptrn-rest-id.js | 69 +++++++++++ ...tr-gen-meth-dflt-ary-ptrn-rest-init-ary.js | 63 ++++++++++ ...str-gen-meth-dflt-ary-ptrn-rest-init-id.js | 63 ++++++++++ ...tr-gen-meth-dflt-ary-ptrn-rest-init-obj.js | 63 ++++++++++ ...n-meth-dflt-ary-ptrn-rest-not-final-ary.js | 63 ++++++++++ ...en-meth-dflt-ary-ptrn-rest-not-final-id.js | 63 ++++++++++ ...n-meth-dflt-ary-ptrn-rest-not-final-obj.js | 63 ++++++++++ ...dstr-gen-meth-dflt-ary-ptrn-rest-obj-id.js | 69 +++++++++++ ...gen-meth-dflt-ary-ptrn-rest-obj-prop-id.js | 77 ++++++++++++ .../dstr-gen-meth-dflt-obj-init-null.js | 59 +++++++++ .../dstr-gen-meth-dflt-obj-init-undefined.js | 59 +++++++++ .../dstr-gen-meth-dflt-obj-ptrn-empty.js | 68 +++++++++++ ...gen-meth-dflt-obj-ptrn-id-get-value-err.js | 66 ++++++++++ ...eth-dflt-obj-ptrn-id-init-fn-name-arrow.js | 69 +++++++++++ ...eth-dflt-obj-ptrn-id-init-fn-name-class.js | 70 +++++++++++ ...eth-dflt-obj-ptrn-id-init-fn-name-cover.js | 70 +++++++++++ ...n-meth-dflt-obj-ptrn-id-init-fn-name-fn.js | 70 +++++++++++ ...-meth-dflt-obj-ptrn-id-init-fn-name-gen.js | 70 +++++++++++ ...-gen-meth-dflt-obj-ptrn-id-init-skipped.js | 73 +++++++++++ ...r-gen-meth-dflt-obj-ptrn-id-init-throws.js | 66 ++++++++++ ...meth-dflt-obj-ptrn-id-init-unresolvable.js | 70 +++++++++++ ...en-meth-dflt-obj-ptrn-id-trailing-comma.js | 63 ++++++++++ .../dstr-gen-meth-dflt-obj-ptrn-list-err.js | 67 ++++++++++ ...tr-gen-meth-dflt-obj-ptrn-prop-ary-init.js | 72 +++++++++++ ...h-dflt-obj-ptrn-prop-ary-trailing-comma.js | 63 ++++++++++ ...-meth-dflt-obj-ptrn-prop-ary-value-null.js | 61 ++++++++++ .../dstr-gen-meth-dflt-obj-ptrn-prop-ary.js | 70 +++++++++++ ...tr-gen-meth-dflt-obj-ptrn-prop-eval-err.js | 63 ++++++++++ ...eth-dflt-obj-ptrn-prop-id-get-value-err.js | 68 +++++++++++ ...meth-dflt-obj-ptrn-prop-id-init-skipped.js | 85 +++++++++++++ ...-meth-dflt-obj-ptrn-prop-id-init-throws.js | 66 ++++++++++ ...dflt-obj-ptrn-prop-id-init-unresolvable.js | 70 +++++++++++ ...str-gen-meth-dflt-obj-ptrn-prop-id-init.js | 66 ++++++++++ ...th-dflt-obj-ptrn-prop-id-trailing-comma.js | 67 ++++++++++ .../dstr-gen-meth-dflt-obj-ptrn-prop-id.js | 66 ++++++++++ ...tr-gen-meth-dflt-obj-ptrn-prop-obj-init.js | 72 +++++++++++ ...-meth-dflt-obj-ptrn-prop-obj-value-null.js | 61 ++++++++++ ...meth-dflt-obj-ptrn-prop-obj-value-undef.js | 61 ++++++++++ .../dstr-gen-meth-dflt-obj-ptrn-prop-obj.js | 70 +++++++++++ .../dstr-meth-dflt-ary-init-iter-close.js | 76 ++++++++++++ .../dstr-meth-dflt-ary-init-iter-get-err.js | 62 ++++++++++ .../dstr-meth-dflt-ary-init-iter-no-close.js | 76 ++++++++++++ .../dstr-meth-dflt-ary-name-iter-val.js | 75 ++++++++++++ ...r-meth-dflt-ary-ptrn-elem-ary-elem-init.js | 67 ++++++++++ ...r-meth-dflt-ary-ptrn-elem-ary-elem-iter.js | 68 +++++++++++ ...eth-dflt-ary-ptrn-elem-ary-elision-init.js | 74 +++++++++++ ...eth-dflt-ary-ptrn-elem-ary-elision-iter.js | 71 +++++++++++ ...-meth-dflt-ary-ptrn-elem-ary-empty-init.js | 69 +++++++++++ ...-meth-dflt-ary-ptrn-elem-ary-empty-iter.js | 67 ++++++++++ ...r-meth-dflt-ary-ptrn-elem-ary-rest-init.js | 71 +++++++++++ ...r-meth-dflt-ary-ptrn-elem-ary-rest-iter.js | 74 +++++++++++ ...tr-meth-dflt-ary-ptrn-elem-ary-val-null.js | 69 +++++++++++ ...th-dflt-ary-ptrn-elem-id-init-exhausted.js | 66 ++++++++++ ...flt-ary-ptrn-elem-id-init-fn-name-arrow.js | 67 ++++++++++ ...flt-ary-ptrn-elem-id-init-fn-name-class.js | 68 +++++++++++ ...flt-ary-ptrn-elem-id-init-fn-name-cover.js | 68 +++++++++++ ...h-dflt-ary-ptrn-elem-id-init-fn-name-fn.js | 68 +++++++++++ ...-dflt-ary-ptrn-elem-id-init-fn-name-gen.js | 68 +++++++++++ ...tr-meth-dflt-ary-ptrn-elem-id-init-hole.js | 62 ++++++++++ ...meth-dflt-ary-ptrn-elem-id-init-skipped.js | 71 +++++++++++ ...-meth-dflt-ary-ptrn-elem-id-init-throws.js | 60 +++++++++ ...r-meth-dflt-ary-ptrn-elem-id-init-undef.js | 65 ++++++++++ ...dflt-ary-ptrn-elem-id-init-unresolvable.js | 67 ++++++++++ ...eth-dflt-ary-ptrn-elem-id-iter-complete.js | 69 +++++++++++ ...tr-meth-dflt-ary-ptrn-elem-id-iter-done.js | 64 ++++++++++ ...eth-dflt-ary-ptrn-elem-id-iter-step-err.js | 68 +++++++++++ ...meth-dflt-ary-ptrn-elem-id-iter-val-err.js | 79 ++++++++++++ ...str-meth-dflt-ary-ptrn-elem-id-iter-val.js | 75 ++++++++++++ ...str-meth-dflt-ary-ptrn-elem-obj-id-init.js | 67 ++++++++++ .../dstr-meth-dflt-ary-ptrn-elem-obj-id.js | 67 ++++++++++ ...eth-dflt-ary-ptrn-elem-obj-prop-id-init.js | 77 ++++++++++++ ...str-meth-dflt-ary-ptrn-elem-obj-prop-id.js | 77 ++++++++++++ ...tr-meth-dflt-ary-ptrn-elem-obj-val-null.js | 69 +++++++++++ ...r-meth-dflt-ary-ptrn-elem-obj-val-undef.js | 69 +++++++++++ ...tr-meth-dflt-ary-ptrn-elision-exhausted.js | 72 +++++++++++ ...str-meth-dflt-ary-ptrn-elision-step-err.js | 76 ++++++++++++ .../object/dstr-meth-dflt-ary-ptrn-elision.js | 81 ++++++++++++ .../object/dstr-meth-dflt-ary-ptrn-empty.js | 64 ++++++++++ .../dstr-meth-dflt-ary-ptrn-rest-ary-elem.js | 88 ++++++++++++++ ...str-meth-dflt-ary-ptrn-rest-ary-elision.js | 94 ++++++++++++++ .../dstr-meth-dflt-ary-ptrn-rest-ary-empty.js | 77 ++++++++++++ .../dstr-meth-dflt-ary-ptrn-rest-ary-rest.js | 73 +++++++++++ ...-dflt-ary-ptrn-rest-id-elision-next-err.js | 62 ++++++++++ ...dstr-meth-dflt-ary-ptrn-rest-id-elision.js | 69 +++++++++++ ...tr-meth-dflt-ary-ptrn-rest-id-exhausted.js | 65 ++++++++++ ...eth-dflt-ary-ptrn-rest-id-iter-step-err.js | 73 +++++++++++ ...meth-dflt-ary-ptrn-rest-id-iter-val-err.js | 75 ++++++++++++ .../object/dstr-meth-dflt-ary-ptrn-rest-id.js | 66 ++++++++++ .../dstr-meth-dflt-ary-ptrn-rest-init-ary.js | 60 +++++++++ .../dstr-meth-dflt-ary-ptrn-rest-init-id.js | 60 +++++++++ .../dstr-meth-dflt-ary-ptrn-rest-init-obj.js | 60 +++++++++ ...r-meth-dflt-ary-ptrn-rest-not-final-ary.js | 60 +++++++++ ...tr-meth-dflt-ary-ptrn-rest-not-final-id.js | 60 +++++++++ ...r-meth-dflt-ary-ptrn-rest-not-final-obj.js | 60 +++++++++ .../dstr-meth-dflt-ary-ptrn-rest-obj-id.js | 66 ++++++++++ ...str-meth-dflt-ary-ptrn-rest-obj-prop-id.js | 74 +++++++++++ .../object/dstr-meth-dflt-obj-init-null.js | 56 +++++++++ .../dstr-meth-dflt-obj-init-undefined.js | 56 +++++++++ .../object/dstr-meth-dflt-obj-ptrn-empty.js | 65 ++++++++++ ...str-meth-dflt-obj-ptrn-id-get-value-err.js | 63 ++++++++++ ...eth-dflt-obj-ptrn-id-init-fn-name-arrow.js | 66 ++++++++++ ...eth-dflt-obj-ptrn-id-init-fn-name-class.js | 67 ++++++++++ ...eth-dflt-obj-ptrn-id-init-fn-name-cover.js | 67 ++++++++++ ...r-meth-dflt-obj-ptrn-id-init-fn-name-fn.js | 67 ++++++++++ ...-meth-dflt-obj-ptrn-id-init-fn-name-gen.js | 67 ++++++++++ ...dstr-meth-dflt-obj-ptrn-id-init-skipped.js | 70 +++++++++++ .../dstr-meth-dflt-obj-ptrn-id-init-throws.js | 63 ++++++++++ ...meth-dflt-obj-ptrn-id-init-unresolvable.js | 67 ++++++++++ ...tr-meth-dflt-obj-ptrn-id-trailing-comma.js | 60 +++++++++ .../dstr-meth-dflt-obj-ptrn-list-err.js | 64 ++++++++++ .../dstr-meth-dflt-obj-ptrn-prop-ary-init.js | 69 +++++++++++ ...h-dflt-obj-ptrn-prop-ary-trailing-comma.js | 60 +++++++++ ...-meth-dflt-obj-ptrn-prop-ary-value-null.js | 58 +++++++++ .../dstr-meth-dflt-obj-ptrn-prop-ary.js | 67 ++++++++++ .../dstr-meth-dflt-obj-ptrn-prop-eval-err.js | 60 +++++++++ ...eth-dflt-obj-ptrn-prop-id-get-value-err.js | 65 ++++++++++ ...meth-dflt-obj-ptrn-prop-id-init-skipped.js | 82 +++++++++++++ ...-meth-dflt-obj-ptrn-prop-id-init-throws.js | 63 ++++++++++ ...dflt-obj-ptrn-prop-id-init-unresolvable.js | 67 ++++++++++ .../dstr-meth-dflt-obj-ptrn-prop-id-init.js | 63 ++++++++++ ...th-dflt-obj-ptrn-prop-id-trailing-comma.js | 64 ++++++++++ .../object/dstr-meth-dflt-obj-ptrn-prop-id.js | 63 ++++++++++ .../dstr-meth-dflt-obj-ptrn-prop-obj-init.js | 69 +++++++++++ ...-meth-dflt-obj-ptrn-prop-obj-value-null.js | 58 +++++++++ ...meth-dflt-obj-ptrn-prop-obj-value-undef.js | 58 +++++++++ .../dstr-meth-dflt-obj-ptrn-prop-obj.js | 67 ++++++++++ .../dstr-gen-meth-dflt-ary-init-iter-close.js | 95 +++++++++++++++ ...str-gen-meth-dflt-ary-init-iter-get-err.js | 82 +++++++++++++ ...tr-gen-meth-dflt-ary-init-iter-no-close.js | 95 +++++++++++++++ .../dstr-gen-meth-dflt-ary-name-iter-val.js | 94 ++++++++++++++ ...n-meth-dflt-ary-ptrn-elem-ary-elem-init.js | 86 +++++++++++++ ...n-meth-dflt-ary-ptrn-elem-ary-elem-iter.js | 87 +++++++++++++ ...eth-dflt-ary-ptrn-elem-ary-elision-init.js | 93 ++++++++++++++ ...eth-dflt-ary-ptrn-elem-ary-elision-iter.js | 90 ++++++++++++++ ...-meth-dflt-ary-ptrn-elem-ary-empty-init.js | 88 ++++++++++++++ ...-meth-dflt-ary-ptrn-elem-ary-empty-iter.js | 86 +++++++++++++ ...n-meth-dflt-ary-ptrn-elem-ary-rest-init.js | 90 ++++++++++++++ ...n-meth-dflt-ary-ptrn-elem-ary-rest-iter.js | 93 ++++++++++++++ ...en-meth-dflt-ary-ptrn-elem-ary-val-null.js | 89 ++++++++++++++ ...th-dflt-ary-ptrn-elem-id-init-exhausted.js | 85 +++++++++++++ ...flt-ary-ptrn-elem-id-init-fn-name-arrow.js | 86 +++++++++++++ ...flt-ary-ptrn-elem-id-init-fn-name-class.js | 87 +++++++++++++ ...flt-ary-ptrn-elem-id-init-fn-name-cover.js | 87 +++++++++++++ ...h-dflt-ary-ptrn-elem-id-init-fn-name-fn.js | 87 +++++++++++++ ...-dflt-ary-ptrn-elem-id-init-fn-name-gen.js | 87 +++++++++++++ ...en-meth-dflt-ary-ptrn-elem-id-init-hole.js | 81 ++++++++++++ ...meth-dflt-ary-ptrn-elem-id-init-skipped.js | 90 ++++++++++++++ ...-meth-dflt-ary-ptrn-elem-id-init-throws.js | 80 ++++++++++++ ...n-meth-dflt-ary-ptrn-elem-id-init-undef.js | 84 +++++++++++++ ...dflt-ary-ptrn-elem-id-init-unresolvable.js | 87 +++++++++++++ ...eth-dflt-ary-ptrn-elem-id-iter-complete.js | 88 ++++++++++++++ ...en-meth-dflt-ary-ptrn-elem-id-iter-done.js | 83 +++++++++++++ ...eth-dflt-ary-ptrn-elem-id-iter-step-err.js | 88 ++++++++++++++ ...meth-dflt-ary-ptrn-elem-id-iter-val-err.js | 99 +++++++++++++++ ...gen-meth-dflt-ary-ptrn-elem-id-iter-val.js | 94 ++++++++++++++ ...gen-meth-dflt-ary-ptrn-elem-obj-id-init.js | 86 +++++++++++++ ...dstr-gen-meth-dflt-ary-ptrn-elem-obj-id.js | 86 +++++++++++++ ...eth-dflt-ary-ptrn-elem-obj-prop-id-init.js | 96 +++++++++++++++ ...gen-meth-dflt-ary-ptrn-elem-obj-prop-id.js | 96 +++++++++++++++ ...en-meth-dflt-ary-ptrn-elem-obj-val-null.js | 89 ++++++++++++++ ...n-meth-dflt-ary-ptrn-elem-obj-val-undef.js | 89 ++++++++++++++ ...en-meth-dflt-ary-ptrn-elision-exhausted.js | 91 ++++++++++++++ ...gen-meth-dflt-ary-ptrn-elision-step-err.js | 96 +++++++++++++++ .../dstr-gen-meth-dflt-ary-ptrn-elision.js | 100 +++++++++++++++ .../dstr-gen-meth-dflt-ary-ptrn-empty.js | 83 +++++++++++++ ...tr-gen-meth-dflt-ary-ptrn-rest-ary-elem.js | 107 ++++++++++++++++ ...gen-meth-dflt-ary-ptrn-rest-ary-elision.js | 113 +++++++++++++++++ ...r-gen-meth-dflt-ary-ptrn-rest-ary-empty.js | 96 +++++++++++++++ ...tr-gen-meth-dflt-ary-ptrn-rest-ary-rest.js | 92 ++++++++++++++ ...-dflt-ary-ptrn-rest-id-elision-next-err.js | 82 +++++++++++++ ...-gen-meth-dflt-ary-ptrn-rest-id-elision.js | 88 ++++++++++++++ ...en-meth-dflt-ary-ptrn-rest-id-exhausted.js | 84 +++++++++++++ ...eth-dflt-ary-ptrn-rest-id-iter-step-err.js | 93 ++++++++++++++ ...meth-dflt-ary-ptrn-rest-id-iter-val-err.js | 95 +++++++++++++++ .../dstr-gen-meth-dflt-ary-ptrn-rest-id.js | 85 +++++++++++++ ...tr-gen-meth-dflt-ary-ptrn-rest-init-ary.js | 79 ++++++++++++ ...str-gen-meth-dflt-ary-ptrn-rest-init-id.js | 79 ++++++++++++ ...tr-gen-meth-dflt-ary-ptrn-rest-init-obj.js | 79 ++++++++++++ ...n-meth-dflt-ary-ptrn-rest-not-final-ary.js | 79 ++++++++++++ ...en-meth-dflt-ary-ptrn-rest-not-final-id.js | 79 ++++++++++++ ...n-meth-dflt-ary-ptrn-rest-not-final-obj.js | 79 ++++++++++++ ...dstr-gen-meth-dflt-ary-ptrn-rest-obj-id.js | 85 +++++++++++++ ...gen-meth-dflt-ary-ptrn-rest-obj-prop-id.js | 93 ++++++++++++++ .../class/dstr-gen-meth-dflt-obj-init-null.js | 76 ++++++++++++ .../dstr-gen-meth-dflt-obj-init-undefined.js | 76 ++++++++++++ .../dstr-gen-meth-dflt-obj-ptrn-empty.js | 84 +++++++++++++ ...gen-meth-dflt-obj-ptrn-id-get-value-err.js | 83 +++++++++++++ ...eth-dflt-obj-ptrn-id-init-fn-name-arrow.js | 85 +++++++++++++ ...eth-dflt-obj-ptrn-id-init-fn-name-class.js | 86 +++++++++++++ ...eth-dflt-obj-ptrn-id-init-fn-name-cover.js | 86 +++++++++++++ ...n-meth-dflt-obj-ptrn-id-init-fn-name-fn.js | 86 +++++++++++++ ...-meth-dflt-obj-ptrn-id-init-fn-name-gen.js | 86 +++++++++++++ ...-gen-meth-dflt-obj-ptrn-id-init-skipped.js | 89 ++++++++++++++ ...r-gen-meth-dflt-obj-ptrn-id-init-throws.js | 83 +++++++++++++ ...meth-dflt-obj-ptrn-id-init-unresolvable.js | 87 +++++++++++++ ...en-meth-dflt-obj-ptrn-id-trailing-comma.js | 79 ++++++++++++ .../dstr-gen-meth-dflt-obj-ptrn-list-err.js | 84 +++++++++++++ ...tr-gen-meth-dflt-obj-ptrn-prop-ary-init.js | 88 ++++++++++++++ ...h-dflt-obj-ptrn-prop-ary-trailing-comma.js | 79 ++++++++++++ ...-meth-dflt-obj-ptrn-prop-ary-value-null.js | 78 ++++++++++++ .../dstr-gen-meth-dflt-obj-ptrn-prop-ary.js | 86 +++++++++++++ ...tr-gen-meth-dflt-obj-ptrn-prop-eval-err.js | 80 ++++++++++++ ...eth-dflt-obj-ptrn-prop-id-get-value-err.js | 85 +++++++++++++ ...meth-dflt-obj-ptrn-prop-id-init-skipped.js | 101 +++++++++++++++ ...-meth-dflt-obj-ptrn-prop-id-init-throws.js | 83 +++++++++++++ ...dflt-obj-ptrn-prop-id-init-unresolvable.js | 87 +++++++++++++ ...str-gen-meth-dflt-obj-ptrn-prop-id-init.js | 82 +++++++++++++ ...th-dflt-obj-ptrn-prop-id-trailing-comma.js | 83 +++++++++++++ .../dstr-gen-meth-dflt-obj-ptrn-prop-id.js | 82 +++++++++++++ ...tr-gen-meth-dflt-obj-ptrn-prop-obj-init.js | 88 ++++++++++++++ ...-meth-dflt-obj-ptrn-prop-obj-value-null.js | 78 ++++++++++++ ...meth-dflt-obj-ptrn-prop-obj-value-undef.js | 78 ++++++++++++ .../dstr-gen-meth-dflt-obj-ptrn-prop-obj.js | 86 +++++++++++++ ...en-meth-static-dflt-ary-init-iter-close.js | 95 +++++++++++++++ ...-meth-static-dflt-ary-init-iter-get-err.js | 81 ++++++++++++ ...meth-static-dflt-ary-init-iter-no-close.js | 95 +++++++++++++++ ...-gen-meth-static-dflt-ary-name-iter-val.js | 94 ++++++++++++++ ...static-dflt-ary-ptrn-elem-ary-elem-init.js | 86 +++++++++++++ ...static-dflt-ary-ptrn-elem-ary-elem-iter.js | 87 +++++++++++++ ...tic-dflt-ary-ptrn-elem-ary-elision-init.js | 93 ++++++++++++++ ...tic-dflt-ary-ptrn-elem-ary-elision-iter.js | 90 ++++++++++++++ ...tatic-dflt-ary-ptrn-elem-ary-empty-init.js | 88 ++++++++++++++ ...tatic-dflt-ary-ptrn-elem-ary-empty-iter.js | 86 +++++++++++++ ...static-dflt-ary-ptrn-elem-ary-rest-init.js | 90 ++++++++++++++ ...static-dflt-ary-ptrn-elem-ary-rest-iter.js | 93 ++++++++++++++ ...-static-dflt-ary-ptrn-elem-ary-val-null.js | 88 ++++++++++++++ ...ic-dflt-ary-ptrn-elem-id-init-exhausted.js | 85 +++++++++++++ ...flt-ary-ptrn-elem-id-init-fn-name-arrow.js | 86 +++++++++++++ ...flt-ary-ptrn-elem-id-init-fn-name-class.js | 87 +++++++++++++ ...flt-ary-ptrn-elem-id-init-fn-name-cover.js | 87 +++++++++++++ ...c-dflt-ary-ptrn-elem-id-init-fn-name-fn.js | 87 +++++++++++++ ...-dflt-ary-ptrn-elem-id-init-fn-name-gen.js | 87 +++++++++++++ ...-static-dflt-ary-ptrn-elem-id-init-hole.js | 81 ++++++++++++ ...atic-dflt-ary-ptrn-elem-id-init-skipped.js | 90 ++++++++++++++ ...tatic-dflt-ary-ptrn-elem-id-init-throws.js | 79 ++++++++++++ ...static-dflt-ary-ptrn-elem-id-init-undef.js | 84 +++++++++++++ ...dflt-ary-ptrn-elem-id-init-unresolvable.js | 86 +++++++++++++ ...tic-dflt-ary-ptrn-elem-id-iter-complete.js | 88 ++++++++++++++ ...-static-dflt-ary-ptrn-elem-id-iter-done.js | 83 +++++++++++++ ...tic-dflt-ary-ptrn-elem-id-iter-step-err.js | 87 +++++++++++++ ...atic-dflt-ary-ptrn-elem-id-iter-val-err.js | 98 +++++++++++++++ ...h-static-dflt-ary-ptrn-elem-id-iter-val.js | 94 ++++++++++++++ ...h-static-dflt-ary-ptrn-elem-obj-id-init.js | 86 +++++++++++++ ...n-meth-static-dflt-ary-ptrn-elem-obj-id.js | 86 +++++++++++++ ...tic-dflt-ary-ptrn-elem-obj-prop-id-init.js | 96 +++++++++++++++ ...h-static-dflt-ary-ptrn-elem-obj-prop-id.js | 96 +++++++++++++++ ...-static-dflt-ary-ptrn-elem-obj-val-null.js | 88 ++++++++++++++ ...static-dflt-ary-ptrn-elem-obj-val-undef.js | 88 ++++++++++++++ ...-static-dflt-ary-ptrn-elision-exhausted.js | 91 ++++++++++++++ ...h-static-dflt-ary-ptrn-elision-step-err.js | 95 +++++++++++++++ ...r-gen-meth-static-dflt-ary-ptrn-elision.js | 100 +++++++++++++++ ...str-gen-meth-static-dflt-ary-ptrn-empty.js | 83 +++++++++++++ ...meth-static-dflt-ary-ptrn-rest-ary-elem.js | 107 ++++++++++++++++ ...h-static-dflt-ary-ptrn-rest-ary-elision.js | 113 +++++++++++++++++ ...eth-static-dflt-ary-ptrn-rest-ary-empty.js | 96 +++++++++++++++ ...meth-static-dflt-ary-ptrn-rest-ary-rest.js | 92 ++++++++++++++ ...-dflt-ary-ptrn-rest-id-elision-next-err.js | 81 ++++++++++++ ...th-static-dflt-ary-ptrn-rest-id-elision.js | 88 ++++++++++++++ ...-static-dflt-ary-ptrn-rest-id-exhausted.js | 84 +++++++++++++ ...tic-dflt-ary-ptrn-rest-id-iter-step-err.js | 92 ++++++++++++++ ...atic-dflt-ary-ptrn-rest-id-iter-val-err.js | 94 ++++++++++++++ ...r-gen-meth-static-dflt-ary-ptrn-rest-id.js | 85 +++++++++++++ ...meth-static-dflt-ary-ptrn-rest-init-ary.js | 79 ++++++++++++ ...-meth-static-dflt-ary-ptrn-rest-init-id.js | 79 ++++++++++++ ...meth-static-dflt-ary-ptrn-rest-init-obj.js | 79 ++++++++++++ ...static-dflt-ary-ptrn-rest-not-final-ary.js | 79 ++++++++++++ ...-static-dflt-ary-ptrn-rest-not-final-id.js | 79 ++++++++++++ ...static-dflt-ary-ptrn-rest-not-final-obj.js | 79 ++++++++++++ ...n-meth-static-dflt-ary-ptrn-rest-obj-id.js | 85 +++++++++++++ ...h-static-dflt-ary-ptrn-rest-obj-prop-id.js | 93 ++++++++++++++ ...dstr-gen-meth-static-dflt-obj-init-null.js | 75 ++++++++++++ ...gen-meth-static-dflt-obj-init-undefined.js | 75 ++++++++++++ ...str-gen-meth-static-dflt-obj-ptrn-empty.js | 84 +++++++++++++ ...h-static-dflt-obj-ptrn-id-get-value-err.js | 82 +++++++++++++ ...tic-dflt-obj-ptrn-id-init-fn-name-arrow.js | 85 +++++++++++++ ...tic-dflt-obj-ptrn-id-init-fn-name-class.js | 86 +++++++++++++ ...tic-dflt-obj-ptrn-id-init-fn-name-cover.js | 86 +++++++++++++ ...static-dflt-obj-ptrn-id-init-fn-name-fn.js | 86 +++++++++++++ ...tatic-dflt-obj-ptrn-id-init-fn-name-gen.js | 86 +++++++++++++ ...th-static-dflt-obj-ptrn-id-init-skipped.js | 89 ++++++++++++++ ...eth-static-dflt-obj-ptrn-id-init-throws.js | 82 +++++++++++++ ...atic-dflt-obj-ptrn-id-init-unresolvable.js | 86 +++++++++++++ ...-static-dflt-obj-ptrn-id-trailing-comma.js | 79 ++++++++++++ ...-gen-meth-static-dflt-obj-ptrn-list-err.js | 83 +++++++++++++ ...meth-static-dflt-obj-ptrn-prop-ary-init.js | 88 ++++++++++++++ ...c-dflt-obj-ptrn-prop-ary-trailing-comma.js | 79 ++++++++++++ ...tatic-dflt-obj-ptrn-prop-ary-value-null.js | 77 ++++++++++++ ...-gen-meth-static-dflt-obj-ptrn-prop-ary.js | 86 +++++++++++++ ...meth-static-dflt-obj-ptrn-prop-eval-err.js | 79 ++++++++++++ ...tic-dflt-obj-ptrn-prop-id-get-value-err.js | 84 +++++++++++++ ...atic-dflt-obj-ptrn-prop-id-init-skipped.js | 101 +++++++++++++++ ...tatic-dflt-obj-ptrn-prop-id-init-throws.js | 82 +++++++++++++ ...dflt-obj-ptrn-prop-id-init-unresolvable.js | 86 +++++++++++++ ...-meth-static-dflt-obj-ptrn-prop-id-init.js | 82 +++++++++++++ ...ic-dflt-obj-ptrn-prop-id-trailing-comma.js | 83 +++++++++++++ ...r-gen-meth-static-dflt-obj-ptrn-prop-id.js | 82 +++++++++++++ ...meth-static-dflt-obj-ptrn-prop-obj-init.js | 88 ++++++++++++++ ...tatic-dflt-obj-ptrn-prop-obj-value-null.js | 77 ++++++++++++ ...atic-dflt-obj-ptrn-prop-obj-value-undef.js | 77 ++++++++++++ ...-gen-meth-static-dflt-obj-ptrn-prop-obj.js | 86 +++++++++++++ .../dstr-meth-dflt-ary-init-iter-close.js | 93 ++++++++++++++ .../dstr-meth-dflt-ary-init-iter-get-err.js | 81 ++++++++++++ .../dstr-meth-dflt-ary-init-iter-no-close.js | 93 ++++++++++++++ .../class/dstr-meth-dflt-ary-name-iter-val.js | 92 ++++++++++++++ ...r-meth-dflt-ary-ptrn-elem-ary-elem-init.js | 84 +++++++++++++ ...r-meth-dflt-ary-ptrn-elem-ary-elem-iter.js | 85 +++++++++++++ ...eth-dflt-ary-ptrn-elem-ary-elision-init.js | 91 ++++++++++++++ ...eth-dflt-ary-ptrn-elem-ary-elision-iter.js | 88 ++++++++++++++ ...-meth-dflt-ary-ptrn-elem-ary-empty-init.js | 86 +++++++++++++ ...-meth-dflt-ary-ptrn-elem-ary-empty-iter.js | 84 +++++++++++++ ...r-meth-dflt-ary-ptrn-elem-ary-rest-init.js | 88 ++++++++++++++ ...r-meth-dflt-ary-ptrn-elem-ary-rest-iter.js | 91 ++++++++++++++ ...tr-meth-dflt-ary-ptrn-elem-ary-val-null.js | 88 ++++++++++++++ ...th-dflt-ary-ptrn-elem-id-init-exhausted.js | 83 +++++++++++++ ...flt-ary-ptrn-elem-id-init-fn-name-arrow.js | 84 +++++++++++++ ...flt-ary-ptrn-elem-id-init-fn-name-class.js | 85 +++++++++++++ ...flt-ary-ptrn-elem-id-init-fn-name-cover.js | 85 +++++++++++++ ...h-dflt-ary-ptrn-elem-id-init-fn-name-fn.js | 85 +++++++++++++ ...-dflt-ary-ptrn-elem-id-init-fn-name-gen.js | 85 +++++++++++++ ...tr-meth-dflt-ary-ptrn-elem-id-init-hole.js | 79 ++++++++++++ ...meth-dflt-ary-ptrn-elem-id-init-skipped.js | 88 ++++++++++++++ ...-meth-dflt-ary-ptrn-elem-id-init-throws.js | 79 ++++++++++++ ...r-meth-dflt-ary-ptrn-elem-id-init-undef.js | 82 +++++++++++++ ...dflt-ary-ptrn-elem-id-init-unresolvable.js | 86 +++++++++++++ ...eth-dflt-ary-ptrn-elem-id-iter-complete.js | 86 +++++++++++++ ...tr-meth-dflt-ary-ptrn-elem-id-iter-done.js | 81 ++++++++++++ ...eth-dflt-ary-ptrn-elem-id-iter-step-err.js | 87 +++++++++++++ ...meth-dflt-ary-ptrn-elem-id-iter-val-err.js | 98 +++++++++++++++ ...str-meth-dflt-ary-ptrn-elem-id-iter-val.js | 92 ++++++++++++++ ...str-meth-dflt-ary-ptrn-elem-obj-id-init.js | 84 +++++++++++++ .../dstr-meth-dflt-ary-ptrn-elem-obj-id.js | 84 +++++++++++++ ...eth-dflt-ary-ptrn-elem-obj-prop-id-init.js | 94 ++++++++++++++ ...str-meth-dflt-ary-ptrn-elem-obj-prop-id.js | 94 ++++++++++++++ ...tr-meth-dflt-ary-ptrn-elem-obj-val-null.js | 88 ++++++++++++++ ...r-meth-dflt-ary-ptrn-elem-obj-val-undef.js | 88 ++++++++++++++ ...tr-meth-dflt-ary-ptrn-elision-exhausted.js | 89 ++++++++++++++ ...str-meth-dflt-ary-ptrn-elision-step-err.js | 95 +++++++++++++++ .../class/dstr-meth-dflt-ary-ptrn-elision.js | 98 +++++++++++++++ .../class/dstr-meth-dflt-ary-ptrn-empty.js | 81 ++++++++++++ .../dstr-meth-dflt-ary-ptrn-rest-ary-elem.js | 105 ++++++++++++++++ ...str-meth-dflt-ary-ptrn-rest-ary-elision.js | 111 +++++++++++++++++ .../dstr-meth-dflt-ary-ptrn-rest-ary-empty.js | 94 ++++++++++++++ .../dstr-meth-dflt-ary-ptrn-rest-ary-rest.js | 90 ++++++++++++++ ...-dflt-ary-ptrn-rest-id-elision-next-err.js | 81 ++++++++++++ ...dstr-meth-dflt-ary-ptrn-rest-id-elision.js | 86 +++++++++++++ ...tr-meth-dflt-ary-ptrn-rest-id-exhausted.js | 82 +++++++++++++ ...eth-dflt-ary-ptrn-rest-id-iter-step-err.js | 92 ++++++++++++++ ...meth-dflt-ary-ptrn-rest-id-iter-val-err.js | 94 ++++++++++++++ .../class/dstr-meth-dflt-ary-ptrn-rest-id.js | 83 +++++++++++++ .../dstr-meth-dflt-ary-ptrn-rest-init-ary.js | 77 ++++++++++++ .../dstr-meth-dflt-ary-ptrn-rest-init-id.js | 77 ++++++++++++ .../dstr-meth-dflt-ary-ptrn-rest-init-obj.js | 77 ++++++++++++ ...r-meth-dflt-ary-ptrn-rest-not-final-ary.js | 77 ++++++++++++ ...tr-meth-dflt-ary-ptrn-rest-not-final-id.js | 77 ++++++++++++ ...r-meth-dflt-ary-ptrn-rest-not-final-obj.js | 77 ++++++++++++ .../dstr-meth-dflt-ary-ptrn-rest-obj-id.js | 83 +++++++++++++ ...str-meth-dflt-ary-ptrn-rest-obj-prop-id.js | 91 ++++++++++++++ .../class/dstr-meth-dflt-obj-init-null.js | 75 ++++++++++++ .../dstr-meth-dflt-obj-init-undefined.js | 75 ++++++++++++ .../class/dstr-meth-dflt-obj-ptrn-empty.js | 82 +++++++++++++ ...str-meth-dflt-obj-ptrn-id-get-value-err.js | 82 +++++++++++++ ...eth-dflt-obj-ptrn-id-init-fn-name-arrow.js | 83 +++++++++++++ ...eth-dflt-obj-ptrn-id-init-fn-name-class.js | 84 +++++++++++++ ...eth-dflt-obj-ptrn-id-init-fn-name-cover.js | 84 +++++++++++++ ...r-meth-dflt-obj-ptrn-id-init-fn-name-fn.js | 84 +++++++++++++ ...-meth-dflt-obj-ptrn-id-init-fn-name-gen.js | 84 +++++++++++++ ...dstr-meth-dflt-obj-ptrn-id-init-skipped.js | 87 +++++++++++++ .../dstr-meth-dflt-obj-ptrn-id-init-throws.js | 82 +++++++++++++ ...meth-dflt-obj-ptrn-id-init-unresolvable.js | 86 +++++++++++++ ...tr-meth-dflt-obj-ptrn-id-trailing-comma.js | 77 ++++++++++++ .../class/dstr-meth-dflt-obj-ptrn-list-err.js | 83 +++++++++++++ .../dstr-meth-dflt-obj-ptrn-prop-ary-init.js | 86 +++++++++++++ ...h-dflt-obj-ptrn-prop-ary-trailing-comma.js | 77 ++++++++++++ ...-meth-dflt-obj-ptrn-prop-ary-value-null.js | 77 ++++++++++++ .../class/dstr-meth-dflt-obj-ptrn-prop-ary.js | 84 +++++++++++++ .../dstr-meth-dflt-obj-ptrn-prop-eval-err.js | 79 ++++++++++++ ...eth-dflt-obj-ptrn-prop-id-get-value-err.js | 84 +++++++++++++ ...meth-dflt-obj-ptrn-prop-id-init-skipped.js | 99 +++++++++++++++ ...-meth-dflt-obj-ptrn-prop-id-init-throws.js | 82 +++++++++++++ ...dflt-obj-ptrn-prop-id-init-unresolvable.js | 86 +++++++++++++ .../dstr-meth-dflt-obj-ptrn-prop-id-init.js | 80 ++++++++++++ ...th-dflt-obj-ptrn-prop-id-trailing-comma.js | 81 ++++++++++++ .../class/dstr-meth-dflt-obj-ptrn-prop-id.js | 80 ++++++++++++ .../dstr-meth-dflt-obj-ptrn-prop-obj-init.js | 86 +++++++++++++ ...-meth-dflt-obj-ptrn-prop-obj-value-null.js | 77 ++++++++++++ ...meth-dflt-obj-ptrn-prop-obj-value-undef.js | 77 ++++++++++++ .../class/dstr-meth-dflt-obj-ptrn-prop-obj.js | 84 +++++++++++++ ...tr-meth-static-dflt-ary-init-iter-close.js | 93 ++++++++++++++ ...-meth-static-dflt-ary-init-iter-get-err.js | 79 ++++++++++++ ...meth-static-dflt-ary-init-iter-no-close.js | 93 ++++++++++++++ ...dstr-meth-static-dflt-ary-name-iter-val.js | 92 ++++++++++++++ ...static-dflt-ary-ptrn-elem-ary-elem-init.js | 84 +++++++++++++ ...static-dflt-ary-ptrn-elem-ary-elem-iter.js | 85 +++++++++++++ ...tic-dflt-ary-ptrn-elem-ary-elision-init.js | 91 ++++++++++++++ ...tic-dflt-ary-ptrn-elem-ary-elision-iter.js | 88 ++++++++++++++ ...tatic-dflt-ary-ptrn-elem-ary-empty-init.js | 86 +++++++++++++ ...tatic-dflt-ary-ptrn-elem-ary-empty-iter.js | 84 +++++++++++++ ...static-dflt-ary-ptrn-elem-ary-rest-init.js | 88 ++++++++++++++ ...static-dflt-ary-ptrn-elem-ary-rest-iter.js | 91 ++++++++++++++ ...-static-dflt-ary-ptrn-elem-ary-val-null.js | 86 +++++++++++++ ...ic-dflt-ary-ptrn-elem-id-init-exhausted.js | 83 +++++++++++++ ...flt-ary-ptrn-elem-id-init-fn-name-arrow.js | 84 +++++++++++++ ...flt-ary-ptrn-elem-id-init-fn-name-class.js | 85 +++++++++++++ ...flt-ary-ptrn-elem-id-init-fn-name-cover.js | 85 +++++++++++++ ...c-dflt-ary-ptrn-elem-id-init-fn-name-fn.js | 85 +++++++++++++ ...-dflt-ary-ptrn-elem-id-init-fn-name-gen.js | 85 +++++++++++++ ...-static-dflt-ary-ptrn-elem-id-init-hole.js | 79 ++++++++++++ ...atic-dflt-ary-ptrn-elem-id-init-skipped.js | 88 ++++++++++++++ ...tatic-dflt-ary-ptrn-elem-id-init-throws.js | 77 ++++++++++++ ...static-dflt-ary-ptrn-elem-id-init-undef.js | 82 +++++++++++++ ...dflt-ary-ptrn-elem-id-init-unresolvable.js | 84 +++++++++++++ ...tic-dflt-ary-ptrn-elem-id-iter-complete.js | 86 +++++++++++++ ...-static-dflt-ary-ptrn-elem-id-iter-done.js | 81 ++++++++++++ ...tic-dflt-ary-ptrn-elem-id-iter-step-err.js | 85 +++++++++++++ ...atic-dflt-ary-ptrn-elem-id-iter-val-err.js | 96 +++++++++++++++ ...h-static-dflt-ary-ptrn-elem-id-iter-val.js | 92 ++++++++++++++ ...h-static-dflt-ary-ptrn-elem-obj-id-init.js | 84 +++++++++++++ ...r-meth-static-dflt-ary-ptrn-elem-obj-id.js | 84 +++++++++++++ ...tic-dflt-ary-ptrn-elem-obj-prop-id-init.js | 94 ++++++++++++++ ...h-static-dflt-ary-ptrn-elem-obj-prop-id.js | 94 ++++++++++++++ ...-static-dflt-ary-ptrn-elem-obj-val-null.js | 86 +++++++++++++ ...static-dflt-ary-ptrn-elem-obj-val-undef.js | 86 +++++++++++++ ...-static-dflt-ary-ptrn-elision-exhausted.js | 89 ++++++++++++++ ...h-static-dflt-ary-ptrn-elision-step-err.js | 93 ++++++++++++++ .../dstr-meth-static-dflt-ary-ptrn-elision.js | 98 +++++++++++++++ .../dstr-meth-static-dflt-ary-ptrn-empty.js | 81 ++++++++++++ ...meth-static-dflt-ary-ptrn-rest-ary-elem.js | 105 ++++++++++++++++ ...h-static-dflt-ary-ptrn-rest-ary-elision.js | 111 +++++++++++++++++ ...eth-static-dflt-ary-ptrn-rest-ary-empty.js | 94 ++++++++++++++ ...meth-static-dflt-ary-ptrn-rest-ary-rest.js | 90 ++++++++++++++ ...-dflt-ary-ptrn-rest-id-elision-next-err.js | 79 ++++++++++++ ...th-static-dflt-ary-ptrn-rest-id-elision.js | 86 +++++++++++++ ...-static-dflt-ary-ptrn-rest-id-exhausted.js | 82 +++++++++++++ ...tic-dflt-ary-ptrn-rest-id-iter-step-err.js | 90 ++++++++++++++ ...atic-dflt-ary-ptrn-rest-id-iter-val-err.js | 92 ++++++++++++++ .../dstr-meth-static-dflt-ary-ptrn-rest-id.js | 83 +++++++++++++ ...meth-static-dflt-ary-ptrn-rest-init-ary.js | 77 ++++++++++++ ...-meth-static-dflt-ary-ptrn-rest-init-id.js | 77 ++++++++++++ ...meth-static-dflt-ary-ptrn-rest-init-obj.js | 77 ++++++++++++ ...static-dflt-ary-ptrn-rest-not-final-ary.js | 77 ++++++++++++ ...-static-dflt-ary-ptrn-rest-not-final-id.js | 77 ++++++++++++ ...static-dflt-ary-ptrn-rest-not-final-obj.js | 77 ++++++++++++ ...r-meth-static-dflt-ary-ptrn-rest-obj-id.js | 83 +++++++++++++ ...h-static-dflt-ary-ptrn-rest-obj-prop-id.js | 91 ++++++++++++++ .../dstr-meth-static-dflt-obj-init-null.js | 73 +++++++++++ ...str-meth-static-dflt-obj-init-undefined.js | 73 +++++++++++ .../dstr-meth-static-dflt-obj-ptrn-empty.js | 82 +++++++++++++ ...h-static-dflt-obj-ptrn-id-get-value-err.js | 80 ++++++++++++ ...tic-dflt-obj-ptrn-id-init-fn-name-arrow.js | 83 +++++++++++++ ...tic-dflt-obj-ptrn-id-init-fn-name-class.js | 84 +++++++++++++ ...tic-dflt-obj-ptrn-id-init-fn-name-cover.js | 84 +++++++++++++ ...static-dflt-obj-ptrn-id-init-fn-name-fn.js | 84 +++++++++++++ ...tatic-dflt-obj-ptrn-id-init-fn-name-gen.js | 84 +++++++++++++ ...th-static-dflt-obj-ptrn-id-init-skipped.js | 87 +++++++++++++ ...eth-static-dflt-obj-ptrn-id-init-throws.js | 80 ++++++++++++ ...atic-dflt-obj-ptrn-id-init-unresolvable.js | 84 +++++++++++++ ...-static-dflt-obj-ptrn-id-trailing-comma.js | 77 ++++++++++++ ...dstr-meth-static-dflt-obj-ptrn-list-err.js | 81 ++++++++++++ ...meth-static-dflt-obj-ptrn-prop-ary-init.js | 86 +++++++++++++ ...c-dflt-obj-ptrn-prop-ary-trailing-comma.js | 77 ++++++++++++ ...tatic-dflt-obj-ptrn-prop-ary-value-null.js | 75 ++++++++++++ ...dstr-meth-static-dflt-obj-ptrn-prop-ary.js | 84 +++++++++++++ ...meth-static-dflt-obj-ptrn-prop-eval-err.js | 77 ++++++++++++ ...tic-dflt-obj-ptrn-prop-id-get-value-err.js | 82 +++++++++++++ ...atic-dflt-obj-ptrn-prop-id-init-skipped.js | 99 +++++++++++++++ ...tatic-dflt-obj-ptrn-prop-id-init-throws.js | 80 ++++++++++++ ...dflt-obj-ptrn-prop-id-init-unresolvable.js | 84 +++++++++++++ ...-meth-static-dflt-obj-ptrn-prop-id-init.js | 80 ++++++++++++ ...ic-dflt-obj-ptrn-prop-id-trailing-comma.js | 81 ++++++++++++ .../dstr-meth-static-dflt-obj-ptrn-prop-id.js | 80 ++++++++++++ ...meth-static-dflt-obj-ptrn-prop-obj-init.js | 86 +++++++++++++ ...tatic-dflt-obj-ptrn-prop-obj-value-null.js | 75 ++++++++++++ ...atic-dflt-obj-ptrn-prop-obj-value-undef.js | 75 ++++++++++++ ...dstr-meth-static-dflt-obj-ptrn-prop-obj.js | 84 +++++++++++++ .../function/dstr-dflt-ary-init-iter-close.js | 72 +++++++++++ .../dstr-dflt-ary-init-iter-get-err.js | 59 +++++++++ .../dstr-dflt-ary-init-iter-no-close.js | 72 +++++++++++ .../function/dstr-dflt-ary-name-iter-val.js | 71 +++++++++++ .../dstr-dflt-ary-ptrn-elem-ary-elem-init.js | 63 ++++++++++ .../dstr-dflt-ary-ptrn-elem-ary-elem-iter.js | 64 ++++++++++ ...str-dflt-ary-ptrn-elem-ary-elision-init.js | 70 +++++++++++ ...str-dflt-ary-ptrn-elem-ary-elision-iter.js | 67 ++++++++++ .../dstr-dflt-ary-ptrn-elem-ary-empty-init.js | 65 ++++++++++ .../dstr-dflt-ary-ptrn-elem-ary-empty-iter.js | 63 ++++++++++ .../dstr-dflt-ary-ptrn-elem-ary-rest-init.js | 67 ++++++++++ .../dstr-dflt-ary-ptrn-elem-ary-rest-iter.js | 70 +++++++++++ .../dstr-dflt-ary-ptrn-elem-ary-val-null.js | 66 ++++++++++ ...tr-dflt-ary-ptrn-elem-id-init-exhausted.js | 62 ++++++++++ ...flt-ary-ptrn-elem-id-init-fn-name-arrow.js | 63 ++++++++++ ...flt-ary-ptrn-elem-id-init-fn-name-class.js | 64 ++++++++++ ...flt-ary-ptrn-elem-id-init-fn-name-cover.js | 64 ++++++++++ ...r-dflt-ary-ptrn-elem-id-init-fn-name-fn.js | 64 ++++++++++ ...-dflt-ary-ptrn-elem-id-init-fn-name-gen.js | 64 ++++++++++ .../dstr-dflt-ary-ptrn-elem-id-init-hole.js | 58 +++++++++ ...dstr-dflt-ary-ptrn-elem-id-init-skipped.js | 67 ++++++++++ .../dstr-dflt-ary-ptrn-elem-id-init-throws.js | 57 +++++++++ .../dstr-dflt-ary-ptrn-elem-id-init-undef.js | 61 ++++++++++ ...dflt-ary-ptrn-elem-id-init-unresolvable.js | 64 ++++++++++ ...str-dflt-ary-ptrn-elem-id-iter-complete.js | 65 ++++++++++ .../dstr-dflt-ary-ptrn-elem-id-iter-done.js | 60 +++++++++ ...str-dflt-ary-ptrn-elem-id-iter-step-err.js | 65 ++++++++++ ...dstr-dflt-ary-ptrn-elem-id-iter-val-err.js | 76 ++++++++++++ .../dstr-dflt-ary-ptrn-elem-id-iter-val.js | 71 +++++++++++ .../dstr-dflt-ary-ptrn-elem-obj-id-init.js | 63 ++++++++++ .../dstr-dflt-ary-ptrn-elem-obj-id.js | 63 ++++++++++ ...str-dflt-ary-ptrn-elem-obj-prop-id-init.js | 73 +++++++++++ .../dstr-dflt-ary-ptrn-elem-obj-prop-id.js | 73 +++++++++++ .../dstr-dflt-ary-ptrn-elem-obj-val-null.js | 66 ++++++++++ .../dstr-dflt-ary-ptrn-elem-obj-val-undef.js | 66 ++++++++++ .../dstr-dflt-ary-ptrn-elision-exhausted.js | 68 +++++++++++ .../dstr-dflt-ary-ptrn-elision-step-err.js | 73 +++++++++++ .../function/dstr-dflt-ary-ptrn-elision.js | 77 ++++++++++++ .../function/dstr-dflt-ary-ptrn-empty.js | 60 +++++++++ .../dstr-dflt-ary-ptrn-rest-ary-elem.js | 84 +++++++++++++ .../dstr-dflt-ary-ptrn-rest-ary-elision.js | 90 ++++++++++++++ .../dstr-dflt-ary-ptrn-rest-ary-empty.js | 73 +++++++++++ .../dstr-dflt-ary-ptrn-rest-ary-rest.js | 69 +++++++++++ ...-dflt-ary-ptrn-rest-id-elision-next-err.js | 59 +++++++++ .../dstr-dflt-ary-ptrn-rest-id-elision.js | 65 ++++++++++ .../dstr-dflt-ary-ptrn-rest-id-exhausted.js | 61 ++++++++++ ...str-dflt-ary-ptrn-rest-id-iter-step-err.js | 70 +++++++++++ ...dstr-dflt-ary-ptrn-rest-id-iter-val-err.js | 72 +++++++++++ .../function/dstr-dflt-ary-ptrn-rest-id.js | 62 ++++++++++ .../dstr-dflt-ary-ptrn-rest-init-ary.js | 56 +++++++++ .../dstr-dflt-ary-ptrn-rest-init-id.js | 56 +++++++++ .../dstr-dflt-ary-ptrn-rest-init-obj.js | 56 +++++++++ .../dstr-dflt-ary-ptrn-rest-not-final-ary.js | 56 +++++++++ .../dstr-dflt-ary-ptrn-rest-not-final-id.js | 56 +++++++++ .../dstr-dflt-ary-ptrn-rest-not-final-obj.js | 56 +++++++++ .../dstr-dflt-ary-ptrn-rest-obj-id.js | 62 ++++++++++ .../dstr-dflt-ary-ptrn-rest-obj-prop-id.js | 70 +++++++++++ .../function/dstr-dflt-obj-init-null.js | 53 ++++++++ .../function/dstr-dflt-obj-init-undefined.js | 53 ++++++++ .../function/dstr-dflt-obj-ptrn-empty.js | 61 ++++++++++ .../dstr-dflt-obj-ptrn-id-get-value-err.js | 60 +++++++++ ...str-dflt-obj-ptrn-id-init-fn-name-arrow.js | 62 ++++++++++ ...str-dflt-obj-ptrn-id-init-fn-name-class.js | 63 ++++++++++ ...str-dflt-obj-ptrn-id-init-fn-name-cover.js | 63 ++++++++++ .../dstr-dflt-obj-ptrn-id-init-fn-name-fn.js | 63 ++++++++++ .../dstr-dflt-obj-ptrn-id-init-fn-name-gen.js | 63 ++++++++++ .../dstr-dflt-obj-ptrn-id-init-skipped.js | 66 ++++++++++ .../dstr-dflt-obj-ptrn-id-init-throws.js | 60 +++++++++ ...dstr-dflt-obj-ptrn-id-init-unresolvable.js | 64 ++++++++++ .../dstr-dflt-obj-ptrn-id-trailing-comma.js | 56 +++++++++ .../function/dstr-dflt-obj-ptrn-list-err.js | 61 ++++++++++ .../dstr-dflt-obj-ptrn-prop-ary-init.js | 65 ++++++++++ ...r-dflt-obj-ptrn-prop-ary-trailing-comma.js | 56 +++++++++ .../dstr-dflt-obj-ptrn-prop-ary-value-null.js | 55 +++++++++ .../function/dstr-dflt-obj-ptrn-prop-ary.js | 63 ++++++++++ .../dstr-dflt-obj-ptrn-prop-eval-err.js | 57 +++++++++ ...str-dflt-obj-ptrn-prop-id-get-value-err.js | 62 ++++++++++ ...dstr-dflt-obj-ptrn-prop-id-init-skipped.js | 78 ++++++++++++ .../dstr-dflt-obj-ptrn-prop-id-init-throws.js | 60 +++++++++ ...dflt-obj-ptrn-prop-id-init-unresolvable.js | 64 ++++++++++ .../dstr-dflt-obj-ptrn-prop-id-init.js | 59 +++++++++ ...tr-dflt-obj-ptrn-prop-id-trailing-comma.js | 60 +++++++++ .../function/dstr-dflt-obj-ptrn-prop-id.js | 59 +++++++++ .../dstr-dflt-obj-ptrn-prop-obj-init.js | 65 ++++++++++ .../dstr-dflt-obj-ptrn-prop-obj-value-null.js | 55 +++++++++ ...dstr-dflt-obj-ptrn-prop-obj-value-undef.js | 55 +++++++++ .../function/dstr-dflt-obj-ptrn-prop-obj.js | 63 ++++++++++ .../dstr-dflt-ary-init-iter-close.js | 71 +++++++++++ .../dstr-dflt-ary-init-iter-get-err.js | 58 +++++++++ .../dstr-dflt-ary-init-iter-no-close.js | 71 +++++++++++ .../generators/dstr-dflt-ary-name-iter-val.js | 70 +++++++++++ .../dstr-dflt-ary-ptrn-elem-ary-elem-init.js | 62 ++++++++++ .../dstr-dflt-ary-ptrn-elem-ary-elem-iter.js | 63 ++++++++++ ...str-dflt-ary-ptrn-elem-ary-elision-init.js | 69 +++++++++++ ...str-dflt-ary-ptrn-elem-ary-elision-iter.js | 66 ++++++++++ .../dstr-dflt-ary-ptrn-elem-ary-empty-init.js | 64 ++++++++++ .../dstr-dflt-ary-ptrn-elem-ary-empty-iter.js | 62 ++++++++++ .../dstr-dflt-ary-ptrn-elem-ary-rest-init.js | 66 ++++++++++ .../dstr-dflt-ary-ptrn-elem-ary-rest-iter.js | 69 +++++++++++ .../dstr-dflt-ary-ptrn-elem-ary-val-null.js | 65 ++++++++++ ...tr-dflt-ary-ptrn-elem-id-init-exhausted.js | 61 ++++++++++ ...flt-ary-ptrn-elem-id-init-fn-name-arrow.js | 62 ++++++++++ ...flt-ary-ptrn-elem-id-init-fn-name-class.js | 63 ++++++++++ ...flt-ary-ptrn-elem-id-init-fn-name-cover.js | 63 ++++++++++ ...r-dflt-ary-ptrn-elem-id-init-fn-name-fn.js | 63 ++++++++++ ...-dflt-ary-ptrn-elem-id-init-fn-name-gen.js | 63 ++++++++++ .../dstr-dflt-ary-ptrn-elem-id-init-hole.js | 57 +++++++++ ...dstr-dflt-ary-ptrn-elem-id-init-skipped.js | 66 ++++++++++ .../dstr-dflt-ary-ptrn-elem-id-init-throws.js | 56 +++++++++ .../dstr-dflt-ary-ptrn-elem-id-init-undef.js | 60 +++++++++ ...dflt-ary-ptrn-elem-id-init-unresolvable.js | 63 ++++++++++ ...str-dflt-ary-ptrn-elem-id-iter-complete.js | 64 ++++++++++ .../dstr-dflt-ary-ptrn-elem-id-iter-done.js | 59 +++++++++ ...str-dflt-ary-ptrn-elem-id-iter-step-err.js | 64 ++++++++++ ...dstr-dflt-ary-ptrn-elem-id-iter-val-err.js | 75 ++++++++++++ .../dstr-dflt-ary-ptrn-elem-id-iter-val.js | 70 +++++++++++ .../dstr-dflt-ary-ptrn-elem-obj-id-init.js | 62 ++++++++++ .../dstr-dflt-ary-ptrn-elem-obj-id.js | 62 ++++++++++ ...str-dflt-ary-ptrn-elem-obj-prop-id-init.js | 72 +++++++++++ .../dstr-dflt-ary-ptrn-elem-obj-prop-id.js | 72 +++++++++++ .../dstr-dflt-ary-ptrn-elem-obj-val-null.js | 65 ++++++++++ .../dstr-dflt-ary-ptrn-elem-obj-val-undef.js | 65 ++++++++++ .../dstr-dflt-ary-ptrn-elision-exhausted.js | 67 ++++++++++ .../dstr-dflt-ary-ptrn-elision-step-err.js | 72 +++++++++++ .../generators/dstr-dflt-ary-ptrn-elision.js | 76 ++++++++++++ .../generators/dstr-dflt-ary-ptrn-empty.js | 59 +++++++++ .../dstr-dflt-ary-ptrn-rest-ary-elem.js | 83 +++++++++++++ .../dstr-dflt-ary-ptrn-rest-ary-elision.js | 89 ++++++++++++++ .../dstr-dflt-ary-ptrn-rest-ary-empty.js | 72 +++++++++++ .../dstr-dflt-ary-ptrn-rest-ary-rest.js | 68 +++++++++++ ...-dflt-ary-ptrn-rest-id-elision-next-err.js | 58 +++++++++ .../dstr-dflt-ary-ptrn-rest-id-elision.js | 64 ++++++++++ .../dstr-dflt-ary-ptrn-rest-id-exhausted.js | 60 +++++++++ ...str-dflt-ary-ptrn-rest-id-iter-step-err.js | 69 +++++++++++ ...dstr-dflt-ary-ptrn-rest-id-iter-val-err.js | 71 +++++++++++ .../generators/dstr-dflt-ary-ptrn-rest-id.js | 61 ++++++++++ .../dstr-dflt-ary-ptrn-rest-init-ary.js | 55 +++++++++ .../dstr-dflt-ary-ptrn-rest-init-id.js | 55 +++++++++ .../dstr-dflt-ary-ptrn-rest-init-obj.js | 55 +++++++++ .../dstr-dflt-ary-ptrn-rest-not-final-ary.js | 55 +++++++++ .../dstr-dflt-ary-ptrn-rest-not-final-id.js | 55 +++++++++ .../dstr-dflt-ary-ptrn-rest-not-final-obj.js | 55 +++++++++ .../dstr-dflt-ary-ptrn-rest-obj-id.js | 61 ++++++++++ .../dstr-dflt-ary-ptrn-rest-obj-prop-id.js | 69 +++++++++++ .../generators/dstr-dflt-obj-init-null.js | 52 ++++++++ .../dstr-dflt-obj-init-undefined.js | 52 ++++++++ .../generators/dstr-dflt-obj-ptrn-empty.js | 60 +++++++++ .../dstr-dflt-obj-ptrn-id-get-value-err.js | 59 +++++++++ ...str-dflt-obj-ptrn-id-init-fn-name-arrow.js | 61 ++++++++++ ...str-dflt-obj-ptrn-id-init-fn-name-class.js | 62 ++++++++++ ...str-dflt-obj-ptrn-id-init-fn-name-cover.js | 62 ++++++++++ .../dstr-dflt-obj-ptrn-id-init-fn-name-fn.js | 62 ++++++++++ .../dstr-dflt-obj-ptrn-id-init-fn-name-gen.js | 62 ++++++++++ .../dstr-dflt-obj-ptrn-id-init-skipped.js | 65 ++++++++++ .../dstr-dflt-obj-ptrn-id-init-throws.js | 59 +++++++++ ...dstr-dflt-obj-ptrn-id-init-unresolvable.js | 63 ++++++++++ .../dstr-dflt-obj-ptrn-id-trailing-comma.js | 55 +++++++++ .../generators/dstr-dflt-obj-ptrn-list-err.js | 60 +++++++++ .../dstr-dflt-obj-ptrn-prop-ary-init.js | 64 ++++++++++ ...r-dflt-obj-ptrn-prop-ary-trailing-comma.js | 55 +++++++++ .../dstr-dflt-obj-ptrn-prop-ary-value-null.js | 54 ++++++++ .../generators/dstr-dflt-obj-ptrn-prop-ary.js | 62 ++++++++++ .../dstr-dflt-obj-ptrn-prop-eval-err.js | 56 +++++++++ ...str-dflt-obj-ptrn-prop-id-get-value-err.js | 61 ++++++++++ ...dstr-dflt-obj-ptrn-prop-id-init-skipped.js | 77 ++++++++++++ .../dstr-dflt-obj-ptrn-prop-id-init-throws.js | 59 +++++++++ ...dflt-obj-ptrn-prop-id-init-unresolvable.js | 63 ++++++++++ .../dstr-dflt-obj-ptrn-prop-id-init.js | 58 +++++++++ ...tr-dflt-obj-ptrn-prop-id-trailing-comma.js | 59 +++++++++ .../generators/dstr-dflt-obj-ptrn-prop-id.js | 58 +++++++++ .../dstr-dflt-obj-ptrn-prop-obj-init.js | 64 ++++++++++ .../dstr-dflt-obj-ptrn-prop-obj-value-null.js | 54 ++++++++ ...dstr-dflt-obj-ptrn-prop-obj-value-undef.js | 54 ++++++++ .../generators/dstr-dflt-obj-ptrn-prop-obj.js | 62 ++++++++++ 1305 files changed, 100223 insertions(+) create mode 100644 test/language/expressions/arrow-function/dstr-dflt-ary-init-iter-close.js create mode 100644 test/language/expressions/arrow-function/dstr-dflt-ary-init-iter-get-err.js create mode 100644 test/language/expressions/arrow-function/dstr-dflt-ary-init-iter-no-close.js create mode 100644 test/language/expressions/arrow-function/dstr-dflt-ary-name-iter-val.js create mode 100644 test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-elem-ary-elem-init.js create mode 100644 test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-elem-ary-elem-iter.js create mode 100644 test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-elem-ary-elision-init.js create mode 100644 test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-elem-ary-elision-iter.js create mode 100644 test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-elem-ary-empty-init.js create mode 100644 test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-elem-ary-empty-iter.js create mode 100644 test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-elem-ary-rest-init.js create mode 100644 test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-elem-ary-rest-iter.js create mode 100644 test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-elem-ary-val-null.js create mode 100644 test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-elem-id-init-exhausted.js create mode 100644 test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-elem-id-init-fn-name-arrow.js create mode 100644 test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-elem-id-init-fn-name-class.js create mode 100644 test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-elem-id-init-fn-name-cover.js create mode 100644 test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-elem-id-init-fn-name-fn.js create mode 100644 test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-elem-id-init-fn-name-gen.js create mode 100644 test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-elem-id-init-hole.js create mode 100644 test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-elem-id-init-skipped.js create mode 100644 test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-elem-id-init-throws.js create mode 100644 test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-elem-id-init-undef.js create mode 100644 test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-elem-id-init-unresolvable.js create mode 100644 test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-elem-id-iter-complete.js create mode 100644 test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-elem-id-iter-done.js create mode 100644 test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-elem-id-iter-step-err.js create mode 100644 test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-elem-id-iter-val-err.js create mode 100644 test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-elem-id-iter-val.js create mode 100644 test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-elem-obj-id-init.js create mode 100644 test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-elem-obj-id.js create mode 100644 test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-elem-obj-prop-id-init.js create mode 100644 test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-elem-obj-prop-id.js create mode 100644 test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-elem-obj-val-null.js create mode 100644 test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-elem-obj-val-undef.js create mode 100644 test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-elision-exhausted.js create mode 100644 test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-elision-step-err.js create mode 100644 test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-elision.js create mode 100644 test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-empty.js create mode 100644 test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-rest-ary-elem.js create mode 100644 test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-rest-ary-elision.js create mode 100644 test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-rest-ary-empty.js create mode 100644 test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-rest-ary-rest.js create mode 100644 test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-rest-id-elision-next-err.js create mode 100644 test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-rest-id-elision.js create mode 100644 test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-rest-id-exhausted.js create mode 100644 test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-rest-id-iter-step-err.js create mode 100644 test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-rest-id-iter-val-err.js create mode 100644 test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-rest-id.js create mode 100644 test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-rest-init-ary.js create mode 100644 test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-rest-init-id.js create mode 100644 test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-rest-init-obj.js create mode 100644 test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-rest-not-final-ary.js create mode 100644 test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-rest-not-final-id.js create mode 100644 test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-rest-not-final-obj.js create mode 100644 test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-rest-obj-id.js create mode 100644 test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-rest-obj-prop-id.js create mode 100644 test/language/expressions/arrow-function/dstr-dflt-obj-init-null.js create mode 100644 test/language/expressions/arrow-function/dstr-dflt-obj-init-undefined.js create mode 100644 test/language/expressions/arrow-function/dstr-dflt-obj-ptrn-empty.js create mode 100644 test/language/expressions/arrow-function/dstr-dflt-obj-ptrn-id-get-value-err.js create mode 100644 test/language/expressions/arrow-function/dstr-dflt-obj-ptrn-id-init-fn-name-arrow.js create mode 100644 test/language/expressions/arrow-function/dstr-dflt-obj-ptrn-id-init-fn-name-class.js create mode 100644 test/language/expressions/arrow-function/dstr-dflt-obj-ptrn-id-init-fn-name-cover.js create mode 100644 test/language/expressions/arrow-function/dstr-dflt-obj-ptrn-id-init-fn-name-fn.js create mode 100644 test/language/expressions/arrow-function/dstr-dflt-obj-ptrn-id-init-fn-name-gen.js create mode 100644 test/language/expressions/arrow-function/dstr-dflt-obj-ptrn-id-init-skipped.js create mode 100644 test/language/expressions/arrow-function/dstr-dflt-obj-ptrn-id-init-throws.js create mode 100644 test/language/expressions/arrow-function/dstr-dflt-obj-ptrn-id-init-unresolvable.js create mode 100644 test/language/expressions/arrow-function/dstr-dflt-obj-ptrn-id-trailing-comma.js create mode 100644 test/language/expressions/arrow-function/dstr-dflt-obj-ptrn-list-err.js create mode 100644 test/language/expressions/arrow-function/dstr-dflt-obj-ptrn-prop-ary-init.js create mode 100644 test/language/expressions/arrow-function/dstr-dflt-obj-ptrn-prop-ary-trailing-comma.js create mode 100644 test/language/expressions/arrow-function/dstr-dflt-obj-ptrn-prop-ary-value-null.js create mode 100644 test/language/expressions/arrow-function/dstr-dflt-obj-ptrn-prop-ary.js create mode 100644 test/language/expressions/arrow-function/dstr-dflt-obj-ptrn-prop-eval-err.js create mode 100644 test/language/expressions/arrow-function/dstr-dflt-obj-ptrn-prop-id-get-value-err.js create mode 100644 test/language/expressions/arrow-function/dstr-dflt-obj-ptrn-prop-id-init-skipped.js create mode 100644 test/language/expressions/arrow-function/dstr-dflt-obj-ptrn-prop-id-init-throws.js create mode 100644 test/language/expressions/arrow-function/dstr-dflt-obj-ptrn-prop-id-init-unresolvable.js create mode 100644 test/language/expressions/arrow-function/dstr-dflt-obj-ptrn-prop-id-init.js create mode 100644 test/language/expressions/arrow-function/dstr-dflt-obj-ptrn-prop-id-trailing-comma.js create mode 100644 test/language/expressions/arrow-function/dstr-dflt-obj-ptrn-prop-id.js create mode 100644 test/language/expressions/arrow-function/dstr-dflt-obj-ptrn-prop-obj-init.js create mode 100644 test/language/expressions/arrow-function/dstr-dflt-obj-ptrn-prop-obj-value-null.js create mode 100644 test/language/expressions/arrow-function/dstr-dflt-obj-ptrn-prop-obj-value-undef.js create mode 100644 test/language/expressions/arrow-function/dstr-dflt-obj-ptrn-prop-obj.js create mode 100644 test/language/expressions/class/dstr-gen-meth-dflt-ary-init-iter-close.js create mode 100644 test/language/expressions/class/dstr-gen-meth-dflt-ary-init-iter-get-err.js create mode 100644 test/language/expressions/class/dstr-gen-meth-dflt-ary-init-iter-no-close.js create mode 100644 test/language/expressions/class/dstr-gen-meth-dflt-ary-name-iter-val.js create mode 100644 test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-elem-ary-elem-init.js create mode 100644 test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-elem-ary-elem-iter.js create mode 100644 test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-elem-ary-elision-init.js create mode 100644 test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-elem-ary-elision-iter.js create mode 100644 test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-elem-ary-empty-init.js create mode 100644 test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-elem-ary-empty-iter.js create mode 100644 test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-elem-ary-rest-init.js create mode 100644 test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-elem-ary-rest-iter.js create mode 100644 test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-elem-ary-val-null.js create mode 100644 test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-elem-id-init-exhausted.js create mode 100644 test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-arrow.js create mode 100644 test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-class.js create mode 100644 test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-cover.js create mode 100644 test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-fn.js create mode 100644 test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-gen.js create mode 100644 test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-elem-id-init-hole.js create mode 100644 test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-elem-id-init-skipped.js create mode 100644 test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-elem-id-init-throws.js create mode 100644 test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-elem-id-init-undef.js create mode 100644 test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-elem-id-init-unresolvable.js create mode 100644 test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-elem-id-iter-complete.js create mode 100644 test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-elem-id-iter-done.js create mode 100644 test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-elem-id-iter-step-err.js create mode 100644 test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-elem-id-iter-val-err.js create mode 100644 test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-elem-id-iter-val.js create mode 100644 test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-elem-obj-id-init.js create mode 100644 test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-elem-obj-id.js create mode 100644 test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-elem-obj-prop-id-init.js create mode 100644 test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-elem-obj-prop-id.js create mode 100644 test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-elem-obj-val-null.js create mode 100644 test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-elem-obj-val-undef.js create mode 100644 test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-elision-exhausted.js create mode 100644 test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-elision-step-err.js create mode 100644 test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-elision.js create mode 100644 test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-empty.js create mode 100644 test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-rest-ary-elem.js create mode 100644 test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-rest-ary-elision.js create mode 100644 test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-rest-ary-empty.js create mode 100644 test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-rest-ary-rest.js create mode 100644 test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-rest-id-elision-next-err.js create mode 100644 test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-rest-id-elision.js create mode 100644 test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-rest-id-exhausted.js create mode 100644 test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-rest-id-iter-step-err.js create mode 100644 test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-rest-id-iter-val-err.js create mode 100644 test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-rest-id.js create mode 100644 test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-rest-init-ary.js create mode 100644 test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-rest-init-id.js create mode 100644 test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-rest-init-obj.js create mode 100644 test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-rest-not-final-ary.js create mode 100644 test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-rest-not-final-id.js create mode 100644 test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-rest-not-final-obj.js create mode 100644 test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-rest-obj-id.js create mode 100644 test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-rest-obj-prop-id.js create mode 100644 test/language/expressions/class/dstr-gen-meth-dflt-obj-init-null.js create mode 100644 test/language/expressions/class/dstr-gen-meth-dflt-obj-init-undefined.js create mode 100644 test/language/expressions/class/dstr-gen-meth-dflt-obj-ptrn-empty.js create mode 100644 test/language/expressions/class/dstr-gen-meth-dflt-obj-ptrn-id-get-value-err.js create mode 100644 test/language/expressions/class/dstr-gen-meth-dflt-obj-ptrn-id-init-fn-name-arrow.js create mode 100644 test/language/expressions/class/dstr-gen-meth-dflt-obj-ptrn-id-init-fn-name-class.js create mode 100644 test/language/expressions/class/dstr-gen-meth-dflt-obj-ptrn-id-init-fn-name-cover.js create mode 100644 test/language/expressions/class/dstr-gen-meth-dflt-obj-ptrn-id-init-fn-name-fn.js create mode 100644 test/language/expressions/class/dstr-gen-meth-dflt-obj-ptrn-id-init-fn-name-gen.js create mode 100644 test/language/expressions/class/dstr-gen-meth-dflt-obj-ptrn-id-init-skipped.js create mode 100644 test/language/expressions/class/dstr-gen-meth-dflt-obj-ptrn-id-init-throws.js create mode 100644 test/language/expressions/class/dstr-gen-meth-dflt-obj-ptrn-id-init-unresolvable.js create mode 100644 test/language/expressions/class/dstr-gen-meth-dflt-obj-ptrn-id-trailing-comma.js create mode 100644 test/language/expressions/class/dstr-gen-meth-dflt-obj-ptrn-list-err.js create mode 100644 test/language/expressions/class/dstr-gen-meth-dflt-obj-ptrn-prop-ary-init.js create mode 100644 test/language/expressions/class/dstr-gen-meth-dflt-obj-ptrn-prop-ary-trailing-comma.js create mode 100644 test/language/expressions/class/dstr-gen-meth-dflt-obj-ptrn-prop-ary-value-null.js create mode 100644 test/language/expressions/class/dstr-gen-meth-dflt-obj-ptrn-prop-ary.js create mode 100644 test/language/expressions/class/dstr-gen-meth-dflt-obj-ptrn-prop-eval-err.js create mode 100644 test/language/expressions/class/dstr-gen-meth-dflt-obj-ptrn-prop-id-get-value-err.js create mode 100644 test/language/expressions/class/dstr-gen-meth-dflt-obj-ptrn-prop-id-init-skipped.js create mode 100644 test/language/expressions/class/dstr-gen-meth-dflt-obj-ptrn-prop-id-init-throws.js create mode 100644 test/language/expressions/class/dstr-gen-meth-dflt-obj-ptrn-prop-id-init-unresolvable.js create mode 100644 test/language/expressions/class/dstr-gen-meth-dflt-obj-ptrn-prop-id-init.js create mode 100644 test/language/expressions/class/dstr-gen-meth-dflt-obj-ptrn-prop-id-trailing-comma.js create mode 100644 test/language/expressions/class/dstr-gen-meth-dflt-obj-ptrn-prop-id.js create mode 100644 test/language/expressions/class/dstr-gen-meth-dflt-obj-ptrn-prop-obj-init.js create mode 100644 test/language/expressions/class/dstr-gen-meth-dflt-obj-ptrn-prop-obj-value-null.js create mode 100644 test/language/expressions/class/dstr-gen-meth-dflt-obj-ptrn-prop-obj-value-undef.js create mode 100644 test/language/expressions/class/dstr-gen-meth-dflt-obj-ptrn-prop-obj.js create mode 100644 test/language/expressions/class/dstr-gen-meth-static-dflt-ary-init-iter-close.js create mode 100644 test/language/expressions/class/dstr-gen-meth-static-dflt-ary-init-iter-get-err.js create mode 100644 test/language/expressions/class/dstr-gen-meth-static-dflt-ary-init-iter-no-close.js create mode 100644 test/language/expressions/class/dstr-gen-meth-static-dflt-ary-name-iter-val.js create mode 100644 test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-ary-elem-init.js create mode 100644 test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-ary-elem-iter.js create mode 100644 test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-ary-elision-init.js create mode 100644 test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-ary-elision-iter.js create mode 100644 test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-ary-empty-init.js create mode 100644 test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-ary-empty-iter.js create mode 100644 test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-ary-rest-init.js create mode 100644 test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-ary-rest-iter.js create mode 100644 test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-ary-val-null.js create mode 100644 test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-id-init-exhausted.js create mode 100644 test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-arrow.js create mode 100644 test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-class.js create mode 100644 test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-cover.js create mode 100644 test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-fn.js create mode 100644 test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-gen.js create mode 100644 test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-id-init-hole.js create mode 100644 test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-id-init-skipped.js create mode 100644 test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-id-init-throws.js create mode 100644 test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-id-init-undef.js create mode 100644 test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-id-init-unresolvable.js create mode 100644 test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-id-iter-complete.js create mode 100644 test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-id-iter-done.js create mode 100644 test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-id-iter-step-err.js create mode 100644 test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-id-iter-val-err.js create mode 100644 test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-id-iter-val.js create mode 100644 test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-obj-id-init.js create mode 100644 test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-obj-id.js create mode 100644 test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-obj-prop-id-init.js create mode 100644 test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-obj-prop-id.js create mode 100644 test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-obj-val-null.js create mode 100644 test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-obj-val-undef.js create mode 100644 test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-elision-exhausted.js create mode 100644 test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-elision-step-err.js create mode 100644 test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-elision.js create mode 100644 test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-empty.js create mode 100644 test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-rest-ary-elem.js create mode 100644 test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-rest-ary-elision.js create mode 100644 test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-rest-ary-empty.js create mode 100644 test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-rest-ary-rest.js create mode 100644 test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-rest-id-elision-next-err.js create mode 100644 test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-rest-id-elision.js create mode 100644 test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-rest-id-exhausted.js create mode 100644 test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-rest-id-iter-step-err.js create mode 100644 test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-rest-id-iter-val-err.js create mode 100644 test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-rest-id.js create mode 100644 test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-rest-init-ary.js create mode 100644 test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-rest-init-id.js create mode 100644 test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-rest-init-obj.js create mode 100644 test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-rest-not-final-ary.js create mode 100644 test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-rest-not-final-id.js create mode 100644 test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-rest-not-final-obj.js create mode 100644 test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-rest-obj-id.js create mode 100644 test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-rest-obj-prop-id.js create mode 100644 test/language/expressions/class/dstr-gen-meth-static-dflt-obj-init-null.js create mode 100644 test/language/expressions/class/dstr-gen-meth-static-dflt-obj-init-undefined.js create mode 100644 test/language/expressions/class/dstr-gen-meth-static-dflt-obj-ptrn-empty.js create mode 100644 test/language/expressions/class/dstr-gen-meth-static-dflt-obj-ptrn-id-get-value-err.js create mode 100644 test/language/expressions/class/dstr-gen-meth-static-dflt-obj-ptrn-id-init-fn-name-arrow.js create mode 100644 test/language/expressions/class/dstr-gen-meth-static-dflt-obj-ptrn-id-init-fn-name-class.js create mode 100644 test/language/expressions/class/dstr-gen-meth-static-dflt-obj-ptrn-id-init-fn-name-cover.js create mode 100644 test/language/expressions/class/dstr-gen-meth-static-dflt-obj-ptrn-id-init-fn-name-fn.js create mode 100644 test/language/expressions/class/dstr-gen-meth-static-dflt-obj-ptrn-id-init-fn-name-gen.js create mode 100644 test/language/expressions/class/dstr-gen-meth-static-dflt-obj-ptrn-id-init-skipped.js create mode 100644 test/language/expressions/class/dstr-gen-meth-static-dflt-obj-ptrn-id-init-throws.js create mode 100644 test/language/expressions/class/dstr-gen-meth-static-dflt-obj-ptrn-id-init-unresolvable.js create mode 100644 test/language/expressions/class/dstr-gen-meth-static-dflt-obj-ptrn-id-trailing-comma.js create mode 100644 test/language/expressions/class/dstr-gen-meth-static-dflt-obj-ptrn-list-err.js create mode 100644 test/language/expressions/class/dstr-gen-meth-static-dflt-obj-ptrn-prop-ary-init.js create mode 100644 test/language/expressions/class/dstr-gen-meth-static-dflt-obj-ptrn-prop-ary-trailing-comma.js create mode 100644 test/language/expressions/class/dstr-gen-meth-static-dflt-obj-ptrn-prop-ary-value-null.js create mode 100644 test/language/expressions/class/dstr-gen-meth-static-dflt-obj-ptrn-prop-ary.js create mode 100644 test/language/expressions/class/dstr-gen-meth-static-dflt-obj-ptrn-prop-eval-err.js create mode 100644 test/language/expressions/class/dstr-gen-meth-static-dflt-obj-ptrn-prop-id-get-value-err.js create mode 100644 test/language/expressions/class/dstr-gen-meth-static-dflt-obj-ptrn-prop-id-init-skipped.js create mode 100644 test/language/expressions/class/dstr-gen-meth-static-dflt-obj-ptrn-prop-id-init-throws.js create mode 100644 test/language/expressions/class/dstr-gen-meth-static-dflt-obj-ptrn-prop-id-init-unresolvable.js create mode 100644 test/language/expressions/class/dstr-gen-meth-static-dflt-obj-ptrn-prop-id-init.js create mode 100644 test/language/expressions/class/dstr-gen-meth-static-dflt-obj-ptrn-prop-id-trailing-comma.js create mode 100644 test/language/expressions/class/dstr-gen-meth-static-dflt-obj-ptrn-prop-id.js create mode 100644 test/language/expressions/class/dstr-gen-meth-static-dflt-obj-ptrn-prop-obj-init.js create mode 100644 test/language/expressions/class/dstr-gen-meth-static-dflt-obj-ptrn-prop-obj-value-null.js create mode 100644 test/language/expressions/class/dstr-gen-meth-static-dflt-obj-ptrn-prop-obj-value-undef.js create mode 100644 test/language/expressions/class/dstr-gen-meth-static-dflt-obj-ptrn-prop-obj.js create mode 100644 test/language/expressions/class/dstr-meth-dflt-ary-init-iter-close.js create mode 100644 test/language/expressions/class/dstr-meth-dflt-ary-init-iter-get-err.js create mode 100644 test/language/expressions/class/dstr-meth-dflt-ary-init-iter-no-close.js create mode 100644 test/language/expressions/class/dstr-meth-dflt-ary-name-iter-val.js create mode 100644 test/language/expressions/class/dstr-meth-dflt-ary-ptrn-elem-ary-elem-init.js create mode 100644 test/language/expressions/class/dstr-meth-dflt-ary-ptrn-elem-ary-elem-iter.js create mode 100644 test/language/expressions/class/dstr-meth-dflt-ary-ptrn-elem-ary-elision-init.js create mode 100644 test/language/expressions/class/dstr-meth-dflt-ary-ptrn-elem-ary-elision-iter.js create mode 100644 test/language/expressions/class/dstr-meth-dflt-ary-ptrn-elem-ary-empty-init.js create mode 100644 test/language/expressions/class/dstr-meth-dflt-ary-ptrn-elem-ary-empty-iter.js create mode 100644 test/language/expressions/class/dstr-meth-dflt-ary-ptrn-elem-ary-rest-init.js create mode 100644 test/language/expressions/class/dstr-meth-dflt-ary-ptrn-elem-ary-rest-iter.js create mode 100644 test/language/expressions/class/dstr-meth-dflt-ary-ptrn-elem-ary-val-null.js create mode 100644 test/language/expressions/class/dstr-meth-dflt-ary-ptrn-elem-id-init-exhausted.js create mode 100644 test/language/expressions/class/dstr-meth-dflt-ary-ptrn-elem-id-init-fn-name-arrow.js create mode 100644 test/language/expressions/class/dstr-meth-dflt-ary-ptrn-elem-id-init-fn-name-class.js create mode 100644 test/language/expressions/class/dstr-meth-dflt-ary-ptrn-elem-id-init-fn-name-cover.js create mode 100644 test/language/expressions/class/dstr-meth-dflt-ary-ptrn-elem-id-init-fn-name-fn.js create mode 100644 test/language/expressions/class/dstr-meth-dflt-ary-ptrn-elem-id-init-fn-name-gen.js create mode 100644 test/language/expressions/class/dstr-meth-dflt-ary-ptrn-elem-id-init-hole.js create mode 100644 test/language/expressions/class/dstr-meth-dflt-ary-ptrn-elem-id-init-skipped.js create mode 100644 test/language/expressions/class/dstr-meth-dflt-ary-ptrn-elem-id-init-throws.js create mode 100644 test/language/expressions/class/dstr-meth-dflt-ary-ptrn-elem-id-init-undef.js create mode 100644 test/language/expressions/class/dstr-meth-dflt-ary-ptrn-elem-id-init-unresolvable.js create mode 100644 test/language/expressions/class/dstr-meth-dflt-ary-ptrn-elem-id-iter-complete.js create mode 100644 test/language/expressions/class/dstr-meth-dflt-ary-ptrn-elem-id-iter-done.js create mode 100644 test/language/expressions/class/dstr-meth-dflt-ary-ptrn-elem-id-iter-step-err.js create mode 100644 test/language/expressions/class/dstr-meth-dflt-ary-ptrn-elem-id-iter-val-err.js create mode 100644 test/language/expressions/class/dstr-meth-dflt-ary-ptrn-elem-id-iter-val.js create mode 100644 test/language/expressions/class/dstr-meth-dflt-ary-ptrn-elem-obj-id-init.js create mode 100644 test/language/expressions/class/dstr-meth-dflt-ary-ptrn-elem-obj-id.js create mode 100644 test/language/expressions/class/dstr-meth-dflt-ary-ptrn-elem-obj-prop-id-init.js create mode 100644 test/language/expressions/class/dstr-meth-dflt-ary-ptrn-elem-obj-prop-id.js create mode 100644 test/language/expressions/class/dstr-meth-dflt-ary-ptrn-elem-obj-val-null.js create mode 100644 test/language/expressions/class/dstr-meth-dflt-ary-ptrn-elem-obj-val-undef.js create mode 100644 test/language/expressions/class/dstr-meth-dflt-ary-ptrn-elision-exhausted.js create mode 100644 test/language/expressions/class/dstr-meth-dflt-ary-ptrn-elision-step-err.js create mode 100644 test/language/expressions/class/dstr-meth-dflt-ary-ptrn-elision.js create mode 100644 test/language/expressions/class/dstr-meth-dflt-ary-ptrn-empty.js create mode 100644 test/language/expressions/class/dstr-meth-dflt-ary-ptrn-rest-ary-elem.js create mode 100644 test/language/expressions/class/dstr-meth-dflt-ary-ptrn-rest-ary-elision.js create mode 100644 test/language/expressions/class/dstr-meth-dflt-ary-ptrn-rest-ary-empty.js create mode 100644 test/language/expressions/class/dstr-meth-dflt-ary-ptrn-rest-ary-rest.js create mode 100644 test/language/expressions/class/dstr-meth-dflt-ary-ptrn-rest-id-elision-next-err.js create mode 100644 test/language/expressions/class/dstr-meth-dflt-ary-ptrn-rest-id-elision.js create mode 100644 test/language/expressions/class/dstr-meth-dflt-ary-ptrn-rest-id-exhausted.js create mode 100644 test/language/expressions/class/dstr-meth-dflt-ary-ptrn-rest-id-iter-step-err.js create mode 100644 test/language/expressions/class/dstr-meth-dflt-ary-ptrn-rest-id-iter-val-err.js create mode 100644 test/language/expressions/class/dstr-meth-dflt-ary-ptrn-rest-id.js create mode 100644 test/language/expressions/class/dstr-meth-dflt-ary-ptrn-rest-init-ary.js create mode 100644 test/language/expressions/class/dstr-meth-dflt-ary-ptrn-rest-init-id.js create mode 100644 test/language/expressions/class/dstr-meth-dflt-ary-ptrn-rest-init-obj.js create mode 100644 test/language/expressions/class/dstr-meth-dflt-ary-ptrn-rest-not-final-ary.js create mode 100644 test/language/expressions/class/dstr-meth-dflt-ary-ptrn-rest-not-final-id.js create mode 100644 test/language/expressions/class/dstr-meth-dflt-ary-ptrn-rest-not-final-obj.js create mode 100644 test/language/expressions/class/dstr-meth-dflt-ary-ptrn-rest-obj-id.js create mode 100644 test/language/expressions/class/dstr-meth-dflt-ary-ptrn-rest-obj-prop-id.js create mode 100644 test/language/expressions/class/dstr-meth-dflt-obj-init-null.js create mode 100644 test/language/expressions/class/dstr-meth-dflt-obj-init-undefined.js create mode 100644 test/language/expressions/class/dstr-meth-dflt-obj-ptrn-empty.js create mode 100644 test/language/expressions/class/dstr-meth-dflt-obj-ptrn-id-get-value-err.js create mode 100644 test/language/expressions/class/dstr-meth-dflt-obj-ptrn-id-init-fn-name-arrow.js create mode 100644 test/language/expressions/class/dstr-meth-dflt-obj-ptrn-id-init-fn-name-class.js create mode 100644 test/language/expressions/class/dstr-meth-dflt-obj-ptrn-id-init-fn-name-cover.js create mode 100644 test/language/expressions/class/dstr-meth-dflt-obj-ptrn-id-init-fn-name-fn.js create mode 100644 test/language/expressions/class/dstr-meth-dflt-obj-ptrn-id-init-fn-name-gen.js create mode 100644 test/language/expressions/class/dstr-meth-dflt-obj-ptrn-id-init-skipped.js create mode 100644 test/language/expressions/class/dstr-meth-dflt-obj-ptrn-id-init-throws.js create mode 100644 test/language/expressions/class/dstr-meth-dflt-obj-ptrn-id-init-unresolvable.js create mode 100644 test/language/expressions/class/dstr-meth-dflt-obj-ptrn-id-trailing-comma.js create mode 100644 test/language/expressions/class/dstr-meth-dflt-obj-ptrn-list-err.js create mode 100644 test/language/expressions/class/dstr-meth-dflt-obj-ptrn-prop-ary-init.js create mode 100644 test/language/expressions/class/dstr-meth-dflt-obj-ptrn-prop-ary-trailing-comma.js create mode 100644 test/language/expressions/class/dstr-meth-dflt-obj-ptrn-prop-ary-value-null.js create mode 100644 test/language/expressions/class/dstr-meth-dflt-obj-ptrn-prop-ary.js create mode 100644 test/language/expressions/class/dstr-meth-dflt-obj-ptrn-prop-eval-err.js create mode 100644 test/language/expressions/class/dstr-meth-dflt-obj-ptrn-prop-id-get-value-err.js create mode 100644 test/language/expressions/class/dstr-meth-dflt-obj-ptrn-prop-id-init-skipped.js create mode 100644 test/language/expressions/class/dstr-meth-dflt-obj-ptrn-prop-id-init-throws.js create mode 100644 test/language/expressions/class/dstr-meth-dflt-obj-ptrn-prop-id-init-unresolvable.js create mode 100644 test/language/expressions/class/dstr-meth-dflt-obj-ptrn-prop-id-init.js create mode 100644 test/language/expressions/class/dstr-meth-dflt-obj-ptrn-prop-id-trailing-comma.js create mode 100644 test/language/expressions/class/dstr-meth-dflt-obj-ptrn-prop-id.js create mode 100644 test/language/expressions/class/dstr-meth-dflt-obj-ptrn-prop-obj-init.js create mode 100644 test/language/expressions/class/dstr-meth-dflt-obj-ptrn-prop-obj-value-null.js create mode 100644 test/language/expressions/class/dstr-meth-dflt-obj-ptrn-prop-obj-value-undef.js create mode 100644 test/language/expressions/class/dstr-meth-dflt-obj-ptrn-prop-obj.js create mode 100644 test/language/expressions/class/dstr-meth-static-dflt-ary-init-iter-close.js create mode 100644 test/language/expressions/class/dstr-meth-static-dflt-ary-init-iter-get-err.js create mode 100644 test/language/expressions/class/dstr-meth-static-dflt-ary-init-iter-no-close.js create mode 100644 test/language/expressions/class/dstr-meth-static-dflt-ary-name-iter-val.js create mode 100644 test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-elem-ary-elem-init.js create mode 100644 test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-elem-ary-elem-iter.js create mode 100644 test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-elem-ary-elision-init.js create mode 100644 test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-elem-ary-elision-iter.js create mode 100644 test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-elem-ary-empty-init.js create mode 100644 test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-elem-ary-empty-iter.js create mode 100644 test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-elem-ary-rest-init.js create mode 100644 test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-elem-ary-rest-iter.js create mode 100644 test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-elem-ary-val-null.js create mode 100644 test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-elem-id-init-exhausted.js create mode 100644 test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-arrow.js create mode 100644 test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-class.js create mode 100644 test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-cover.js create mode 100644 test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-fn.js create mode 100644 test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-gen.js create mode 100644 test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-elem-id-init-hole.js create mode 100644 test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-elem-id-init-skipped.js create mode 100644 test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-elem-id-init-throws.js create mode 100644 test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-elem-id-init-undef.js create mode 100644 test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-elem-id-init-unresolvable.js create mode 100644 test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-elem-id-iter-complete.js create mode 100644 test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-elem-id-iter-done.js create mode 100644 test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-elem-id-iter-step-err.js create mode 100644 test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-elem-id-iter-val-err.js create mode 100644 test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-elem-id-iter-val.js create mode 100644 test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-elem-obj-id-init.js create mode 100644 test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-elem-obj-id.js create mode 100644 test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-elem-obj-prop-id-init.js create mode 100644 test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-elem-obj-prop-id.js create mode 100644 test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-elem-obj-val-null.js create mode 100644 test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-elem-obj-val-undef.js create mode 100644 test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-elision-exhausted.js create mode 100644 test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-elision-step-err.js create mode 100644 test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-elision.js create mode 100644 test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-empty.js create mode 100644 test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-rest-ary-elem.js create mode 100644 test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-rest-ary-elision.js create mode 100644 test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-rest-ary-empty.js create mode 100644 test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-rest-ary-rest.js create mode 100644 test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-rest-id-elision-next-err.js create mode 100644 test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-rest-id-elision.js create mode 100644 test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-rest-id-exhausted.js create mode 100644 test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-rest-id-iter-step-err.js create mode 100644 test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-rest-id-iter-val-err.js create mode 100644 test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-rest-id.js create mode 100644 test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-rest-init-ary.js create mode 100644 test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-rest-init-id.js create mode 100644 test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-rest-init-obj.js create mode 100644 test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-rest-not-final-ary.js create mode 100644 test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-rest-not-final-id.js create mode 100644 test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-rest-not-final-obj.js create mode 100644 test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-rest-obj-id.js create mode 100644 test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-rest-obj-prop-id.js create mode 100644 test/language/expressions/class/dstr-meth-static-dflt-obj-init-null.js create mode 100644 test/language/expressions/class/dstr-meth-static-dflt-obj-init-undefined.js create mode 100644 test/language/expressions/class/dstr-meth-static-dflt-obj-ptrn-empty.js create mode 100644 test/language/expressions/class/dstr-meth-static-dflt-obj-ptrn-id-get-value-err.js create mode 100644 test/language/expressions/class/dstr-meth-static-dflt-obj-ptrn-id-init-fn-name-arrow.js create mode 100644 test/language/expressions/class/dstr-meth-static-dflt-obj-ptrn-id-init-fn-name-class.js create mode 100644 test/language/expressions/class/dstr-meth-static-dflt-obj-ptrn-id-init-fn-name-cover.js create mode 100644 test/language/expressions/class/dstr-meth-static-dflt-obj-ptrn-id-init-fn-name-fn.js create mode 100644 test/language/expressions/class/dstr-meth-static-dflt-obj-ptrn-id-init-fn-name-gen.js create mode 100644 test/language/expressions/class/dstr-meth-static-dflt-obj-ptrn-id-init-skipped.js create mode 100644 test/language/expressions/class/dstr-meth-static-dflt-obj-ptrn-id-init-throws.js create mode 100644 test/language/expressions/class/dstr-meth-static-dflt-obj-ptrn-id-init-unresolvable.js create mode 100644 test/language/expressions/class/dstr-meth-static-dflt-obj-ptrn-id-trailing-comma.js create mode 100644 test/language/expressions/class/dstr-meth-static-dflt-obj-ptrn-list-err.js create mode 100644 test/language/expressions/class/dstr-meth-static-dflt-obj-ptrn-prop-ary-init.js create mode 100644 test/language/expressions/class/dstr-meth-static-dflt-obj-ptrn-prop-ary-trailing-comma.js create mode 100644 test/language/expressions/class/dstr-meth-static-dflt-obj-ptrn-prop-ary-value-null.js create mode 100644 test/language/expressions/class/dstr-meth-static-dflt-obj-ptrn-prop-ary.js create mode 100644 test/language/expressions/class/dstr-meth-static-dflt-obj-ptrn-prop-eval-err.js create mode 100644 test/language/expressions/class/dstr-meth-static-dflt-obj-ptrn-prop-id-get-value-err.js create mode 100644 test/language/expressions/class/dstr-meth-static-dflt-obj-ptrn-prop-id-init-skipped.js create mode 100644 test/language/expressions/class/dstr-meth-static-dflt-obj-ptrn-prop-id-init-throws.js create mode 100644 test/language/expressions/class/dstr-meth-static-dflt-obj-ptrn-prop-id-init-unresolvable.js create mode 100644 test/language/expressions/class/dstr-meth-static-dflt-obj-ptrn-prop-id-init.js create mode 100644 test/language/expressions/class/dstr-meth-static-dflt-obj-ptrn-prop-id-trailing-comma.js create mode 100644 test/language/expressions/class/dstr-meth-static-dflt-obj-ptrn-prop-id.js create mode 100644 test/language/expressions/class/dstr-meth-static-dflt-obj-ptrn-prop-obj-init.js create mode 100644 test/language/expressions/class/dstr-meth-static-dflt-obj-ptrn-prop-obj-value-null.js create mode 100644 test/language/expressions/class/dstr-meth-static-dflt-obj-ptrn-prop-obj-value-undef.js create mode 100644 test/language/expressions/class/dstr-meth-static-dflt-obj-ptrn-prop-obj.js create mode 100644 test/language/expressions/function/dstr-dflt-ary-init-iter-close.js create mode 100644 test/language/expressions/function/dstr-dflt-ary-init-iter-get-err.js create mode 100644 test/language/expressions/function/dstr-dflt-ary-init-iter-no-close.js create mode 100644 test/language/expressions/function/dstr-dflt-ary-name-iter-val.js create mode 100644 test/language/expressions/function/dstr-dflt-ary-ptrn-elem-ary-elem-init.js create mode 100644 test/language/expressions/function/dstr-dflt-ary-ptrn-elem-ary-elem-iter.js create mode 100644 test/language/expressions/function/dstr-dflt-ary-ptrn-elem-ary-elision-init.js create mode 100644 test/language/expressions/function/dstr-dflt-ary-ptrn-elem-ary-elision-iter.js create mode 100644 test/language/expressions/function/dstr-dflt-ary-ptrn-elem-ary-empty-init.js create mode 100644 test/language/expressions/function/dstr-dflt-ary-ptrn-elem-ary-empty-iter.js create mode 100644 test/language/expressions/function/dstr-dflt-ary-ptrn-elem-ary-rest-init.js create mode 100644 test/language/expressions/function/dstr-dflt-ary-ptrn-elem-ary-rest-iter.js create mode 100644 test/language/expressions/function/dstr-dflt-ary-ptrn-elem-ary-val-null.js create mode 100644 test/language/expressions/function/dstr-dflt-ary-ptrn-elem-id-init-exhausted.js create mode 100644 test/language/expressions/function/dstr-dflt-ary-ptrn-elem-id-init-fn-name-arrow.js create mode 100644 test/language/expressions/function/dstr-dflt-ary-ptrn-elem-id-init-fn-name-class.js create mode 100644 test/language/expressions/function/dstr-dflt-ary-ptrn-elem-id-init-fn-name-cover.js create mode 100644 test/language/expressions/function/dstr-dflt-ary-ptrn-elem-id-init-fn-name-fn.js create mode 100644 test/language/expressions/function/dstr-dflt-ary-ptrn-elem-id-init-fn-name-gen.js create mode 100644 test/language/expressions/function/dstr-dflt-ary-ptrn-elem-id-init-hole.js create mode 100644 test/language/expressions/function/dstr-dflt-ary-ptrn-elem-id-init-skipped.js create mode 100644 test/language/expressions/function/dstr-dflt-ary-ptrn-elem-id-init-throws.js create mode 100644 test/language/expressions/function/dstr-dflt-ary-ptrn-elem-id-init-undef.js create mode 100644 test/language/expressions/function/dstr-dflt-ary-ptrn-elem-id-init-unresolvable.js create mode 100644 test/language/expressions/function/dstr-dflt-ary-ptrn-elem-id-iter-complete.js create mode 100644 test/language/expressions/function/dstr-dflt-ary-ptrn-elem-id-iter-done.js create mode 100644 test/language/expressions/function/dstr-dflt-ary-ptrn-elem-id-iter-step-err.js create mode 100644 test/language/expressions/function/dstr-dflt-ary-ptrn-elem-id-iter-val-err.js create mode 100644 test/language/expressions/function/dstr-dflt-ary-ptrn-elem-id-iter-val.js create mode 100644 test/language/expressions/function/dstr-dflt-ary-ptrn-elem-obj-id-init.js create mode 100644 test/language/expressions/function/dstr-dflt-ary-ptrn-elem-obj-id.js create mode 100644 test/language/expressions/function/dstr-dflt-ary-ptrn-elem-obj-prop-id-init.js create mode 100644 test/language/expressions/function/dstr-dflt-ary-ptrn-elem-obj-prop-id.js create mode 100644 test/language/expressions/function/dstr-dflt-ary-ptrn-elem-obj-val-null.js create mode 100644 test/language/expressions/function/dstr-dflt-ary-ptrn-elem-obj-val-undef.js create mode 100644 test/language/expressions/function/dstr-dflt-ary-ptrn-elision-exhausted.js create mode 100644 test/language/expressions/function/dstr-dflt-ary-ptrn-elision-step-err.js create mode 100644 test/language/expressions/function/dstr-dflt-ary-ptrn-elision.js create mode 100644 test/language/expressions/function/dstr-dflt-ary-ptrn-empty.js create mode 100644 test/language/expressions/function/dstr-dflt-ary-ptrn-rest-ary-elem.js create mode 100644 test/language/expressions/function/dstr-dflt-ary-ptrn-rest-ary-elision.js create mode 100644 test/language/expressions/function/dstr-dflt-ary-ptrn-rest-ary-empty.js create mode 100644 test/language/expressions/function/dstr-dflt-ary-ptrn-rest-ary-rest.js create mode 100644 test/language/expressions/function/dstr-dflt-ary-ptrn-rest-id-elision-next-err.js create mode 100644 test/language/expressions/function/dstr-dflt-ary-ptrn-rest-id-elision.js create mode 100644 test/language/expressions/function/dstr-dflt-ary-ptrn-rest-id-exhausted.js create mode 100644 test/language/expressions/function/dstr-dflt-ary-ptrn-rest-id-iter-step-err.js create mode 100644 test/language/expressions/function/dstr-dflt-ary-ptrn-rest-id-iter-val-err.js create mode 100644 test/language/expressions/function/dstr-dflt-ary-ptrn-rest-id.js create mode 100644 test/language/expressions/function/dstr-dflt-ary-ptrn-rest-init-ary.js create mode 100644 test/language/expressions/function/dstr-dflt-ary-ptrn-rest-init-id.js create mode 100644 test/language/expressions/function/dstr-dflt-ary-ptrn-rest-init-obj.js create mode 100644 test/language/expressions/function/dstr-dflt-ary-ptrn-rest-not-final-ary.js create mode 100644 test/language/expressions/function/dstr-dflt-ary-ptrn-rest-not-final-id.js create mode 100644 test/language/expressions/function/dstr-dflt-ary-ptrn-rest-not-final-obj.js create mode 100644 test/language/expressions/function/dstr-dflt-ary-ptrn-rest-obj-id.js create mode 100644 test/language/expressions/function/dstr-dflt-ary-ptrn-rest-obj-prop-id.js create mode 100644 test/language/expressions/function/dstr-dflt-obj-init-null.js create mode 100644 test/language/expressions/function/dstr-dflt-obj-init-undefined.js create mode 100644 test/language/expressions/function/dstr-dflt-obj-ptrn-empty.js create mode 100644 test/language/expressions/function/dstr-dflt-obj-ptrn-id-get-value-err.js create mode 100644 test/language/expressions/function/dstr-dflt-obj-ptrn-id-init-fn-name-arrow.js create mode 100644 test/language/expressions/function/dstr-dflt-obj-ptrn-id-init-fn-name-class.js create mode 100644 test/language/expressions/function/dstr-dflt-obj-ptrn-id-init-fn-name-cover.js create mode 100644 test/language/expressions/function/dstr-dflt-obj-ptrn-id-init-fn-name-fn.js create mode 100644 test/language/expressions/function/dstr-dflt-obj-ptrn-id-init-fn-name-gen.js create mode 100644 test/language/expressions/function/dstr-dflt-obj-ptrn-id-init-skipped.js create mode 100644 test/language/expressions/function/dstr-dflt-obj-ptrn-id-init-throws.js create mode 100644 test/language/expressions/function/dstr-dflt-obj-ptrn-id-init-unresolvable.js create mode 100644 test/language/expressions/function/dstr-dflt-obj-ptrn-id-trailing-comma.js create mode 100644 test/language/expressions/function/dstr-dflt-obj-ptrn-list-err.js create mode 100644 test/language/expressions/function/dstr-dflt-obj-ptrn-prop-ary-init.js create mode 100644 test/language/expressions/function/dstr-dflt-obj-ptrn-prop-ary-trailing-comma.js create mode 100644 test/language/expressions/function/dstr-dflt-obj-ptrn-prop-ary-value-null.js create mode 100644 test/language/expressions/function/dstr-dflt-obj-ptrn-prop-ary.js create mode 100644 test/language/expressions/function/dstr-dflt-obj-ptrn-prop-eval-err.js create mode 100644 test/language/expressions/function/dstr-dflt-obj-ptrn-prop-id-get-value-err.js create mode 100644 test/language/expressions/function/dstr-dflt-obj-ptrn-prop-id-init-skipped.js create mode 100644 test/language/expressions/function/dstr-dflt-obj-ptrn-prop-id-init-throws.js create mode 100644 test/language/expressions/function/dstr-dflt-obj-ptrn-prop-id-init-unresolvable.js create mode 100644 test/language/expressions/function/dstr-dflt-obj-ptrn-prop-id-init.js create mode 100644 test/language/expressions/function/dstr-dflt-obj-ptrn-prop-id-trailing-comma.js create mode 100644 test/language/expressions/function/dstr-dflt-obj-ptrn-prop-id.js create mode 100644 test/language/expressions/function/dstr-dflt-obj-ptrn-prop-obj-init.js create mode 100644 test/language/expressions/function/dstr-dflt-obj-ptrn-prop-obj-value-null.js create mode 100644 test/language/expressions/function/dstr-dflt-obj-ptrn-prop-obj-value-undef.js create mode 100644 test/language/expressions/function/dstr-dflt-obj-ptrn-prop-obj.js create mode 100644 test/language/expressions/generators/dstr-dflt-ary-init-iter-close.js create mode 100644 test/language/expressions/generators/dstr-dflt-ary-init-iter-get-err.js create mode 100644 test/language/expressions/generators/dstr-dflt-ary-init-iter-no-close.js create mode 100644 test/language/expressions/generators/dstr-dflt-ary-name-iter-val.js create mode 100644 test/language/expressions/generators/dstr-dflt-ary-ptrn-elem-ary-elem-init.js create mode 100644 test/language/expressions/generators/dstr-dflt-ary-ptrn-elem-ary-elem-iter.js create mode 100644 test/language/expressions/generators/dstr-dflt-ary-ptrn-elem-ary-elision-init.js create mode 100644 test/language/expressions/generators/dstr-dflt-ary-ptrn-elem-ary-elision-iter.js create mode 100644 test/language/expressions/generators/dstr-dflt-ary-ptrn-elem-ary-empty-init.js create mode 100644 test/language/expressions/generators/dstr-dflt-ary-ptrn-elem-ary-empty-iter.js create mode 100644 test/language/expressions/generators/dstr-dflt-ary-ptrn-elem-ary-rest-init.js create mode 100644 test/language/expressions/generators/dstr-dflt-ary-ptrn-elem-ary-rest-iter.js create mode 100644 test/language/expressions/generators/dstr-dflt-ary-ptrn-elem-ary-val-null.js create mode 100644 test/language/expressions/generators/dstr-dflt-ary-ptrn-elem-id-init-exhausted.js create mode 100644 test/language/expressions/generators/dstr-dflt-ary-ptrn-elem-id-init-fn-name-arrow.js create mode 100644 test/language/expressions/generators/dstr-dflt-ary-ptrn-elem-id-init-fn-name-class.js create mode 100644 test/language/expressions/generators/dstr-dflt-ary-ptrn-elem-id-init-fn-name-cover.js create mode 100644 test/language/expressions/generators/dstr-dflt-ary-ptrn-elem-id-init-fn-name-fn.js create mode 100644 test/language/expressions/generators/dstr-dflt-ary-ptrn-elem-id-init-fn-name-gen.js create mode 100644 test/language/expressions/generators/dstr-dflt-ary-ptrn-elem-id-init-hole.js create mode 100644 test/language/expressions/generators/dstr-dflt-ary-ptrn-elem-id-init-skipped.js create mode 100644 test/language/expressions/generators/dstr-dflt-ary-ptrn-elem-id-init-throws.js create mode 100644 test/language/expressions/generators/dstr-dflt-ary-ptrn-elem-id-init-undef.js create mode 100644 test/language/expressions/generators/dstr-dflt-ary-ptrn-elem-id-init-unresolvable.js create mode 100644 test/language/expressions/generators/dstr-dflt-ary-ptrn-elem-id-iter-complete.js create mode 100644 test/language/expressions/generators/dstr-dflt-ary-ptrn-elem-id-iter-done.js create mode 100644 test/language/expressions/generators/dstr-dflt-ary-ptrn-elem-id-iter-step-err.js create mode 100644 test/language/expressions/generators/dstr-dflt-ary-ptrn-elem-id-iter-val-err.js create mode 100644 test/language/expressions/generators/dstr-dflt-ary-ptrn-elem-id-iter-val.js create mode 100644 test/language/expressions/generators/dstr-dflt-ary-ptrn-elem-obj-id-init.js create mode 100644 test/language/expressions/generators/dstr-dflt-ary-ptrn-elem-obj-id.js create mode 100644 test/language/expressions/generators/dstr-dflt-ary-ptrn-elem-obj-prop-id-init.js create mode 100644 test/language/expressions/generators/dstr-dflt-ary-ptrn-elem-obj-prop-id.js create mode 100644 test/language/expressions/generators/dstr-dflt-ary-ptrn-elem-obj-val-null.js create mode 100644 test/language/expressions/generators/dstr-dflt-ary-ptrn-elem-obj-val-undef.js create mode 100644 test/language/expressions/generators/dstr-dflt-ary-ptrn-elision-exhausted.js create mode 100644 test/language/expressions/generators/dstr-dflt-ary-ptrn-elision-step-err.js create mode 100644 test/language/expressions/generators/dstr-dflt-ary-ptrn-elision.js create mode 100644 test/language/expressions/generators/dstr-dflt-ary-ptrn-empty.js create mode 100644 test/language/expressions/generators/dstr-dflt-ary-ptrn-rest-ary-elem.js create mode 100644 test/language/expressions/generators/dstr-dflt-ary-ptrn-rest-ary-elision.js create mode 100644 test/language/expressions/generators/dstr-dflt-ary-ptrn-rest-ary-empty.js create mode 100644 test/language/expressions/generators/dstr-dflt-ary-ptrn-rest-ary-rest.js create mode 100644 test/language/expressions/generators/dstr-dflt-ary-ptrn-rest-id-elision-next-err.js create mode 100644 test/language/expressions/generators/dstr-dflt-ary-ptrn-rest-id-elision.js create mode 100644 test/language/expressions/generators/dstr-dflt-ary-ptrn-rest-id-exhausted.js create mode 100644 test/language/expressions/generators/dstr-dflt-ary-ptrn-rest-id-iter-step-err.js create mode 100644 test/language/expressions/generators/dstr-dflt-ary-ptrn-rest-id-iter-val-err.js create mode 100644 test/language/expressions/generators/dstr-dflt-ary-ptrn-rest-id.js create mode 100644 test/language/expressions/generators/dstr-dflt-ary-ptrn-rest-init-ary.js create mode 100644 test/language/expressions/generators/dstr-dflt-ary-ptrn-rest-init-id.js create mode 100644 test/language/expressions/generators/dstr-dflt-ary-ptrn-rest-init-obj.js create mode 100644 test/language/expressions/generators/dstr-dflt-ary-ptrn-rest-not-final-ary.js create mode 100644 test/language/expressions/generators/dstr-dflt-ary-ptrn-rest-not-final-id.js create mode 100644 test/language/expressions/generators/dstr-dflt-ary-ptrn-rest-not-final-obj.js create mode 100644 test/language/expressions/generators/dstr-dflt-ary-ptrn-rest-obj-id.js create mode 100644 test/language/expressions/generators/dstr-dflt-ary-ptrn-rest-obj-prop-id.js create mode 100644 test/language/expressions/generators/dstr-dflt-obj-init-null.js create mode 100644 test/language/expressions/generators/dstr-dflt-obj-init-undefined.js create mode 100644 test/language/expressions/generators/dstr-dflt-obj-ptrn-empty.js create mode 100644 test/language/expressions/generators/dstr-dflt-obj-ptrn-id-get-value-err.js create mode 100644 test/language/expressions/generators/dstr-dflt-obj-ptrn-id-init-fn-name-arrow.js create mode 100644 test/language/expressions/generators/dstr-dflt-obj-ptrn-id-init-fn-name-class.js create mode 100644 test/language/expressions/generators/dstr-dflt-obj-ptrn-id-init-fn-name-cover.js create mode 100644 test/language/expressions/generators/dstr-dflt-obj-ptrn-id-init-fn-name-fn.js create mode 100644 test/language/expressions/generators/dstr-dflt-obj-ptrn-id-init-fn-name-gen.js create mode 100644 test/language/expressions/generators/dstr-dflt-obj-ptrn-id-init-skipped.js create mode 100644 test/language/expressions/generators/dstr-dflt-obj-ptrn-id-init-throws.js create mode 100644 test/language/expressions/generators/dstr-dflt-obj-ptrn-id-init-unresolvable.js create mode 100644 test/language/expressions/generators/dstr-dflt-obj-ptrn-id-trailing-comma.js create mode 100644 test/language/expressions/generators/dstr-dflt-obj-ptrn-list-err.js create mode 100644 test/language/expressions/generators/dstr-dflt-obj-ptrn-prop-ary-init.js create mode 100644 test/language/expressions/generators/dstr-dflt-obj-ptrn-prop-ary-trailing-comma.js create mode 100644 test/language/expressions/generators/dstr-dflt-obj-ptrn-prop-ary-value-null.js create mode 100644 test/language/expressions/generators/dstr-dflt-obj-ptrn-prop-ary.js create mode 100644 test/language/expressions/generators/dstr-dflt-obj-ptrn-prop-eval-err.js create mode 100644 test/language/expressions/generators/dstr-dflt-obj-ptrn-prop-id-get-value-err.js create mode 100644 test/language/expressions/generators/dstr-dflt-obj-ptrn-prop-id-init-skipped.js create mode 100644 test/language/expressions/generators/dstr-dflt-obj-ptrn-prop-id-init-throws.js create mode 100644 test/language/expressions/generators/dstr-dflt-obj-ptrn-prop-id-init-unresolvable.js create mode 100644 test/language/expressions/generators/dstr-dflt-obj-ptrn-prop-id-init.js create mode 100644 test/language/expressions/generators/dstr-dflt-obj-ptrn-prop-id-trailing-comma.js create mode 100644 test/language/expressions/generators/dstr-dflt-obj-ptrn-prop-id.js create mode 100644 test/language/expressions/generators/dstr-dflt-obj-ptrn-prop-obj-init.js create mode 100644 test/language/expressions/generators/dstr-dflt-obj-ptrn-prop-obj-value-null.js create mode 100644 test/language/expressions/generators/dstr-dflt-obj-ptrn-prop-obj-value-undef.js create mode 100644 test/language/expressions/generators/dstr-dflt-obj-ptrn-prop-obj.js create mode 100644 test/language/expressions/object/dstr-gen-meth-dflt-ary-init-iter-close.js create mode 100644 test/language/expressions/object/dstr-gen-meth-dflt-ary-init-iter-get-err.js create mode 100644 test/language/expressions/object/dstr-gen-meth-dflt-ary-init-iter-no-close.js create mode 100644 test/language/expressions/object/dstr-gen-meth-dflt-ary-name-iter-val.js create mode 100644 test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-elem-ary-elem-init.js create mode 100644 test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-elem-ary-elem-iter.js create mode 100644 test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-elem-ary-elision-init.js create mode 100644 test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-elem-ary-elision-iter.js create mode 100644 test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-elem-ary-empty-init.js create mode 100644 test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-elem-ary-empty-iter.js create mode 100644 test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-elem-ary-rest-init.js create mode 100644 test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-elem-ary-rest-iter.js create mode 100644 test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-elem-ary-val-null.js create mode 100644 test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-elem-id-init-exhausted.js create mode 100644 test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-arrow.js create mode 100644 test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-class.js create mode 100644 test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-cover.js create mode 100644 test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-fn.js create mode 100644 test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-gen.js create mode 100644 test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-elem-id-init-hole.js create mode 100644 test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-elem-id-init-skipped.js create mode 100644 test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-elem-id-init-throws.js create mode 100644 test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-elem-id-init-undef.js create mode 100644 test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-elem-id-init-unresolvable.js create mode 100644 test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-elem-id-iter-complete.js create mode 100644 test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-elem-id-iter-done.js create mode 100644 test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-elem-id-iter-step-err.js create mode 100644 test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-elem-id-iter-val-err.js create mode 100644 test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-elem-id-iter-val.js create mode 100644 test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-elem-obj-id-init.js create mode 100644 test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-elem-obj-id.js create mode 100644 test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-elem-obj-prop-id-init.js create mode 100644 test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-elem-obj-prop-id.js create mode 100644 test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-elem-obj-val-null.js create mode 100644 test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-elem-obj-val-undef.js create mode 100644 test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-elision-exhausted.js create mode 100644 test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-elision-step-err.js create mode 100644 test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-elision.js create mode 100644 test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-empty.js create mode 100644 test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-rest-ary-elem.js create mode 100644 test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-rest-ary-elision.js create mode 100644 test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-rest-ary-empty.js create mode 100644 test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-rest-ary-rest.js create mode 100644 test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-rest-id-elision-next-err.js create mode 100644 test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-rest-id-elision.js create mode 100644 test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-rest-id-exhausted.js create mode 100644 test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-rest-id-iter-step-err.js create mode 100644 test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-rest-id-iter-val-err.js create mode 100644 test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-rest-id.js create mode 100644 test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-rest-init-ary.js create mode 100644 test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-rest-init-id.js create mode 100644 test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-rest-init-obj.js create mode 100644 test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-rest-not-final-ary.js create mode 100644 test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-rest-not-final-id.js create mode 100644 test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-rest-not-final-obj.js create mode 100644 test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-rest-obj-id.js create mode 100644 test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-rest-obj-prop-id.js create mode 100644 test/language/expressions/object/dstr-gen-meth-dflt-obj-init-null.js create mode 100644 test/language/expressions/object/dstr-gen-meth-dflt-obj-init-undefined.js create mode 100644 test/language/expressions/object/dstr-gen-meth-dflt-obj-ptrn-empty.js create mode 100644 test/language/expressions/object/dstr-gen-meth-dflt-obj-ptrn-id-get-value-err.js create mode 100644 test/language/expressions/object/dstr-gen-meth-dflt-obj-ptrn-id-init-fn-name-arrow.js create mode 100644 test/language/expressions/object/dstr-gen-meth-dflt-obj-ptrn-id-init-fn-name-class.js create mode 100644 test/language/expressions/object/dstr-gen-meth-dflt-obj-ptrn-id-init-fn-name-cover.js create mode 100644 test/language/expressions/object/dstr-gen-meth-dflt-obj-ptrn-id-init-fn-name-fn.js create mode 100644 test/language/expressions/object/dstr-gen-meth-dflt-obj-ptrn-id-init-fn-name-gen.js create mode 100644 test/language/expressions/object/dstr-gen-meth-dflt-obj-ptrn-id-init-skipped.js create mode 100644 test/language/expressions/object/dstr-gen-meth-dflt-obj-ptrn-id-init-throws.js create mode 100644 test/language/expressions/object/dstr-gen-meth-dflt-obj-ptrn-id-init-unresolvable.js create mode 100644 test/language/expressions/object/dstr-gen-meth-dflt-obj-ptrn-id-trailing-comma.js create mode 100644 test/language/expressions/object/dstr-gen-meth-dflt-obj-ptrn-list-err.js create mode 100644 test/language/expressions/object/dstr-gen-meth-dflt-obj-ptrn-prop-ary-init.js create mode 100644 test/language/expressions/object/dstr-gen-meth-dflt-obj-ptrn-prop-ary-trailing-comma.js create mode 100644 test/language/expressions/object/dstr-gen-meth-dflt-obj-ptrn-prop-ary-value-null.js create mode 100644 test/language/expressions/object/dstr-gen-meth-dflt-obj-ptrn-prop-ary.js create mode 100644 test/language/expressions/object/dstr-gen-meth-dflt-obj-ptrn-prop-eval-err.js create mode 100644 test/language/expressions/object/dstr-gen-meth-dflt-obj-ptrn-prop-id-get-value-err.js create mode 100644 test/language/expressions/object/dstr-gen-meth-dflt-obj-ptrn-prop-id-init-skipped.js create mode 100644 test/language/expressions/object/dstr-gen-meth-dflt-obj-ptrn-prop-id-init-throws.js create mode 100644 test/language/expressions/object/dstr-gen-meth-dflt-obj-ptrn-prop-id-init-unresolvable.js create mode 100644 test/language/expressions/object/dstr-gen-meth-dflt-obj-ptrn-prop-id-init.js create mode 100644 test/language/expressions/object/dstr-gen-meth-dflt-obj-ptrn-prop-id-trailing-comma.js create mode 100644 test/language/expressions/object/dstr-gen-meth-dflt-obj-ptrn-prop-id.js create mode 100644 test/language/expressions/object/dstr-gen-meth-dflt-obj-ptrn-prop-obj-init.js create mode 100644 test/language/expressions/object/dstr-gen-meth-dflt-obj-ptrn-prop-obj-value-null.js create mode 100644 test/language/expressions/object/dstr-gen-meth-dflt-obj-ptrn-prop-obj-value-undef.js create mode 100644 test/language/expressions/object/dstr-gen-meth-dflt-obj-ptrn-prop-obj.js create mode 100644 test/language/expressions/object/dstr-meth-dflt-ary-init-iter-close.js create mode 100644 test/language/expressions/object/dstr-meth-dflt-ary-init-iter-get-err.js create mode 100644 test/language/expressions/object/dstr-meth-dflt-ary-init-iter-no-close.js create mode 100644 test/language/expressions/object/dstr-meth-dflt-ary-name-iter-val.js create mode 100644 test/language/expressions/object/dstr-meth-dflt-ary-ptrn-elem-ary-elem-init.js create mode 100644 test/language/expressions/object/dstr-meth-dflt-ary-ptrn-elem-ary-elem-iter.js create mode 100644 test/language/expressions/object/dstr-meth-dflt-ary-ptrn-elem-ary-elision-init.js create mode 100644 test/language/expressions/object/dstr-meth-dflt-ary-ptrn-elem-ary-elision-iter.js create mode 100644 test/language/expressions/object/dstr-meth-dflt-ary-ptrn-elem-ary-empty-init.js create mode 100644 test/language/expressions/object/dstr-meth-dflt-ary-ptrn-elem-ary-empty-iter.js create mode 100644 test/language/expressions/object/dstr-meth-dflt-ary-ptrn-elem-ary-rest-init.js create mode 100644 test/language/expressions/object/dstr-meth-dflt-ary-ptrn-elem-ary-rest-iter.js create mode 100644 test/language/expressions/object/dstr-meth-dflt-ary-ptrn-elem-ary-val-null.js create mode 100644 test/language/expressions/object/dstr-meth-dflt-ary-ptrn-elem-id-init-exhausted.js create mode 100644 test/language/expressions/object/dstr-meth-dflt-ary-ptrn-elem-id-init-fn-name-arrow.js create mode 100644 test/language/expressions/object/dstr-meth-dflt-ary-ptrn-elem-id-init-fn-name-class.js create mode 100644 test/language/expressions/object/dstr-meth-dflt-ary-ptrn-elem-id-init-fn-name-cover.js create mode 100644 test/language/expressions/object/dstr-meth-dflt-ary-ptrn-elem-id-init-fn-name-fn.js create mode 100644 test/language/expressions/object/dstr-meth-dflt-ary-ptrn-elem-id-init-fn-name-gen.js create mode 100644 test/language/expressions/object/dstr-meth-dflt-ary-ptrn-elem-id-init-hole.js create mode 100644 test/language/expressions/object/dstr-meth-dflt-ary-ptrn-elem-id-init-skipped.js create mode 100644 test/language/expressions/object/dstr-meth-dflt-ary-ptrn-elem-id-init-throws.js create mode 100644 test/language/expressions/object/dstr-meth-dflt-ary-ptrn-elem-id-init-undef.js create mode 100644 test/language/expressions/object/dstr-meth-dflt-ary-ptrn-elem-id-init-unresolvable.js create mode 100644 test/language/expressions/object/dstr-meth-dflt-ary-ptrn-elem-id-iter-complete.js create mode 100644 test/language/expressions/object/dstr-meth-dflt-ary-ptrn-elem-id-iter-done.js create mode 100644 test/language/expressions/object/dstr-meth-dflt-ary-ptrn-elem-id-iter-step-err.js create mode 100644 test/language/expressions/object/dstr-meth-dflt-ary-ptrn-elem-id-iter-val-err.js create mode 100644 test/language/expressions/object/dstr-meth-dflt-ary-ptrn-elem-id-iter-val.js create mode 100644 test/language/expressions/object/dstr-meth-dflt-ary-ptrn-elem-obj-id-init.js create mode 100644 test/language/expressions/object/dstr-meth-dflt-ary-ptrn-elem-obj-id.js create mode 100644 test/language/expressions/object/dstr-meth-dflt-ary-ptrn-elem-obj-prop-id-init.js create mode 100644 test/language/expressions/object/dstr-meth-dflt-ary-ptrn-elem-obj-prop-id.js create mode 100644 test/language/expressions/object/dstr-meth-dflt-ary-ptrn-elem-obj-val-null.js create mode 100644 test/language/expressions/object/dstr-meth-dflt-ary-ptrn-elem-obj-val-undef.js create mode 100644 test/language/expressions/object/dstr-meth-dflt-ary-ptrn-elision-exhausted.js create mode 100644 test/language/expressions/object/dstr-meth-dflt-ary-ptrn-elision-step-err.js create mode 100644 test/language/expressions/object/dstr-meth-dflt-ary-ptrn-elision.js create mode 100644 test/language/expressions/object/dstr-meth-dflt-ary-ptrn-empty.js create mode 100644 test/language/expressions/object/dstr-meth-dflt-ary-ptrn-rest-ary-elem.js create mode 100644 test/language/expressions/object/dstr-meth-dflt-ary-ptrn-rest-ary-elision.js create mode 100644 test/language/expressions/object/dstr-meth-dflt-ary-ptrn-rest-ary-empty.js create mode 100644 test/language/expressions/object/dstr-meth-dflt-ary-ptrn-rest-ary-rest.js create mode 100644 test/language/expressions/object/dstr-meth-dflt-ary-ptrn-rest-id-elision-next-err.js create mode 100644 test/language/expressions/object/dstr-meth-dflt-ary-ptrn-rest-id-elision.js create mode 100644 test/language/expressions/object/dstr-meth-dflt-ary-ptrn-rest-id-exhausted.js create mode 100644 test/language/expressions/object/dstr-meth-dflt-ary-ptrn-rest-id-iter-step-err.js create mode 100644 test/language/expressions/object/dstr-meth-dflt-ary-ptrn-rest-id-iter-val-err.js create mode 100644 test/language/expressions/object/dstr-meth-dflt-ary-ptrn-rest-id.js create mode 100644 test/language/expressions/object/dstr-meth-dflt-ary-ptrn-rest-init-ary.js create mode 100644 test/language/expressions/object/dstr-meth-dflt-ary-ptrn-rest-init-id.js create mode 100644 test/language/expressions/object/dstr-meth-dflt-ary-ptrn-rest-init-obj.js create mode 100644 test/language/expressions/object/dstr-meth-dflt-ary-ptrn-rest-not-final-ary.js create mode 100644 test/language/expressions/object/dstr-meth-dflt-ary-ptrn-rest-not-final-id.js create mode 100644 test/language/expressions/object/dstr-meth-dflt-ary-ptrn-rest-not-final-obj.js create mode 100644 test/language/expressions/object/dstr-meth-dflt-ary-ptrn-rest-obj-id.js create mode 100644 test/language/expressions/object/dstr-meth-dflt-ary-ptrn-rest-obj-prop-id.js create mode 100644 test/language/expressions/object/dstr-meth-dflt-obj-init-null.js create mode 100644 test/language/expressions/object/dstr-meth-dflt-obj-init-undefined.js create mode 100644 test/language/expressions/object/dstr-meth-dflt-obj-ptrn-empty.js create mode 100644 test/language/expressions/object/dstr-meth-dflt-obj-ptrn-id-get-value-err.js create mode 100644 test/language/expressions/object/dstr-meth-dflt-obj-ptrn-id-init-fn-name-arrow.js create mode 100644 test/language/expressions/object/dstr-meth-dflt-obj-ptrn-id-init-fn-name-class.js create mode 100644 test/language/expressions/object/dstr-meth-dflt-obj-ptrn-id-init-fn-name-cover.js create mode 100644 test/language/expressions/object/dstr-meth-dflt-obj-ptrn-id-init-fn-name-fn.js create mode 100644 test/language/expressions/object/dstr-meth-dflt-obj-ptrn-id-init-fn-name-gen.js create mode 100644 test/language/expressions/object/dstr-meth-dflt-obj-ptrn-id-init-skipped.js create mode 100644 test/language/expressions/object/dstr-meth-dflt-obj-ptrn-id-init-throws.js create mode 100644 test/language/expressions/object/dstr-meth-dflt-obj-ptrn-id-init-unresolvable.js create mode 100644 test/language/expressions/object/dstr-meth-dflt-obj-ptrn-id-trailing-comma.js create mode 100644 test/language/expressions/object/dstr-meth-dflt-obj-ptrn-list-err.js create mode 100644 test/language/expressions/object/dstr-meth-dflt-obj-ptrn-prop-ary-init.js create mode 100644 test/language/expressions/object/dstr-meth-dflt-obj-ptrn-prop-ary-trailing-comma.js create mode 100644 test/language/expressions/object/dstr-meth-dflt-obj-ptrn-prop-ary-value-null.js create mode 100644 test/language/expressions/object/dstr-meth-dflt-obj-ptrn-prop-ary.js create mode 100644 test/language/expressions/object/dstr-meth-dflt-obj-ptrn-prop-eval-err.js create mode 100644 test/language/expressions/object/dstr-meth-dflt-obj-ptrn-prop-id-get-value-err.js create mode 100644 test/language/expressions/object/dstr-meth-dflt-obj-ptrn-prop-id-init-skipped.js create mode 100644 test/language/expressions/object/dstr-meth-dflt-obj-ptrn-prop-id-init-throws.js create mode 100644 test/language/expressions/object/dstr-meth-dflt-obj-ptrn-prop-id-init-unresolvable.js create mode 100644 test/language/expressions/object/dstr-meth-dflt-obj-ptrn-prop-id-init.js create mode 100644 test/language/expressions/object/dstr-meth-dflt-obj-ptrn-prop-id-trailing-comma.js create mode 100644 test/language/expressions/object/dstr-meth-dflt-obj-ptrn-prop-id.js create mode 100644 test/language/expressions/object/dstr-meth-dflt-obj-ptrn-prop-obj-init.js create mode 100644 test/language/expressions/object/dstr-meth-dflt-obj-ptrn-prop-obj-value-null.js create mode 100644 test/language/expressions/object/dstr-meth-dflt-obj-ptrn-prop-obj-value-undef.js create mode 100644 test/language/expressions/object/dstr-meth-dflt-obj-ptrn-prop-obj.js create mode 100644 test/language/statements/class/dstr-gen-meth-dflt-ary-init-iter-close.js create mode 100644 test/language/statements/class/dstr-gen-meth-dflt-ary-init-iter-get-err.js create mode 100644 test/language/statements/class/dstr-gen-meth-dflt-ary-init-iter-no-close.js create mode 100644 test/language/statements/class/dstr-gen-meth-dflt-ary-name-iter-val.js create mode 100644 test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-elem-ary-elem-init.js create mode 100644 test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-elem-ary-elem-iter.js create mode 100644 test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-elem-ary-elision-init.js create mode 100644 test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-elem-ary-elision-iter.js create mode 100644 test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-elem-ary-empty-init.js create mode 100644 test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-elem-ary-empty-iter.js create mode 100644 test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-elem-ary-rest-init.js create mode 100644 test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-elem-ary-rest-iter.js create mode 100644 test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-elem-ary-val-null.js create mode 100644 test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-elem-id-init-exhausted.js create mode 100644 test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-arrow.js create mode 100644 test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-class.js create mode 100644 test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-cover.js create mode 100644 test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-fn.js create mode 100644 test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-gen.js create mode 100644 test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-elem-id-init-hole.js create mode 100644 test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-elem-id-init-skipped.js create mode 100644 test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-elem-id-init-throws.js create mode 100644 test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-elem-id-init-undef.js create mode 100644 test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-elem-id-init-unresolvable.js create mode 100644 test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-elem-id-iter-complete.js create mode 100644 test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-elem-id-iter-done.js create mode 100644 test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-elem-id-iter-step-err.js create mode 100644 test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-elem-id-iter-val-err.js create mode 100644 test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-elem-id-iter-val.js create mode 100644 test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-elem-obj-id-init.js create mode 100644 test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-elem-obj-id.js create mode 100644 test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-elem-obj-prop-id-init.js create mode 100644 test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-elem-obj-prop-id.js create mode 100644 test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-elem-obj-val-null.js create mode 100644 test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-elem-obj-val-undef.js create mode 100644 test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-elision-exhausted.js create mode 100644 test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-elision-step-err.js create mode 100644 test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-elision.js create mode 100644 test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-empty.js create mode 100644 test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-rest-ary-elem.js create mode 100644 test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-rest-ary-elision.js create mode 100644 test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-rest-ary-empty.js create mode 100644 test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-rest-ary-rest.js create mode 100644 test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-rest-id-elision-next-err.js create mode 100644 test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-rest-id-elision.js create mode 100644 test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-rest-id-exhausted.js create mode 100644 test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-rest-id-iter-step-err.js create mode 100644 test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-rest-id-iter-val-err.js create mode 100644 test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-rest-id.js create mode 100644 test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-rest-init-ary.js create mode 100644 test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-rest-init-id.js create mode 100644 test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-rest-init-obj.js create mode 100644 test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-rest-not-final-ary.js create mode 100644 test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-rest-not-final-id.js create mode 100644 test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-rest-not-final-obj.js create mode 100644 test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-rest-obj-id.js create mode 100644 test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-rest-obj-prop-id.js create mode 100644 test/language/statements/class/dstr-gen-meth-dflt-obj-init-null.js create mode 100644 test/language/statements/class/dstr-gen-meth-dflt-obj-init-undefined.js create mode 100644 test/language/statements/class/dstr-gen-meth-dflt-obj-ptrn-empty.js create mode 100644 test/language/statements/class/dstr-gen-meth-dflt-obj-ptrn-id-get-value-err.js create mode 100644 test/language/statements/class/dstr-gen-meth-dflt-obj-ptrn-id-init-fn-name-arrow.js create mode 100644 test/language/statements/class/dstr-gen-meth-dflt-obj-ptrn-id-init-fn-name-class.js create mode 100644 test/language/statements/class/dstr-gen-meth-dflt-obj-ptrn-id-init-fn-name-cover.js create mode 100644 test/language/statements/class/dstr-gen-meth-dflt-obj-ptrn-id-init-fn-name-fn.js create mode 100644 test/language/statements/class/dstr-gen-meth-dflt-obj-ptrn-id-init-fn-name-gen.js create mode 100644 test/language/statements/class/dstr-gen-meth-dflt-obj-ptrn-id-init-skipped.js create mode 100644 test/language/statements/class/dstr-gen-meth-dflt-obj-ptrn-id-init-throws.js create mode 100644 test/language/statements/class/dstr-gen-meth-dflt-obj-ptrn-id-init-unresolvable.js create mode 100644 test/language/statements/class/dstr-gen-meth-dflt-obj-ptrn-id-trailing-comma.js create mode 100644 test/language/statements/class/dstr-gen-meth-dflt-obj-ptrn-list-err.js create mode 100644 test/language/statements/class/dstr-gen-meth-dflt-obj-ptrn-prop-ary-init.js create mode 100644 test/language/statements/class/dstr-gen-meth-dflt-obj-ptrn-prop-ary-trailing-comma.js create mode 100644 test/language/statements/class/dstr-gen-meth-dflt-obj-ptrn-prop-ary-value-null.js create mode 100644 test/language/statements/class/dstr-gen-meth-dflt-obj-ptrn-prop-ary.js create mode 100644 test/language/statements/class/dstr-gen-meth-dflt-obj-ptrn-prop-eval-err.js create mode 100644 test/language/statements/class/dstr-gen-meth-dflt-obj-ptrn-prop-id-get-value-err.js create mode 100644 test/language/statements/class/dstr-gen-meth-dflt-obj-ptrn-prop-id-init-skipped.js create mode 100644 test/language/statements/class/dstr-gen-meth-dflt-obj-ptrn-prop-id-init-throws.js create mode 100644 test/language/statements/class/dstr-gen-meth-dflt-obj-ptrn-prop-id-init-unresolvable.js create mode 100644 test/language/statements/class/dstr-gen-meth-dflt-obj-ptrn-prop-id-init.js create mode 100644 test/language/statements/class/dstr-gen-meth-dflt-obj-ptrn-prop-id-trailing-comma.js create mode 100644 test/language/statements/class/dstr-gen-meth-dflt-obj-ptrn-prop-id.js create mode 100644 test/language/statements/class/dstr-gen-meth-dflt-obj-ptrn-prop-obj-init.js create mode 100644 test/language/statements/class/dstr-gen-meth-dflt-obj-ptrn-prop-obj-value-null.js create mode 100644 test/language/statements/class/dstr-gen-meth-dflt-obj-ptrn-prop-obj-value-undef.js create mode 100644 test/language/statements/class/dstr-gen-meth-dflt-obj-ptrn-prop-obj.js create mode 100644 test/language/statements/class/dstr-gen-meth-static-dflt-ary-init-iter-close.js create mode 100644 test/language/statements/class/dstr-gen-meth-static-dflt-ary-init-iter-get-err.js create mode 100644 test/language/statements/class/dstr-gen-meth-static-dflt-ary-init-iter-no-close.js create mode 100644 test/language/statements/class/dstr-gen-meth-static-dflt-ary-name-iter-val.js create mode 100644 test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-ary-elem-init.js create mode 100644 test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-ary-elem-iter.js create mode 100644 test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-ary-elision-init.js create mode 100644 test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-ary-elision-iter.js create mode 100644 test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-ary-empty-init.js create mode 100644 test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-ary-empty-iter.js create mode 100644 test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-ary-rest-init.js create mode 100644 test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-ary-rest-iter.js create mode 100644 test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-ary-val-null.js create mode 100644 test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-id-init-exhausted.js create mode 100644 test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-arrow.js create mode 100644 test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-class.js create mode 100644 test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-cover.js create mode 100644 test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-fn.js create mode 100644 test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-gen.js create mode 100644 test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-id-init-hole.js create mode 100644 test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-id-init-skipped.js create mode 100644 test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-id-init-throws.js create mode 100644 test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-id-init-undef.js create mode 100644 test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-id-init-unresolvable.js create mode 100644 test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-id-iter-complete.js create mode 100644 test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-id-iter-done.js create mode 100644 test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-id-iter-step-err.js create mode 100644 test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-id-iter-val-err.js create mode 100644 test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-id-iter-val.js create mode 100644 test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-obj-id-init.js create mode 100644 test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-obj-id.js create mode 100644 test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-obj-prop-id-init.js create mode 100644 test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-obj-prop-id.js create mode 100644 test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-obj-val-null.js create mode 100644 test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-obj-val-undef.js create mode 100644 test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-elision-exhausted.js create mode 100644 test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-elision-step-err.js create mode 100644 test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-elision.js create mode 100644 test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-empty.js create mode 100644 test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-rest-ary-elem.js create mode 100644 test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-rest-ary-elision.js create mode 100644 test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-rest-ary-empty.js create mode 100644 test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-rest-ary-rest.js create mode 100644 test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-rest-id-elision-next-err.js create mode 100644 test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-rest-id-elision.js create mode 100644 test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-rest-id-exhausted.js create mode 100644 test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-rest-id-iter-step-err.js create mode 100644 test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-rest-id-iter-val-err.js create mode 100644 test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-rest-id.js create mode 100644 test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-rest-init-ary.js create mode 100644 test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-rest-init-id.js create mode 100644 test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-rest-init-obj.js create mode 100644 test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-rest-not-final-ary.js create mode 100644 test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-rest-not-final-id.js create mode 100644 test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-rest-not-final-obj.js create mode 100644 test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-rest-obj-id.js create mode 100644 test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-rest-obj-prop-id.js create mode 100644 test/language/statements/class/dstr-gen-meth-static-dflt-obj-init-null.js create mode 100644 test/language/statements/class/dstr-gen-meth-static-dflt-obj-init-undefined.js create mode 100644 test/language/statements/class/dstr-gen-meth-static-dflt-obj-ptrn-empty.js create mode 100644 test/language/statements/class/dstr-gen-meth-static-dflt-obj-ptrn-id-get-value-err.js create mode 100644 test/language/statements/class/dstr-gen-meth-static-dflt-obj-ptrn-id-init-fn-name-arrow.js create mode 100644 test/language/statements/class/dstr-gen-meth-static-dflt-obj-ptrn-id-init-fn-name-class.js create mode 100644 test/language/statements/class/dstr-gen-meth-static-dflt-obj-ptrn-id-init-fn-name-cover.js create mode 100644 test/language/statements/class/dstr-gen-meth-static-dflt-obj-ptrn-id-init-fn-name-fn.js create mode 100644 test/language/statements/class/dstr-gen-meth-static-dflt-obj-ptrn-id-init-fn-name-gen.js create mode 100644 test/language/statements/class/dstr-gen-meth-static-dflt-obj-ptrn-id-init-skipped.js create mode 100644 test/language/statements/class/dstr-gen-meth-static-dflt-obj-ptrn-id-init-throws.js create mode 100644 test/language/statements/class/dstr-gen-meth-static-dflt-obj-ptrn-id-init-unresolvable.js create mode 100644 test/language/statements/class/dstr-gen-meth-static-dflt-obj-ptrn-id-trailing-comma.js create mode 100644 test/language/statements/class/dstr-gen-meth-static-dflt-obj-ptrn-list-err.js create mode 100644 test/language/statements/class/dstr-gen-meth-static-dflt-obj-ptrn-prop-ary-init.js create mode 100644 test/language/statements/class/dstr-gen-meth-static-dflt-obj-ptrn-prop-ary-trailing-comma.js create mode 100644 test/language/statements/class/dstr-gen-meth-static-dflt-obj-ptrn-prop-ary-value-null.js create mode 100644 test/language/statements/class/dstr-gen-meth-static-dflt-obj-ptrn-prop-ary.js create mode 100644 test/language/statements/class/dstr-gen-meth-static-dflt-obj-ptrn-prop-eval-err.js create mode 100644 test/language/statements/class/dstr-gen-meth-static-dflt-obj-ptrn-prop-id-get-value-err.js create mode 100644 test/language/statements/class/dstr-gen-meth-static-dflt-obj-ptrn-prop-id-init-skipped.js create mode 100644 test/language/statements/class/dstr-gen-meth-static-dflt-obj-ptrn-prop-id-init-throws.js create mode 100644 test/language/statements/class/dstr-gen-meth-static-dflt-obj-ptrn-prop-id-init-unresolvable.js create mode 100644 test/language/statements/class/dstr-gen-meth-static-dflt-obj-ptrn-prop-id-init.js create mode 100644 test/language/statements/class/dstr-gen-meth-static-dflt-obj-ptrn-prop-id-trailing-comma.js create mode 100644 test/language/statements/class/dstr-gen-meth-static-dflt-obj-ptrn-prop-id.js create mode 100644 test/language/statements/class/dstr-gen-meth-static-dflt-obj-ptrn-prop-obj-init.js create mode 100644 test/language/statements/class/dstr-gen-meth-static-dflt-obj-ptrn-prop-obj-value-null.js create mode 100644 test/language/statements/class/dstr-gen-meth-static-dflt-obj-ptrn-prop-obj-value-undef.js create mode 100644 test/language/statements/class/dstr-gen-meth-static-dflt-obj-ptrn-prop-obj.js create mode 100644 test/language/statements/class/dstr-meth-dflt-ary-init-iter-close.js create mode 100644 test/language/statements/class/dstr-meth-dflt-ary-init-iter-get-err.js create mode 100644 test/language/statements/class/dstr-meth-dflt-ary-init-iter-no-close.js create mode 100644 test/language/statements/class/dstr-meth-dflt-ary-name-iter-val.js create mode 100644 test/language/statements/class/dstr-meth-dflt-ary-ptrn-elem-ary-elem-init.js create mode 100644 test/language/statements/class/dstr-meth-dflt-ary-ptrn-elem-ary-elem-iter.js create mode 100644 test/language/statements/class/dstr-meth-dflt-ary-ptrn-elem-ary-elision-init.js create mode 100644 test/language/statements/class/dstr-meth-dflt-ary-ptrn-elem-ary-elision-iter.js create mode 100644 test/language/statements/class/dstr-meth-dflt-ary-ptrn-elem-ary-empty-init.js create mode 100644 test/language/statements/class/dstr-meth-dflt-ary-ptrn-elem-ary-empty-iter.js create mode 100644 test/language/statements/class/dstr-meth-dflt-ary-ptrn-elem-ary-rest-init.js create mode 100644 test/language/statements/class/dstr-meth-dflt-ary-ptrn-elem-ary-rest-iter.js create mode 100644 test/language/statements/class/dstr-meth-dflt-ary-ptrn-elem-ary-val-null.js create mode 100644 test/language/statements/class/dstr-meth-dflt-ary-ptrn-elem-id-init-exhausted.js create mode 100644 test/language/statements/class/dstr-meth-dflt-ary-ptrn-elem-id-init-fn-name-arrow.js create mode 100644 test/language/statements/class/dstr-meth-dflt-ary-ptrn-elem-id-init-fn-name-class.js create mode 100644 test/language/statements/class/dstr-meth-dflt-ary-ptrn-elem-id-init-fn-name-cover.js create mode 100644 test/language/statements/class/dstr-meth-dflt-ary-ptrn-elem-id-init-fn-name-fn.js create mode 100644 test/language/statements/class/dstr-meth-dflt-ary-ptrn-elem-id-init-fn-name-gen.js create mode 100644 test/language/statements/class/dstr-meth-dflt-ary-ptrn-elem-id-init-hole.js create mode 100644 test/language/statements/class/dstr-meth-dflt-ary-ptrn-elem-id-init-skipped.js create mode 100644 test/language/statements/class/dstr-meth-dflt-ary-ptrn-elem-id-init-throws.js create mode 100644 test/language/statements/class/dstr-meth-dflt-ary-ptrn-elem-id-init-undef.js create mode 100644 test/language/statements/class/dstr-meth-dflt-ary-ptrn-elem-id-init-unresolvable.js create mode 100644 test/language/statements/class/dstr-meth-dflt-ary-ptrn-elem-id-iter-complete.js create mode 100644 test/language/statements/class/dstr-meth-dflt-ary-ptrn-elem-id-iter-done.js create mode 100644 test/language/statements/class/dstr-meth-dflt-ary-ptrn-elem-id-iter-step-err.js create mode 100644 test/language/statements/class/dstr-meth-dflt-ary-ptrn-elem-id-iter-val-err.js create mode 100644 test/language/statements/class/dstr-meth-dflt-ary-ptrn-elem-id-iter-val.js create mode 100644 test/language/statements/class/dstr-meth-dflt-ary-ptrn-elem-obj-id-init.js create mode 100644 test/language/statements/class/dstr-meth-dflt-ary-ptrn-elem-obj-id.js create mode 100644 test/language/statements/class/dstr-meth-dflt-ary-ptrn-elem-obj-prop-id-init.js create mode 100644 test/language/statements/class/dstr-meth-dflt-ary-ptrn-elem-obj-prop-id.js create mode 100644 test/language/statements/class/dstr-meth-dflt-ary-ptrn-elem-obj-val-null.js create mode 100644 test/language/statements/class/dstr-meth-dflt-ary-ptrn-elem-obj-val-undef.js create mode 100644 test/language/statements/class/dstr-meth-dflt-ary-ptrn-elision-exhausted.js create mode 100644 test/language/statements/class/dstr-meth-dflt-ary-ptrn-elision-step-err.js create mode 100644 test/language/statements/class/dstr-meth-dflt-ary-ptrn-elision.js create mode 100644 test/language/statements/class/dstr-meth-dflt-ary-ptrn-empty.js create mode 100644 test/language/statements/class/dstr-meth-dflt-ary-ptrn-rest-ary-elem.js create mode 100644 test/language/statements/class/dstr-meth-dflt-ary-ptrn-rest-ary-elision.js create mode 100644 test/language/statements/class/dstr-meth-dflt-ary-ptrn-rest-ary-empty.js create mode 100644 test/language/statements/class/dstr-meth-dflt-ary-ptrn-rest-ary-rest.js create mode 100644 test/language/statements/class/dstr-meth-dflt-ary-ptrn-rest-id-elision-next-err.js create mode 100644 test/language/statements/class/dstr-meth-dflt-ary-ptrn-rest-id-elision.js create mode 100644 test/language/statements/class/dstr-meth-dflt-ary-ptrn-rest-id-exhausted.js create mode 100644 test/language/statements/class/dstr-meth-dflt-ary-ptrn-rest-id-iter-step-err.js create mode 100644 test/language/statements/class/dstr-meth-dflt-ary-ptrn-rest-id-iter-val-err.js create mode 100644 test/language/statements/class/dstr-meth-dflt-ary-ptrn-rest-id.js create mode 100644 test/language/statements/class/dstr-meth-dflt-ary-ptrn-rest-init-ary.js create mode 100644 test/language/statements/class/dstr-meth-dflt-ary-ptrn-rest-init-id.js create mode 100644 test/language/statements/class/dstr-meth-dflt-ary-ptrn-rest-init-obj.js create mode 100644 test/language/statements/class/dstr-meth-dflt-ary-ptrn-rest-not-final-ary.js create mode 100644 test/language/statements/class/dstr-meth-dflt-ary-ptrn-rest-not-final-id.js create mode 100644 test/language/statements/class/dstr-meth-dflt-ary-ptrn-rest-not-final-obj.js create mode 100644 test/language/statements/class/dstr-meth-dflt-ary-ptrn-rest-obj-id.js create mode 100644 test/language/statements/class/dstr-meth-dflt-ary-ptrn-rest-obj-prop-id.js create mode 100644 test/language/statements/class/dstr-meth-dflt-obj-init-null.js create mode 100644 test/language/statements/class/dstr-meth-dflt-obj-init-undefined.js create mode 100644 test/language/statements/class/dstr-meth-dflt-obj-ptrn-empty.js create mode 100644 test/language/statements/class/dstr-meth-dflt-obj-ptrn-id-get-value-err.js create mode 100644 test/language/statements/class/dstr-meth-dflt-obj-ptrn-id-init-fn-name-arrow.js create mode 100644 test/language/statements/class/dstr-meth-dflt-obj-ptrn-id-init-fn-name-class.js create mode 100644 test/language/statements/class/dstr-meth-dflt-obj-ptrn-id-init-fn-name-cover.js create mode 100644 test/language/statements/class/dstr-meth-dflt-obj-ptrn-id-init-fn-name-fn.js create mode 100644 test/language/statements/class/dstr-meth-dflt-obj-ptrn-id-init-fn-name-gen.js create mode 100644 test/language/statements/class/dstr-meth-dflt-obj-ptrn-id-init-skipped.js create mode 100644 test/language/statements/class/dstr-meth-dflt-obj-ptrn-id-init-throws.js create mode 100644 test/language/statements/class/dstr-meth-dflt-obj-ptrn-id-init-unresolvable.js create mode 100644 test/language/statements/class/dstr-meth-dflt-obj-ptrn-id-trailing-comma.js create mode 100644 test/language/statements/class/dstr-meth-dflt-obj-ptrn-list-err.js create mode 100644 test/language/statements/class/dstr-meth-dflt-obj-ptrn-prop-ary-init.js create mode 100644 test/language/statements/class/dstr-meth-dflt-obj-ptrn-prop-ary-trailing-comma.js create mode 100644 test/language/statements/class/dstr-meth-dflt-obj-ptrn-prop-ary-value-null.js create mode 100644 test/language/statements/class/dstr-meth-dflt-obj-ptrn-prop-ary.js create mode 100644 test/language/statements/class/dstr-meth-dflt-obj-ptrn-prop-eval-err.js create mode 100644 test/language/statements/class/dstr-meth-dflt-obj-ptrn-prop-id-get-value-err.js create mode 100644 test/language/statements/class/dstr-meth-dflt-obj-ptrn-prop-id-init-skipped.js create mode 100644 test/language/statements/class/dstr-meth-dflt-obj-ptrn-prop-id-init-throws.js create mode 100644 test/language/statements/class/dstr-meth-dflt-obj-ptrn-prop-id-init-unresolvable.js create mode 100644 test/language/statements/class/dstr-meth-dflt-obj-ptrn-prop-id-init.js create mode 100644 test/language/statements/class/dstr-meth-dflt-obj-ptrn-prop-id-trailing-comma.js create mode 100644 test/language/statements/class/dstr-meth-dflt-obj-ptrn-prop-id.js create mode 100644 test/language/statements/class/dstr-meth-dflt-obj-ptrn-prop-obj-init.js create mode 100644 test/language/statements/class/dstr-meth-dflt-obj-ptrn-prop-obj-value-null.js create mode 100644 test/language/statements/class/dstr-meth-dflt-obj-ptrn-prop-obj-value-undef.js create mode 100644 test/language/statements/class/dstr-meth-dflt-obj-ptrn-prop-obj.js create mode 100644 test/language/statements/class/dstr-meth-static-dflt-ary-init-iter-close.js create mode 100644 test/language/statements/class/dstr-meth-static-dflt-ary-init-iter-get-err.js create mode 100644 test/language/statements/class/dstr-meth-static-dflt-ary-init-iter-no-close.js create mode 100644 test/language/statements/class/dstr-meth-static-dflt-ary-name-iter-val.js create mode 100644 test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-elem-ary-elem-init.js create mode 100644 test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-elem-ary-elem-iter.js create mode 100644 test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-elem-ary-elision-init.js create mode 100644 test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-elem-ary-elision-iter.js create mode 100644 test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-elem-ary-empty-init.js create mode 100644 test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-elem-ary-empty-iter.js create mode 100644 test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-elem-ary-rest-init.js create mode 100644 test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-elem-ary-rest-iter.js create mode 100644 test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-elem-ary-val-null.js create mode 100644 test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-elem-id-init-exhausted.js create mode 100644 test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-arrow.js create mode 100644 test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-class.js create mode 100644 test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-cover.js create mode 100644 test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-fn.js create mode 100644 test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-gen.js create mode 100644 test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-elem-id-init-hole.js create mode 100644 test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-elem-id-init-skipped.js create mode 100644 test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-elem-id-init-throws.js create mode 100644 test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-elem-id-init-undef.js create mode 100644 test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-elem-id-init-unresolvable.js create mode 100644 test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-elem-id-iter-complete.js create mode 100644 test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-elem-id-iter-done.js create mode 100644 test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-elem-id-iter-step-err.js create mode 100644 test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-elem-id-iter-val-err.js create mode 100644 test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-elem-id-iter-val.js create mode 100644 test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-elem-obj-id-init.js create mode 100644 test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-elem-obj-id.js create mode 100644 test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-elem-obj-prop-id-init.js create mode 100644 test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-elem-obj-prop-id.js create mode 100644 test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-elem-obj-val-null.js create mode 100644 test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-elem-obj-val-undef.js create mode 100644 test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-elision-exhausted.js create mode 100644 test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-elision-step-err.js create mode 100644 test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-elision.js create mode 100644 test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-empty.js create mode 100644 test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-rest-ary-elem.js create mode 100644 test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-rest-ary-elision.js create mode 100644 test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-rest-ary-empty.js create mode 100644 test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-rest-ary-rest.js create mode 100644 test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-rest-id-elision-next-err.js create mode 100644 test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-rest-id-elision.js create mode 100644 test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-rest-id-exhausted.js create mode 100644 test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-rest-id-iter-step-err.js create mode 100644 test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-rest-id-iter-val-err.js create mode 100644 test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-rest-id.js create mode 100644 test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-rest-init-ary.js create mode 100644 test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-rest-init-id.js create mode 100644 test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-rest-init-obj.js create mode 100644 test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-rest-not-final-ary.js create mode 100644 test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-rest-not-final-id.js create mode 100644 test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-rest-not-final-obj.js create mode 100644 test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-rest-obj-id.js create mode 100644 test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-rest-obj-prop-id.js create mode 100644 test/language/statements/class/dstr-meth-static-dflt-obj-init-null.js create mode 100644 test/language/statements/class/dstr-meth-static-dflt-obj-init-undefined.js create mode 100644 test/language/statements/class/dstr-meth-static-dflt-obj-ptrn-empty.js create mode 100644 test/language/statements/class/dstr-meth-static-dflt-obj-ptrn-id-get-value-err.js create mode 100644 test/language/statements/class/dstr-meth-static-dflt-obj-ptrn-id-init-fn-name-arrow.js create mode 100644 test/language/statements/class/dstr-meth-static-dflt-obj-ptrn-id-init-fn-name-class.js create mode 100644 test/language/statements/class/dstr-meth-static-dflt-obj-ptrn-id-init-fn-name-cover.js create mode 100644 test/language/statements/class/dstr-meth-static-dflt-obj-ptrn-id-init-fn-name-fn.js create mode 100644 test/language/statements/class/dstr-meth-static-dflt-obj-ptrn-id-init-fn-name-gen.js create mode 100644 test/language/statements/class/dstr-meth-static-dflt-obj-ptrn-id-init-skipped.js create mode 100644 test/language/statements/class/dstr-meth-static-dflt-obj-ptrn-id-init-throws.js create mode 100644 test/language/statements/class/dstr-meth-static-dflt-obj-ptrn-id-init-unresolvable.js create mode 100644 test/language/statements/class/dstr-meth-static-dflt-obj-ptrn-id-trailing-comma.js create mode 100644 test/language/statements/class/dstr-meth-static-dflt-obj-ptrn-list-err.js create mode 100644 test/language/statements/class/dstr-meth-static-dflt-obj-ptrn-prop-ary-init.js create mode 100644 test/language/statements/class/dstr-meth-static-dflt-obj-ptrn-prop-ary-trailing-comma.js create mode 100644 test/language/statements/class/dstr-meth-static-dflt-obj-ptrn-prop-ary-value-null.js create mode 100644 test/language/statements/class/dstr-meth-static-dflt-obj-ptrn-prop-ary.js create mode 100644 test/language/statements/class/dstr-meth-static-dflt-obj-ptrn-prop-eval-err.js create mode 100644 test/language/statements/class/dstr-meth-static-dflt-obj-ptrn-prop-id-get-value-err.js create mode 100644 test/language/statements/class/dstr-meth-static-dflt-obj-ptrn-prop-id-init-skipped.js create mode 100644 test/language/statements/class/dstr-meth-static-dflt-obj-ptrn-prop-id-init-throws.js create mode 100644 test/language/statements/class/dstr-meth-static-dflt-obj-ptrn-prop-id-init-unresolvable.js create mode 100644 test/language/statements/class/dstr-meth-static-dflt-obj-ptrn-prop-id-init.js create mode 100644 test/language/statements/class/dstr-meth-static-dflt-obj-ptrn-prop-id-trailing-comma.js create mode 100644 test/language/statements/class/dstr-meth-static-dflt-obj-ptrn-prop-id.js create mode 100644 test/language/statements/class/dstr-meth-static-dflt-obj-ptrn-prop-obj-init.js create mode 100644 test/language/statements/class/dstr-meth-static-dflt-obj-ptrn-prop-obj-value-null.js create mode 100644 test/language/statements/class/dstr-meth-static-dflt-obj-ptrn-prop-obj-value-undef.js create mode 100644 test/language/statements/class/dstr-meth-static-dflt-obj-ptrn-prop-obj.js create mode 100644 test/language/statements/function/dstr-dflt-ary-init-iter-close.js create mode 100644 test/language/statements/function/dstr-dflt-ary-init-iter-get-err.js create mode 100644 test/language/statements/function/dstr-dflt-ary-init-iter-no-close.js create mode 100644 test/language/statements/function/dstr-dflt-ary-name-iter-val.js create mode 100644 test/language/statements/function/dstr-dflt-ary-ptrn-elem-ary-elem-init.js create mode 100644 test/language/statements/function/dstr-dflt-ary-ptrn-elem-ary-elem-iter.js create mode 100644 test/language/statements/function/dstr-dflt-ary-ptrn-elem-ary-elision-init.js create mode 100644 test/language/statements/function/dstr-dflt-ary-ptrn-elem-ary-elision-iter.js create mode 100644 test/language/statements/function/dstr-dflt-ary-ptrn-elem-ary-empty-init.js create mode 100644 test/language/statements/function/dstr-dflt-ary-ptrn-elem-ary-empty-iter.js create mode 100644 test/language/statements/function/dstr-dflt-ary-ptrn-elem-ary-rest-init.js create mode 100644 test/language/statements/function/dstr-dflt-ary-ptrn-elem-ary-rest-iter.js create mode 100644 test/language/statements/function/dstr-dflt-ary-ptrn-elem-ary-val-null.js create mode 100644 test/language/statements/function/dstr-dflt-ary-ptrn-elem-id-init-exhausted.js create mode 100644 test/language/statements/function/dstr-dflt-ary-ptrn-elem-id-init-fn-name-arrow.js create mode 100644 test/language/statements/function/dstr-dflt-ary-ptrn-elem-id-init-fn-name-class.js create mode 100644 test/language/statements/function/dstr-dflt-ary-ptrn-elem-id-init-fn-name-cover.js create mode 100644 test/language/statements/function/dstr-dflt-ary-ptrn-elem-id-init-fn-name-fn.js create mode 100644 test/language/statements/function/dstr-dflt-ary-ptrn-elem-id-init-fn-name-gen.js create mode 100644 test/language/statements/function/dstr-dflt-ary-ptrn-elem-id-init-hole.js create mode 100644 test/language/statements/function/dstr-dflt-ary-ptrn-elem-id-init-skipped.js create mode 100644 test/language/statements/function/dstr-dflt-ary-ptrn-elem-id-init-throws.js create mode 100644 test/language/statements/function/dstr-dflt-ary-ptrn-elem-id-init-undef.js create mode 100644 test/language/statements/function/dstr-dflt-ary-ptrn-elem-id-init-unresolvable.js create mode 100644 test/language/statements/function/dstr-dflt-ary-ptrn-elem-id-iter-complete.js create mode 100644 test/language/statements/function/dstr-dflt-ary-ptrn-elem-id-iter-done.js create mode 100644 test/language/statements/function/dstr-dflt-ary-ptrn-elem-id-iter-step-err.js create mode 100644 test/language/statements/function/dstr-dflt-ary-ptrn-elem-id-iter-val-err.js create mode 100644 test/language/statements/function/dstr-dflt-ary-ptrn-elem-id-iter-val.js create mode 100644 test/language/statements/function/dstr-dflt-ary-ptrn-elem-obj-id-init.js create mode 100644 test/language/statements/function/dstr-dflt-ary-ptrn-elem-obj-id.js create mode 100644 test/language/statements/function/dstr-dflt-ary-ptrn-elem-obj-prop-id-init.js create mode 100644 test/language/statements/function/dstr-dflt-ary-ptrn-elem-obj-prop-id.js create mode 100644 test/language/statements/function/dstr-dflt-ary-ptrn-elem-obj-val-null.js create mode 100644 test/language/statements/function/dstr-dflt-ary-ptrn-elem-obj-val-undef.js create mode 100644 test/language/statements/function/dstr-dflt-ary-ptrn-elision-exhausted.js create mode 100644 test/language/statements/function/dstr-dflt-ary-ptrn-elision-step-err.js create mode 100644 test/language/statements/function/dstr-dflt-ary-ptrn-elision.js create mode 100644 test/language/statements/function/dstr-dflt-ary-ptrn-empty.js create mode 100644 test/language/statements/function/dstr-dflt-ary-ptrn-rest-ary-elem.js create mode 100644 test/language/statements/function/dstr-dflt-ary-ptrn-rest-ary-elision.js create mode 100644 test/language/statements/function/dstr-dflt-ary-ptrn-rest-ary-empty.js create mode 100644 test/language/statements/function/dstr-dflt-ary-ptrn-rest-ary-rest.js create mode 100644 test/language/statements/function/dstr-dflt-ary-ptrn-rest-id-elision-next-err.js create mode 100644 test/language/statements/function/dstr-dflt-ary-ptrn-rest-id-elision.js create mode 100644 test/language/statements/function/dstr-dflt-ary-ptrn-rest-id-exhausted.js create mode 100644 test/language/statements/function/dstr-dflt-ary-ptrn-rest-id-iter-step-err.js create mode 100644 test/language/statements/function/dstr-dflt-ary-ptrn-rest-id-iter-val-err.js create mode 100644 test/language/statements/function/dstr-dflt-ary-ptrn-rest-id.js create mode 100644 test/language/statements/function/dstr-dflt-ary-ptrn-rest-init-ary.js create mode 100644 test/language/statements/function/dstr-dflt-ary-ptrn-rest-init-id.js create mode 100644 test/language/statements/function/dstr-dflt-ary-ptrn-rest-init-obj.js create mode 100644 test/language/statements/function/dstr-dflt-ary-ptrn-rest-not-final-ary.js create mode 100644 test/language/statements/function/dstr-dflt-ary-ptrn-rest-not-final-id.js create mode 100644 test/language/statements/function/dstr-dflt-ary-ptrn-rest-not-final-obj.js create mode 100644 test/language/statements/function/dstr-dflt-ary-ptrn-rest-obj-id.js create mode 100644 test/language/statements/function/dstr-dflt-ary-ptrn-rest-obj-prop-id.js create mode 100644 test/language/statements/function/dstr-dflt-obj-init-null.js create mode 100644 test/language/statements/function/dstr-dflt-obj-init-undefined.js create mode 100644 test/language/statements/function/dstr-dflt-obj-ptrn-empty.js create mode 100644 test/language/statements/function/dstr-dflt-obj-ptrn-id-get-value-err.js create mode 100644 test/language/statements/function/dstr-dflt-obj-ptrn-id-init-fn-name-arrow.js create mode 100644 test/language/statements/function/dstr-dflt-obj-ptrn-id-init-fn-name-class.js create mode 100644 test/language/statements/function/dstr-dflt-obj-ptrn-id-init-fn-name-cover.js create mode 100644 test/language/statements/function/dstr-dflt-obj-ptrn-id-init-fn-name-fn.js create mode 100644 test/language/statements/function/dstr-dflt-obj-ptrn-id-init-fn-name-gen.js create mode 100644 test/language/statements/function/dstr-dflt-obj-ptrn-id-init-skipped.js create mode 100644 test/language/statements/function/dstr-dflt-obj-ptrn-id-init-throws.js create mode 100644 test/language/statements/function/dstr-dflt-obj-ptrn-id-init-unresolvable.js create mode 100644 test/language/statements/function/dstr-dflt-obj-ptrn-id-trailing-comma.js create mode 100644 test/language/statements/function/dstr-dflt-obj-ptrn-list-err.js create mode 100644 test/language/statements/function/dstr-dflt-obj-ptrn-prop-ary-init.js create mode 100644 test/language/statements/function/dstr-dflt-obj-ptrn-prop-ary-trailing-comma.js create mode 100644 test/language/statements/function/dstr-dflt-obj-ptrn-prop-ary-value-null.js create mode 100644 test/language/statements/function/dstr-dflt-obj-ptrn-prop-ary.js create mode 100644 test/language/statements/function/dstr-dflt-obj-ptrn-prop-eval-err.js create mode 100644 test/language/statements/function/dstr-dflt-obj-ptrn-prop-id-get-value-err.js create mode 100644 test/language/statements/function/dstr-dflt-obj-ptrn-prop-id-init-skipped.js create mode 100644 test/language/statements/function/dstr-dflt-obj-ptrn-prop-id-init-throws.js create mode 100644 test/language/statements/function/dstr-dflt-obj-ptrn-prop-id-init-unresolvable.js create mode 100644 test/language/statements/function/dstr-dflt-obj-ptrn-prop-id-init.js create mode 100644 test/language/statements/function/dstr-dflt-obj-ptrn-prop-id-trailing-comma.js create mode 100644 test/language/statements/function/dstr-dflt-obj-ptrn-prop-id.js create mode 100644 test/language/statements/function/dstr-dflt-obj-ptrn-prop-obj-init.js create mode 100644 test/language/statements/function/dstr-dflt-obj-ptrn-prop-obj-value-null.js create mode 100644 test/language/statements/function/dstr-dflt-obj-ptrn-prop-obj-value-undef.js create mode 100644 test/language/statements/function/dstr-dflt-obj-ptrn-prop-obj.js create mode 100644 test/language/statements/generators/dstr-dflt-ary-init-iter-close.js create mode 100644 test/language/statements/generators/dstr-dflt-ary-init-iter-get-err.js create mode 100644 test/language/statements/generators/dstr-dflt-ary-init-iter-no-close.js create mode 100644 test/language/statements/generators/dstr-dflt-ary-name-iter-val.js create mode 100644 test/language/statements/generators/dstr-dflt-ary-ptrn-elem-ary-elem-init.js create mode 100644 test/language/statements/generators/dstr-dflt-ary-ptrn-elem-ary-elem-iter.js create mode 100644 test/language/statements/generators/dstr-dflt-ary-ptrn-elem-ary-elision-init.js create mode 100644 test/language/statements/generators/dstr-dflt-ary-ptrn-elem-ary-elision-iter.js create mode 100644 test/language/statements/generators/dstr-dflt-ary-ptrn-elem-ary-empty-init.js create mode 100644 test/language/statements/generators/dstr-dflt-ary-ptrn-elem-ary-empty-iter.js create mode 100644 test/language/statements/generators/dstr-dflt-ary-ptrn-elem-ary-rest-init.js create mode 100644 test/language/statements/generators/dstr-dflt-ary-ptrn-elem-ary-rest-iter.js create mode 100644 test/language/statements/generators/dstr-dflt-ary-ptrn-elem-ary-val-null.js create mode 100644 test/language/statements/generators/dstr-dflt-ary-ptrn-elem-id-init-exhausted.js create mode 100644 test/language/statements/generators/dstr-dflt-ary-ptrn-elem-id-init-fn-name-arrow.js create mode 100644 test/language/statements/generators/dstr-dflt-ary-ptrn-elem-id-init-fn-name-class.js create mode 100644 test/language/statements/generators/dstr-dflt-ary-ptrn-elem-id-init-fn-name-cover.js create mode 100644 test/language/statements/generators/dstr-dflt-ary-ptrn-elem-id-init-fn-name-fn.js create mode 100644 test/language/statements/generators/dstr-dflt-ary-ptrn-elem-id-init-fn-name-gen.js create mode 100644 test/language/statements/generators/dstr-dflt-ary-ptrn-elem-id-init-hole.js create mode 100644 test/language/statements/generators/dstr-dflt-ary-ptrn-elem-id-init-skipped.js create mode 100644 test/language/statements/generators/dstr-dflt-ary-ptrn-elem-id-init-throws.js create mode 100644 test/language/statements/generators/dstr-dflt-ary-ptrn-elem-id-init-undef.js create mode 100644 test/language/statements/generators/dstr-dflt-ary-ptrn-elem-id-init-unresolvable.js create mode 100644 test/language/statements/generators/dstr-dflt-ary-ptrn-elem-id-iter-complete.js create mode 100644 test/language/statements/generators/dstr-dflt-ary-ptrn-elem-id-iter-done.js create mode 100644 test/language/statements/generators/dstr-dflt-ary-ptrn-elem-id-iter-step-err.js create mode 100644 test/language/statements/generators/dstr-dflt-ary-ptrn-elem-id-iter-val-err.js create mode 100644 test/language/statements/generators/dstr-dflt-ary-ptrn-elem-id-iter-val.js create mode 100644 test/language/statements/generators/dstr-dflt-ary-ptrn-elem-obj-id-init.js create mode 100644 test/language/statements/generators/dstr-dflt-ary-ptrn-elem-obj-id.js create mode 100644 test/language/statements/generators/dstr-dflt-ary-ptrn-elem-obj-prop-id-init.js create mode 100644 test/language/statements/generators/dstr-dflt-ary-ptrn-elem-obj-prop-id.js create mode 100644 test/language/statements/generators/dstr-dflt-ary-ptrn-elem-obj-val-null.js create mode 100644 test/language/statements/generators/dstr-dflt-ary-ptrn-elem-obj-val-undef.js create mode 100644 test/language/statements/generators/dstr-dflt-ary-ptrn-elision-exhausted.js create mode 100644 test/language/statements/generators/dstr-dflt-ary-ptrn-elision-step-err.js create mode 100644 test/language/statements/generators/dstr-dflt-ary-ptrn-elision.js create mode 100644 test/language/statements/generators/dstr-dflt-ary-ptrn-empty.js create mode 100644 test/language/statements/generators/dstr-dflt-ary-ptrn-rest-ary-elem.js create mode 100644 test/language/statements/generators/dstr-dflt-ary-ptrn-rest-ary-elision.js create mode 100644 test/language/statements/generators/dstr-dflt-ary-ptrn-rest-ary-empty.js create mode 100644 test/language/statements/generators/dstr-dflt-ary-ptrn-rest-ary-rest.js create mode 100644 test/language/statements/generators/dstr-dflt-ary-ptrn-rest-id-elision-next-err.js create mode 100644 test/language/statements/generators/dstr-dflt-ary-ptrn-rest-id-elision.js create mode 100644 test/language/statements/generators/dstr-dflt-ary-ptrn-rest-id-exhausted.js create mode 100644 test/language/statements/generators/dstr-dflt-ary-ptrn-rest-id-iter-step-err.js create mode 100644 test/language/statements/generators/dstr-dflt-ary-ptrn-rest-id-iter-val-err.js create mode 100644 test/language/statements/generators/dstr-dflt-ary-ptrn-rest-id.js create mode 100644 test/language/statements/generators/dstr-dflt-ary-ptrn-rest-init-ary.js create mode 100644 test/language/statements/generators/dstr-dflt-ary-ptrn-rest-init-id.js create mode 100644 test/language/statements/generators/dstr-dflt-ary-ptrn-rest-init-obj.js create mode 100644 test/language/statements/generators/dstr-dflt-ary-ptrn-rest-not-final-ary.js create mode 100644 test/language/statements/generators/dstr-dflt-ary-ptrn-rest-not-final-id.js create mode 100644 test/language/statements/generators/dstr-dflt-ary-ptrn-rest-not-final-obj.js create mode 100644 test/language/statements/generators/dstr-dflt-ary-ptrn-rest-obj-id.js create mode 100644 test/language/statements/generators/dstr-dflt-ary-ptrn-rest-obj-prop-id.js create mode 100644 test/language/statements/generators/dstr-dflt-obj-init-null.js create mode 100644 test/language/statements/generators/dstr-dflt-obj-init-undefined.js create mode 100644 test/language/statements/generators/dstr-dflt-obj-ptrn-empty.js create mode 100644 test/language/statements/generators/dstr-dflt-obj-ptrn-id-get-value-err.js create mode 100644 test/language/statements/generators/dstr-dflt-obj-ptrn-id-init-fn-name-arrow.js create mode 100644 test/language/statements/generators/dstr-dflt-obj-ptrn-id-init-fn-name-class.js create mode 100644 test/language/statements/generators/dstr-dflt-obj-ptrn-id-init-fn-name-cover.js create mode 100644 test/language/statements/generators/dstr-dflt-obj-ptrn-id-init-fn-name-fn.js create mode 100644 test/language/statements/generators/dstr-dflt-obj-ptrn-id-init-fn-name-gen.js create mode 100644 test/language/statements/generators/dstr-dflt-obj-ptrn-id-init-skipped.js create mode 100644 test/language/statements/generators/dstr-dflt-obj-ptrn-id-init-throws.js create mode 100644 test/language/statements/generators/dstr-dflt-obj-ptrn-id-init-unresolvable.js create mode 100644 test/language/statements/generators/dstr-dflt-obj-ptrn-id-trailing-comma.js create mode 100644 test/language/statements/generators/dstr-dflt-obj-ptrn-list-err.js create mode 100644 test/language/statements/generators/dstr-dflt-obj-ptrn-prop-ary-init.js create mode 100644 test/language/statements/generators/dstr-dflt-obj-ptrn-prop-ary-trailing-comma.js create mode 100644 test/language/statements/generators/dstr-dflt-obj-ptrn-prop-ary-value-null.js create mode 100644 test/language/statements/generators/dstr-dflt-obj-ptrn-prop-ary.js create mode 100644 test/language/statements/generators/dstr-dflt-obj-ptrn-prop-eval-err.js create mode 100644 test/language/statements/generators/dstr-dflt-obj-ptrn-prop-id-get-value-err.js create mode 100644 test/language/statements/generators/dstr-dflt-obj-ptrn-prop-id-init-skipped.js create mode 100644 test/language/statements/generators/dstr-dflt-obj-ptrn-prop-id-init-throws.js create mode 100644 test/language/statements/generators/dstr-dflt-obj-ptrn-prop-id-init-unresolvable.js create mode 100644 test/language/statements/generators/dstr-dflt-obj-ptrn-prop-id-init.js create mode 100644 test/language/statements/generators/dstr-dflt-obj-ptrn-prop-id-trailing-comma.js create mode 100644 test/language/statements/generators/dstr-dflt-obj-ptrn-prop-id.js create mode 100644 test/language/statements/generators/dstr-dflt-obj-ptrn-prop-obj-init.js create mode 100644 test/language/statements/generators/dstr-dflt-obj-ptrn-prop-obj-value-null.js create mode 100644 test/language/statements/generators/dstr-dflt-obj-ptrn-prop-obj-value-undef.js create mode 100644 test/language/statements/generators/dstr-dflt-obj-ptrn-prop-obj.js diff --git a/test/language/expressions/arrow-function/dstr-dflt-ary-init-iter-close.js b/test/language/expressions/arrow-function/dstr-dflt-ary-init-iter-close.js new file mode 100644 index 0000000000..4b307161f3 --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-dflt-ary-init-iter-close.js @@ -0,0 +1,72 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-close.case +// - src/dstr-binding/default/arrow-function-dflt.template +/*--- +description: Iterator is closed when not exhausted by pattern evaluation (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +es6id: 14.2.16 +features: [Symbol.iterator, destructuring-binding, default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + [...] + 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator, + result). + [...] + +---*/ +var doneCallCount = 0; +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return { value: null, done: false }; + }, + return: function() { + doneCallCount += 1; + return {}; + } + }; +}; + +var callCount = 0; +var f; +f = ([x] = iter) => { + assert.sameValue(doneCallCount, 1); + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); diff --git a/test/language/expressions/arrow-function/dstr-dflt-ary-init-iter-get-err.js b/test/language/expressions/arrow-function/dstr-dflt-ary-init-iter-get-err.js new file mode 100644 index 0000000000..eaeb44fd7f --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-dflt-ary-init-iter-get-err.js @@ -0,0 +1,57 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-get-err.case +// - src/dstr-binding/error/arrow-function-dflt.template +/*--- +description: Abrupt completion returned by GetIterator (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +es6id: 14.2.16 +features: [Symbol.iterator, destructuring-binding, default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 = ([x] = iter) => {}; + +assert.throws(Test262Error, function() { + f(); +}); diff --git a/test/language/expressions/arrow-function/dstr-dflt-ary-init-iter-no-close.js b/test/language/expressions/arrow-function/dstr-dflt-ary-init-iter-no-close.js new file mode 100644 index 0000000000..baf72d0f96 --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-dflt-ary-init-iter-no-close.js @@ -0,0 +1,72 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-no-close.case +// - src/dstr-binding/default/arrow-function-dflt.template +/*--- +description: Iterator is not closed when exhausted by pattern evaluation (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +es6id: 14.2.16 +features: [Symbol.iterator, destructuring-binding, default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + [...] + 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator, + result). + [...] + +---*/ +var doneCallCount = 0; +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return { value: null, done: true }; + }, + return: function() { + doneCallCount += 1; + return {}; + } + }; +}; + +var callCount = 0; +var f; +f = ([x] = iter) => { + assert.sameValue(doneCallCount, 0); + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); diff --git a/test/language/expressions/arrow-function/dstr-dflt-ary-name-iter-val.js b/test/language/expressions/arrow-function/dstr-dflt-ary-name-iter-val.js new file mode 100644 index 0000000000..007b2a93a0 --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-dflt-ary-name-iter-val.js @@ -0,0 +1,71 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-name-iter-val.case +// - src/dstr-binding/default/arrow-function-dflt.template +/*--- +description: SingleNameBinding with normal value iteration (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +es6id: 14.2.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set + iteratorRecord.[[done]] to true. + iii. ReturnIfAbrupt(v). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var f; +f = ([x, y, z] = [1, 2, 3]) => { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 3); + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); diff --git a/test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-elem-ary-elem-init.js b/test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-elem-ary-elem-init.js new file mode 100644 index 0000000000..c944f6b188 --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-elem-ary-elem-init.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elem-init.case +// - src/dstr-binding/default/arrow-function-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is used (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +es6id: 14.2.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +var f; +f = ([[x, y, z] = [4, 5, 6]] = []) => { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); diff --git a/test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-elem-ary-elem-iter.js b/test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-elem-ary-elem-iter.js new file mode 100644 index 0000000000..bf660a34a1 --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-elem-ary-elem-iter.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elem-iter.case +// - src/dstr-binding/default/arrow-function-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +es6id: 14.2.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +var f; +f = ([[x, y, z] = [4, 5, 6]] = [[7, 8, 9]]) => { + assert.sameValue(x, 7); + assert.sameValue(y, 8); + assert.sameValue(z, 9); + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); diff --git a/test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-elem-ary-elision-init.js b/test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-elem-ary-elision-init.js new file mode 100644 index 0000000000..772e84043c --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-elem-ary-elision-init.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elision-init.case +// - src/dstr-binding/default/arrow-function-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is used (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +es6id: 14.2.16 +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var callCount = 0; +var f; +f = ([[,] = g()] = []) => { + assert.sameValue(first, 1); + assert.sameValue(second, 0); + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); diff --git a/test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-elem-ary-elision-iter.js b/test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-elem-ary-elision-iter.js new file mode 100644 index 0000000000..70a29eee1b --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-elem-ary-elision-iter.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elision-iter.case +// - src/dstr-binding/default/arrow-function-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +es6id: 14.2.16 +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var callCount = 0; +function* g() { + callCount += 1; +}; + +var callCount = 0; +var f; +f = ([[,] = g()] = [[]]) => { + assert.sameValue(callCount, 0); + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); diff --git a/test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-elem-ary-empty-init.js b/test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-elem-ary-empty-init.js new file mode 100644 index 0000000000..5f8c73b1bc --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-elem-ary-empty-init.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-empty-init.case +// - src/dstr-binding/default/arrow-function-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is used (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +es6id: 14.2.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var initCount = 0; +var iterCount = 0; +var iter = function*() { iterCount += 1; }(); + +var callCount = 0; +var f; +f = ([[] = function() { initCount += 1; return iter; }()] = []) => { + assert.sameValue(initCount, 1); + assert.sameValue(iterCount, 0); + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); diff --git a/test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-elem-ary-empty-iter.js b/test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-elem-ary-empty-iter.js new file mode 100644 index 0000000000..59b29253e8 --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-elem-ary-empty-iter.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-empty-iter.case +// - src/dstr-binding/default/arrow-function-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +es6id: 14.2.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var initCount = 0; + +var callCount = 0; +var f; +f = ([[] = function() { initCount += 1; }()] = [[23]]) => { + assert.sameValue(initCount, 0); + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); diff --git a/test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-elem-ary-rest-init.js b/test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-elem-ary-rest-init.js new file mode 100644 index 0000000000..39ac897434 --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-elem-ary-rest-init.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-rest-init.case +// - src/dstr-binding/default/arrow-function-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is used (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +es6id: 14.2.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var values = [2, 1, 3]; + +var callCount = 0; +var f; +f = ([[...x] = values] = []) => { + assert(Array.isArray(x)); + assert.sameValue(x[0], 2); + assert.sameValue(x[1], 1); + assert.sameValue(x[2], 3); + assert.sameValue(x.length, 3); + assert.notSameValue(x, values); + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); diff --git a/test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-elem-ary-rest-iter.js b/test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-elem-ary-rest-iter.js new file mode 100644 index 0000000000..fcae828b7a --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-elem-ary-rest-iter.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-rest-iter.case +// - src/dstr-binding/default/arrow-function-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +es6id: 14.2.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var values = [2, 1, 3]; +var initCount = 0; + +var callCount = 0; +var f; +f = ([[...x] = function() { initCount += 1; }()] = [values]) => { + assert(Array.isArray(x)); + assert.sameValue(x[0], 2); + assert.sameValue(x[1], 1); + assert.sameValue(x[2], 3); + assert.sameValue(x.length, 3); + assert.notSameValue(x, values); + assert.sameValue(initCount, 0); + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); diff --git a/test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-elem-ary-val-null.js b/test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-elem-ary-val-null.js new file mode 100644 index 0000000000..0bd2b6748f --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-elem-ary-val-null.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-val-null.case +// - src/dstr-binding/error/arrow-function-dflt.template +/*--- +description: Nested array destructuring with a null value (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +es6id: 14.2.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 = ([[x]] = [null]) => {}; + +assert.throws(TypeError, function() { + f(); +}); diff --git a/test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-elem-id-init-exhausted.js b/test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-elem-id-init-exhausted.js new file mode 100644 index 0000000000..1f1511bebc --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-elem-id-init-exhausted.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-exhausted.case +// - src/dstr-binding/default/arrow-function-dflt.template +/*--- +description: Destructuring initializer with an exhausted iterator (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +es6id: 14.2.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var f; +f = ([x = 23] = []) => { + assert.sameValue(x, 23); + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); diff --git a/test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-elem-id-init-fn-name-arrow.js b/test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-elem-id-init-fn-name-arrow.js new file mode 100644 index 0000000000..c5ab4cc6f3 --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-elem-id-init-fn-name-arrow.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-arrow.case +// - src/dstr-binding/default/arrow-function-dflt.template +/*--- +description: SingleNameBinding does assign name to arrow functions (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +es6id: 14.2.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var f; +f = ([arrow = () => {}] = []) => { + assert.sameValue(arrow.name, 'arrow'); + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); diff --git a/test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-elem-id-init-fn-name-class.js b/test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-elem-id-init-fn-name-class.js new file mode 100644 index 0000000000..a46881b92c --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-elem-id-init-fn-name-class.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-class.case +// - src/dstr-binding/default/arrow-function-dflt.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +es6id: 14.2.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var f; +f = ([cls = class {}, xCls = class X {}] = []) => { + assert.sameValue(cls.name, 'cls'); + assert.notSameValue(xCls.name, 'xCls'); + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); diff --git a/test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-elem-id-init-fn-name-cover.js b/test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-elem-id-init-fn-name-cover.js new file mode 100644 index 0000000000..930de09f94 --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-elem-id-init-fn-name-cover.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-cover.case +// - src/dstr-binding/default/arrow-function-dflt.template +/*--- +description: SingleNameBinding does assign name to "anonymous" functions "through" cover grammar (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +es6id: 14.2.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var f; +f = ([cover = (function () {}), xCover = (0, function() {})] = []) => { + assert.sameValue(cover.name, 'cover'); + assert.notSameValue(xCover.name, 'xCover'); + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); diff --git a/test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-elem-id-init-fn-name-fn.js b/test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-elem-id-init-fn-name-fn.js new file mode 100644 index 0000000000..80b41c2bad --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-elem-id-init-fn-name-fn.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-fn.case +// - src/dstr-binding/default/arrow-function-dflt.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +es6id: 14.2.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var f; +f = ([fn = function () {}, xFn = function x() {}] = []) => { + assert.sameValue(fn.name, 'fn'); + assert.notSameValue(xFn.name, 'xFn'); + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); diff --git a/test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-elem-id-init-fn-name-gen.js b/test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-elem-id-init-fn-name-gen.js new file mode 100644 index 0000000000..e346d06fd2 --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-elem-id-init-fn-name-gen.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-gen.case +// - src/dstr-binding/default/arrow-function-dflt.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +es6id: 14.2.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var f; +f = ([gen = function* () {}, xGen = function* x() {}] = []) => { + assert.sameValue(gen.name, 'gen'); + assert.notSameValue(xGen.name, 'xGen'); + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); diff --git a/test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-elem-id-init-hole.js b/test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-elem-id-init-hole.js new file mode 100644 index 0000000000..22e088818c --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-elem-id-init-hole.js @@ -0,0 +1,58 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-hole.case +// - src/dstr-binding/default/arrow-function-dflt.template +/*--- +description: Destructuring initializer with a "hole" (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +es6id: 14.2.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + SingleNameBinding : BindingIdentifier Initializeropt + [...] 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + [...] + 7. If environment is undefined, return PutValue(lhs, v). 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var f; +f = ([x = 23] = [,]) => { + assert.sameValue(x, 23); + // another statement + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); diff --git a/test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-elem-id-init-skipped.js b/test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-elem-id-init-skipped.js new file mode 100644 index 0000000000..9b59130d68 --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-elem-id-init-skipped.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-skipped.case +// - src/dstr-binding/default/arrow-function-dflt.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +es6id: 14.2.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var callCount = 0; +var f; +f = ([w = counter(), x = counter(), y = counter(), z = counter()] = [null, 0, false, '']) => { + assert.sameValue(w, null); + assert.sameValue(x, 0); + assert.sameValue(y, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); diff --git a/test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-elem-id-init-throws.js b/test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-elem-id-init-throws.js new file mode 100644 index 0000000000..f995586e8a --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-elem-id-init-throws.js @@ -0,0 +1,55 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-throws.case +// - src/dstr-binding/error/arrow-function-dflt.template +/*--- +description: Destructuring initializer returns an abrupt completion (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +es6id: 14.2.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 = ([x = (function() { throw new Test262Error(); })()] = [undefined]) => {}; + +assert.throws(Test262Error, function() { + f(); +}); diff --git a/test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-elem-id-init-undef.js b/test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-elem-id-init-undef.js new file mode 100644 index 0000000000..0592bc6bc1 --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-elem-id-init-undef.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-undef.case +// - src/dstr-binding/default/arrow-function-dflt.template +/*--- +description: Destructuring initializer with an undefined value (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +es6id: 14.2.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var f; +f = ([x = 23] = [undefined]) => { + assert.sameValue(x, 23); + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); diff --git a/test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-elem-id-init-unresolvable.js b/test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-elem-id-init-unresolvable.js new file mode 100644 index 0000000000..106cb8994e --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-elem-id-init-unresolvable.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-unresolvable.case +// - src/dstr-binding/error/arrow-function-dflt.template +/*--- +description: Destructuring initializer is an unresolvable reference (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +es6id: 14.2.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 = ([ x = unresolvableReference ] = []) => {}; + +assert.throws(ReferenceError, function() { + f(); +}); diff --git a/test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-elem-id-iter-complete.js b/test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-elem-id-iter-complete.js new file mode 100644 index 0000000000..fb6bb8a0ab --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-elem-id-iter-complete.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-complete.case +// - src/dstr-binding/default/arrow-function-dflt.template +/*--- +description: SingleNameBinding when value iteration completes (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +es6id: 14.2.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var f; +f = ([x] = []) => { + assert.sameValue(x, undefined); + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); diff --git a/test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-elem-id-iter-done.js b/test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-elem-id-iter-done.js new file mode 100644 index 0000000000..b824a423da --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-elem-id-iter-done.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-done.case +// - src/dstr-binding/default/arrow-function-dflt.template +/*--- +description: SingleNameBinding when value iteration was completed previously (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +es6id: 14.2.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var f; +f = ([_, x] = []) => { + assert.sameValue(x, undefined); + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); diff --git a/test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-elem-id-iter-step-err.js b/test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-elem-id-iter-step-err.js new file mode 100644 index 0000000000..b60418872b --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-elem-id-iter-step-err.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-step-err.case +// - src/dstr-binding/error/arrow-function-dflt.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +es6id: 14.2.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 = ([x] = g) => {}; + +assert.throws(Test262Error, function() { + f(); +}); diff --git a/test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-elem-id-iter-val-err.js b/test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-elem-id-iter-val-err.js new file mode 100644 index 0000000000..1a19f2ada9 --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-elem-id-iter-val-err.js @@ -0,0 +1,74 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val-err.case +// - src/dstr-binding/error/arrow-function-dflt.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +es6id: 14.2.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 = ([x] = g) => {}; + +assert.throws(Test262Error, function() { + f(); +}); diff --git a/test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-elem-id-iter-val.js b/test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-elem-id-iter-val.js new file mode 100644 index 0000000000..c466253804 --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-elem-id-iter-val.js @@ -0,0 +1,71 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val.case +// - src/dstr-binding/default/arrow-function-dflt.template +/*--- +description: SingleNameBinding when value iteration was completed previously (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +es6id: 14.2.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set + iteratorRecord.[[done]] to true. + iii. ReturnIfAbrupt(v). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var f; +f = ([x, y, z] = [1, 2, 3]) => { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 3); + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); diff --git a/test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-elem-obj-id-init.js b/test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-elem-obj-id-init.js new file mode 100644 index 0000000000..0014c7d938 --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-elem-obj-id-init.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-id-init.case +// - src/dstr-binding/default/arrow-function-dflt.template +/*--- +description: BindingElement with object binding pattern and initializer is used (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +es6id: 14.2.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +var f; +f = ([{ x, y, z } = { x: 44, y: 55, z: 66 }] = []) => { + assert.sameValue(x, 44); + assert.sameValue(y, 55); + assert.sameValue(z, 66); + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); diff --git a/test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-elem-obj-id.js b/test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-elem-obj-id.js new file mode 100644 index 0000000000..1f80bc0a10 --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-elem-obj-id.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-id.case +// - src/dstr-binding/default/arrow-function-dflt.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +es6id: 14.2.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +var f; +f = ([{ x, y, z } = { x: 44, y: 55, z: 66 }] = [{ x: 11, y: 22, z: 33 }]) => { + assert.sameValue(x, 11); + assert.sameValue(y, 22); + assert.sameValue(z, 33); + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); diff --git a/test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-elem-obj-prop-id-init.js b/test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-elem-obj-prop-id-init.js new file mode 100644 index 0000000000..0d258dc3c0 --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-elem-obj-prop-id-init.js @@ -0,0 +1,73 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-prop-id-init.case +// - src/dstr-binding/default/arrow-function-dflt.template +/*--- +description: BindingElement with object binding pattern and initializer is used (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +es6id: 14.2.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +var f; +f = ([{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }] = []) => { + assert.sameValue(v, 444); + assert.sameValue(x, 555); + assert.sameValue(z, 666); + + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); diff --git a/test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-elem-obj-prop-id.js b/test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-elem-obj-prop-id.js new file mode 100644 index 0000000000..426db50f4b --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-elem-obj-prop-id.js @@ -0,0 +1,73 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-prop-id.case +// - src/dstr-binding/default/arrow-function-dflt.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +es6id: 14.2.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +var f; +f = ([{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }] = [{ u: 777, w: 888, y: 999 }]) => { + assert.sameValue(v, 777); + assert.sameValue(x, 888); + assert.sameValue(z, 999); + + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); diff --git a/test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-elem-obj-val-null.js b/test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-elem-obj-val-null.js new file mode 100644 index 0000000000..35d7bb1683 --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-elem-obj-val-null.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-null.case +// - src/dstr-binding/error/arrow-function-dflt.template +/*--- +description: Nested object destructuring with a null value (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +es6id: 14.2.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 = ([{ x }] = [null]) => {}; + +assert.throws(TypeError, function() { + f(); +}); diff --git a/test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-elem-obj-val-undef.js b/test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-elem-obj-val-undef.js new file mode 100644 index 0000000000..6b5a2e2442 --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-elem-obj-val-undef.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-undef.case +// - src/dstr-binding/error/arrow-function-dflt.template +/*--- +description: Nested object destructuring with a value of `undefined` (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +es6id: 14.2.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 = ([{ x }] = []) => {}; + +assert.throws(TypeError, function() { + f(); +}); diff --git a/test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-elision-exhausted.js b/test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-elision-exhausted.js new file mode 100644 index 0000000000..eaa6898ad5 --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-elision-exhausted.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-exhausted.case +// - src/dstr-binding/default/arrow-function-dflt.template +/*--- +description: Elision accepts exhausted iterator (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +es6id: 14.2.16 +features: [generator, destructuring-binding, default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + [...] + 2. Return NormalCompletion(empty). + +---*/ +var iter = function*() {}(); +iter.next(); + +var callCount = 0; +var f; +f = ([,] = iter) => { + + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); diff --git a/test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-elision-step-err.js b/test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-elision-step-err.js new file mode 100644 index 0000000000..4d7f207220 --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-elision-step-err.js @@ -0,0 +1,71 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-step-err.case +// - src/dstr-binding/error/arrow-function-dflt.template +/*--- +description: Elision advances iterator and forwards abrupt completions (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +es6id: 14.2.16 +features: [generator, destructuring-binding, default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 = ([,] = iter) => {}; + +assert.throws(Test262Error, function() { + f(); +}); + +iter.next(); +assert.sameValue(following, 0, 'Iterator was properly closed.'); diff --git a/test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-elision.js b/test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-elision.js new file mode 100644 index 0000000000..11c566aa03 --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-elision.js @@ -0,0 +1,77 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision.case +// - src/dstr-binding/default/arrow-function-dflt.template +/*--- +description: Elision advances iterator (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +es6id: 14.2.16 +features: [generator, destructuring-binding, default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + 2. Return NormalCompletion(empty). + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var callCount = 0; +var f; +f = ([,] = g()) => { + assert.sameValue(first, 1); + assert.sameValue(second, 0); + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); diff --git a/test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-empty.js b/test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-empty.js new file mode 100644 index 0000000000..bcca029c1a --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-empty.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-empty.case +// - src/dstr-binding/default/arrow-function-dflt.template +/*--- +description: No iteration occurs for an "empty" array binding pattern (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +es6id: 14.2.16 +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ ] + + 1. Return NormalCompletion(empty). + +---*/ +var iterations = 0; +var iter = function*() { + iterations += 1; +}(); + +var callCount = 0; +var f; +f = ([] = iter) => { + assert.sameValue(iterations, 0); + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); diff --git a/test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-rest-ary-elem.js b/test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-rest-ary-elem.js new file mode 100644 index 0000000000..8e5d7be5ea --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-rest-ary-elem.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-elem.case +// - src/dstr-binding/default/arrow-function-dflt.template +/*--- +description: Rest element containing an array BindingElementList pattern (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +es6id: 14.2.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set + iteratorRecord.[[done]] to true. + iii. ReturnIfAbrupt(v). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var f; +f = ([...[x, y, z]] = [3, 4, 5]) => { + assert.sameValue(x, 3); + assert.sameValue(y, 4); + assert.sameValue(z, 5); + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); diff --git a/test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-rest-ary-elision.js b/test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-rest-ary-elision.js new file mode 100644 index 0000000000..fc32bf2576 --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-rest-ary-elision.js @@ -0,0 +1,90 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-elision.case +// - src/dstr-binding/default/arrow-function-dflt.template +/*--- +description: Rest element containing an elision (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +es6id: 14.2.16 +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + 2. Return NormalCompletion(empty). + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var callCount = 0; +var f; +f = ([...[,]] = g()) => { + assert.sameValue(first, 1); + assert.sameValue(second, 1); + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); diff --git a/test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-rest-ary-empty.js b/test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-rest-ary-empty.js new file mode 100644 index 0000000000..0ee5addff0 --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-rest-ary-empty.js @@ -0,0 +1,73 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-empty.case +// - src/dstr-binding/default/arrow-function-dflt.template +/*--- +description: Rest element containing an "empty" array pattern (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +es6id: 14.2.16 +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ ] + + 1. Return NormalCompletion(empty). + +---*/ +var iterations = 0; +var iter = function*() { + iterations += 1; +}(); + +var callCount = 0; +var f; +f = ([...[]] = iter) => { + assert.sameValue(iterations, 1); + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); diff --git a/test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-rest-ary-rest.js b/test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-rest-ary-rest.js new file mode 100644 index 0000000000..f89170ab25 --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-rest-ary-rest.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-rest.case +// - src/dstr-binding/default/arrow-function-dflt.template +/*--- +description: Rest element containing a rest element (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +es6id: 14.2.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ +var values = [1, 2, 3]; + +var callCount = 0; +var f; +f = ([...[...x]] = values) => { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 1); + assert.sameValue(x[1], 2); + assert.sameValue(x[2], 3); + assert.notSameValue(x, values); + + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); diff --git a/test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-rest-id-elision-next-err.js b/test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-rest-id-elision-next-err.js new file mode 100644 index 0000000000..e0c7bdf585 --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-rest-id-elision-next-err.js @@ -0,0 +1,57 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision-next-err.case +// - src/dstr-binding/error/arrow-function-dflt.template +/*--- +description: Rest element following elision elements (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +es6id: 14.2.16 +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 = ([, ...x] = iter) => {}; + +assert.throws(Test262Error, function() { + f(); +}); diff --git a/test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-rest-id-elision.js b/test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-rest-id-elision.js new file mode 100644 index 0000000000..b74b48d34e --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-rest-id-elision.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision.case +// - src/dstr-binding/default/arrow-function-dflt.template +/*--- +description: Rest element following elision elements (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +es6id: 14.2.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + ArrayBindingPattern : [ Elisionopt BindingRestElement ] + 1. If Elision is present, then + a. Let status be the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with + iteratorRecord as the argument. + b. ReturnIfAbrupt(status). + 2. Return the result of performing IteratorBindingInitialization for + BindingRestElement with iteratorRecord and environment as arguments. +---*/ +var values = [1, 2, 3, 4, 5]; + +var callCount = 0; +var f; +f = ([ , , ...x] = values) => { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 3); + assert.sameValue(x[1], 4); + assert.sameValue(x[2], 5); + assert.notSameValue(x, values); + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); diff --git a/test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-rest-id-exhausted.js b/test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-rest-id-exhausted.js new file mode 100644 index 0000000000..eb4a970668 --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-rest-id-exhausted.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-exhausted.case +// - src/dstr-binding/default/arrow-function-dflt.template +/*--- +description: RestElement applied to an exhausted iterator (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +es6id: 14.2.16 +features: [Symbol.iterator, destructuring-binding, default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier, + environment). + 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat, + [...] + b. If iteratorRecord.[[done]] is true, then + i. If environment is undefined, return PutValue(lhs, A). + ii. Return InitializeReferencedBinding(lhs, A). + +---*/ + +var callCount = 0; +var f; +f = ([, , ...x] = [1, 2]) => { + assert(Array.isArray(x)); + assert.sameValue(x.length, 0); + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); diff --git a/test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-rest-id-iter-step-err.js b/test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-rest-id-iter-step-err.js new file mode 100644 index 0000000000..74f5feb72c --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-rest-id-iter-step-err.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-step-err.case +// - src/dstr-binding/error/arrow-function-dflt.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +es6id: 14.2.16 +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 = ([...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/arrow-function/dstr-dflt-ary-ptrn-rest-id-iter-val-err.js b/test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-rest-id-iter-val-err.js new file mode 100644 index 0000000000..09824400eb --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-rest-id-iter-val-err.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-val-err.case +// - src/dstr-binding/error/arrow-function-dflt.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +es6id: 14.2.16 +features: [Symbol.iterator, destructuring-binding, default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 = ([...x] = iter) => {}; + +assert.throws(Test262Error, function() { + f(); +}); diff --git a/test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-rest-id.js b/test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-rest-id.js new file mode 100644 index 0000000000..e29d45297e --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-rest-id.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id.case +// - src/dstr-binding/default/arrow-function-dflt.template +/*--- +description: Lone rest element (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +es6id: 14.2.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + [...] 3. Let A be ArrayCreate(0). [...] 5. Repeat + [...] + f. Let status be CreateDataProperty(A, ToString (n), nextValue). + [...] +---*/ +var values = [1, 2, 3]; + +var callCount = 0; +var f; +f = ([...x] = values) => { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 1); + assert.sameValue(x[1], 2); + assert.sameValue(x[2], 3); + assert.notSameValue(x, values); + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); diff --git a/test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-rest-init-ary.js b/test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-rest-init-ary.js new file mode 100644 index 0000000000..f29bdba84e --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-rest-init-ary.js @@ -0,0 +1,56 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-ary.case +// - src/dstr-binding/default/arrow-function-dflt.template +/*--- +description: Reset element (nested array pattern) does not support initializer (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +es6id: 14.2.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +negative: SyntaxError +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +var f; +f = ([...[ x ] = []] = []) => { + + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); diff --git a/test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-rest-init-id.js b/test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-rest-init-id.js new file mode 100644 index 0000000000..eb7e99091c --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-rest-init-id.js @@ -0,0 +1,56 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-id.case +// - src/dstr-binding/default/arrow-function-dflt.template +/*--- +description: Reset element (identifier) does not support initializer (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +es6id: 14.2.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +negative: SyntaxError +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +var f; +f = ([...x = []] = []) => { + + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); diff --git a/test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-rest-init-obj.js b/test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-rest-init-obj.js new file mode 100644 index 0000000000..1b0a57bcc5 --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-rest-init-obj.js @@ -0,0 +1,56 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-obj.case +// - src/dstr-binding/default/arrow-function-dflt.template +/*--- +description: Reset element (nested object pattern) does not support initializer (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +es6id: 14.2.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +negative: SyntaxError +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +var f; +f = ([...{ x } = []] = []) => { + + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); diff --git a/test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-rest-not-final-ary.js b/test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-rest-not-final-ary.js new file mode 100644 index 0000000000..d3a812c951 --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-rest-not-final-ary.js @@ -0,0 +1,56 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-ary.case +// - src/dstr-binding/default/arrow-function-dflt.template +/*--- +description: Rest element (array binding pattern) may not be followed by any element (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +es6id: 14.2.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +negative: SyntaxError +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +var f; +f = ([...[x], y] = [1, 2, 3]) => { + + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); diff --git a/test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-rest-not-final-id.js b/test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-rest-not-final-id.js new file mode 100644 index 0000000000..2fb75b7f77 --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-rest-not-final-id.js @@ -0,0 +1,56 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-id.case +// - src/dstr-binding/default/arrow-function-dflt.template +/*--- +description: Rest element (identifier) may not be followed by any element (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +es6id: 14.2.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +negative: SyntaxError +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +var f; +f = ([...x, y] = [1, 2, 3]) => { + + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); diff --git a/test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-rest-not-final-obj.js b/test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-rest-not-final-obj.js new file mode 100644 index 0000000000..8b16b1f347 --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-rest-not-final-obj.js @@ -0,0 +1,56 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-obj.case +// - src/dstr-binding/default/arrow-function-dflt.template +/*--- +description: Rest element (object binding pattern) may not be followed by any element (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +es6id: 14.2.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +negative: SyntaxError +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +var f; +f = ([...{ x }, y] = [1, 2, 3]) => { + + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); diff --git a/test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-rest-obj-id.js b/test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-rest-obj-id.js new file mode 100644 index 0000000000..e7f805fbe1 --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-rest-obj-id.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-obj-id.case +// - src/dstr-binding/default/arrow-function-dflt.template +/*--- +description: Rest element containing an object binding pattern (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +es6id: 14.2.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ + +var callCount = 0; +var f; +f = ([...{ length }] = [1, 2, 3]) => { + assert.sameValue(length, 3); + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); diff --git a/test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-rest-obj-prop-id.js b/test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-rest-obj-prop-id.js new file mode 100644 index 0000000000..2b8a3acb7c --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-dflt-ary-ptrn-rest-obj-prop-id.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-obj-prop-id.case +// - src/dstr-binding/default/arrow-function-dflt.template +/*--- +description: Rest element containing an object binding pattern (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +es6id: 14.2.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ + +var callCount = 0; +var f; +f = ([...{ 0: v, 1: w, 2: x, 3: y, length: z }] = [7, 8, 9]) => { + assert.sameValue(v, 7); + assert.sameValue(w, 8); + assert.sameValue(x, 9); + assert.sameValue(y, undefined); + assert.sameValue(z, 3); + + assert.throws(ReferenceError, function() { + length; + }); + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); diff --git a/test/language/expressions/arrow-function/dstr-dflt-obj-init-null.js b/test/language/expressions/arrow-function/dstr-dflt-obj-init-null.js new file mode 100644 index 0000000000..ad8cb90af5 --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-dflt-obj-init-null.js @@ -0,0 +1,51 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-null.case +// - src/dstr-binding/error/arrow-function-dflt.template +/*--- +description: Value specifed for object binding pattern must be object coercible (null) (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +es6id: 14.2.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + +var f = ({} = null) => {}; + +assert.throws(TypeError, function() { + f(); +}); diff --git a/test/language/expressions/arrow-function/dstr-dflt-obj-init-undefined.js b/test/language/expressions/arrow-function/dstr-dflt-obj-init-undefined.js new file mode 100644 index 0000000000..07cab579d3 --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-dflt-obj-init-undefined.js @@ -0,0 +1,51 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-undefined.case +// - src/dstr-binding/error/arrow-function-dflt.template +/*--- +description: Value specifed for object binding pattern must be object coercible (undefined) (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +es6id: 14.2.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + +var f = ({} = undefined) => {}; + +assert.throws(TypeError, function() { + f(); +}); diff --git a/test/language/expressions/arrow-function/dstr-dflt-obj-ptrn-empty.js b/test/language/expressions/arrow-function/dstr-dflt-obj-ptrn-empty.js new file mode 100644 index 0000000000..397246c92a --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-dflt-obj-ptrn-empty.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-empty.case +// - src/dstr-binding/default/arrow-function-dflt.template +/*--- +description: No property access occurs for an "empty" object binding pattern (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +es6id: 14.2.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ +var accessCount = 0; +var obj = Object.defineProperty({}, 'attr', { + get: function() { + accessCount += 1; + } +}); + +var callCount = 0; +var f; +f = ({} = obj) => { + assert.sameValue(accessCount, 0); + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); diff --git a/test/language/expressions/arrow-function/dstr-dflt-obj-ptrn-id-get-value-err.js b/test/language/expressions/arrow-function/dstr-dflt-obj-ptrn-id-get-value-err.js new file mode 100644 index 0000000000..7ada409523 --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-dflt-obj-ptrn-id-get-value-err.js @@ -0,0 +1,58 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-get-value-err.case +// - src/dstr-binding/error/arrow-function-dflt.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +es6id: 14.2.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 = ({ poisoned } = poisonedProperty) => {}; + +assert.throws(Test262Error, function() { + f(); +}); diff --git a/test/language/expressions/arrow-function/dstr-dflt-obj-ptrn-id-init-fn-name-arrow.js b/test/language/expressions/arrow-function/dstr-dflt-obj-ptrn-id-init-fn-name-arrow.js new file mode 100644 index 0000000000..b4b51ea40f --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-dflt-obj-ptrn-id-init-fn-name-arrow.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-arrow.case +// - src/dstr-binding/default/arrow-function-dflt.template +/*--- +description: SingleNameBinding assigns `name` to arrow functions (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +es6id: 14.2.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +var f; +f = ({ arrow = () => {} } = {}) => { + assert.sameValue(arrow.name, 'arrow'); + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); diff --git a/test/language/expressions/arrow-function/dstr-dflt-obj-ptrn-id-init-fn-name-class.js b/test/language/expressions/arrow-function/dstr-dflt-obj-ptrn-id-init-fn-name-class.js new file mode 100644 index 0000000000..af4e0a53e0 --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-dflt-obj-ptrn-id-init-fn-name-class.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-class.case +// - src/dstr-binding/default/arrow-function-dflt.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +es6id: 14.2.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +var f; +f = ({ cls = class {}, xCls = class X {} } = {}) => { + assert.sameValue(cls.name, 'cls'); + assert.notSameValue(xCls.name, 'xCls'); + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); diff --git a/test/language/expressions/arrow-function/dstr-dflt-obj-ptrn-id-init-fn-name-cover.js b/test/language/expressions/arrow-function/dstr-dflt-obj-ptrn-id-init-fn-name-cover.js new file mode 100644 index 0000000000..851b36cdb1 --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-dflt-obj-ptrn-id-init-fn-name-cover.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-cover.case +// - src/dstr-binding/default/arrow-function-dflt.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" functions "through" cover grammar (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +es6id: 14.2.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +var f; +f = ({ cover = (function () {}), xCover = (0, function() {}) } = {}) => { + assert.sameValue(cover.name, 'cover'); + assert.notSameValue(xCover.name, 'xCover'); + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); diff --git a/test/language/expressions/arrow-function/dstr-dflt-obj-ptrn-id-init-fn-name-fn.js b/test/language/expressions/arrow-function/dstr-dflt-obj-ptrn-id-init-fn-name-fn.js new file mode 100644 index 0000000000..0f9e21fc64 --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-dflt-obj-ptrn-id-init-fn-name-fn.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-fn.case +// - src/dstr-binding/default/arrow-function-dflt.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +es6id: 14.2.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +var f; +f = ({ fn = function () {}, xFn = function x() {} } = {}) => { + assert.sameValue(fn.name, 'fn'); + assert.notSameValue(xFn.name, 'xFn'); + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); diff --git a/test/language/expressions/arrow-function/dstr-dflt-obj-ptrn-id-init-fn-name-gen.js b/test/language/expressions/arrow-function/dstr-dflt-obj-ptrn-id-init-fn-name-gen.js new file mode 100644 index 0000000000..26210d7445 --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-dflt-obj-ptrn-id-init-fn-name-gen.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-gen.case +// - src/dstr-binding/default/arrow-function-dflt.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +es6id: 14.2.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +var f; +f = ({ gen = function* () {}, xGen = function* x() {} } = {}) => { + assert.sameValue(gen.name, 'gen'); + assert.notSameValue(xGen.name, 'xGen'); + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); diff --git a/test/language/expressions/arrow-function/dstr-dflt-obj-ptrn-id-init-skipped.js b/test/language/expressions/arrow-function/dstr-dflt-obj-ptrn-id-init-skipped.js new file mode 100644 index 0000000000..007cc7849f --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-dflt-obj-ptrn-id-init-skipped.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-skipped.case +// - src/dstr-binding/default/arrow-function-dflt.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +es6id: 14.2.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + [...] +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var callCount = 0; +var f; +f = ({ w = counter(), x = counter(), y = counter(), z = counter() } = { w: null, x: 0, y: false, z: '' }) => { + assert.sameValue(w, null); + assert.sameValue(x, 0); + assert.sameValue(y, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); diff --git a/test/language/expressions/arrow-function/dstr-dflt-obj-ptrn-id-init-throws.js b/test/language/expressions/arrow-function/dstr-dflt-obj-ptrn-id-init-throws.js new file mode 100644 index 0000000000..207ea5c9bb --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-dflt-obj-ptrn-id-init-throws.js @@ -0,0 +1,58 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-throws.case +// - src/dstr-binding/error/arrow-function-dflt.template +/*--- +description: Error thrown when evaluating the initializer (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +es6id: 14.2.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 = ({ x = thrower() } = {}) => {}; + +assert.throws(Test262Error, function() { + f(); +}); diff --git a/test/language/expressions/arrow-function/dstr-dflt-obj-ptrn-id-init-unresolvable.js b/test/language/expressions/arrow-function/dstr-dflt-obj-ptrn-id-init-unresolvable.js new file mode 100644 index 0000000000..f325728b2b --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-dflt-obj-ptrn-id-init-unresolvable.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-unresolvable.case +// - src/dstr-binding/error/arrow-function-dflt.template +/*--- +description: Destructuring initializer is an unresolvable reference (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +es6id: 14.2.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 = ({ x = unresolvableReference } = {}) => {}; + +assert.throws(ReferenceError, function() { + f(); +}); diff --git a/test/language/expressions/arrow-function/dstr-dflt-obj-ptrn-id-trailing-comma.js b/test/language/expressions/arrow-function/dstr-dflt-obj-ptrn-id-trailing-comma.js new file mode 100644 index 0000000000..eba3658f1c --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-dflt-obj-ptrn-id-trailing-comma.js @@ -0,0 +1,56 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-trailing-comma.case +// - src/dstr-binding/default/arrow-function-dflt.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +es6id: 14.2.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var callCount = 0; +var f; +f = ({ x, } = { x: 23 }) => { + assert.sameValue(x, 23); + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); diff --git a/test/language/expressions/arrow-function/dstr-dflt-obj-ptrn-list-err.js b/test/language/expressions/arrow-function/dstr-dflt-obj-ptrn-list-err.js new file mode 100644 index 0000000000..a20d7c3247 --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-dflt-obj-ptrn-list-err.js @@ -0,0 +1,59 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-list-err.case +// - src/dstr-binding/error/arrow-function-dflt.template +/*--- +description: Binding property list evaluation is interrupted by an abrupt completion (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +es6id: 14.2.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 = ({ a, b = thrower(), c = ++initCount } = {}) => {}; + +assert.throws(Test262Error, function() { + f(); +}); + +assert.sameValue(initCount, 0); diff --git a/test/language/expressions/arrow-function/dstr-dflt-obj-ptrn-prop-ary-init.js b/test/language/expressions/arrow-function/dstr-dflt-obj-ptrn-prop-ary-init.js new file mode 100644 index 0000000000..2099d9bdfd --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-dflt-obj-ptrn-prop-ary-init.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-init.case +// - src/dstr-binding/default/arrow-function-dflt.template +/*--- +description: Object binding pattern with "nested" array binding pattern using initializer (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +es6id: 14.2.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +var f; +f = ({ w: [x, y, z] = [4, 5, 6] } = {}) => { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); diff --git a/test/language/expressions/arrow-function/dstr-dflt-obj-ptrn-prop-ary-trailing-comma.js b/test/language/expressions/arrow-function/dstr-dflt-obj-ptrn-prop-ary-trailing-comma.js new file mode 100644 index 0000000000..0497319adf --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-dflt-obj-ptrn-prop-ary-trailing-comma.js @@ -0,0 +1,56 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-trailing-comma.case +// - src/dstr-binding/default/arrow-function-dflt.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +es6id: 14.2.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var callCount = 0; +var f; +f = ({ x: [y], } = { x: [45] }) => { + assert.sameValue(y,45); + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); diff --git a/test/language/expressions/arrow-function/dstr-dflt-obj-ptrn-prop-ary-value-null.js b/test/language/expressions/arrow-function/dstr-dflt-obj-ptrn-prop-ary-value-null.js new file mode 100644 index 0000000000..847d6d3a81 --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-dflt-obj-ptrn-prop-ary-value-null.js @@ -0,0 +1,53 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-value-null.case +// - src/dstr-binding/error/arrow-function-dflt.template +/*--- +description: Object binding pattern with "nested" array binding pattern taking the `null` value (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +es6id: 14.2.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 = ({ w: [x, y, z] = [4, 5, 6] } = { w: null }) => {}; + +assert.throws(TypeError, function() { + f(); +}); diff --git a/test/language/expressions/arrow-function/dstr-dflt-obj-ptrn-prop-ary.js b/test/language/expressions/arrow-function/dstr-dflt-obj-ptrn-prop-ary.js new file mode 100644 index 0000000000..50aa1593c8 --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-dflt-obj-ptrn-prop-ary.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary.case +// - src/dstr-binding/default/arrow-function-dflt.template +/*--- +description: Object binding pattern with "nested" array binding pattern not using initializer (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +es6id: 14.2.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +var f; +f = ({ w: [x, y, z] = [4, 5, 6] } = { w: [7, undefined, ] }) => { + assert.sameValue(x, 7); + assert.sameValue(y, undefined); + assert.sameValue(z, undefined); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); diff --git a/test/language/expressions/arrow-function/dstr-dflt-obj-ptrn-prop-eval-err.js b/test/language/expressions/arrow-function/dstr-dflt-obj-ptrn-prop-eval-err.js new file mode 100644 index 0000000000..a3e162b057 --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-dflt-obj-ptrn-prop-eval-err.js @@ -0,0 +1,55 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-eval-err.case +// - src/dstr-binding/error/arrow-function-dflt.template +/*--- +description: Evaluation of property name returns an abrupt completion (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +es6id: 14.2.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 = ({ [thrower()]: x } = {}) => {}; + +assert.throws(Test262Error, function() { + f(); +}); diff --git a/test/language/expressions/arrow-function/dstr-dflt-obj-ptrn-prop-id-get-value-err.js b/test/language/expressions/arrow-function/dstr-dflt-obj-ptrn-prop-id-get-value-err.js new file mode 100644 index 0000000000..ff4f06cf43 --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-dflt-obj-ptrn-prop-id-get-value-err.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-get-value-err.case +// - src/dstr-binding/error/arrow-function-dflt.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +es6id: 14.2.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 = ({ poisoned: x = ++initEvalCount } = poisonedProperty) => {}; + +assert.throws(Test262Error, function() { + f(); +}); + +assert.sameValue(initEvalCount, 0); diff --git a/test/language/expressions/arrow-function/dstr-dflt-obj-ptrn-prop-id-init-skipped.js b/test/language/expressions/arrow-function/dstr-dflt-obj-ptrn-prop-id-init-skipped.js new file mode 100644 index 0000000000..160e36e227 --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-dflt-obj-ptrn-prop-id-init-skipped.js @@ -0,0 +1,78 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-skipped.case +// - src/dstr-binding/default/arrow-function-dflt.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +es6id: 14.2.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + [...] +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var callCount = 0; +var f; +f = ({ s: t = counter(), u: v = counter(), w: x = counter(), y: z = counter() } = { s: null, u: 0, w: false, y: '' }) => { + assert.sameValue(t, null); + assert.sameValue(v, 0); + assert.sameValue(x, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + + assert.throws(ReferenceError, function() { + s; + }); + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); diff --git a/test/language/expressions/arrow-function/dstr-dflt-obj-ptrn-prop-id-init-throws.js b/test/language/expressions/arrow-function/dstr-dflt-obj-ptrn-prop-id-init-throws.js new file mode 100644 index 0000000000..d4c6a88517 --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-dflt-obj-ptrn-prop-id-init-throws.js @@ -0,0 +1,58 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-throws.case +// - src/dstr-binding/error/arrow-function-dflt.template +/*--- +description: Error thrown when evaluating the initializer (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +es6id: 14.2.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 = ({ x: y = thrower() } = {}) => {}; + +assert.throws(Test262Error, function() { + f(); +}); diff --git a/test/language/expressions/arrow-function/dstr-dflt-obj-ptrn-prop-id-init-unresolvable.js b/test/language/expressions/arrow-function/dstr-dflt-obj-ptrn-prop-id-init-unresolvable.js new file mode 100644 index 0000000000..9f4fc6e8ee --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-dflt-obj-ptrn-prop-id-init-unresolvable.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-unresolvable.case +// - src/dstr-binding/error/arrow-function-dflt.template +/*--- +description: Destructuring initializer is an unresolvable reference (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +es6id: 14.2.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 = ({ x: y = unresolvableReference } = {}) => {}; + +assert.throws(ReferenceError, function() { + f(); +}); diff --git a/test/language/expressions/arrow-function/dstr-dflt-obj-ptrn-prop-id-init.js b/test/language/expressions/arrow-function/dstr-dflt-obj-ptrn-prop-id-init.js new file mode 100644 index 0000000000..c5457d4cf0 --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-dflt-obj-ptrn-prop-id-init.js @@ -0,0 +1,59 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init.case +// - src/dstr-binding/default/arrow-function-dflt.template +/*--- +description: Binding as specified via property name, identifier, and initializer (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +es6id: 14.2.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var f; +f = ({ x: y = 33 } = { }) => { + assert.sameValue(y, 33); + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); diff --git a/test/language/expressions/arrow-function/dstr-dflt-obj-ptrn-prop-id-trailing-comma.js b/test/language/expressions/arrow-function/dstr-dflt-obj-ptrn-prop-id-trailing-comma.js new file mode 100644 index 0000000000..c821daed0b --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-dflt-obj-ptrn-prop-id-trailing-comma.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-trailing-comma.case +// - src/dstr-binding/default/arrow-function-dflt.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +es6id: 14.2.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var callCount = 0; +var f; +f = ({ x: y, } = { x: 23 }) => { + assert.sameValue(y, 23); + + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); diff --git a/test/language/expressions/arrow-function/dstr-dflt-obj-ptrn-prop-id.js b/test/language/expressions/arrow-function/dstr-dflt-obj-ptrn-prop-id.js new file mode 100644 index 0000000000..1a0cd7c06e --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-dflt-obj-ptrn-prop-id.js @@ -0,0 +1,59 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id.case +// - src/dstr-binding/default/arrow-function-dflt.template +/*--- +description: Binding as specified via property name and identifier (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +es6id: 14.2.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var f; +f = ({ x: y } = { x: 23 }) => { + assert.sameValue(y, 23); + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); diff --git a/test/language/expressions/arrow-function/dstr-dflt-obj-ptrn-prop-obj-init.js b/test/language/expressions/arrow-function/dstr-dflt-obj-ptrn-prop-obj-init.js new file mode 100644 index 0000000000..8556606597 --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-dflt-obj-ptrn-prop-obj-init.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-init.case +// - src/dstr-binding/default/arrow-function-dflt.template +/*--- +description: Object binding pattern with "nested" object binding pattern using initializer (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +es6id: 14.2.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +var f; +f = ({ w: { x, y, z } = { x: 4, y: 5, z: 6 } } = { w: undefined }) => { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); diff --git a/test/language/expressions/arrow-function/dstr-dflt-obj-ptrn-prop-obj-value-null.js b/test/language/expressions/arrow-function/dstr-dflt-obj-ptrn-prop-obj-value-null.js new file mode 100644 index 0000000000..5a759a5c54 --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-dflt-obj-ptrn-prop-obj-value-null.js @@ -0,0 +1,53 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-null.case +// - src/dstr-binding/error/arrow-function-dflt.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +es6id: 14.2.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 = ({ w: { x, y, z } = { x: 4, y: 5, z: 6 } } = { w: null }) => {}; + +assert.throws(TypeError, function() { + f(); +}); diff --git a/test/language/expressions/arrow-function/dstr-dflt-obj-ptrn-prop-obj-value-undef.js b/test/language/expressions/arrow-function/dstr-dflt-obj-ptrn-prop-obj-value-undef.js new file mode 100644 index 0000000000..9f0aa5b63b --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-dflt-obj-ptrn-prop-obj-value-undef.js @@ -0,0 +1,53 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-undef.case +// - src/dstr-binding/error/arrow-function-dflt.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +es6id: 14.2.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 = ({ w: { x, y, z } = undefined } = { }) => {}; + +assert.throws(TypeError, function() { + f(); +}); diff --git a/test/language/expressions/arrow-function/dstr-dflt-obj-ptrn-prop-obj.js b/test/language/expressions/arrow-function/dstr-dflt-obj-ptrn-prop-obj.js new file mode 100644 index 0000000000..eecdcf3f47 --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-dflt-obj-ptrn-prop-obj.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj.case +// - src/dstr-binding/default/arrow-function-dflt.template +/*--- +description: Object binding pattern with "nested" object binding pattern not using initializer (arrow function expression (default parameter)) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +es6id: 14.2.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +var f; +f = ({ w: { x, y, z } = { x: 4, y: 5, z: 6 } } = { w: { x: undefined, z: 7 } }) => { + assert.sameValue(x, undefined); + assert.sameValue(y, undefined); + assert.sameValue(z, 7); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-dflt-ary-init-iter-close.js b/test/language/expressions/class/dstr-gen-meth-dflt-ary-init-iter-close.js new file mode 100644 index 0000000000..5ec3fbf266 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-dflt-ary-init-iter-close.js @@ -0,0 +1,97 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-close.case +// - src/dstr-binding/default/cls-expr-gen-meth-dflt.template +/*--- +description: Iterator is closed when not exhausted by pattern evaluation (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [Symbol.iterator, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + [...] + 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator, + result). + [...] + +---*/ +var doneCallCount = 0; +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return { value: null, done: false }; + }, + return: function() { + doneCallCount += 1; + return {}; + } + }; +}; + +var callCount = 0; +var C = class { + *method([x] = iter) { + assert.sameValue(doneCallCount, 1); + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-dflt-ary-init-iter-get-err.js b/test/language/expressions/class/dstr-gen-meth-dflt-ary-init-iter-get-err.js new file mode 100644 index 0000000000..e10e935773 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-dflt-ary-init-iter-get-err.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-get-err.case +// - src/dstr-binding/error/cls-expr-gen-meth-dflt.template +/*--- +description: Abrupt completion returned by GetIterator (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [Symbol.iterator, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 { + *method([x] = iter) {} +}; +var c = new C(); + +assert.throws(Test262Error, function() { + c.method(); +}); diff --git a/test/language/expressions/class/dstr-gen-meth-dflt-ary-init-iter-no-close.js b/test/language/expressions/class/dstr-gen-meth-dflt-ary-init-iter-no-close.js new file mode 100644 index 0000000000..5b8eb1dc9e --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-dflt-ary-init-iter-no-close.js @@ -0,0 +1,97 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-no-close.case +// - src/dstr-binding/default/cls-expr-gen-meth-dflt.template +/*--- +description: Iterator is not closed when exhausted by pattern evaluation (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [Symbol.iterator, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + [...] + 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator, + result). + [...] + +---*/ +var doneCallCount = 0; +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return { value: null, done: true }; + }, + return: function() { + doneCallCount += 1; + return {}; + } + }; +}; + +var callCount = 0; +var C = class { + *method([x] = iter) { + assert.sameValue(doneCallCount, 0); + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-dflt-ary-name-iter-val.js b/test/language/expressions/class/dstr-gen-meth-dflt-ary-name-iter-val.js new file mode 100644 index 0000000000..1d776ca4ee --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-dflt-ary-name-iter-val.js @@ -0,0 +1,96 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-name-iter-val.case +// - src/dstr-binding/default/cls-expr-gen-meth-dflt.template +/*--- +description: SingleNameBinding with normal value iteration (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set + iteratorRecord.[[done]] to true. + iii. ReturnIfAbrupt(v). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var C = class { + *method([x, y, z] = [1, 2, 3]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 3); + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-elem-ary-elem-init.js b/test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-elem-ary-elem-init.js new file mode 100644 index 0000000000..70d1e1aa8a --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-elem-ary-elem-init.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elem-init.case +// - src/dstr-binding/default/cls-expr-gen-meth-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is used (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +var C = class { + *method([[x, y, z] = [4, 5, 6]] = []) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-elem-ary-elem-iter.js b/test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-elem-ary-elem-iter.js new file mode 100644 index 0000000000..8c1b836d26 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-elem-ary-elem-iter.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elem-iter.case +// - src/dstr-binding/default/cls-expr-gen-meth-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +var C = class { + *method([[x, y, z] = [4, 5, 6]] = [[7, 8, 9]]) { + assert.sameValue(x, 7); + assert.sameValue(y, 8); + assert.sameValue(z, 9); + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-elem-ary-elision-init.js b/test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-elem-ary-elision-init.js new file mode 100644 index 0000000000..7de1fc0011 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-elem-ary-elision-init.js @@ -0,0 +1,95 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elision-init.case +// - src/dstr-binding/default/cls-expr-gen-meth-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is used (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var callCount = 0; +var C = class { + *method([[,] = g()] = []) { + assert.sameValue(first, 1); + assert.sameValue(second, 0); + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-elem-ary-elision-iter.js b/test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-elem-ary-elision-iter.js new file mode 100644 index 0000000000..26b9bf7849 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-elem-ary-elision-iter.js @@ -0,0 +1,92 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elision-iter.case +// - src/dstr-binding/default/cls-expr-gen-meth-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var callCount = 0; +function* g() { + callCount += 1; +}; + +var callCount = 0; +var C = class { + *method([[,] = g()] = [[]]) { + assert.sameValue(callCount, 0); + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-elem-ary-empty-init.js b/test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-elem-ary-empty-init.js new file mode 100644 index 0000000000..c9ab70830c --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-elem-ary-empty-init.js @@ -0,0 +1,90 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-empty-init.case +// - src/dstr-binding/default/cls-expr-gen-meth-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is used (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var initCount = 0; +var iterCount = 0; +var iter = function*() { iterCount += 1; }(); + +var callCount = 0; +var C = class { + *method([[] = function() { initCount += 1; return iter; }()] = []) { + assert.sameValue(initCount, 1); + assert.sameValue(iterCount, 0); + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-elem-ary-empty-iter.js b/test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-elem-ary-empty-iter.js new file mode 100644 index 0000000000..b875facc4c --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-elem-ary-empty-iter.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-empty-iter.case +// - src/dstr-binding/default/cls-expr-gen-meth-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var initCount = 0; + +var callCount = 0; +var C = class { + *method([[] = function() { initCount += 1; }()] = [[23]]) { + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-elem-ary-rest-init.js b/test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-elem-ary-rest-init.js new file mode 100644 index 0000000000..a83bcae854 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-elem-ary-rest-init.js @@ -0,0 +1,92 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-rest-init.case +// - src/dstr-binding/default/cls-expr-gen-meth-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is used (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var values = [2, 1, 3]; + +var callCount = 0; +var C = class { + *method([[...x] = values] = []) { + assert(Array.isArray(x)); + assert.sameValue(x[0], 2); + assert.sameValue(x[1], 1); + assert.sameValue(x[2], 3); + assert.sameValue(x.length, 3); + assert.notSameValue(x, values); + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-elem-ary-rest-iter.js b/test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-elem-ary-rest-iter.js new file mode 100644 index 0000000000..618957ca5e --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-elem-ary-rest-iter.js @@ -0,0 +1,95 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-rest-iter.case +// - src/dstr-binding/default/cls-expr-gen-meth-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var values = [2, 1, 3]; +var initCount = 0; + +var callCount = 0; +var C = class { + *method([[...x] = function() { initCount += 1; }()] = [values]) { + assert(Array.isArray(x)); + assert.sameValue(x[0], 2); + assert.sameValue(x[1], 1); + assert.sameValue(x[2], 3); + assert.sameValue(x.length, 3); + assert.notSameValue(x, values); + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-elem-ary-val-null.js b/test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-elem-ary-val-null.js new file mode 100644 index 0000000000..d5fd9e35a9 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-elem-ary-val-null.js @@ -0,0 +1,91 @@ +// 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-gen-meth-dflt.template +/*--- +description: Nested array destructuring with a null value (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 { + *method([[x]] = [null]) {} +}; +var c = new C(); + +assert.throws(TypeError, function() { + c.method(); +}); diff --git a/test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-elem-id-init-exhausted.js b/test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-elem-id-init-exhausted.js new file mode 100644 index 0000000000..7b746fb3b0 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-elem-id-init-exhausted.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-exhausted.case +// - src/dstr-binding/default/cls-expr-gen-meth-dflt.template +/*--- +description: Destructuring initializer with an exhausted iterator (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var C = class { + *method([x = 23] = []) { + assert.sameValue(x, 23); + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-arrow.js b/test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-arrow.js new file mode 100644 index 0000000000..be56485759 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-arrow.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-arrow.case +// - src/dstr-binding/default/cls-expr-gen-meth-dflt.template +/*--- +description: SingleNameBinding does assign name to arrow functions (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var C = class { + *method([arrow = () => {}] = []) { + assert.sameValue(arrow.name, 'arrow'); + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-class.js b/test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-class.js new file mode 100644 index 0000000000..a56a220167 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-class.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-class.case +// - src/dstr-binding/default/cls-expr-gen-meth-dflt.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var C = class { + *method([cls = class {}, xCls = class X {}] = []) { + assert.sameValue(cls.name, 'cls'); + assert.notSameValue(xCls.name, 'xCls'); + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-cover.js b/test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-cover.js new file mode 100644 index 0000000000..1fb2a704cb --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-cover.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-cover.case +// - src/dstr-binding/default/cls-expr-gen-meth-dflt.template +/*--- +description: SingleNameBinding does assign name to "anonymous" functions "through" cover grammar (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var C = class { + *method([cover = (function () {}), xCover = (0, function() {})] = []) { + assert.sameValue(cover.name, 'cover'); + assert.notSameValue(xCover.name, 'xCover'); + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-fn.js b/test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-fn.js new file mode 100644 index 0000000000..89ac7ba12d --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-fn.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-fn.case +// - src/dstr-binding/default/cls-expr-gen-meth-dflt.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var C = class { + *method([fn = function () {}, xFn = function x() {}] = []) { + assert.sameValue(fn.name, 'fn'); + assert.notSameValue(xFn.name, 'xFn'); + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-gen.js b/test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-gen.js new file mode 100644 index 0000000000..5340f5067d --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-gen.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-gen.case +// - src/dstr-binding/default/cls-expr-gen-meth-dflt.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var C = class { + *method([gen = function* () {}, xGen = function* x() {}] = []) { + assert.sameValue(gen.name, 'gen'); + assert.notSameValue(xGen.name, 'xGen'); + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-elem-id-init-hole.js b/test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-elem-id-init-hole.js new file mode 100644 index 0000000000..ee357d99d1 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-elem-id-init-hole.js @@ -0,0 +1,83 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-hole.case +// - src/dstr-binding/default/cls-expr-gen-meth-dflt.template +/*--- +description: Destructuring initializer with a "hole" (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + SingleNameBinding : BindingIdentifier Initializeropt + [...] 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + [...] + 7. If environment is undefined, return PutValue(lhs, v). 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var C = class { + *method([x = 23] = [,]) { + assert.sameValue(x, 23); + // another statement + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-elem-id-init-skipped.js b/test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-elem-id-init-skipped.js new file mode 100644 index 0000000000..c53995899a --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-elem-id-init-skipped.js @@ -0,0 +1,92 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-skipped.case +// - src/dstr-binding/default/cls-expr-gen-meth-dflt.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var callCount = 0; +var C = class { + *method([w = counter(), x = counter(), y = counter(), z = counter()] = [null, 0, false, '']) { + assert.sameValue(w, null); + assert.sameValue(x, 0); + assert.sameValue(y, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-elem-id-init-throws.js b/test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-elem-id-init-throws.js new file mode 100644 index 0000000000..2a2cee1105 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-elem-id-init-throws.js @@ -0,0 +1,82 @@ +// 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-gen-meth-dflt.template +/*--- +description: Destructuring initializer returns an abrupt completion (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 { + *method([x = (function() { throw new Test262Error(); })()] = [undefined]) {} +}; +var c = new C(); + +assert.throws(Test262Error, function() { + c.method(); +}); diff --git a/test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-elem-id-init-undef.js b/test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-elem-id-init-undef.js new file mode 100644 index 0000000000..f230d56376 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-elem-id-init-undef.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-undef.case +// - src/dstr-binding/default/cls-expr-gen-meth-dflt.template +/*--- +description: Destructuring initializer with an undefined value (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var C = class { + *method([x = 23] = [undefined]) { + assert.sameValue(x, 23); + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-elem-id-init-unresolvable.js b/test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-elem-id-init-unresolvable.js new file mode 100644 index 0000000000..348d8bef41 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-elem-id-init-unresolvable.js @@ -0,0 +1,89 @@ +// 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-gen-meth-dflt.template +/*--- +description: Destructuring initializer is an unresolvable reference (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 { + *method([ x = unresolvableReference ] = []) {} +}; +var c = new C(); + +assert.throws(ReferenceError, function() { + c.method(); +}); diff --git a/test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-elem-id-iter-complete.js b/test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-elem-id-iter-complete.js new file mode 100644 index 0000000000..fb47225655 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-elem-id-iter-complete.js @@ -0,0 +1,90 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-complete.case +// - src/dstr-binding/default/cls-expr-gen-meth-dflt.template +/*--- +description: SingleNameBinding when value iteration completes (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var C = class { + *method([x] = []) { + assert.sameValue(x, undefined); + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-elem-id-iter-done.js b/test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-elem-id-iter-done.js new file mode 100644 index 0000000000..b4cc4ff6fa --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-elem-id-iter-done.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-done.case +// - src/dstr-binding/default/cls-expr-gen-meth-dflt.template +/*--- +description: SingleNameBinding when value iteration was completed previously (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var C = class { + *method([_, x] = []) { + assert.sameValue(x, undefined); + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-elem-id-iter-step-err.js b/test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-elem-id-iter-step-err.js new file mode 100644 index 0000000000..5442af3b35 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-elem-id-iter-step-err.js @@ -0,0 +1,90 @@ +// 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-gen-meth-dflt.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 { + *method([x] = g) {} +}; +var c = new C(); + +assert.throws(Test262Error, function() { + c.method(); +}); diff --git a/test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-elem-id-iter-val-err.js b/test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-elem-id-iter-val-err.js new file mode 100644 index 0000000000..7f668a669c --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-elem-id-iter-val-err.js @@ -0,0 +1,101 @@ +// 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-gen-meth-dflt.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 { + *method([x] = g) {} +}; +var c = new C(); + +assert.throws(Test262Error, function() { + c.method(); +}); diff --git a/test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-elem-id-iter-val.js b/test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-elem-id-iter-val.js new file mode 100644 index 0000000000..e1d22ac8aa --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-elem-id-iter-val.js @@ -0,0 +1,96 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val.case +// - src/dstr-binding/default/cls-expr-gen-meth-dflt.template +/*--- +description: SingleNameBinding when value iteration was completed previously (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set + iteratorRecord.[[done]] to true. + iii. ReturnIfAbrupt(v). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var C = class { + *method([x, y, z] = [1, 2, 3]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 3); + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-elem-obj-id-init.js b/test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-elem-obj-id-init.js new file mode 100644 index 0000000000..9bcdf7d3f1 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-elem-obj-id-init.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-id-init.case +// - src/dstr-binding/default/cls-expr-gen-meth-dflt.template +/*--- +description: BindingElement with object binding pattern and initializer is used (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +var C = class { + *method([{ x, y, z } = { x: 44, y: 55, z: 66 }] = []) { + assert.sameValue(x, 44); + assert.sameValue(y, 55); + assert.sameValue(z, 66); + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-elem-obj-id.js b/test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-elem-obj-id.js new file mode 100644 index 0000000000..95f4ab5280 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-elem-obj-id.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-id.case +// - src/dstr-binding/default/cls-expr-gen-meth-dflt.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +var C = class { + *method([{ x, y, z } = { x: 44, y: 55, z: 66 }] = [{ x: 11, y: 22, z: 33 }]) { + assert.sameValue(x, 11); + assert.sameValue(y, 22); + assert.sameValue(z, 33); + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-elem-obj-prop-id-init.js b/test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-elem-obj-prop-id-init.js new file mode 100644 index 0000000000..ac92abdb3f --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-elem-obj-prop-id-init.js @@ -0,0 +1,98 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-prop-id-init.case +// - src/dstr-binding/default/cls-expr-gen-meth-dflt.template +/*--- +description: BindingElement with object binding pattern and initializer is used (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +var C = class { + *method([{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }] = []) { + assert.sameValue(v, 444); + assert.sameValue(x, 555); + assert.sameValue(z, 666); + + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-elem-obj-prop-id.js b/test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-elem-obj-prop-id.js new file mode 100644 index 0000000000..b3ee8ae3cf --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-elem-obj-prop-id.js @@ -0,0 +1,98 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-prop-id.case +// - src/dstr-binding/default/cls-expr-gen-meth-dflt.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +var C = class { + *method([{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }] = [{ u: 777, w: 888, y: 999 }]) { + assert.sameValue(v, 777); + assert.sameValue(x, 888); + assert.sameValue(z, 999); + + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-elem-obj-val-null.js b/test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-elem-obj-val-null.js new file mode 100644 index 0000000000..694a464f73 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-elem-obj-val-null.js @@ -0,0 +1,91 @@ +// 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-gen-meth-dflt.template +/*--- +description: Nested object destructuring with a null value (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 { + *method([{ x }] = [null]) {} +}; +var c = new C(); + +assert.throws(TypeError, function() { + c.method(); +}); diff --git a/test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-elem-obj-val-undef.js b/test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-elem-obj-val-undef.js new file mode 100644 index 0000000000..0030d16177 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-elem-obj-val-undef.js @@ -0,0 +1,91 @@ +// 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-gen-meth-dflt.template +/*--- +description: Nested object destructuring with a value of `undefined` (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 { + *method([{ x }] = []) {} +}; +var c = new C(); + +assert.throws(TypeError, function() { + c.method(); +}); diff --git a/test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-elision-exhausted.js b/test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-elision-exhausted.js new file mode 100644 index 0000000000..36949a0289 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-elision-exhausted.js @@ -0,0 +1,93 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-exhausted.case +// - src/dstr-binding/default/cls-expr-gen-meth-dflt.template +/*--- +description: Elision accepts exhausted iterator (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [generator, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + [...] + 2. Return NormalCompletion(empty). + +---*/ +var iter = function*() {}(); +iter.next(); + +var callCount = 0; +var C = class { + *method([,] = iter) { + + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-elision-step-err.js b/test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-elision-step-err.js new file mode 100644 index 0000000000..cf54109d27 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-elision-step-err.js @@ -0,0 +1,98 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-step-err.case +// - src/dstr-binding/error/cls-expr-gen-meth-dflt.template +/*--- +description: Elision advances iterator and forwards abrupt completions (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [generator, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 { + *method([,] = iter) {} +}; +var c = new C(); + +assert.throws(Test262Error, function() { + c.method(); +}); + +iter.next(); +assert.sameValue(following, 0, 'Iterator was properly closed.'); diff --git a/test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-elision.js b/test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-elision.js new file mode 100644 index 0000000000..af13c56752 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-elision.js @@ -0,0 +1,102 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision.case +// - src/dstr-binding/default/cls-expr-gen-meth-dflt.template +/*--- +description: Elision advances iterator (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [generator, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + 2. Return NormalCompletion(empty). + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var callCount = 0; +var C = class { + *method([,] = g()) { + assert.sameValue(first, 1); + assert.sameValue(second, 0); + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-empty.js b/test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-empty.js new file mode 100644 index 0000000000..26ac515f73 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-empty.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-empty.case +// - src/dstr-binding/default/cls-expr-gen-meth-dflt.template +/*--- +description: No iteration occurs for an "empty" array binding pattern (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ ] + + 1. Return NormalCompletion(empty). + +---*/ +var iterations = 0; +var iter = function*() { + iterations += 1; +}(); + +var callCount = 0; +var C = class { + *method([] = iter) { + assert.sameValue(iterations, 0); + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-rest-ary-elem.js b/test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-rest-ary-elem.js new file mode 100644 index 0000000000..04dce5bcdb --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-rest-ary-elem.js @@ -0,0 +1,109 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-elem.case +// - src/dstr-binding/default/cls-expr-gen-meth-dflt.template +/*--- +description: Rest element containing an array BindingElementList pattern (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set + iteratorRecord.[[done]] to true. + iii. ReturnIfAbrupt(v). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var C = class { + *method([...[x, y, z]] = [3, 4, 5]) { + assert.sameValue(x, 3); + assert.sameValue(y, 4); + assert.sameValue(z, 5); + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-rest-ary-elision.js b/test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-rest-ary-elision.js new file mode 100644 index 0000000000..90bf9c7c3e --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-rest-ary-elision.js @@ -0,0 +1,115 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-elision.case +// - src/dstr-binding/default/cls-expr-gen-meth-dflt.template +/*--- +description: Rest element containing an elision (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + 2. Return NormalCompletion(empty). + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var callCount = 0; +var C = class { + *method([...[,]] = g()) { + assert.sameValue(first, 1); + assert.sameValue(second, 1); + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-rest-ary-empty.js b/test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-rest-ary-empty.js new file mode 100644 index 0000000000..a38c651dbc --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-rest-ary-empty.js @@ -0,0 +1,98 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-empty.case +// - src/dstr-binding/default/cls-expr-gen-meth-dflt.template +/*--- +description: Rest element containing an "empty" array pattern (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ ] + + 1. Return NormalCompletion(empty). + +---*/ +var iterations = 0; +var iter = function*() { + iterations += 1; +}(); + +var callCount = 0; +var C = class { + *method([...[]] = iter) { + assert.sameValue(iterations, 1); + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-rest-ary-rest.js b/test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-rest-ary-rest.js new file mode 100644 index 0000000000..46bff62018 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-rest-ary-rest.js @@ -0,0 +1,94 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-rest.case +// - src/dstr-binding/default/cls-expr-gen-meth-dflt.template +/*--- +description: Rest element containing a rest element (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ +var values = [1, 2, 3]; + +var callCount = 0; +var C = class { + *method([...[...x]] = values) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 1); + assert.sameValue(x[1], 2); + assert.sameValue(x[2], 3); + assert.notSameValue(x, values); + + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-rest-id-elision-next-err.js b/test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-rest-id-elision-next-err.js new file mode 100644 index 0000000000..18172ac3f7 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-rest-id-elision-next-err.js @@ -0,0 +1,84 @@ +// 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-gen-meth-dflt.template +/*--- +description: Rest element following elision elements (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 { + *method([, ...x] = iter) {} +}; +var c = new C(); + +assert.throws(Test262Error, function() { + c.method(); +}); diff --git a/test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-rest-id-elision.js b/test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-rest-id-elision.js new file mode 100644 index 0000000000..948f050d56 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-rest-id-elision.js @@ -0,0 +1,90 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision.case +// - src/dstr-binding/default/cls-expr-gen-meth-dflt.template +/*--- +description: Rest element following elision elements (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + ArrayBindingPattern : [ Elisionopt BindingRestElement ] + 1. If Elision is present, then + a. Let status be the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with + iteratorRecord as the argument. + b. ReturnIfAbrupt(status). + 2. Return the result of performing IteratorBindingInitialization for + BindingRestElement with iteratorRecord and environment as arguments. +---*/ +var values = [1, 2, 3, 4, 5]; + +var callCount = 0; +var C = class { + *method([ , , ...x] = values) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 3); + assert.sameValue(x[1], 4); + assert.sameValue(x[2], 5); + assert.notSameValue(x, values); + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-rest-id-exhausted.js b/test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-rest-id-exhausted.js new file mode 100644 index 0000000000..44e6da0cb8 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-rest-id-exhausted.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-exhausted.case +// - src/dstr-binding/default/cls-expr-gen-meth-dflt.template +/*--- +description: RestElement applied to an exhausted iterator (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [Symbol.iterator, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier, + environment). + 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat, + [...] + b. If iteratorRecord.[[done]] is true, then + i. If environment is undefined, return PutValue(lhs, A). + ii. Return InitializeReferencedBinding(lhs, A). + +---*/ + +var callCount = 0; +var C = class { + *method([, , ...x] = [1, 2]) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 0); + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-rest-id-iter-step-err.js b/test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-rest-id-iter-step-err.js new file mode 100644 index 0000000000..add399581e --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-rest-id-iter-step-err.js @@ -0,0 +1,95 @@ +// 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-gen-meth-dflt.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 { + *method([...x] = iter) {} +}; +var c = new C(); + +assert.throws(Test262Error, function() { + c.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-gen-meth-dflt-ary-ptrn-rest-id-iter-val-err.js b/test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-rest-id-iter-val-err.js new file mode 100644 index 0000000000..706d49fbb5 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-rest-id-iter-val-err.js @@ -0,0 +1,97 @@ +// 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-gen-meth-dflt.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [Symbol.iterator, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 { + *method([...x] = iter) {} +}; +var c = new C(); + +assert.throws(Test262Error, function() { + c.method(); +}); diff --git a/test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-rest-id.js b/test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-rest-id.js new file mode 100644 index 0000000000..2518d14f7e --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-rest-id.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id.case +// - src/dstr-binding/default/cls-expr-gen-meth-dflt.template +/*--- +description: Lone rest element (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + [...] 3. Let A be ArrayCreate(0). [...] 5. Repeat + [...] + f. Let status be CreateDataProperty(A, ToString (n), nextValue). + [...] +---*/ +var values = [1, 2, 3]; + +var callCount = 0; +var C = class { + *method([...x] = values) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 1); + assert.sameValue(x[1], 2); + assert.sameValue(x[2], 3); + assert.notSameValue(x, values); + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-rest-init-ary.js b/test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-rest-init-ary.js new file mode 100644 index 0000000000..2315149861 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-rest-init-ary.js @@ -0,0 +1,81 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-ary.case +// - src/dstr-binding/default/cls-expr-gen-meth-dflt.template +/*--- +description: Reset element (nested array pattern) does not support initializer (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +negative: SyntaxError +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +var C = class { + *method([...[ x ] = []] = []) { + + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-rest-init-id.js b/test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-rest-init-id.js new file mode 100644 index 0000000000..f83d0e588b --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-rest-init-id.js @@ -0,0 +1,81 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-id.case +// - src/dstr-binding/default/cls-expr-gen-meth-dflt.template +/*--- +description: Reset element (identifier) does not support initializer (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +negative: SyntaxError +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +var C = class { + *method([...x = []] = []) { + + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-rest-init-obj.js b/test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-rest-init-obj.js new file mode 100644 index 0000000000..55ccba416a --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-rest-init-obj.js @@ -0,0 +1,81 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-obj.case +// - src/dstr-binding/default/cls-expr-gen-meth-dflt.template +/*--- +description: Reset element (nested object pattern) does not support initializer (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +negative: SyntaxError +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +var C = class { + *method([...{ x } = []] = []) { + + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-rest-not-final-ary.js b/test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-rest-not-final-ary.js new file mode 100644 index 0000000000..80070d8f03 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-rest-not-final-ary.js @@ -0,0 +1,81 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-ary.case +// - src/dstr-binding/default/cls-expr-gen-meth-dflt.template +/*--- +description: Rest element (array binding pattern) may not be followed by any element (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +negative: SyntaxError +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +var C = class { + *method([...[x], y] = [1, 2, 3]) { + + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-rest-not-final-id.js b/test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-rest-not-final-id.js new file mode 100644 index 0000000000..da97778617 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-rest-not-final-id.js @@ -0,0 +1,81 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-id.case +// - src/dstr-binding/default/cls-expr-gen-meth-dflt.template +/*--- +description: Rest element (identifier) may not be followed by any element (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +negative: SyntaxError +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +var C = class { + *method([...x, y] = [1, 2, 3]) { + + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-rest-not-final-obj.js b/test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-rest-not-final-obj.js new file mode 100644 index 0000000000..f567a2a913 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-rest-not-final-obj.js @@ -0,0 +1,81 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-obj.case +// - src/dstr-binding/default/cls-expr-gen-meth-dflt.template +/*--- +description: Rest element (object binding pattern) may not be followed by any element (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +negative: SyntaxError +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +var C = class { + *method([...{ x }, y] = [1, 2, 3]) { + + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-rest-obj-id.js b/test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-rest-obj-id.js new file mode 100644 index 0000000000..260d91c083 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-rest-obj-id.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-obj-id.case +// - src/dstr-binding/default/cls-expr-gen-meth-dflt.template +/*--- +description: Rest element containing an object binding pattern (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ + +var callCount = 0; +var C = class { + *method([...{ length }] = [1, 2, 3]) { + assert.sameValue(length, 3); + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-rest-obj-prop-id.js b/test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-rest-obj-prop-id.js new file mode 100644 index 0000000000..732d662e49 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-dflt-ary-ptrn-rest-obj-prop-id.js @@ -0,0 +1,95 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-obj-prop-id.case +// - src/dstr-binding/default/cls-expr-gen-meth-dflt.template +/*--- +description: Rest element containing an object binding pattern (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ + +var callCount = 0; +var C = class { + *method([...{ 0: v, 1: w, 2: x, 3: y, length: z }] = [7, 8, 9]) { + assert.sameValue(v, 7); + assert.sameValue(w, 8); + assert.sameValue(x, 9); + assert.sameValue(y, undefined); + assert.sameValue(z, 3); + + assert.throws(ReferenceError, function() { + length; + }); + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-dflt-obj-init-null.js b/test/language/expressions/class/dstr-gen-meth-dflt-obj-init-null.js new file mode 100644 index 0000000000..1aff6a1410 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-dflt-obj-init-null.js @@ -0,0 +1,78 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-null.case +// - src/dstr-binding/error/cls-expr-gen-meth-dflt.template +/*--- +description: Value specifed for object binding pattern must be object coercible (null) (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + +var C = class { + *method({} = null) {} +}; +var c = new C(); + +assert.throws(TypeError, function() { + c.method(); +}); diff --git a/test/language/expressions/class/dstr-gen-meth-dflt-obj-init-undefined.js b/test/language/expressions/class/dstr-gen-meth-dflt-obj-init-undefined.js new file mode 100644 index 0000000000..b69a7a96d1 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-dflt-obj-init-undefined.js @@ -0,0 +1,78 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-undefined.case +// - src/dstr-binding/error/cls-expr-gen-meth-dflt.template +/*--- +description: Value specifed for object binding pattern must be object coercible (undefined) (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + +var C = class { + *method({} = undefined) {} +}; +var c = new C(); + +assert.throws(TypeError, function() { + c.method(); +}); diff --git a/test/language/expressions/class/dstr-gen-meth-dflt-obj-ptrn-empty.js b/test/language/expressions/class/dstr-gen-meth-dflt-obj-ptrn-empty.js new file mode 100644 index 0000000000..02e1770e81 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-dflt-obj-ptrn-empty.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-empty.case +// - src/dstr-binding/default/cls-expr-gen-meth-dflt.template +/*--- +description: No property access occurs for an "empty" object binding pattern (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ +var accessCount = 0; +var obj = Object.defineProperty({}, 'attr', { + get: function() { + accessCount += 1; + } +}); + +var callCount = 0; +var C = class { + *method({} = obj) { + assert.sameValue(accessCount, 0); + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-dflt-obj-ptrn-id-get-value-err.js b/test/language/expressions/class/dstr-gen-meth-dflt-obj-ptrn-id-get-value-err.js new file mode 100644 index 0000000000..5800d000b8 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-dflt-obj-ptrn-id-get-value-err.js @@ -0,0 +1,85 @@ +// 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-gen-meth-dflt.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 { + *method({ poisoned } = poisonedProperty) {} +}; +var c = new C(); + +assert.throws(Test262Error, function() { + c.method(); +}); diff --git a/test/language/expressions/class/dstr-gen-meth-dflt-obj-ptrn-id-init-fn-name-arrow.js b/test/language/expressions/class/dstr-gen-meth-dflt-obj-ptrn-id-init-fn-name-arrow.js new file mode 100644 index 0000000000..22cbe3b001 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-dflt-obj-ptrn-id-init-fn-name-arrow.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-arrow.case +// - src/dstr-binding/default/cls-expr-gen-meth-dflt.template +/*--- +description: SingleNameBinding assigns `name` to arrow functions (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +var C = class { + *method({ arrow = () => {} } = {}) { + assert.sameValue(arrow.name, 'arrow'); + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-dflt-obj-ptrn-id-init-fn-name-class.js b/test/language/expressions/class/dstr-gen-meth-dflt-obj-ptrn-id-init-fn-name-class.js new file mode 100644 index 0000000000..c7a2a2d4d2 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-dflt-obj-ptrn-id-init-fn-name-class.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-class.case +// - src/dstr-binding/default/cls-expr-gen-meth-dflt.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +var C = class { + *method({ cls = class {}, xCls = class X {} } = {}) { + assert.sameValue(cls.name, 'cls'); + assert.notSameValue(xCls.name, 'xCls'); + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-dflt-obj-ptrn-id-init-fn-name-cover.js b/test/language/expressions/class/dstr-gen-meth-dflt-obj-ptrn-id-init-fn-name-cover.js new file mode 100644 index 0000000000..86f7db7941 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-dflt-obj-ptrn-id-init-fn-name-cover.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-cover.case +// - src/dstr-binding/default/cls-expr-gen-meth-dflt.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" functions "through" cover grammar (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +var C = class { + *method({ cover = (function () {}), xCover = (0, function() {}) } = {}) { + assert.sameValue(cover.name, 'cover'); + assert.notSameValue(xCover.name, 'xCover'); + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-dflt-obj-ptrn-id-init-fn-name-fn.js b/test/language/expressions/class/dstr-gen-meth-dflt-obj-ptrn-id-init-fn-name-fn.js new file mode 100644 index 0000000000..c0b5a7a7d2 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-dflt-obj-ptrn-id-init-fn-name-fn.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-fn.case +// - src/dstr-binding/default/cls-expr-gen-meth-dflt.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +var C = class { + *method({ fn = function () {}, xFn = function x() {} } = {}) { + assert.sameValue(fn.name, 'fn'); + assert.notSameValue(xFn.name, 'xFn'); + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-dflt-obj-ptrn-id-init-fn-name-gen.js b/test/language/expressions/class/dstr-gen-meth-dflt-obj-ptrn-id-init-fn-name-gen.js new file mode 100644 index 0000000000..eb1df5b800 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-dflt-obj-ptrn-id-init-fn-name-gen.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-gen.case +// - src/dstr-binding/default/cls-expr-gen-meth-dflt.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +var C = class { + *method({ gen = function* () {}, xGen = function* x() {} } = {}) { + assert.sameValue(gen.name, 'gen'); + assert.notSameValue(xGen.name, 'xGen'); + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-dflt-obj-ptrn-id-init-skipped.js b/test/language/expressions/class/dstr-gen-meth-dflt-obj-ptrn-id-init-skipped.js new file mode 100644 index 0000000000..5d45cdaabe --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-dflt-obj-ptrn-id-init-skipped.js @@ -0,0 +1,91 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-skipped.case +// - src/dstr-binding/default/cls-expr-gen-meth-dflt.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + [...] +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var callCount = 0; +var C = class { + *method({ w = counter(), x = counter(), y = counter(), z = counter() } = { w: null, x: 0, y: false, z: '' }) { + assert.sameValue(w, null); + assert.sameValue(x, 0); + assert.sameValue(y, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-dflt-obj-ptrn-id-init-throws.js b/test/language/expressions/class/dstr-gen-meth-dflt-obj-ptrn-id-init-throws.js new file mode 100644 index 0000000000..2aa4c95429 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-dflt-obj-ptrn-id-init-throws.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-throws.case +// - src/dstr-binding/error/cls-expr-gen-meth-dflt.template +/*--- +description: Error thrown when evaluating the initializer (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 { + *method({ x = thrower() } = {}) {} +}; +var c = new C(); + +assert.throws(Test262Error, function() { + c.method(); +}); diff --git a/test/language/expressions/class/dstr-gen-meth-dflt-obj-ptrn-id-init-unresolvable.js b/test/language/expressions/class/dstr-gen-meth-dflt-obj-ptrn-id-init-unresolvable.js new file mode 100644 index 0000000000..567c0ecddb --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-dflt-obj-ptrn-id-init-unresolvable.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-unresolvable.case +// - src/dstr-binding/error/cls-expr-gen-meth-dflt.template +/*--- +description: Destructuring initializer is an unresolvable reference (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 { + *method({ x = unresolvableReference } = {}) {} +}; +var c = new C(); + +assert.throws(ReferenceError, function() { + c.method(); +}); diff --git a/test/language/expressions/class/dstr-gen-meth-dflt-obj-ptrn-id-trailing-comma.js b/test/language/expressions/class/dstr-gen-meth-dflt-obj-ptrn-id-trailing-comma.js new file mode 100644 index 0000000000..1b22895006 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-dflt-obj-ptrn-id-trailing-comma.js @@ -0,0 +1,81 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-trailing-comma.case +// - src/dstr-binding/default/cls-expr-gen-meth-dflt.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var callCount = 0; +var C = class { + *method({ x, } = { x: 23 }) { + assert.sameValue(x, 23); + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-dflt-obj-ptrn-list-err.js b/test/language/expressions/class/dstr-gen-meth-dflt-obj-ptrn-list-err.js new file mode 100644 index 0000000000..beb528d28e --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-dflt-obj-ptrn-list-err.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-list-err.case +// - src/dstr-binding/error/cls-expr-gen-meth-dflt.template +/*--- +description: Binding property list evaluation is interrupted by an abrupt completion (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 { + *method({ a, b = thrower(), c = ++initCount } = {}) {} +}; +var c = new C(); + +assert.throws(Test262Error, function() { + c.method(); +}); + +assert.sameValue(initCount, 0); diff --git a/test/language/expressions/class/dstr-gen-meth-dflt-obj-ptrn-prop-ary-init.js b/test/language/expressions/class/dstr-gen-meth-dflt-obj-ptrn-prop-ary-init.js new file mode 100644 index 0000000000..ca3ff9ba3c --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-dflt-obj-ptrn-prop-ary-init.js @@ -0,0 +1,90 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-init.case +// - src/dstr-binding/default/cls-expr-gen-meth-dflt.template +/*--- +description: Object binding pattern with "nested" array binding pattern using initializer (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +var C = class { + *method({ w: [x, y, z] = [4, 5, 6] } = {}) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-dflt-obj-ptrn-prop-ary-trailing-comma.js b/test/language/expressions/class/dstr-gen-meth-dflt-obj-ptrn-prop-ary-trailing-comma.js new file mode 100644 index 0000000000..ab1a9ae881 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-dflt-obj-ptrn-prop-ary-trailing-comma.js @@ -0,0 +1,81 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-trailing-comma.case +// - src/dstr-binding/default/cls-expr-gen-meth-dflt.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var callCount = 0; +var C = class { + *method({ x: [y], } = { x: [45] }) { + assert.sameValue(y,45); + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-dflt-obj-ptrn-prop-ary-value-null.js b/test/language/expressions/class/dstr-gen-meth-dflt-obj-ptrn-prop-ary-value-null.js new file mode 100644 index 0000000000..c874bfd3bf --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-dflt-obj-ptrn-prop-ary-value-null.js @@ -0,0 +1,80 @@ +// 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-gen-meth-dflt.template +/*--- +description: Object binding pattern with "nested" array binding pattern taking the `null` value (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 { + *method({ w: [x, y, z] = [4, 5, 6] } = { w: null }) {} +}; +var c = new C(); + +assert.throws(TypeError, function() { + c.method(); +}); diff --git a/test/language/expressions/class/dstr-gen-meth-dflt-obj-ptrn-prop-ary.js b/test/language/expressions/class/dstr-gen-meth-dflt-obj-ptrn-prop-ary.js new file mode 100644 index 0000000000..a3e2c0edc1 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-dflt-obj-ptrn-prop-ary.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary.case +// - src/dstr-binding/default/cls-expr-gen-meth-dflt.template +/*--- +description: Object binding pattern with "nested" array binding pattern not using initializer (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +var C = class { + *method({ w: [x, y, z] = [4, 5, 6] } = { w: [7, undefined, ] }) { + assert.sameValue(x, 7); + assert.sameValue(y, undefined); + assert.sameValue(z, undefined); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-dflt-obj-ptrn-prop-eval-err.js b/test/language/expressions/class/dstr-gen-meth-dflt-obj-ptrn-prop-eval-err.js new file mode 100644 index 0000000000..4ee40778f8 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-dflt-obj-ptrn-prop-eval-err.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-eval-err.case +// - src/dstr-binding/error/cls-expr-gen-meth-dflt.template +/*--- +description: Evaluation of property name returns an abrupt completion (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 { + *method({ [thrower()]: x } = {}) {} +}; +var c = new C(); + +assert.throws(Test262Error, function() { + c.method(); +}); diff --git a/test/language/expressions/class/dstr-gen-meth-dflt-obj-ptrn-prop-id-get-value-err.js b/test/language/expressions/class/dstr-gen-meth-dflt-obj-ptrn-prop-id-get-value-err.js new file mode 100644 index 0000000000..b06248f4f6 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-dflt-obj-ptrn-prop-id-get-value-err.js @@ -0,0 +1,87 @@ +// 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-gen-meth-dflt.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 { + *method({ poisoned: x = ++initEvalCount } = poisonedProperty) {} +}; +var c = new C(); + +assert.throws(Test262Error, function() { + c.method(); +}); + +assert.sameValue(initEvalCount, 0); diff --git a/test/language/expressions/class/dstr-gen-meth-dflt-obj-ptrn-prop-id-init-skipped.js b/test/language/expressions/class/dstr-gen-meth-dflt-obj-ptrn-prop-id-init-skipped.js new file mode 100644 index 0000000000..ebfa2c6aa0 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-dflt-obj-ptrn-prop-id-init-skipped.js @@ -0,0 +1,103 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-skipped.case +// - src/dstr-binding/default/cls-expr-gen-meth-dflt.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + [...] +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var callCount = 0; +var C = class { + *method({ s: t = counter(), u: v = counter(), w: x = counter(), y: z = counter() } = { s: null, u: 0, w: false, y: '' }) { + assert.sameValue(t, null); + assert.sameValue(v, 0); + assert.sameValue(x, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + + assert.throws(ReferenceError, function() { + s; + }); + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-dflt-obj-ptrn-prop-id-init-throws.js b/test/language/expressions/class/dstr-gen-meth-dflt-obj-ptrn-prop-id-init-throws.js new file mode 100644 index 0000000000..76e5e738cc --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-dflt-obj-ptrn-prop-id-init-throws.js @@ -0,0 +1,85 @@ +// 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-gen-meth-dflt.template +/*--- +description: Error thrown when evaluating the initializer (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 { + *method({ x: y = thrower() } = {}) {} +}; +var c = new C(); + +assert.throws(Test262Error, function() { + c.method(); +}); diff --git a/test/language/expressions/class/dstr-gen-meth-dflt-obj-ptrn-prop-id-init-unresolvable.js b/test/language/expressions/class/dstr-gen-meth-dflt-obj-ptrn-prop-id-init-unresolvable.js new file mode 100644 index 0000000000..a93b613ec7 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-dflt-obj-ptrn-prop-id-init-unresolvable.js @@ -0,0 +1,89 @@ +// 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-gen-meth-dflt.template +/*--- +description: Destructuring initializer is an unresolvable reference (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 { + *method({ x: y = unresolvableReference } = {}) {} +}; +var c = new C(); + +assert.throws(ReferenceError, function() { + c.method(); +}); diff --git a/test/language/expressions/class/dstr-gen-meth-dflt-obj-ptrn-prop-id-init.js b/test/language/expressions/class/dstr-gen-meth-dflt-obj-ptrn-prop-id-init.js new file mode 100644 index 0000000000..dc090c89ea --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-dflt-obj-ptrn-prop-id-init.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init.case +// - src/dstr-binding/default/cls-expr-gen-meth-dflt.template +/*--- +description: Binding as specified via property name, identifier, and initializer (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var C = class { + *method({ x: y = 33 } = { }) { + assert.sameValue(y, 33); + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-dflt-obj-ptrn-prop-id-trailing-comma.js b/test/language/expressions/class/dstr-gen-meth-dflt-obj-ptrn-prop-id-trailing-comma.js new file mode 100644 index 0000000000..a42a191280 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-dflt-obj-ptrn-prop-id-trailing-comma.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-trailing-comma.case +// - src/dstr-binding/default/cls-expr-gen-meth-dflt.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var callCount = 0; +var C = class { + *method({ x: y, } = { x: 23 }) { + assert.sameValue(y, 23); + + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-dflt-obj-ptrn-prop-id.js b/test/language/expressions/class/dstr-gen-meth-dflt-obj-ptrn-prop-id.js new file mode 100644 index 0000000000..6eabd4be86 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-dflt-obj-ptrn-prop-id.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id.case +// - src/dstr-binding/default/cls-expr-gen-meth-dflt.template +/*--- +description: Binding as specified via property name and identifier (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var C = class { + *method({ x: y } = { x: 23 }) { + assert.sameValue(y, 23); + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-dflt-obj-ptrn-prop-obj-init.js b/test/language/expressions/class/dstr-gen-meth-dflt-obj-ptrn-prop-obj-init.js new file mode 100644 index 0000000000..473f6185e3 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-dflt-obj-ptrn-prop-obj-init.js @@ -0,0 +1,90 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-init.case +// - src/dstr-binding/default/cls-expr-gen-meth-dflt.template +/*--- +description: Object binding pattern with "nested" object binding pattern using initializer (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +var C = class { + *method({ w: { x, y, z } = { x: 4, y: 5, z: 6 } } = { w: undefined }) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-dflt-obj-ptrn-prop-obj-value-null.js b/test/language/expressions/class/dstr-gen-meth-dflt-obj-ptrn-prop-obj-value-null.js new file mode 100644 index 0000000000..7e480412ab --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-dflt-obj-ptrn-prop-obj-value-null.js @@ -0,0 +1,80 @@ +// 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-gen-meth-dflt.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 { + *method({ w: { x, y, z } = { x: 4, y: 5, z: 6 } } = { w: null }) {} +}; +var c = new C(); + +assert.throws(TypeError, function() { + c.method(); +}); diff --git a/test/language/expressions/class/dstr-gen-meth-dflt-obj-ptrn-prop-obj-value-undef.js b/test/language/expressions/class/dstr-gen-meth-dflt-obj-ptrn-prop-obj-value-undef.js new file mode 100644 index 0000000000..c53dcdd371 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-dflt-obj-ptrn-prop-obj-value-undef.js @@ -0,0 +1,80 @@ +// 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-gen-meth-dflt.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 { + *method({ w: { x, y, z } = undefined } = { }) {} +}; +var c = new C(); + +assert.throws(TypeError, function() { + c.method(); +}); diff --git a/test/language/expressions/class/dstr-gen-meth-dflt-obj-ptrn-prop-obj.js b/test/language/expressions/class/dstr-gen-meth-dflt-obj-ptrn-prop-obj.js new file mode 100644 index 0000000000..9872afb5d6 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-dflt-obj-ptrn-prop-obj.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj.case +// - src/dstr-binding/default/cls-expr-gen-meth-dflt.template +/*--- +description: Object binding pattern with "nested" object binding pattern not using initializer (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +var C = class { + *method({ w: { x, y, z } = { x: 4, y: 5, z: 6 } } = { w: { x: undefined, z: 7 } }) { + assert.sameValue(x, undefined); + assert.sameValue(y, undefined); + assert.sameValue(z, 7); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-init-iter-close.js b/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-init-iter-close.js new file mode 100644 index 0000000000..b781bb7e1a --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-init-iter-close.js @@ -0,0 +1,97 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-close.case +// - src/dstr-binding/default/cls-expr-gen-meth-static-dflt.template +/*--- +description: Iterator is closed when not exhausted by pattern evaluation (static class expression generator method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [Symbol.iterator, destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + [...] + 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator, + result). + [...] + +---*/ +var doneCallCount = 0; +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return { value: null, done: false }; + }, + return: function() { + doneCallCount += 1; + return {}; + } + }; +}; + +var callCount = 0; +var C = class { + static *method([x] = iter) { + assert.sameValue(doneCallCount, 1); + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-init-iter-get-err.js b/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-init-iter-get-err.js new file mode 100644 index 0000000000..89d07e3dda --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-init-iter-get-err.js @@ -0,0 +1,83 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-get-err.case +// - src/dstr-binding/error/cls-expr-gen-meth-static-dflt.template +/*--- +description: Abrupt completion returned by GetIterator (static class expression generator method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [Symbol.iterator, destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 *method([x] = iter) {} +}; + +assert.throws(Test262Error, function() { + C.method(); +}); diff --git a/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-init-iter-no-close.js b/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-init-iter-no-close.js new file mode 100644 index 0000000000..5748e6082a --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-init-iter-no-close.js @@ -0,0 +1,97 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-no-close.case +// - src/dstr-binding/default/cls-expr-gen-meth-static-dflt.template +/*--- +description: Iterator is not closed when exhausted by pattern evaluation (static class expression generator method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [Symbol.iterator, destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + [...] + 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator, + result). + [...] + +---*/ +var doneCallCount = 0; +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return { value: null, done: true }; + }, + return: function() { + doneCallCount += 1; + return {}; + } + }; +}; + +var callCount = 0; +var C = class { + static *method([x] = iter) { + assert.sameValue(doneCallCount, 0); + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-name-iter-val.js b/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-name-iter-val.js new file mode 100644 index 0000000000..dffc01152b --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-name-iter-val.js @@ -0,0 +1,96 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-name-iter-val.case +// - src/dstr-binding/default/cls-expr-gen-meth-static-dflt.template +/*--- +description: SingleNameBinding with normal value iteration (static class expression generator method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set + iteratorRecord.[[done]] to true. + iii. ReturnIfAbrupt(v). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var C = class { + static *method([x, y, z] = [1, 2, 3]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 3); + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-ary-elem-init.js b/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-ary-elem-init.js new file mode 100644 index 0000000000..6717d46c78 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-ary-elem-init.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elem-init.case +// - src/dstr-binding/default/cls-expr-gen-meth-static-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is used (static class expression generator method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +var C = class { + static *method([[x, y, z] = [4, 5, 6]] = []) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-ary-elem-iter.js b/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-ary-elem-iter.js new file mode 100644 index 0000000000..27b7467eda --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-ary-elem-iter.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elem-iter.case +// - src/dstr-binding/default/cls-expr-gen-meth-static-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (static class expression generator method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +var C = class { + static *method([[x, y, z] = [4, 5, 6]] = [[7, 8, 9]]) { + assert.sameValue(x, 7); + assert.sameValue(y, 8); + assert.sameValue(z, 9); + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-ary-elision-init.js b/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-ary-elision-init.js new file mode 100644 index 0000000000..b0a3866a69 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-ary-elision-init.js @@ -0,0 +1,95 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elision-init.case +// - src/dstr-binding/default/cls-expr-gen-meth-static-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is used (static class expression generator method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [generators, destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var callCount = 0; +var C = class { + static *method([[,] = g()] = []) { + assert.sameValue(first, 1); + assert.sameValue(second, 0); + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-ary-elision-iter.js b/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-ary-elision-iter.js new file mode 100644 index 0000000000..56ed0ddfab --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-ary-elision-iter.js @@ -0,0 +1,92 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elision-iter.case +// - src/dstr-binding/default/cls-expr-gen-meth-static-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (static class expression generator method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [generators, destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var callCount = 0; +function* g() { + callCount += 1; +}; + +var callCount = 0; +var C = class { + static *method([[,] = g()] = [[]]) { + assert.sameValue(callCount, 0); + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-ary-empty-init.js b/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-ary-empty-init.js new file mode 100644 index 0000000000..61af0230de --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-ary-empty-init.js @@ -0,0 +1,90 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-empty-init.case +// - src/dstr-binding/default/cls-expr-gen-meth-static-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is used (static class expression generator method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var initCount = 0; +var iterCount = 0; +var iter = function*() { iterCount += 1; }(); + +var callCount = 0; +var C = class { + static *method([[] = function() { initCount += 1; return iter; }()] = []) { + assert.sameValue(initCount, 1); + assert.sameValue(iterCount, 0); + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-ary-empty-iter.js b/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-ary-empty-iter.js new file mode 100644 index 0000000000..2b4492bb4b --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-ary-empty-iter.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-empty-iter.case +// - src/dstr-binding/default/cls-expr-gen-meth-static-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (static class expression generator method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var initCount = 0; + +var callCount = 0; +var C = class { + static *method([[] = function() { initCount += 1; }()] = [[23]]) { + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-ary-rest-init.js b/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-ary-rest-init.js new file mode 100644 index 0000000000..4f89c895f6 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-ary-rest-init.js @@ -0,0 +1,92 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-rest-init.case +// - src/dstr-binding/default/cls-expr-gen-meth-static-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is used (static class expression generator method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var values = [2, 1, 3]; + +var callCount = 0; +var C = class { + static *method([[...x] = values] = []) { + assert(Array.isArray(x)); + assert.sameValue(x[0], 2); + assert.sameValue(x[1], 1); + assert.sameValue(x[2], 3); + assert.sameValue(x.length, 3); + assert.notSameValue(x, values); + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-ary-rest-iter.js b/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-ary-rest-iter.js new file mode 100644 index 0000000000..d6575d32b3 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-ary-rest-iter.js @@ -0,0 +1,95 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-rest-iter.case +// - src/dstr-binding/default/cls-expr-gen-meth-static-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (static class expression generator method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var values = [2, 1, 3]; +var initCount = 0; + +var callCount = 0; +var C = class { + static *method([[...x] = function() { initCount += 1; }()] = [values]) { + assert(Array.isArray(x)); + assert.sameValue(x[0], 2); + assert.sameValue(x[1], 1); + assert.sameValue(x[2], 3); + assert.sameValue(x.length, 3); + assert.notSameValue(x, values); + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-ary-val-null.js b/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-ary-val-null.js new file mode 100644 index 0000000000..ab30c0295f --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-ary-val-null.js @@ -0,0 +1,90 @@ +// 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-gen-meth-static-dflt.template +/*--- +description: Nested array destructuring with a null value (static class expression generator method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 *method([[x]] = [null]) {} +}; + +assert.throws(TypeError, function() { + C.method(); +}); diff --git a/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-id-init-exhausted.js b/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-id-init-exhausted.js new file mode 100644 index 0000000000..f895f84408 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-id-init-exhausted.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-exhausted.case +// - src/dstr-binding/default/cls-expr-gen-meth-static-dflt.template +/*--- +description: Destructuring initializer with an exhausted iterator (static class expression generator method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var C = class { + static *method([x = 23] = []) { + assert.sameValue(x, 23); + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-arrow.js b/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-arrow.js new file mode 100644 index 0000000000..0de7c850ce --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-arrow.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-arrow.case +// - src/dstr-binding/default/cls-expr-gen-meth-static-dflt.template +/*--- +description: SingleNameBinding does assign name to arrow functions (static class expression generator method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var C = class { + static *method([arrow = () => {}] = []) { + assert.sameValue(arrow.name, 'arrow'); + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-class.js b/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-class.js new file mode 100644 index 0000000000..c3b75da5fc --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-class.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-class.case +// - src/dstr-binding/default/cls-expr-gen-meth-static-dflt.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (static class expression generator method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var C = class { + static *method([cls = class {}, xCls = class X {}] = []) { + assert.sameValue(cls.name, 'cls'); + assert.notSameValue(xCls.name, 'xCls'); + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-cover.js b/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-cover.js new file mode 100644 index 0000000000..96a0d2af20 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-cover.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-cover.case +// - src/dstr-binding/default/cls-expr-gen-meth-static-dflt.template +/*--- +description: SingleNameBinding does assign name to "anonymous" functions "through" cover grammar (static class expression generator method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var C = class { + static *method([cover = (function () {}), xCover = (0, function() {})] = []) { + assert.sameValue(cover.name, 'cover'); + assert.notSameValue(xCover.name, 'xCover'); + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-fn.js b/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-fn.js new file mode 100644 index 0000000000..77cec8416b --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-fn.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-fn.case +// - src/dstr-binding/default/cls-expr-gen-meth-static-dflt.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (static class expression generator method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var C = class { + static *method([fn = function () {}, xFn = function x() {}] = []) { + assert.sameValue(fn.name, 'fn'); + assert.notSameValue(xFn.name, 'xFn'); + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-gen.js b/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-gen.js new file mode 100644 index 0000000000..146f538f3d --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-gen.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-gen.case +// - src/dstr-binding/default/cls-expr-gen-meth-static-dflt.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (static class expression generator method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var C = class { + static *method([gen = function* () {}, xGen = function* x() {}] = []) { + assert.sameValue(gen.name, 'gen'); + assert.notSameValue(xGen.name, 'xGen'); + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-id-init-hole.js b/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-id-init-hole.js new file mode 100644 index 0000000000..b006b2d714 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-id-init-hole.js @@ -0,0 +1,83 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-hole.case +// - src/dstr-binding/default/cls-expr-gen-meth-static-dflt.template +/*--- +description: Destructuring initializer with a "hole" (static class expression generator method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + SingleNameBinding : BindingIdentifier Initializeropt + [...] 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + [...] + 7. If environment is undefined, return PutValue(lhs, v). 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var C = class { + static *method([x = 23] = [,]) { + assert.sameValue(x, 23); + // another statement + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-id-init-skipped.js b/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-id-init-skipped.js new file mode 100644 index 0000000000..40d6954590 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-id-init-skipped.js @@ -0,0 +1,92 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-skipped.case +// - src/dstr-binding/default/cls-expr-gen-meth-static-dflt.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (static class expression generator method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var callCount = 0; +var C = class { + static *method([w = counter(), x = counter(), y = counter(), z = counter()] = [null, 0, false, '']) { + assert.sameValue(w, null); + assert.sameValue(x, 0); + assert.sameValue(y, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-id-init-throws.js b/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-id-init-throws.js new file mode 100644 index 0000000000..8bed6e5d2b --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-id-init-throws.js @@ -0,0 +1,81 @@ +// 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-gen-meth-static-dflt.template +/*--- +description: Destructuring initializer returns an abrupt completion (static class expression generator method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 *method([x = (function() { throw new Test262Error(); })()] = [undefined]) {} +}; + +assert.throws(Test262Error, function() { + C.method(); +}); diff --git a/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-id-init-undef.js b/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-id-init-undef.js new file mode 100644 index 0000000000..41b93806ef --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-id-init-undef.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-undef.case +// - src/dstr-binding/default/cls-expr-gen-meth-static-dflt.template +/*--- +description: Destructuring initializer with an undefined value (static class expression generator method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var C = class { + static *method([x = 23] = [undefined]) { + assert.sameValue(x, 23); + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-id-init-unresolvable.js b/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-id-init-unresolvable.js new file mode 100644 index 0000000000..1c9202de2e --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-id-init-unresolvable.js @@ -0,0 +1,88 @@ +// 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-gen-meth-static-dflt.template +/*--- +description: Destructuring initializer is an unresolvable reference (static class expression generator method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 *method([ x = unresolvableReference ] = []) {} +}; + +assert.throws(ReferenceError, function() { + C.method(); +}); diff --git a/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-id-iter-complete.js b/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-id-iter-complete.js new file mode 100644 index 0000000000..897c2a023a --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-id-iter-complete.js @@ -0,0 +1,90 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-complete.case +// - src/dstr-binding/default/cls-expr-gen-meth-static-dflt.template +/*--- +description: SingleNameBinding when value iteration completes (static class expression generator method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var C = class { + static *method([x] = []) { + assert.sameValue(x, undefined); + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-id-iter-done.js b/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-id-iter-done.js new file mode 100644 index 0000000000..2a5e4615c8 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-id-iter-done.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-done.case +// - src/dstr-binding/default/cls-expr-gen-meth-static-dflt.template +/*--- +description: SingleNameBinding when value iteration was completed previously (static class expression generator method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var C = class { + static *method([_, x] = []) { + assert.sameValue(x, undefined); + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-id-iter-step-err.js b/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-id-iter-step-err.js new file mode 100644 index 0000000000..4b40f416c8 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-id-iter-step-err.js @@ -0,0 +1,89 @@ +// 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-gen-meth-static-dflt.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (static class expression generator method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 *method([x] = g) {} +}; + +assert.throws(Test262Error, function() { + C.method(); +}); diff --git a/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-id-iter-val-err.js b/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-id-iter-val-err.js new file mode 100644 index 0000000000..979439b46f --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-id-iter-val-err.js @@ -0,0 +1,100 @@ +// 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-gen-meth-static-dflt.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (static class expression generator method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 *method([x] = g) {} +}; + +assert.throws(Test262Error, function() { + C.method(); +}); diff --git a/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-id-iter-val.js b/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-id-iter-val.js new file mode 100644 index 0000000000..b5ed63acc8 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-id-iter-val.js @@ -0,0 +1,96 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val.case +// - src/dstr-binding/default/cls-expr-gen-meth-static-dflt.template +/*--- +description: SingleNameBinding when value iteration was completed previously (static class expression generator method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set + iteratorRecord.[[done]] to true. + iii. ReturnIfAbrupt(v). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var C = class { + static *method([x, y, z] = [1, 2, 3]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 3); + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-obj-id-init.js b/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-obj-id-init.js new file mode 100644 index 0000000000..0bb492c796 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-obj-id-init.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-id-init.case +// - src/dstr-binding/default/cls-expr-gen-meth-static-dflt.template +/*--- +description: BindingElement with object binding pattern and initializer is used (static class expression generator method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +var C = class { + static *method([{ x, y, z } = { x: 44, y: 55, z: 66 }] = []) { + assert.sameValue(x, 44); + assert.sameValue(y, 55); + assert.sameValue(z, 66); + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-obj-id.js b/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-obj-id.js new file mode 100644 index 0000000000..1a0459234e --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-obj-id.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-id.case +// - src/dstr-binding/default/cls-expr-gen-meth-static-dflt.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (static class expression generator method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +var C = class { + static *method([{ x, y, z } = { x: 44, y: 55, z: 66 }] = [{ x: 11, y: 22, z: 33 }]) { + assert.sameValue(x, 11); + assert.sameValue(y, 22); + assert.sameValue(z, 33); + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-obj-prop-id-init.js b/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-obj-prop-id-init.js new file mode 100644 index 0000000000..4c98a45189 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-obj-prop-id-init.js @@ -0,0 +1,98 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-prop-id-init.case +// - src/dstr-binding/default/cls-expr-gen-meth-static-dflt.template +/*--- +description: BindingElement with object binding pattern and initializer is used (static class expression generator method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +var C = class { + static *method([{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }] = []) { + assert.sameValue(v, 444); + assert.sameValue(x, 555); + assert.sameValue(z, 666); + + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-obj-prop-id.js b/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-obj-prop-id.js new file mode 100644 index 0000000000..436c528725 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-obj-prop-id.js @@ -0,0 +1,98 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-prop-id.case +// - src/dstr-binding/default/cls-expr-gen-meth-static-dflt.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (static class expression generator method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +var C = class { + static *method([{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }] = [{ u: 777, w: 888, y: 999 }]) { + assert.sameValue(v, 777); + assert.sameValue(x, 888); + assert.sameValue(z, 999); + + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-obj-val-null.js b/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-obj-val-null.js new file mode 100644 index 0000000000..01068ecfbf --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-obj-val-null.js @@ -0,0 +1,90 @@ +// 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-gen-meth-static-dflt.template +/*--- +description: Nested object destructuring with a null value (static class expression generator method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 *method([{ x }] = [null]) {} +}; + +assert.throws(TypeError, function() { + C.method(); +}); diff --git a/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-obj-val-undef.js b/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-obj-val-undef.js new file mode 100644 index 0000000000..c5701430c2 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-obj-val-undef.js @@ -0,0 +1,90 @@ +// 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-gen-meth-static-dflt.template +/*--- +description: Nested object destructuring with a value of `undefined` (static class expression generator method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 *method([{ x }] = []) {} +}; + +assert.throws(TypeError, function() { + C.method(); +}); diff --git a/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-elision-exhausted.js b/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-elision-exhausted.js new file mode 100644 index 0000000000..1da4f38388 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-elision-exhausted.js @@ -0,0 +1,93 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-exhausted.case +// - src/dstr-binding/default/cls-expr-gen-meth-static-dflt.template +/*--- +description: Elision accepts exhausted iterator (static class expression generator method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [generator, destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + [...] + 2. Return NormalCompletion(empty). + +---*/ +var iter = function*() {}(); +iter.next(); + +var callCount = 0; +var C = class { + static *method([,] = iter) { + + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-elision-step-err.js b/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-elision-step-err.js new file mode 100644 index 0000000000..5c5ae10c2e --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-elision-step-err.js @@ -0,0 +1,97 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-step-err.case +// - src/dstr-binding/error/cls-expr-gen-meth-static-dflt.template +/*--- +description: Elision advances iterator and forwards abrupt completions (static class expression generator method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [generator, destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 *method([,] = iter) {} +}; + +assert.throws(Test262Error, function() { + C.method(); +}); + +iter.next(); +assert.sameValue(following, 0, 'Iterator was properly closed.'); diff --git a/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-elision.js b/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-elision.js new file mode 100644 index 0000000000..b86cbe98e3 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-elision.js @@ -0,0 +1,102 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision.case +// - src/dstr-binding/default/cls-expr-gen-meth-static-dflt.template +/*--- +description: Elision advances iterator (static class expression generator method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [generator, destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + 2. Return NormalCompletion(empty). + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var callCount = 0; +var C = class { + static *method([,] = g()) { + assert.sameValue(first, 1); + assert.sameValue(second, 0); + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-empty.js b/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-empty.js new file mode 100644 index 0000000000..ee27b3244d --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-empty.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-empty.case +// - src/dstr-binding/default/cls-expr-gen-meth-static-dflt.template +/*--- +description: No iteration occurs for an "empty" array binding pattern (static class expression generator method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [generators, destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ ] + + 1. Return NormalCompletion(empty). + +---*/ +var iterations = 0; +var iter = function*() { + iterations += 1; +}(); + +var callCount = 0; +var C = class { + static *method([] = iter) { + assert.sameValue(iterations, 0); + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-rest-ary-elem.js b/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-rest-ary-elem.js new file mode 100644 index 0000000000..27a0f206c9 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-rest-ary-elem.js @@ -0,0 +1,109 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-elem.case +// - src/dstr-binding/default/cls-expr-gen-meth-static-dflt.template +/*--- +description: Rest element containing an array BindingElementList pattern (static class expression generator method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set + iteratorRecord.[[done]] to true. + iii. ReturnIfAbrupt(v). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var C = class { + static *method([...[x, y, z]] = [3, 4, 5]) { + assert.sameValue(x, 3); + assert.sameValue(y, 4); + assert.sameValue(z, 5); + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-rest-ary-elision.js b/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-rest-ary-elision.js new file mode 100644 index 0000000000..a7e2cb735d --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-rest-ary-elision.js @@ -0,0 +1,115 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-elision.case +// - src/dstr-binding/default/cls-expr-gen-meth-static-dflt.template +/*--- +description: Rest element containing an elision (static class expression generator method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [generators, destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + 2. Return NormalCompletion(empty). + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var callCount = 0; +var C = class { + static *method([...[,]] = g()) { + assert.sameValue(first, 1); + assert.sameValue(second, 1); + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-rest-ary-empty.js b/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-rest-ary-empty.js new file mode 100644 index 0000000000..fcc26dd6e9 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-rest-ary-empty.js @@ -0,0 +1,98 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-empty.case +// - src/dstr-binding/default/cls-expr-gen-meth-static-dflt.template +/*--- +description: Rest element containing an "empty" array pattern (static class expression generator method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [generators, destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ ] + + 1. Return NormalCompletion(empty). + +---*/ +var iterations = 0; +var iter = function*() { + iterations += 1; +}(); + +var callCount = 0; +var C = class { + static *method([...[]] = iter) { + assert.sameValue(iterations, 1); + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-rest-ary-rest.js b/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-rest-ary-rest.js new file mode 100644 index 0000000000..d1004dedcf --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-rest-ary-rest.js @@ -0,0 +1,94 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-rest.case +// - src/dstr-binding/default/cls-expr-gen-meth-static-dflt.template +/*--- +description: Rest element containing a rest element (static class expression generator method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ +var values = [1, 2, 3]; + +var callCount = 0; +var C = class { + static *method([...[...x]] = values) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 1); + assert.sameValue(x[1], 2); + assert.sameValue(x[2], 3); + assert.notSameValue(x, values); + + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-rest-id-elision-next-err.js b/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-rest-id-elision-next-err.js new file mode 100644 index 0000000000..1634e689b6 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-rest-id-elision-next-err.js @@ -0,0 +1,83 @@ +// 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-gen-meth-static-dflt.template +/*--- +description: Rest element following elision elements (static class expression generator method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [generators, destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 *method([, ...x] = iter) {} +}; + +assert.throws(Test262Error, function() { + C.method(); +}); diff --git a/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-rest-id-elision.js b/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-rest-id-elision.js new file mode 100644 index 0000000000..646ca4f0ae --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-rest-id-elision.js @@ -0,0 +1,90 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision.case +// - src/dstr-binding/default/cls-expr-gen-meth-static-dflt.template +/*--- +description: Rest element following elision elements (static class expression generator method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + ArrayBindingPattern : [ Elisionopt BindingRestElement ] + 1. If Elision is present, then + a. Let status be the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with + iteratorRecord as the argument. + b. ReturnIfAbrupt(status). + 2. Return the result of performing IteratorBindingInitialization for + BindingRestElement with iteratorRecord and environment as arguments. +---*/ +var values = [1, 2, 3, 4, 5]; + +var callCount = 0; +var C = class { + static *method([ , , ...x] = values) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 3); + assert.sameValue(x[1], 4); + assert.sameValue(x[2], 5); + assert.notSameValue(x, values); + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-rest-id-exhausted.js b/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-rest-id-exhausted.js new file mode 100644 index 0000000000..69d79e5ac4 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-rest-id-exhausted.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-exhausted.case +// - src/dstr-binding/default/cls-expr-gen-meth-static-dflt.template +/*--- +description: RestElement applied to an exhausted iterator (static class expression generator method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [Symbol.iterator, destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier, + environment). + 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat, + [...] + b. If iteratorRecord.[[done]] is true, then + i. If environment is undefined, return PutValue(lhs, A). + ii. Return InitializeReferencedBinding(lhs, A). + +---*/ + +var callCount = 0; +var C = class { + static *method([, , ...x] = [1, 2]) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 0); + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-rest-id-iter-step-err.js b/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-rest-id-iter-step-err.js new file mode 100644 index 0000000000..9c5815d618 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-rest-id-iter-step-err.js @@ -0,0 +1,94 @@ +// 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-gen-meth-static-dflt.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (static class expression generator method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [generators, destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 *method([...x] = iter) {} +}; + +assert.throws(Test262Error, function() { + C.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-gen-meth-static-dflt-ary-ptrn-rest-id-iter-val-err.js b/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-rest-id-iter-val-err.js new file mode 100644 index 0000000000..aa351c7dc5 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-rest-id-iter-val-err.js @@ -0,0 +1,96 @@ +// 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-gen-meth-static-dflt.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (static class expression generator method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [Symbol.iterator, destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 *method([...x] = iter) {} +}; + +assert.throws(Test262Error, function() { + C.method(); +}); diff --git a/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-rest-id.js b/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-rest-id.js new file mode 100644 index 0000000000..f6cc057b57 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-rest-id.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id.case +// - src/dstr-binding/default/cls-expr-gen-meth-static-dflt.template +/*--- +description: Lone rest element (static class expression generator method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + [...] 3. Let A be ArrayCreate(0). [...] 5. Repeat + [...] + f. Let status be CreateDataProperty(A, ToString (n), nextValue). + [...] +---*/ +var values = [1, 2, 3]; + +var callCount = 0; +var C = class { + static *method([...x] = values) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 1); + assert.sameValue(x[1], 2); + assert.sameValue(x[2], 3); + assert.notSameValue(x, values); + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-rest-init-ary.js b/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-rest-init-ary.js new file mode 100644 index 0000000000..4a391cacce --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-rest-init-ary.js @@ -0,0 +1,81 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-ary.case +// - src/dstr-binding/default/cls-expr-gen-meth-static-dflt.template +/*--- +description: Reset element (nested array pattern) does not support initializer (static class expression generator method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +negative: SyntaxError +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation + for m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +var C = class { + static *method([...[ x ] = []] = []) { + + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-rest-init-id.js b/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-rest-init-id.js new file mode 100644 index 0000000000..dbc1fc0a0c --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-rest-init-id.js @@ -0,0 +1,81 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-id.case +// - src/dstr-binding/default/cls-expr-gen-meth-static-dflt.template +/*--- +description: Reset element (identifier) does not support initializer (static class expression generator method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +negative: SyntaxError +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation + for m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +var C = class { + static *method([...x = []] = []) { + + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-rest-init-obj.js b/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-rest-init-obj.js new file mode 100644 index 0000000000..671fd4247f --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-rest-init-obj.js @@ -0,0 +1,81 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-obj.case +// - src/dstr-binding/default/cls-expr-gen-meth-static-dflt.template +/*--- +description: Reset element (nested object pattern) does not support initializer (static class expression generator method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +negative: SyntaxError +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation + for m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +var C = class { + static *method([...{ x } = []] = []) { + + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-rest-not-final-ary.js b/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-rest-not-final-ary.js new file mode 100644 index 0000000000..a902340322 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-rest-not-final-ary.js @@ -0,0 +1,81 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-ary.case +// - src/dstr-binding/default/cls-expr-gen-meth-static-dflt.template +/*--- +description: Rest element (array binding pattern) may not be followed by any element (static class expression generator method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +negative: SyntaxError +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation + for m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +var C = class { + static *method([...[x], y] = [1, 2, 3]) { + + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-rest-not-final-id.js b/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-rest-not-final-id.js new file mode 100644 index 0000000000..b709bb2404 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-rest-not-final-id.js @@ -0,0 +1,81 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-id.case +// - src/dstr-binding/default/cls-expr-gen-meth-static-dflt.template +/*--- +description: Rest element (identifier) may not be followed by any element (static class expression generator method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +negative: SyntaxError +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation + for m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +var C = class { + static *method([...x, y] = [1, 2, 3]) { + + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-rest-not-final-obj.js b/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-rest-not-final-obj.js new file mode 100644 index 0000000000..07add9b7ee --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-rest-not-final-obj.js @@ -0,0 +1,81 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-obj.case +// - src/dstr-binding/default/cls-expr-gen-meth-static-dflt.template +/*--- +description: Rest element (object binding pattern) may not be followed by any element (static class expression generator method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +negative: SyntaxError +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation + for m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +var C = class { + static *method([...{ x }, y] = [1, 2, 3]) { + + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-rest-obj-id.js b/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-rest-obj-id.js new file mode 100644 index 0000000000..b4d48e8924 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-rest-obj-id.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-obj-id.case +// - src/dstr-binding/default/cls-expr-gen-meth-static-dflt.template +/*--- +description: Rest element containing an object binding pattern (static class expression generator method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ + +var callCount = 0; +var C = class { + static *method([...{ length }] = [1, 2, 3]) { + assert.sameValue(length, 3); + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-rest-obj-prop-id.js b/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-rest-obj-prop-id.js new file mode 100644 index 0000000000..4d3741bc65 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-dflt-ary-ptrn-rest-obj-prop-id.js @@ -0,0 +1,95 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-obj-prop-id.case +// - src/dstr-binding/default/cls-expr-gen-meth-static-dflt.template +/*--- +description: Rest element containing an object binding pattern (static class expression generator method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ + +var callCount = 0; +var C = class { + static *method([...{ 0: v, 1: w, 2: x, 3: y, length: z }] = [7, 8, 9]) { + assert.sameValue(v, 7); + assert.sameValue(w, 8); + assert.sameValue(x, 9); + assert.sameValue(y, undefined); + assert.sameValue(z, 3); + + assert.throws(ReferenceError, function() { + length; + }); + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-static-dflt-obj-init-null.js b/test/language/expressions/class/dstr-gen-meth-static-dflt-obj-init-null.js new file mode 100644 index 0000000000..3644d4e90f --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-dflt-obj-init-null.js @@ -0,0 +1,77 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-null.case +// - src/dstr-binding/error/cls-expr-gen-meth-static-dflt.template +/*--- +description: Value specifed for object binding pattern must be object coercible (null) (static class expression generator method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + +var C = class { + static *method({} = null) {} +}; + +assert.throws(TypeError, function() { + C.method(); +}); diff --git a/test/language/expressions/class/dstr-gen-meth-static-dflt-obj-init-undefined.js b/test/language/expressions/class/dstr-gen-meth-static-dflt-obj-init-undefined.js new file mode 100644 index 0000000000..6396ae7403 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-dflt-obj-init-undefined.js @@ -0,0 +1,77 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-undefined.case +// - src/dstr-binding/error/cls-expr-gen-meth-static-dflt.template +/*--- +description: Value specifed for object binding pattern must be object coercible (undefined) (static class expression generator method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + +var C = class { + static *method({} = undefined) {} +}; + +assert.throws(TypeError, function() { + C.method(); +}); diff --git a/test/language/expressions/class/dstr-gen-meth-static-dflt-obj-ptrn-empty.js b/test/language/expressions/class/dstr-gen-meth-static-dflt-obj-ptrn-empty.js new file mode 100644 index 0000000000..54b92d2a1f --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-dflt-obj-ptrn-empty.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-empty.case +// - src/dstr-binding/default/cls-expr-gen-meth-static-dflt.template +/*--- +description: No property access occurs for an "empty" object binding pattern (static class expression generator method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ +var accessCount = 0; +var obj = Object.defineProperty({}, 'attr', { + get: function() { + accessCount += 1; + } +}); + +var callCount = 0; +var C = class { + static *method({} = obj) { + assert.sameValue(accessCount, 0); + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-static-dflt-obj-ptrn-id-get-value-err.js b/test/language/expressions/class/dstr-gen-meth-static-dflt-obj-ptrn-id-get-value-err.js new file mode 100644 index 0000000000..64fb0dde5d --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-dflt-obj-ptrn-id-get-value-err.js @@ -0,0 +1,84 @@ +// 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-gen-meth-static-dflt.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (static class expression generator method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 *method({ poisoned } = poisonedProperty) {} +}; + +assert.throws(Test262Error, function() { + C.method(); +}); diff --git a/test/language/expressions/class/dstr-gen-meth-static-dflt-obj-ptrn-id-init-fn-name-arrow.js b/test/language/expressions/class/dstr-gen-meth-static-dflt-obj-ptrn-id-init-fn-name-arrow.js new file mode 100644 index 0000000000..5737b12bd8 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-dflt-obj-ptrn-id-init-fn-name-arrow.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-arrow.case +// - src/dstr-binding/default/cls-expr-gen-meth-static-dflt.template +/*--- +description: SingleNameBinding assigns `name` to arrow functions (static class expression generator method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +var C = class { + static *method({ arrow = () => {} } = {}) { + assert.sameValue(arrow.name, 'arrow'); + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-static-dflt-obj-ptrn-id-init-fn-name-class.js b/test/language/expressions/class/dstr-gen-meth-static-dflt-obj-ptrn-id-init-fn-name-class.js new file mode 100644 index 0000000000..6f343be628 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-dflt-obj-ptrn-id-init-fn-name-class.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-class.case +// - src/dstr-binding/default/cls-expr-gen-meth-static-dflt.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (static class expression generator method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +var C = class { + static *method({ cls = class {}, xCls = class X {} } = {}) { + assert.sameValue(cls.name, 'cls'); + assert.notSameValue(xCls.name, 'xCls'); + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-static-dflt-obj-ptrn-id-init-fn-name-cover.js b/test/language/expressions/class/dstr-gen-meth-static-dflt-obj-ptrn-id-init-fn-name-cover.js new file mode 100644 index 0000000000..0cd868faeb --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-dflt-obj-ptrn-id-init-fn-name-cover.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-cover.case +// - src/dstr-binding/default/cls-expr-gen-meth-static-dflt.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" functions "through" cover grammar (static class expression generator method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +var C = class { + static *method({ cover = (function () {}), xCover = (0, function() {}) } = {}) { + assert.sameValue(cover.name, 'cover'); + assert.notSameValue(xCover.name, 'xCover'); + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-static-dflt-obj-ptrn-id-init-fn-name-fn.js b/test/language/expressions/class/dstr-gen-meth-static-dflt-obj-ptrn-id-init-fn-name-fn.js new file mode 100644 index 0000000000..79d4f11b5f --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-dflt-obj-ptrn-id-init-fn-name-fn.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-fn.case +// - src/dstr-binding/default/cls-expr-gen-meth-static-dflt.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (static class expression generator method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +var C = class { + static *method({ fn = function () {}, xFn = function x() {} } = {}) { + assert.sameValue(fn.name, 'fn'); + assert.notSameValue(xFn.name, 'xFn'); + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-static-dflt-obj-ptrn-id-init-fn-name-gen.js b/test/language/expressions/class/dstr-gen-meth-static-dflt-obj-ptrn-id-init-fn-name-gen.js new file mode 100644 index 0000000000..652f36dc28 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-dflt-obj-ptrn-id-init-fn-name-gen.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-gen.case +// - src/dstr-binding/default/cls-expr-gen-meth-static-dflt.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (static class expression generator method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +var C = class { + static *method({ gen = function* () {}, xGen = function* x() {} } = {}) { + assert.sameValue(gen.name, 'gen'); + assert.notSameValue(xGen.name, 'xGen'); + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-static-dflt-obj-ptrn-id-init-skipped.js b/test/language/expressions/class/dstr-gen-meth-static-dflt-obj-ptrn-id-init-skipped.js new file mode 100644 index 0000000000..9afc1abf96 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-dflt-obj-ptrn-id-init-skipped.js @@ -0,0 +1,91 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-skipped.case +// - src/dstr-binding/default/cls-expr-gen-meth-static-dflt.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (static class expression generator method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + [...] +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var callCount = 0; +var C = class { + static *method({ w = counter(), x = counter(), y = counter(), z = counter() } = { w: null, x: 0, y: false, z: '' }) { + assert.sameValue(w, null); + assert.sameValue(x, 0); + assert.sameValue(y, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-static-dflt-obj-ptrn-id-init-throws.js b/test/language/expressions/class/dstr-gen-meth-static-dflt-obj-ptrn-id-init-throws.js new file mode 100644 index 0000000000..f827603e03 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-dflt-obj-ptrn-id-init-throws.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-throws.case +// - src/dstr-binding/error/cls-expr-gen-meth-static-dflt.template +/*--- +description: Error thrown when evaluating the initializer (static class expression generator method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 *method({ x = thrower() } = {}) {} +}; + +assert.throws(Test262Error, function() { + C.method(); +}); diff --git a/test/language/expressions/class/dstr-gen-meth-static-dflt-obj-ptrn-id-init-unresolvable.js b/test/language/expressions/class/dstr-gen-meth-static-dflt-obj-ptrn-id-init-unresolvable.js new file mode 100644 index 0000000000..08ed1c3c48 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-dflt-obj-ptrn-id-init-unresolvable.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-unresolvable.case +// - src/dstr-binding/error/cls-expr-gen-meth-static-dflt.template +/*--- +description: Destructuring initializer is an unresolvable reference (static class expression generator method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 *method({ x = unresolvableReference } = {}) {} +}; + +assert.throws(ReferenceError, function() { + C.method(); +}); diff --git a/test/language/expressions/class/dstr-gen-meth-static-dflt-obj-ptrn-id-trailing-comma.js b/test/language/expressions/class/dstr-gen-meth-static-dflt-obj-ptrn-id-trailing-comma.js new file mode 100644 index 0000000000..3ca13d770b --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-dflt-obj-ptrn-id-trailing-comma.js @@ -0,0 +1,81 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-trailing-comma.case +// - src/dstr-binding/default/cls-expr-gen-meth-static-dflt.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (static class expression generator method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var callCount = 0; +var C = class { + static *method({ x, } = { x: 23 }) { + assert.sameValue(x, 23); + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-static-dflt-obj-ptrn-list-err.js b/test/language/expressions/class/dstr-gen-meth-static-dflt-obj-ptrn-list-err.js new file mode 100644 index 0000000000..933841417c --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-dflt-obj-ptrn-list-err.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-list-err.case +// - src/dstr-binding/error/cls-expr-gen-meth-static-dflt.template +/*--- +description: Binding property list evaluation is interrupted by an abrupt completion (static class expression generator method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 *method({ a, b = thrower(), c = ++initCount } = {}) {} +}; + +assert.throws(Test262Error, function() { + C.method(); +}); + +assert.sameValue(initCount, 0); diff --git a/test/language/expressions/class/dstr-gen-meth-static-dflt-obj-ptrn-prop-ary-init.js b/test/language/expressions/class/dstr-gen-meth-static-dflt-obj-ptrn-prop-ary-init.js new file mode 100644 index 0000000000..bff15eda57 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-dflt-obj-ptrn-prop-ary-init.js @@ -0,0 +1,90 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-init.case +// - src/dstr-binding/default/cls-expr-gen-meth-static-dflt.template +/*--- +description: Object binding pattern with "nested" array binding pattern using initializer (static class expression generator method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +var C = class { + static *method({ w: [x, y, z] = [4, 5, 6] } = {}) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-static-dflt-obj-ptrn-prop-ary-trailing-comma.js b/test/language/expressions/class/dstr-gen-meth-static-dflt-obj-ptrn-prop-ary-trailing-comma.js new file mode 100644 index 0000000000..6022779eac --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-dflt-obj-ptrn-prop-ary-trailing-comma.js @@ -0,0 +1,81 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-trailing-comma.case +// - src/dstr-binding/default/cls-expr-gen-meth-static-dflt.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (static class expression generator method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var callCount = 0; +var C = class { + static *method({ x: [y], } = { x: [45] }) { + assert.sameValue(y,45); + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-static-dflt-obj-ptrn-prop-ary-value-null.js b/test/language/expressions/class/dstr-gen-meth-static-dflt-obj-ptrn-prop-ary-value-null.js new file mode 100644 index 0000000000..7e87084d8b --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-dflt-obj-ptrn-prop-ary-value-null.js @@ -0,0 +1,79 @@ +// 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-gen-meth-static-dflt.template +/*--- +description: Object binding pattern with "nested" array binding pattern taking the `null` value (static class expression generator method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 *method({ w: [x, y, z] = [4, 5, 6] } = { w: null }) {} +}; + +assert.throws(TypeError, function() { + C.method(); +}); diff --git a/test/language/expressions/class/dstr-gen-meth-static-dflt-obj-ptrn-prop-ary.js b/test/language/expressions/class/dstr-gen-meth-static-dflt-obj-ptrn-prop-ary.js new file mode 100644 index 0000000000..53992c64e7 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-dflt-obj-ptrn-prop-ary.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary.case +// - src/dstr-binding/default/cls-expr-gen-meth-static-dflt.template +/*--- +description: Object binding pattern with "nested" array binding pattern not using initializer (static class expression generator method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +var C = class { + static *method({ w: [x, y, z] = [4, 5, 6] } = { w: [7, undefined, ] }) { + assert.sameValue(x, 7); + assert.sameValue(y, undefined); + assert.sameValue(z, undefined); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-static-dflt-obj-ptrn-prop-eval-err.js b/test/language/expressions/class/dstr-gen-meth-static-dflt-obj-ptrn-prop-eval-err.js new file mode 100644 index 0000000000..957abff41f --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-dflt-obj-ptrn-prop-eval-err.js @@ -0,0 +1,81 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-eval-err.case +// - src/dstr-binding/error/cls-expr-gen-meth-static-dflt.template +/*--- +description: Evaluation of property name returns an abrupt completion (static class expression generator method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 *method({ [thrower()]: x } = {}) {} +}; + +assert.throws(Test262Error, function() { + C.method(); +}); diff --git a/test/language/expressions/class/dstr-gen-meth-static-dflt-obj-ptrn-prop-id-get-value-err.js b/test/language/expressions/class/dstr-gen-meth-static-dflt-obj-ptrn-prop-id-get-value-err.js new file mode 100644 index 0000000000..d2a64a431c --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-dflt-obj-ptrn-prop-id-get-value-err.js @@ -0,0 +1,86 @@ +// 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-gen-meth-static-dflt.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (static class expression generator method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 *method({ poisoned: x = ++initEvalCount } = poisonedProperty) {} +}; + +assert.throws(Test262Error, function() { + C.method(); +}); + +assert.sameValue(initEvalCount, 0); diff --git a/test/language/expressions/class/dstr-gen-meth-static-dflt-obj-ptrn-prop-id-init-skipped.js b/test/language/expressions/class/dstr-gen-meth-static-dflt-obj-ptrn-prop-id-init-skipped.js new file mode 100644 index 0000000000..e1f7c98718 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-dflt-obj-ptrn-prop-id-init-skipped.js @@ -0,0 +1,103 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-skipped.case +// - src/dstr-binding/default/cls-expr-gen-meth-static-dflt.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (static class expression generator method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + [...] +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var callCount = 0; +var C = class { + static *method({ s: t = counter(), u: v = counter(), w: x = counter(), y: z = counter() } = { s: null, u: 0, w: false, y: '' }) { + assert.sameValue(t, null); + assert.sameValue(v, 0); + assert.sameValue(x, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + + assert.throws(ReferenceError, function() { + s; + }); + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-static-dflt-obj-ptrn-prop-id-init-throws.js b/test/language/expressions/class/dstr-gen-meth-static-dflt-obj-ptrn-prop-id-init-throws.js new file mode 100644 index 0000000000..47d1612bc4 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-dflt-obj-ptrn-prop-id-init-throws.js @@ -0,0 +1,84 @@ +// 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-gen-meth-static-dflt.template +/*--- +description: Error thrown when evaluating the initializer (static class expression generator method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 *method({ x: y = thrower() } = {}) {} +}; + +assert.throws(Test262Error, function() { + C.method(); +}); diff --git a/test/language/expressions/class/dstr-gen-meth-static-dflt-obj-ptrn-prop-id-init-unresolvable.js b/test/language/expressions/class/dstr-gen-meth-static-dflt-obj-ptrn-prop-id-init-unresolvable.js new file mode 100644 index 0000000000..6c7272f1a8 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-dflt-obj-ptrn-prop-id-init-unresolvable.js @@ -0,0 +1,88 @@ +// 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-gen-meth-static-dflt.template +/*--- +description: Destructuring initializer is an unresolvable reference (static class expression generator method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 *method({ x: y = unresolvableReference } = {}) {} +}; + +assert.throws(ReferenceError, function() { + C.method(); +}); diff --git a/test/language/expressions/class/dstr-gen-meth-static-dflt-obj-ptrn-prop-id-init.js b/test/language/expressions/class/dstr-gen-meth-static-dflt-obj-ptrn-prop-id-init.js new file mode 100644 index 0000000000..d4312c0ba0 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-dflt-obj-ptrn-prop-id-init.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init.case +// - src/dstr-binding/default/cls-expr-gen-meth-static-dflt.template +/*--- +description: Binding as specified via property name, identifier, and initializer (static class expression generator method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var C = class { + static *method({ x: y = 33 } = { }) { + assert.sameValue(y, 33); + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-static-dflt-obj-ptrn-prop-id-trailing-comma.js b/test/language/expressions/class/dstr-gen-meth-static-dflt-obj-ptrn-prop-id-trailing-comma.js new file mode 100644 index 0000000000..0ec19be6f4 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-dflt-obj-ptrn-prop-id-trailing-comma.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-trailing-comma.case +// - src/dstr-binding/default/cls-expr-gen-meth-static-dflt.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (static class expression generator method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var callCount = 0; +var C = class { + static *method({ x: y, } = { x: 23 }) { + assert.sameValue(y, 23); + + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-static-dflt-obj-ptrn-prop-id.js b/test/language/expressions/class/dstr-gen-meth-static-dflt-obj-ptrn-prop-id.js new file mode 100644 index 0000000000..3c46c08466 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-dflt-obj-ptrn-prop-id.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id.case +// - src/dstr-binding/default/cls-expr-gen-meth-static-dflt.template +/*--- +description: Binding as specified via property name and identifier (static class expression generator method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var C = class { + static *method({ x: y } = { x: 23 }) { + assert.sameValue(y, 23); + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-static-dflt-obj-ptrn-prop-obj-init.js b/test/language/expressions/class/dstr-gen-meth-static-dflt-obj-ptrn-prop-obj-init.js new file mode 100644 index 0000000000..abc8d4c86e --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-dflt-obj-ptrn-prop-obj-init.js @@ -0,0 +1,90 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-init.case +// - src/dstr-binding/default/cls-expr-gen-meth-static-dflt.template +/*--- +description: Object binding pattern with "nested" object binding pattern using initializer (static class expression generator method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +var C = class { + static *method({ w: { x, y, z } = { x: 4, y: 5, z: 6 } } = { w: undefined }) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-gen-meth-static-dflt-obj-ptrn-prop-obj-value-null.js b/test/language/expressions/class/dstr-gen-meth-static-dflt-obj-ptrn-prop-obj-value-null.js new file mode 100644 index 0000000000..3d4ae8b65a --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-dflt-obj-ptrn-prop-obj-value-null.js @@ -0,0 +1,79 @@ +// 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-gen-meth-static-dflt.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (static class expression generator method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 *method({ w: { x, y, z } = { x: 4, y: 5, z: 6 } } = { w: null }) {} +}; + +assert.throws(TypeError, function() { + C.method(); +}); diff --git a/test/language/expressions/class/dstr-gen-meth-static-dflt-obj-ptrn-prop-obj-value-undef.js b/test/language/expressions/class/dstr-gen-meth-static-dflt-obj-ptrn-prop-obj-value-undef.js new file mode 100644 index 0000000000..ad4e55460f --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-dflt-obj-ptrn-prop-obj-value-undef.js @@ -0,0 +1,79 @@ +// 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-gen-meth-static-dflt.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (static class expression generator method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 *method({ w: { x, y, z } = undefined } = { }) {} +}; + +assert.throws(TypeError, function() { + C.method(); +}); diff --git a/test/language/expressions/class/dstr-gen-meth-static-dflt-obj-ptrn-prop-obj.js b/test/language/expressions/class/dstr-gen-meth-static-dflt-obj-ptrn-prop-obj.js new file mode 100644 index 0000000000..5f1da2e141 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-dflt-obj-ptrn-prop-obj.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj.case +// - src/dstr-binding/default/cls-expr-gen-meth-static-dflt.template +/*--- +description: Object binding pattern with "nested" object binding pattern not using initializer (static class expression generator method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +var C = class { + static *method({ w: { x, y, z } = { x: 4, y: 5, z: 6 } } = { w: { x: undefined, z: 7 } }) { + assert.sameValue(x, undefined); + assert.sameValue(y, undefined); + assert.sameValue(z, 7); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-dflt-ary-init-iter-close.js b/test/language/expressions/class/dstr-meth-dflt-ary-init-iter-close.js new file mode 100644 index 0000000000..4f8d734a78 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-dflt-ary-init-iter-close.js @@ -0,0 +1,94 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-close.case +// - src/dstr-binding/default/cls-expr-meth-dflt.template +/*--- +description: Iterator is closed when not exhausted by pattern evaluation (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [Symbol.iterator, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + [...] + 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator, + result). + [...] + +---*/ +var doneCallCount = 0; +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return { value: null, done: false }; + }, + return: function() { + doneCallCount += 1; + return {}; + } + }; +}; + +var callCount = 0; +var C = class { + method([x] = iter) { + assert.sameValue(doneCallCount, 1); + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-dflt-ary-init-iter-get-err.js b/test/language/expressions/class/dstr-meth-dflt-ary-init-iter-get-err.js new file mode 100644 index 0000000000..7f7d334b28 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-dflt-ary-init-iter-get-err.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-get-err.case +// - src/dstr-binding/error/cls-expr-meth-dflt.template +/*--- +description: Abrupt completion returned by GetIterator (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [Symbol.iterator, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 { + method([x] = iter) {} +}; + +var c = new C(); + +assert.throws(Test262Error, function() { + c.method(); +}); diff --git a/test/language/expressions/class/dstr-meth-dflt-ary-init-iter-no-close.js b/test/language/expressions/class/dstr-meth-dflt-ary-init-iter-no-close.js new file mode 100644 index 0000000000..a1f911c269 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-dflt-ary-init-iter-no-close.js @@ -0,0 +1,94 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-no-close.case +// - src/dstr-binding/default/cls-expr-meth-dflt.template +/*--- +description: Iterator is not closed when exhausted by pattern evaluation (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [Symbol.iterator, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + [...] + 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator, + result). + [...] + +---*/ +var doneCallCount = 0; +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return { value: null, done: true }; + }, + return: function() { + doneCallCount += 1; + return {}; + } + }; +}; + +var callCount = 0; +var C = class { + method([x] = iter) { + assert.sameValue(doneCallCount, 0); + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-dflt-ary-name-iter-val.js b/test/language/expressions/class/dstr-meth-dflt-ary-name-iter-val.js new file mode 100644 index 0000000000..93c6528881 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-dflt-ary-name-iter-val.js @@ -0,0 +1,93 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-name-iter-val.case +// - src/dstr-binding/default/cls-expr-meth-dflt.template +/*--- +description: SingleNameBinding with normal value iteration (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set + iteratorRecord.[[done]] to true. + iii. ReturnIfAbrupt(v). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var C = class { + method([x, y, z] = [1, 2, 3]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 3); + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-dflt-ary-ptrn-elem-ary-elem-init.js b/test/language/expressions/class/dstr-meth-dflt-ary-ptrn-elem-ary-elem-init.js new file mode 100644 index 0000000000..dd721c9542 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-dflt-ary-ptrn-elem-ary-elem-init.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elem-init.case +// - src/dstr-binding/default/cls-expr-meth-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is used (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +var C = class { + method([[x, y, z] = [4, 5, 6]] = []) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-dflt-ary-ptrn-elem-ary-elem-iter.js b/test/language/expressions/class/dstr-meth-dflt-ary-ptrn-elem-ary-elem-iter.js new file mode 100644 index 0000000000..ae219f8bea --- /dev/null +++ b/test/language/expressions/class/dstr-meth-dflt-ary-ptrn-elem-ary-elem-iter.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elem-iter.case +// - src/dstr-binding/default/cls-expr-meth-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +var C = class { + method([[x, y, z] = [4, 5, 6]] = [[7, 8, 9]]) { + assert.sameValue(x, 7); + assert.sameValue(y, 8); + assert.sameValue(z, 9); + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-dflt-ary-ptrn-elem-ary-elision-init.js b/test/language/expressions/class/dstr-meth-dflt-ary-ptrn-elem-ary-elision-init.js new file mode 100644 index 0000000000..62f5527d34 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-dflt-ary-ptrn-elem-ary-elision-init.js @@ -0,0 +1,92 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elision-init.case +// - src/dstr-binding/default/cls-expr-meth-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is used (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var callCount = 0; +var C = class { + method([[,] = g()] = []) { + assert.sameValue(first, 1); + assert.sameValue(second, 0); + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-dflt-ary-ptrn-elem-ary-elision-iter.js b/test/language/expressions/class/dstr-meth-dflt-ary-ptrn-elem-ary-elision-iter.js new file mode 100644 index 0000000000..74bc12df53 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-dflt-ary-ptrn-elem-ary-elision-iter.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elision-iter.case +// - src/dstr-binding/default/cls-expr-meth-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var callCount = 0; +function* g() { + callCount += 1; +}; + +var callCount = 0; +var C = class { + method([[,] = g()] = [[]]) { + assert.sameValue(callCount, 0); + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-dflt-ary-ptrn-elem-ary-empty-init.js b/test/language/expressions/class/dstr-meth-dflt-ary-ptrn-elem-ary-empty-init.js new file mode 100644 index 0000000000..80d63fec64 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-dflt-ary-ptrn-elem-ary-empty-init.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-empty-init.case +// - src/dstr-binding/default/cls-expr-meth-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is used (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var initCount = 0; +var iterCount = 0; +var iter = function*() { iterCount += 1; }(); + +var callCount = 0; +var C = class { + method([[] = function() { initCount += 1; return iter; }()] = []) { + assert.sameValue(initCount, 1); + assert.sameValue(iterCount, 0); + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-dflt-ary-ptrn-elem-ary-empty-iter.js b/test/language/expressions/class/dstr-meth-dflt-ary-ptrn-elem-ary-empty-iter.js new file mode 100644 index 0000000000..d54438a6bb --- /dev/null +++ b/test/language/expressions/class/dstr-meth-dflt-ary-ptrn-elem-ary-empty-iter.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-empty-iter.case +// - src/dstr-binding/default/cls-expr-meth-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var initCount = 0; + +var callCount = 0; +var C = class { + method([[] = function() { initCount += 1; }()] = [[23]]) { + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-dflt-ary-ptrn-elem-ary-rest-init.js b/test/language/expressions/class/dstr-meth-dflt-ary-ptrn-elem-ary-rest-init.js new file mode 100644 index 0000000000..0d6939ed2f --- /dev/null +++ b/test/language/expressions/class/dstr-meth-dflt-ary-ptrn-elem-ary-rest-init.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-rest-init.case +// - src/dstr-binding/default/cls-expr-meth-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is used (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var values = [2, 1, 3]; + +var callCount = 0; +var C = class { + method([[...x] = values] = []) { + assert(Array.isArray(x)); + assert.sameValue(x[0], 2); + assert.sameValue(x[1], 1); + assert.sameValue(x[2], 3); + assert.sameValue(x.length, 3); + assert.notSameValue(x, values); + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-dflt-ary-ptrn-elem-ary-rest-iter.js b/test/language/expressions/class/dstr-meth-dflt-ary-ptrn-elem-ary-rest-iter.js new file mode 100644 index 0000000000..386a893b6d --- /dev/null +++ b/test/language/expressions/class/dstr-meth-dflt-ary-ptrn-elem-ary-rest-iter.js @@ -0,0 +1,92 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-rest-iter.case +// - src/dstr-binding/default/cls-expr-meth-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var values = [2, 1, 3]; +var initCount = 0; + +var callCount = 0; +var C = class { + method([[...x] = function() { initCount += 1; }()] = [values]) { + assert(Array.isArray(x)); + assert.sameValue(x[0], 2); + assert.sameValue(x[1], 1); + assert.sameValue(x[2], 3); + assert.sameValue(x.length, 3); + assert.notSameValue(x, values); + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-dflt-ary-ptrn-elem-ary-val-null.js b/test/language/expressions/class/dstr-meth-dflt-ary-ptrn-elem-ary-val-null.js new file mode 100644 index 0000000000..ce8dd79337 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-dflt-ary-ptrn-elem-ary-val-null.js @@ -0,0 +1,89 @@ +// 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-meth-dflt.template +/*--- +description: Nested array destructuring with a null value (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 { + method([[x]] = [null]) {} +}; + +var c = new C(); + +assert.throws(TypeError, function() { + c.method(); +}); diff --git a/test/language/expressions/class/dstr-meth-dflt-ary-ptrn-elem-id-init-exhausted.js b/test/language/expressions/class/dstr-meth-dflt-ary-ptrn-elem-id-init-exhausted.js new file mode 100644 index 0000000000..a70eb23993 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-dflt-ary-ptrn-elem-id-init-exhausted.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-exhausted.case +// - src/dstr-binding/default/cls-expr-meth-dflt.template +/*--- +description: Destructuring initializer with an exhausted iterator (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var C = class { + method([x = 23] = []) { + assert.sameValue(x, 23); + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-dflt-ary-ptrn-elem-id-init-fn-name-arrow.js b/test/language/expressions/class/dstr-meth-dflt-ary-ptrn-elem-id-init-fn-name-arrow.js new file mode 100644 index 0000000000..d72c43292c --- /dev/null +++ b/test/language/expressions/class/dstr-meth-dflt-ary-ptrn-elem-id-init-fn-name-arrow.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-arrow.case +// - src/dstr-binding/default/cls-expr-meth-dflt.template +/*--- +description: SingleNameBinding does assign name to arrow functions (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var C = class { + method([arrow = () => {}] = []) { + assert.sameValue(arrow.name, 'arrow'); + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-dflt-ary-ptrn-elem-id-init-fn-name-class.js b/test/language/expressions/class/dstr-meth-dflt-ary-ptrn-elem-id-init-fn-name-class.js new file mode 100644 index 0000000000..e04cea08d0 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-dflt-ary-ptrn-elem-id-init-fn-name-class.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-class.case +// - src/dstr-binding/default/cls-expr-meth-dflt.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var C = class { + method([cls = class {}, xCls = class X {}] = []) { + assert.sameValue(cls.name, 'cls'); + assert.notSameValue(xCls.name, 'xCls'); + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-dflt-ary-ptrn-elem-id-init-fn-name-cover.js b/test/language/expressions/class/dstr-meth-dflt-ary-ptrn-elem-id-init-fn-name-cover.js new file mode 100644 index 0000000000..4511ea6e57 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-dflt-ary-ptrn-elem-id-init-fn-name-cover.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-cover.case +// - src/dstr-binding/default/cls-expr-meth-dflt.template +/*--- +description: SingleNameBinding does assign name to "anonymous" functions "through" cover grammar (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var C = class { + method([cover = (function () {}), xCover = (0, function() {})] = []) { + assert.sameValue(cover.name, 'cover'); + assert.notSameValue(xCover.name, 'xCover'); + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-dflt-ary-ptrn-elem-id-init-fn-name-fn.js b/test/language/expressions/class/dstr-meth-dflt-ary-ptrn-elem-id-init-fn-name-fn.js new file mode 100644 index 0000000000..4c3eb06ddd --- /dev/null +++ b/test/language/expressions/class/dstr-meth-dflt-ary-ptrn-elem-id-init-fn-name-fn.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-fn.case +// - src/dstr-binding/default/cls-expr-meth-dflt.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var C = class { + method([fn = function () {}, xFn = function x() {}] = []) { + assert.sameValue(fn.name, 'fn'); + assert.notSameValue(xFn.name, 'xFn'); + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-dflt-ary-ptrn-elem-id-init-fn-name-gen.js b/test/language/expressions/class/dstr-meth-dflt-ary-ptrn-elem-id-init-fn-name-gen.js new file mode 100644 index 0000000000..a4d6571b64 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-dflt-ary-ptrn-elem-id-init-fn-name-gen.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-gen.case +// - src/dstr-binding/default/cls-expr-meth-dflt.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var C = class { + method([gen = function* () {}, xGen = function* x() {}] = []) { + assert.sameValue(gen.name, 'gen'); + assert.notSameValue(xGen.name, 'xGen'); + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-dflt-ary-ptrn-elem-id-init-hole.js b/test/language/expressions/class/dstr-meth-dflt-ary-ptrn-elem-id-init-hole.js new file mode 100644 index 0000000000..aa3c93ae7e --- /dev/null +++ b/test/language/expressions/class/dstr-meth-dflt-ary-ptrn-elem-id-init-hole.js @@ -0,0 +1,80 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-hole.case +// - src/dstr-binding/default/cls-expr-meth-dflt.template +/*--- +description: Destructuring initializer with a "hole" (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + SingleNameBinding : BindingIdentifier Initializeropt + [...] 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + [...] + 7. If environment is undefined, return PutValue(lhs, v). 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var C = class { + method([x = 23] = [,]) { + assert.sameValue(x, 23); + // another statement + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-dflt-ary-ptrn-elem-id-init-skipped.js b/test/language/expressions/class/dstr-meth-dflt-ary-ptrn-elem-id-init-skipped.js new file mode 100644 index 0000000000..3c7f8e025b --- /dev/null +++ b/test/language/expressions/class/dstr-meth-dflt-ary-ptrn-elem-id-init-skipped.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-skipped.case +// - src/dstr-binding/default/cls-expr-meth-dflt.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var callCount = 0; +var C = class { + method([w = counter(), x = counter(), y = counter(), z = counter()] = [null, 0, false, '']) { + assert.sameValue(w, null); + assert.sameValue(x, 0); + assert.sameValue(y, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-dflt-ary-ptrn-elem-id-init-throws.js b/test/language/expressions/class/dstr-meth-dflt-ary-ptrn-elem-id-init-throws.js new file mode 100644 index 0000000000..f250556b80 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-dflt-ary-ptrn-elem-id-init-throws.js @@ -0,0 +1,80 @@ +// 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-meth-dflt.template +/*--- +description: Destructuring initializer returns an abrupt completion (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 { + method([x = (function() { throw new Test262Error(); })()] = [undefined]) {} +}; + +var c = new C(); + +assert.throws(Test262Error, function() { + c.method(); +}); diff --git a/test/language/expressions/class/dstr-meth-dflt-ary-ptrn-elem-id-init-undef.js b/test/language/expressions/class/dstr-meth-dflt-ary-ptrn-elem-id-init-undef.js new file mode 100644 index 0000000000..7f68be7eb8 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-dflt-ary-ptrn-elem-id-init-undef.js @@ -0,0 +1,83 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-undef.case +// - src/dstr-binding/default/cls-expr-meth-dflt.template +/*--- +description: Destructuring initializer with an undefined value (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var C = class { + method([x = 23] = [undefined]) { + assert.sameValue(x, 23); + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-dflt-ary-ptrn-elem-id-init-unresolvable.js b/test/language/expressions/class/dstr-meth-dflt-ary-ptrn-elem-id-init-unresolvable.js new file mode 100644 index 0000000000..c6dc329fb6 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-dflt-ary-ptrn-elem-id-init-unresolvable.js @@ -0,0 +1,87 @@ +// 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-meth-dflt.template +/*--- +description: Destructuring initializer is an unresolvable reference (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 { + method([ x = unresolvableReference ] = []) {} +}; + +var c = new C(); + +assert.throws(ReferenceError, function() { + c.method(); +}); diff --git a/test/language/expressions/class/dstr-meth-dflt-ary-ptrn-elem-id-iter-complete.js b/test/language/expressions/class/dstr-meth-dflt-ary-ptrn-elem-id-iter-complete.js new file mode 100644 index 0000000000..8f28a8b739 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-dflt-ary-ptrn-elem-id-iter-complete.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-complete.case +// - src/dstr-binding/default/cls-expr-meth-dflt.template +/*--- +description: SingleNameBinding when value iteration completes (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var C = class { + method([x] = []) { + assert.sameValue(x, undefined); + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-dflt-ary-ptrn-elem-id-iter-done.js b/test/language/expressions/class/dstr-meth-dflt-ary-ptrn-elem-id-iter-done.js new file mode 100644 index 0000000000..dc85571e41 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-dflt-ary-ptrn-elem-id-iter-done.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-done.case +// - src/dstr-binding/default/cls-expr-meth-dflt.template +/*--- +description: SingleNameBinding when value iteration was completed previously (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var C = class { + method([_, x] = []) { + assert.sameValue(x, undefined); + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-dflt-ary-ptrn-elem-id-iter-step-err.js b/test/language/expressions/class/dstr-meth-dflt-ary-ptrn-elem-id-iter-step-err.js new file mode 100644 index 0000000000..fa9c705add --- /dev/null +++ b/test/language/expressions/class/dstr-meth-dflt-ary-ptrn-elem-id-iter-step-err.js @@ -0,0 +1,88 @@ +// 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-meth-dflt.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 { + method([x] = g) {} +}; + +var c = new C(); + +assert.throws(Test262Error, function() { + c.method(); +}); diff --git a/test/language/expressions/class/dstr-meth-dflt-ary-ptrn-elem-id-iter-val-err.js b/test/language/expressions/class/dstr-meth-dflt-ary-ptrn-elem-id-iter-val-err.js new file mode 100644 index 0000000000..6a26ea83a9 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-dflt-ary-ptrn-elem-id-iter-val-err.js @@ -0,0 +1,99 @@ +// 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-meth-dflt.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 { + method([x] = g) {} +}; + +var c = new C(); + +assert.throws(Test262Error, function() { + c.method(); +}); diff --git a/test/language/expressions/class/dstr-meth-dflt-ary-ptrn-elem-id-iter-val.js b/test/language/expressions/class/dstr-meth-dflt-ary-ptrn-elem-id-iter-val.js new file mode 100644 index 0000000000..32cd2dd411 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-dflt-ary-ptrn-elem-id-iter-val.js @@ -0,0 +1,93 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val.case +// - src/dstr-binding/default/cls-expr-meth-dflt.template +/*--- +description: SingleNameBinding when value iteration was completed previously (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set + iteratorRecord.[[done]] to true. + iii. ReturnIfAbrupt(v). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var C = class { + method([x, y, z] = [1, 2, 3]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 3); + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-dflt-ary-ptrn-elem-obj-id-init.js b/test/language/expressions/class/dstr-meth-dflt-ary-ptrn-elem-obj-id-init.js new file mode 100644 index 0000000000..5b2288f612 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-dflt-ary-ptrn-elem-obj-id-init.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-id-init.case +// - src/dstr-binding/default/cls-expr-meth-dflt.template +/*--- +description: BindingElement with object binding pattern and initializer is used (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +var C = class { + method([{ x, y, z } = { x: 44, y: 55, z: 66 }] = []) { + assert.sameValue(x, 44); + assert.sameValue(y, 55); + assert.sameValue(z, 66); + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-dflt-ary-ptrn-elem-obj-id.js b/test/language/expressions/class/dstr-meth-dflt-ary-ptrn-elem-obj-id.js new file mode 100644 index 0000000000..72b011bee4 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-dflt-ary-ptrn-elem-obj-id.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-id.case +// - src/dstr-binding/default/cls-expr-meth-dflt.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +var C = class { + method([{ x, y, z } = { x: 44, y: 55, z: 66 }] = [{ x: 11, y: 22, z: 33 }]) { + assert.sameValue(x, 11); + assert.sameValue(y, 22); + assert.sameValue(z, 33); + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-dflt-ary-ptrn-elem-obj-prop-id-init.js b/test/language/expressions/class/dstr-meth-dflt-ary-ptrn-elem-obj-prop-id-init.js new file mode 100644 index 0000000000..063b40c76e --- /dev/null +++ b/test/language/expressions/class/dstr-meth-dflt-ary-ptrn-elem-obj-prop-id-init.js @@ -0,0 +1,95 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-prop-id-init.case +// - src/dstr-binding/default/cls-expr-meth-dflt.template +/*--- +description: BindingElement with object binding pattern and initializer is used (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +var C = class { + method([{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }] = []) { + assert.sameValue(v, 444); + assert.sameValue(x, 555); + assert.sameValue(z, 666); + + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-dflt-ary-ptrn-elem-obj-prop-id.js b/test/language/expressions/class/dstr-meth-dflt-ary-ptrn-elem-obj-prop-id.js new file mode 100644 index 0000000000..84f11026d0 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-dflt-ary-ptrn-elem-obj-prop-id.js @@ -0,0 +1,95 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-prop-id.case +// - src/dstr-binding/default/cls-expr-meth-dflt.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +var C = class { + method([{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }] = [{ u: 777, w: 888, y: 999 }]) { + assert.sameValue(v, 777); + assert.sameValue(x, 888); + assert.sameValue(z, 999); + + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-dflt-ary-ptrn-elem-obj-val-null.js b/test/language/expressions/class/dstr-meth-dflt-ary-ptrn-elem-obj-val-null.js new file mode 100644 index 0000000000..effbe693eb --- /dev/null +++ b/test/language/expressions/class/dstr-meth-dflt-ary-ptrn-elem-obj-val-null.js @@ -0,0 +1,89 @@ +// 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-meth-dflt.template +/*--- +description: Nested object destructuring with a null value (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 { + method([{ x }] = [null]) {} +}; + +var c = new C(); + +assert.throws(TypeError, function() { + c.method(); +}); diff --git a/test/language/expressions/class/dstr-meth-dflt-ary-ptrn-elem-obj-val-undef.js b/test/language/expressions/class/dstr-meth-dflt-ary-ptrn-elem-obj-val-undef.js new file mode 100644 index 0000000000..f5dbd72624 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-dflt-ary-ptrn-elem-obj-val-undef.js @@ -0,0 +1,89 @@ +// 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-meth-dflt.template +/*--- +description: Nested object destructuring with a value of `undefined` (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 { + method([{ x }] = []) {} +}; + +var c = new C(); + +assert.throws(TypeError, function() { + c.method(); +}); diff --git a/test/language/expressions/class/dstr-meth-dflt-ary-ptrn-elision-exhausted.js b/test/language/expressions/class/dstr-meth-dflt-ary-ptrn-elision-exhausted.js new file mode 100644 index 0000000000..e77ba40411 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-dflt-ary-ptrn-elision-exhausted.js @@ -0,0 +1,90 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-exhausted.case +// - src/dstr-binding/default/cls-expr-meth-dflt.template +/*--- +description: Elision accepts exhausted iterator (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [generator, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + [...] + 2. Return NormalCompletion(empty). + +---*/ +var iter = function*() {}(); +iter.next(); + +var callCount = 0; +var C = class { + method([,] = iter) { + + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-dflt-ary-ptrn-elision-step-err.js b/test/language/expressions/class/dstr-meth-dflt-ary-ptrn-elision-step-err.js new file mode 100644 index 0000000000..df36675334 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-dflt-ary-ptrn-elision-step-err.js @@ -0,0 +1,96 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-step-err.case +// - src/dstr-binding/error/cls-expr-meth-dflt.template +/*--- +description: Elision advances iterator and forwards abrupt completions (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [generator, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 { + method([,] = iter) {} +}; + +var c = new C(); + +assert.throws(Test262Error, function() { + c.method(); +}); + +iter.next(); +assert.sameValue(following, 0, 'Iterator was properly closed.'); diff --git a/test/language/expressions/class/dstr-meth-dflt-ary-ptrn-elision.js b/test/language/expressions/class/dstr-meth-dflt-ary-ptrn-elision.js new file mode 100644 index 0000000000..d3ef75c8cd --- /dev/null +++ b/test/language/expressions/class/dstr-meth-dflt-ary-ptrn-elision.js @@ -0,0 +1,99 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision.case +// - src/dstr-binding/default/cls-expr-meth-dflt.template +/*--- +description: Elision advances iterator (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [generator, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + 2. Return NormalCompletion(empty). + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var callCount = 0; +var C = class { + method([,] = g()) { + assert.sameValue(first, 1); + assert.sameValue(second, 0); + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-dflt-ary-ptrn-empty.js b/test/language/expressions/class/dstr-meth-dflt-ary-ptrn-empty.js new file mode 100644 index 0000000000..ff630bf270 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-dflt-ary-ptrn-empty.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-empty.case +// - src/dstr-binding/default/cls-expr-meth-dflt.template +/*--- +description: No iteration occurs for an "empty" array binding pattern (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ ] + + 1. Return NormalCompletion(empty). + +---*/ +var iterations = 0; +var iter = function*() { + iterations += 1; +}(); + +var callCount = 0; +var C = class { + method([] = iter) { + assert.sameValue(iterations, 0); + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-dflt-ary-ptrn-rest-ary-elem.js b/test/language/expressions/class/dstr-meth-dflt-ary-ptrn-rest-ary-elem.js new file mode 100644 index 0000000000..0831478c18 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-dflt-ary-ptrn-rest-ary-elem.js @@ -0,0 +1,106 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-elem.case +// - src/dstr-binding/default/cls-expr-meth-dflt.template +/*--- +description: Rest element containing an array BindingElementList pattern (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set + iteratorRecord.[[done]] to true. + iii. ReturnIfAbrupt(v). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var C = class { + method([...[x, y, z]] = [3, 4, 5]) { + assert.sameValue(x, 3); + assert.sameValue(y, 4); + assert.sameValue(z, 5); + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-dflt-ary-ptrn-rest-ary-elision.js b/test/language/expressions/class/dstr-meth-dflt-ary-ptrn-rest-ary-elision.js new file mode 100644 index 0000000000..8c7d982d7c --- /dev/null +++ b/test/language/expressions/class/dstr-meth-dflt-ary-ptrn-rest-ary-elision.js @@ -0,0 +1,112 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-elision.case +// - src/dstr-binding/default/cls-expr-meth-dflt.template +/*--- +description: Rest element containing an elision (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + 2. Return NormalCompletion(empty). + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var callCount = 0; +var C = class { + method([...[,]] = g()) { + assert.sameValue(first, 1); + assert.sameValue(second, 1); + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-dflt-ary-ptrn-rest-ary-empty.js b/test/language/expressions/class/dstr-meth-dflt-ary-ptrn-rest-ary-empty.js new file mode 100644 index 0000000000..8aeaabe213 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-dflt-ary-ptrn-rest-ary-empty.js @@ -0,0 +1,95 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-empty.case +// - src/dstr-binding/default/cls-expr-meth-dflt.template +/*--- +description: Rest element containing an "empty" array pattern (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ ] + + 1. Return NormalCompletion(empty). + +---*/ +var iterations = 0; +var iter = function*() { + iterations += 1; +}(); + +var callCount = 0; +var C = class { + method([...[]] = iter) { + assert.sameValue(iterations, 1); + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-dflt-ary-ptrn-rest-ary-rest.js b/test/language/expressions/class/dstr-meth-dflt-ary-ptrn-rest-ary-rest.js new file mode 100644 index 0000000000..95cef0266f --- /dev/null +++ b/test/language/expressions/class/dstr-meth-dflt-ary-ptrn-rest-ary-rest.js @@ -0,0 +1,91 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-rest.case +// - src/dstr-binding/default/cls-expr-meth-dflt.template +/*--- +description: Rest element containing a rest element (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ +var values = [1, 2, 3]; + +var callCount = 0; +var C = class { + method([...[...x]] = values) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 1); + assert.sameValue(x[1], 2); + assert.sameValue(x[2], 3); + assert.notSameValue(x, values); + + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-dflt-ary-ptrn-rest-id-elision-next-err.js b/test/language/expressions/class/dstr-meth-dflt-ary-ptrn-rest-id-elision-next-err.js new file mode 100644 index 0000000000..05070994ee --- /dev/null +++ b/test/language/expressions/class/dstr-meth-dflt-ary-ptrn-rest-id-elision-next-err.js @@ -0,0 +1,82 @@ +// 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-meth-dflt.template +/*--- +description: Rest element following elision elements (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 { + method([, ...x] = iter) {} +}; + +var c = new C(); + +assert.throws(Test262Error, function() { + c.method(); +}); diff --git a/test/language/expressions/class/dstr-meth-dflt-ary-ptrn-rest-id-elision.js b/test/language/expressions/class/dstr-meth-dflt-ary-ptrn-rest-id-elision.js new file mode 100644 index 0000000000..5f87669e17 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-dflt-ary-ptrn-rest-id-elision.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision.case +// - src/dstr-binding/default/cls-expr-meth-dflt.template +/*--- +description: Rest element following elision elements (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + ArrayBindingPattern : [ Elisionopt BindingRestElement ] + 1. If Elision is present, then + a. Let status be the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with + iteratorRecord as the argument. + b. ReturnIfAbrupt(status). + 2. Return the result of performing IteratorBindingInitialization for + BindingRestElement with iteratorRecord and environment as arguments. +---*/ +var values = [1, 2, 3, 4, 5]; + +var callCount = 0; +var C = class { + method([ , , ...x] = values) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 3); + assert.sameValue(x[1], 4); + assert.sameValue(x[2], 5); + assert.notSameValue(x, values); + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-dflt-ary-ptrn-rest-id-exhausted.js b/test/language/expressions/class/dstr-meth-dflt-ary-ptrn-rest-id-exhausted.js new file mode 100644 index 0000000000..71317f95ef --- /dev/null +++ b/test/language/expressions/class/dstr-meth-dflt-ary-ptrn-rest-id-exhausted.js @@ -0,0 +1,83 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-exhausted.case +// - src/dstr-binding/default/cls-expr-meth-dflt.template +/*--- +description: RestElement applied to an exhausted iterator (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [Symbol.iterator, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier, + environment). + 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat, + [...] + b. If iteratorRecord.[[done]] is true, then + i. If environment is undefined, return PutValue(lhs, A). + ii. Return InitializeReferencedBinding(lhs, A). + +---*/ + +var callCount = 0; +var C = class { + method([, , ...x] = [1, 2]) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 0); + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-dflt-ary-ptrn-rest-id-iter-step-err.js b/test/language/expressions/class/dstr-meth-dflt-ary-ptrn-rest-id-iter-step-err.js new file mode 100644 index 0000000000..f745fe8eb8 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-dflt-ary-ptrn-rest-id-iter-step-err.js @@ -0,0 +1,93 @@ +// 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-meth-dflt.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 { + method([...x] = iter) {} +}; + +var c = new C(); + +assert.throws(Test262Error, function() { + c.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-meth-dflt-ary-ptrn-rest-id-iter-val-err.js b/test/language/expressions/class/dstr-meth-dflt-ary-ptrn-rest-id-iter-val-err.js new file mode 100644 index 0000000000..c7fbaa69d3 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-dflt-ary-ptrn-rest-id-iter-val-err.js @@ -0,0 +1,95 @@ +// 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-meth-dflt.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [Symbol.iterator, destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 { + method([...x] = iter) {} +}; + +var c = new C(); + +assert.throws(Test262Error, function() { + c.method(); +}); diff --git a/test/language/expressions/class/dstr-meth-dflt-ary-ptrn-rest-id.js b/test/language/expressions/class/dstr-meth-dflt-ary-ptrn-rest-id.js new file mode 100644 index 0000000000..f6e995cd32 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-dflt-ary-ptrn-rest-id.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id.case +// - src/dstr-binding/default/cls-expr-meth-dflt.template +/*--- +description: Lone rest element (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + [...] 3. Let A be ArrayCreate(0). [...] 5. Repeat + [...] + f. Let status be CreateDataProperty(A, ToString (n), nextValue). + [...] +---*/ +var values = [1, 2, 3]; + +var callCount = 0; +var C = class { + method([...x] = values) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 1); + assert.sameValue(x[1], 2); + assert.sameValue(x[2], 3); + assert.notSameValue(x, values); + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-dflt-ary-ptrn-rest-init-ary.js b/test/language/expressions/class/dstr-meth-dflt-ary-ptrn-rest-init-ary.js new file mode 100644 index 0000000000..4f293e0afa --- /dev/null +++ b/test/language/expressions/class/dstr-meth-dflt-ary-ptrn-rest-init-ary.js @@ -0,0 +1,78 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-ary.case +// - src/dstr-binding/default/cls-expr-meth-dflt.template +/*--- +description: Reset element (nested array pattern) does not support initializer (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +negative: SyntaxError +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +var C = class { + method([...[ x ] = []] = []) { + + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-dflt-ary-ptrn-rest-init-id.js b/test/language/expressions/class/dstr-meth-dflt-ary-ptrn-rest-init-id.js new file mode 100644 index 0000000000..341bdf9f09 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-dflt-ary-ptrn-rest-init-id.js @@ -0,0 +1,78 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-id.case +// - src/dstr-binding/default/cls-expr-meth-dflt.template +/*--- +description: Reset element (identifier) does not support initializer (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +negative: SyntaxError +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +var C = class { + method([...x = []] = []) { + + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-dflt-ary-ptrn-rest-init-obj.js b/test/language/expressions/class/dstr-meth-dflt-ary-ptrn-rest-init-obj.js new file mode 100644 index 0000000000..73c2d5a26a --- /dev/null +++ b/test/language/expressions/class/dstr-meth-dflt-ary-ptrn-rest-init-obj.js @@ -0,0 +1,78 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-obj.case +// - src/dstr-binding/default/cls-expr-meth-dflt.template +/*--- +description: Reset element (nested object pattern) does not support initializer (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +negative: SyntaxError +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +var C = class { + method([...{ x } = []] = []) { + + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-dflt-ary-ptrn-rest-not-final-ary.js b/test/language/expressions/class/dstr-meth-dflt-ary-ptrn-rest-not-final-ary.js new file mode 100644 index 0000000000..f29a418331 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-dflt-ary-ptrn-rest-not-final-ary.js @@ -0,0 +1,78 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-ary.case +// - src/dstr-binding/default/cls-expr-meth-dflt.template +/*--- +description: Rest element (array binding pattern) may not be followed by any element (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +negative: SyntaxError +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +var C = class { + method([...[x], y] = [1, 2, 3]) { + + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-dflt-ary-ptrn-rest-not-final-id.js b/test/language/expressions/class/dstr-meth-dflt-ary-ptrn-rest-not-final-id.js new file mode 100644 index 0000000000..4fc4c49e5d --- /dev/null +++ b/test/language/expressions/class/dstr-meth-dflt-ary-ptrn-rest-not-final-id.js @@ -0,0 +1,78 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-id.case +// - src/dstr-binding/default/cls-expr-meth-dflt.template +/*--- +description: Rest element (identifier) may not be followed by any element (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +negative: SyntaxError +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +var C = class { + method([...x, y] = [1, 2, 3]) { + + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-dflt-ary-ptrn-rest-not-final-obj.js b/test/language/expressions/class/dstr-meth-dflt-ary-ptrn-rest-not-final-obj.js new file mode 100644 index 0000000000..dd50423693 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-dflt-ary-ptrn-rest-not-final-obj.js @@ -0,0 +1,78 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-obj.case +// - src/dstr-binding/default/cls-expr-meth-dflt.template +/*--- +description: Rest element (object binding pattern) may not be followed by any element (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +negative: SyntaxError +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +var C = class { + method([...{ x }, y] = [1, 2, 3]) { + + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-dflt-ary-ptrn-rest-obj-id.js b/test/language/expressions/class/dstr-meth-dflt-ary-ptrn-rest-obj-id.js new file mode 100644 index 0000000000..7c1930e2d6 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-dflt-ary-ptrn-rest-obj-id.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-obj-id.case +// - src/dstr-binding/default/cls-expr-meth-dflt.template +/*--- +description: Rest element containing an object binding pattern (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ + +var callCount = 0; +var C = class { + method([...{ length }] = [1, 2, 3]) { + assert.sameValue(length, 3); + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-dflt-ary-ptrn-rest-obj-prop-id.js b/test/language/expressions/class/dstr-meth-dflt-ary-ptrn-rest-obj-prop-id.js new file mode 100644 index 0000000000..de108a6515 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-dflt-ary-ptrn-rest-obj-prop-id.js @@ -0,0 +1,92 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-obj-prop-id.case +// - src/dstr-binding/default/cls-expr-meth-dflt.template +/*--- +description: Rest element containing an object binding pattern (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ + +var callCount = 0; +var C = class { + method([...{ 0: v, 1: w, 2: x, 3: y, length: z }] = [7, 8, 9]) { + assert.sameValue(v, 7); + assert.sameValue(w, 8); + assert.sameValue(x, 9); + assert.sameValue(y, undefined); + assert.sameValue(z, 3); + + assert.throws(ReferenceError, function() { + length; + }); + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-dflt-obj-init-null.js b/test/language/expressions/class/dstr-meth-dflt-obj-init-null.js new file mode 100644 index 0000000000..e7f1a5b6e1 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-dflt-obj-init-null.js @@ -0,0 +1,76 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-null.case +// - src/dstr-binding/error/cls-expr-meth-dflt.template +/*--- +description: Value specifed for object binding pattern must be object coercible (null) (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + +var C = class { + method({} = null) {} +}; + +var c = new C(); + +assert.throws(TypeError, function() { + c.method(); +}); diff --git a/test/language/expressions/class/dstr-meth-dflt-obj-init-undefined.js b/test/language/expressions/class/dstr-meth-dflt-obj-init-undefined.js new file mode 100644 index 0000000000..0e1d427ab0 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-dflt-obj-init-undefined.js @@ -0,0 +1,76 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-undefined.case +// - src/dstr-binding/error/cls-expr-meth-dflt.template +/*--- +description: Value specifed for object binding pattern must be object coercible (undefined) (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + +var C = class { + method({} = undefined) {} +}; + +var c = new C(); + +assert.throws(TypeError, function() { + c.method(); +}); diff --git a/test/language/expressions/class/dstr-meth-dflt-obj-ptrn-empty.js b/test/language/expressions/class/dstr-meth-dflt-obj-ptrn-empty.js new file mode 100644 index 0000000000..ac14023bc8 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-dflt-obj-ptrn-empty.js @@ -0,0 +1,83 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-empty.case +// - src/dstr-binding/default/cls-expr-meth-dflt.template +/*--- +description: No property access occurs for an "empty" object binding pattern (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ +var accessCount = 0; +var obj = Object.defineProperty({}, 'attr', { + get: function() { + accessCount += 1; + } +}); + +var callCount = 0; +var C = class { + method({} = obj) { + assert.sameValue(accessCount, 0); + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-dflt-obj-ptrn-id-get-value-err.js b/test/language/expressions/class/dstr-meth-dflt-obj-ptrn-id-get-value-err.js new file mode 100644 index 0000000000..619606d6f0 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-dflt-obj-ptrn-id-get-value-err.js @@ -0,0 +1,83 @@ +// 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-meth-dflt.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 { + method({ poisoned } = poisonedProperty) {} +}; + +var c = new C(); + +assert.throws(Test262Error, function() { + c.method(); +}); diff --git a/test/language/expressions/class/dstr-meth-dflt-obj-ptrn-id-init-fn-name-arrow.js b/test/language/expressions/class/dstr-meth-dflt-obj-ptrn-id-init-fn-name-arrow.js new file mode 100644 index 0000000000..0662f03000 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-dflt-obj-ptrn-id-init-fn-name-arrow.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-arrow.case +// - src/dstr-binding/default/cls-expr-meth-dflt.template +/*--- +description: SingleNameBinding assigns `name` to arrow functions (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +var C = class { + method({ arrow = () => {} } = {}) { + assert.sameValue(arrow.name, 'arrow'); + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-dflt-obj-ptrn-id-init-fn-name-class.js b/test/language/expressions/class/dstr-meth-dflt-obj-ptrn-id-init-fn-name-class.js new file mode 100644 index 0000000000..ba1e077fb5 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-dflt-obj-ptrn-id-init-fn-name-class.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-class.case +// - src/dstr-binding/default/cls-expr-meth-dflt.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +var C = class { + method({ cls = class {}, xCls = class X {} } = {}) { + assert.sameValue(cls.name, 'cls'); + assert.notSameValue(xCls.name, 'xCls'); + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-dflt-obj-ptrn-id-init-fn-name-cover.js b/test/language/expressions/class/dstr-meth-dflt-obj-ptrn-id-init-fn-name-cover.js new file mode 100644 index 0000000000..273f6b73f7 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-dflt-obj-ptrn-id-init-fn-name-cover.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-cover.case +// - src/dstr-binding/default/cls-expr-meth-dflt.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" functions "through" cover grammar (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +var C = class { + method({ cover = (function () {}), xCover = (0, function() {}) } = {}) { + assert.sameValue(cover.name, 'cover'); + assert.notSameValue(xCover.name, 'xCover'); + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-dflt-obj-ptrn-id-init-fn-name-fn.js b/test/language/expressions/class/dstr-meth-dflt-obj-ptrn-id-init-fn-name-fn.js new file mode 100644 index 0000000000..2cda3ab551 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-dflt-obj-ptrn-id-init-fn-name-fn.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-fn.case +// - src/dstr-binding/default/cls-expr-meth-dflt.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +var C = class { + method({ fn = function () {}, xFn = function x() {} } = {}) { + assert.sameValue(fn.name, 'fn'); + assert.notSameValue(xFn.name, 'xFn'); + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-dflt-obj-ptrn-id-init-fn-name-gen.js b/test/language/expressions/class/dstr-meth-dflt-obj-ptrn-id-init-fn-name-gen.js new file mode 100644 index 0000000000..54bac900ee --- /dev/null +++ b/test/language/expressions/class/dstr-meth-dflt-obj-ptrn-id-init-fn-name-gen.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-gen.case +// - src/dstr-binding/default/cls-expr-meth-dflt.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +var C = class { + method({ gen = function* () {}, xGen = function* x() {} } = {}) { + assert.sameValue(gen.name, 'gen'); + assert.notSameValue(xGen.name, 'xGen'); + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-dflt-obj-ptrn-id-init-skipped.js b/test/language/expressions/class/dstr-meth-dflt-obj-ptrn-id-init-skipped.js new file mode 100644 index 0000000000..551d5dedb9 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-dflt-obj-ptrn-id-init-skipped.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-skipped.case +// - src/dstr-binding/default/cls-expr-meth-dflt.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + [...] +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var callCount = 0; +var C = class { + method({ w = counter(), x = counter(), y = counter(), z = counter() } = { w: null, x: 0, y: false, z: '' }) { + assert.sameValue(w, null); + assert.sameValue(x, 0); + assert.sameValue(y, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-dflt-obj-ptrn-id-init-throws.js b/test/language/expressions/class/dstr-meth-dflt-obj-ptrn-id-init-throws.js new file mode 100644 index 0000000000..49c37658db --- /dev/null +++ b/test/language/expressions/class/dstr-meth-dflt-obj-ptrn-id-init-throws.js @@ -0,0 +1,83 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-throws.case +// - src/dstr-binding/error/cls-expr-meth-dflt.template +/*--- +description: Error thrown when evaluating the initializer (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 { + method({ x = thrower() } = {}) {} +}; + +var c = new C(); + +assert.throws(Test262Error, function() { + c.method(); +}); diff --git a/test/language/expressions/class/dstr-meth-dflt-obj-ptrn-id-init-unresolvable.js b/test/language/expressions/class/dstr-meth-dflt-obj-ptrn-id-init-unresolvable.js new file mode 100644 index 0000000000..0ffb1f121e --- /dev/null +++ b/test/language/expressions/class/dstr-meth-dflt-obj-ptrn-id-init-unresolvable.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-unresolvable.case +// - src/dstr-binding/error/cls-expr-meth-dflt.template +/*--- +description: Destructuring initializer is an unresolvable reference (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 { + method({ x = unresolvableReference } = {}) {} +}; + +var c = new C(); + +assert.throws(ReferenceError, function() { + c.method(); +}); diff --git a/test/language/expressions/class/dstr-meth-dflt-obj-ptrn-id-trailing-comma.js b/test/language/expressions/class/dstr-meth-dflt-obj-ptrn-id-trailing-comma.js new file mode 100644 index 0000000000..bbdab81371 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-dflt-obj-ptrn-id-trailing-comma.js @@ -0,0 +1,78 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-trailing-comma.case +// - src/dstr-binding/default/cls-expr-meth-dflt.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var callCount = 0; +var C = class { + method({ x, } = { x: 23 }) { + assert.sameValue(x, 23); + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-dflt-obj-ptrn-list-err.js b/test/language/expressions/class/dstr-meth-dflt-obj-ptrn-list-err.js new file mode 100644 index 0000000000..7c12126ed6 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-dflt-obj-ptrn-list-err.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-list-err.case +// - src/dstr-binding/error/cls-expr-meth-dflt.template +/*--- +description: Binding property list evaluation is interrupted by an abrupt completion (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 { + method({ a, b = thrower(), c = ++initCount } = {}) {} +}; + +var c = new C(); + +assert.throws(Test262Error, function() { + c.method(); +}); + +assert.sameValue(initCount, 0); diff --git a/test/language/expressions/class/dstr-meth-dflt-obj-ptrn-prop-ary-init.js b/test/language/expressions/class/dstr-meth-dflt-obj-ptrn-prop-ary-init.js new file mode 100644 index 0000000000..17d86c6590 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-dflt-obj-ptrn-prop-ary-init.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-init.case +// - src/dstr-binding/default/cls-expr-meth-dflt.template +/*--- +description: Object binding pattern with "nested" array binding pattern using initializer (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +var C = class { + method({ w: [x, y, z] = [4, 5, 6] } = {}) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-dflt-obj-ptrn-prop-ary-trailing-comma.js b/test/language/expressions/class/dstr-meth-dflt-obj-ptrn-prop-ary-trailing-comma.js new file mode 100644 index 0000000000..be61b0be2f --- /dev/null +++ b/test/language/expressions/class/dstr-meth-dflt-obj-ptrn-prop-ary-trailing-comma.js @@ -0,0 +1,78 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-trailing-comma.case +// - src/dstr-binding/default/cls-expr-meth-dflt.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var callCount = 0; +var C = class { + method({ x: [y], } = { x: [45] }) { + assert.sameValue(y,45); + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-dflt-obj-ptrn-prop-ary-value-null.js b/test/language/expressions/class/dstr-meth-dflt-obj-ptrn-prop-ary-value-null.js new file mode 100644 index 0000000000..f722c1d81b --- /dev/null +++ b/test/language/expressions/class/dstr-meth-dflt-obj-ptrn-prop-ary-value-null.js @@ -0,0 +1,78 @@ +// 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-meth-dflt.template +/*--- +description: Object binding pattern with "nested" array binding pattern taking the `null` value (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 { + method({ w: [x, y, z] = [4, 5, 6] } = { w: null }) {} +}; + +var c = new C(); + +assert.throws(TypeError, function() { + c.method(); +}); diff --git a/test/language/expressions/class/dstr-meth-dflt-obj-ptrn-prop-ary.js b/test/language/expressions/class/dstr-meth-dflt-obj-ptrn-prop-ary.js new file mode 100644 index 0000000000..3d6a80d2e7 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-dflt-obj-ptrn-prop-ary.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary.case +// - src/dstr-binding/default/cls-expr-meth-dflt.template +/*--- +description: Object binding pattern with "nested" array binding pattern not using initializer (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +var C = class { + method({ w: [x, y, z] = [4, 5, 6] } = { w: [7, undefined, ] }) { + assert.sameValue(x, 7); + assert.sameValue(y, undefined); + assert.sameValue(z, undefined); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-dflt-obj-ptrn-prop-eval-err.js b/test/language/expressions/class/dstr-meth-dflt-obj-ptrn-prop-eval-err.js new file mode 100644 index 0000000000..59a1aa73b0 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-dflt-obj-ptrn-prop-eval-err.js @@ -0,0 +1,80 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-eval-err.case +// - src/dstr-binding/error/cls-expr-meth-dflt.template +/*--- +description: Evaluation of property name returns an abrupt completion (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 { + method({ [thrower()]: x } = {}) {} +}; + +var c = new C(); + +assert.throws(Test262Error, function() { + c.method(); +}); diff --git a/test/language/expressions/class/dstr-meth-dflt-obj-ptrn-prop-id-get-value-err.js b/test/language/expressions/class/dstr-meth-dflt-obj-ptrn-prop-id-get-value-err.js new file mode 100644 index 0000000000..05fa3149d6 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-dflt-obj-ptrn-prop-id-get-value-err.js @@ -0,0 +1,85 @@ +// 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-meth-dflt.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 { + method({ poisoned: x = ++initEvalCount } = poisonedProperty) {} +}; + +var c = new C(); + +assert.throws(Test262Error, function() { + c.method(); +}); + +assert.sameValue(initEvalCount, 0); diff --git a/test/language/expressions/class/dstr-meth-dflt-obj-ptrn-prop-id-init-skipped.js b/test/language/expressions/class/dstr-meth-dflt-obj-ptrn-prop-id-init-skipped.js new file mode 100644 index 0000000000..33693c6d99 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-dflt-obj-ptrn-prop-id-init-skipped.js @@ -0,0 +1,100 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-skipped.case +// - src/dstr-binding/default/cls-expr-meth-dflt.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + [...] +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var callCount = 0; +var C = class { + method({ s: t = counter(), u: v = counter(), w: x = counter(), y: z = counter() } = { s: null, u: 0, w: false, y: '' }) { + assert.sameValue(t, null); + assert.sameValue(v, 0); + assert.sameValue(x, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + + assert.throws(ReferenceError, function() { + s; + }); + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-dflt-obj-ptrn-prop-id-init-throws.js b/test/language/expressions/class/dstr-meth-dflt-obj-ptrn-prop-id-init-throws.js new file mode 100644 index 0000000000..9636632a65 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-dflt-obj-ptrn-prop-id-init-throws.js @@ -0,0 +1,83 @@ +// 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-meth-dflt.template +/*--- +description: Error thrown when evaluating the initializer (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 { + method({ x: y = thrower() } = {}) {} +}; + +var c = new C(); + +assert.throws(Test262Error, function() { + c.method(); +}); diff --git a/test/language/expressions/class/dstr-meth-dflt-obj-ptrn-prop-id-init-unresolvable.js b/test/language/expressions/class/dstr-meth-dflt-obj-ptrn-prop-id-init-unresolvable.js new file mode 100644 index 0000000000..0f3a519b0c --- /dev/null +++ b/test/language/expressions/class/dstr-meth-dflt-obj-ptrn-prop-id-init-unresolvable.js @@ -0,0 +1,87 @@ +// 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-meth-dflt.template +/*--- +description: Destructuring initializer is an unresolvable reference (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 { + method({ x: y = unresolvableReference } = {}) {} +}; + +var c = new C(); + +assert.throws(ReferenceError, function() { + c.method(); +}); diff --git a/test/language/expressions/class/dstr-meth-dflt-obj-ptrn-prop-id-init.js b/test/language/expressions/class/dstr-meth-dflt-obj-ptrn-prop-id-init.js new file mode 100644 index 0000000000..51f7c12be4 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-dflt-obj-ptrn-prop-id-init.js @@ -0,0 +1,81 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init.case +// - src/dstr-binding/default/cls-expr-meth-dflt.template +/*--- +description: Binding as specified via property name, identifier, and initializer (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var C = class { + method({ x: y = 33 } = { }) { + assert.sameValue(y, 33); + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-dflt-obj-ptrn-prop-id-trailing-comma.js b/test/language/expressions/class/dstr-meth-dflt-obj-ptrn-prop-id-trailing-comma.js new file mode 100644 index 0000000000..3653a3c831 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-dflt-obj-ptrn-prop-id-trailing-comma.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-trailing-comma.case +// - src/dstr-binding/default/cls-expr-meth-dflt.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var callCount = 0; +var C = class { + method({ x: y, } = { x: 23 }) { + assert.sameValue(y, 23); + + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-dflt-obj-ptrn-prop-id.js b/test/language/expressions/class/dstr-meth-dflt-obj-ptrn-prop-id.js new file mode 100644 index 0000000000..0f6fea520c --- /dev/null +++ b/test/language/expressions/class/dstr-meth-dflt-obj-ptrn-prop-id.js @@ -0,0 +1,81 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id.case +// - src/dstr-binding/default/cls-expr-meth-dflt.template +/*--- +description: Binding as specified via property name and identifier (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var C = class { + method({ x: y } = { x: 23 }) { + assert.sameValue(y, 23); + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-dflt-obj-ptrn-prop-obj-init.js b/test/language/expressions/class/dstr-meth-dflt-obj-ptrn-prop-obj-init.js new file mode 100644 index 0000000000..a26fa513e8 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-dflt-obj-ptrn-prop-obj-init.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-init.case +// - src/dstr-binding/default/cls-expr-meth-dflt.template +/*--- +description: Object binding pattern with "nested" object binding pattern using initializer (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +var C = class { + method({ w: { x, y, z } = { x: 4, y: 5, z: 6 } } = { w: undefined }) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-dflt-obj-ptrn-prop-obj-value-null.js b/test/language/expressions/class/dstr-meth-dflt-obj-ptrn-prop-obj-value-null.js new file mode 100644 index 0000000000..694c3c01ea --- /dev/null +++ b/test/language/expressions/class/dstr-meth-dflt-obj-ptrn-prop-obj-value-null.js @@ -0,0 +1,78 @@ +// 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-meth-dflt.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 { + method({ w: { x, y, z } = { x: 4, y: 5, z: 6 } } = { w: null }) {} +}; + +var c = new C(); + +assert.throws(TypeError, function() { + c.method(); +}); diff --git a/test/language/expressions/class/dstr-meth-dflt-obj-ptrn-prop-obj-value-undef.js b/test/language/expressions/class/dstr-meth-dflt-obj-ptrn-prop-obj-value-undef.js new file mode 100644 index 0000000000..53b387028d --- /dev/null +++ b/test/language/expressions/class/dstr-meth-dflt-obj-ptrn-prop-obj-value-undef.js @@ -0,0 +1,78 @@ +// 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-meth-dflt.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 { + method({ w: { x, y, z } = undefined } = { }) {} +}; + +var c = new C(); + +assert.throws(TypeError, function() { + c.method(); +}); diff --git a/test/language/expressions/class/dstr-meth-dflt-obj-ptrn-prop-obj.js b/test/language/expressions/class/dstr-meth-dflt-obj-ptrn-prop-obj.js new file mode 100644 index 0000000000..16769c24ce --- /dev/null +++ b/test/language/expressions/class/dstr-meth-dflt-obj-ptrn-prop-obj.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj.case +// - src/dstr-binding/default/cls-expr-meth-dflt.template +/*--- +description: Object binding pattern with "nested" object binding pattern not using initializer (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +var C = class { + method({ w: { x, y, z } = { x: 4, y: 5, z: 6 } } = { w: { x: undefined, z: 7 } }) { + assert.sameValue(x, undefined); + assert.sameValue(y, undefined); + assert.sameValue(z, 7); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-static-dflt-ary-init-iter-close.js b/test/language/expressions/class/dstr-meth-static-dflt-ary-init-iter-close.js new file mode 100644 index 0000000000..51f7f4df12 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-dflt-ary-init-iter-close.js @@ -0,0 +1,94 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-close.case +// - src/dstr-binding/default/cls-expr-meth-static-dflt.template +/*--- +description: Iterator is closed when not exhausted by pattern evaluation (static class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [Symbol.iterator, destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + [...] + 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator, + result). + [...] + +---*/ +var doneCallCount = 0; +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return { value: null, done: false }; + }, + return: function() { + doneCallCount += 1; + return {}; + } + }; +}; + +var callCount = 0; +var C = class { + static method([x] = iter) { + assert.sameValue(doneCallCount, 1); + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-static-dflt-ary-init-iter-get-err.js b/test/language/expressions/class/dstr-meth-static-dflt-ary-init-iter-get-err.js new file mode 100644 index 0000000000..bbe954a8a8 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-dflt-ary-init-iter-get-err.js @@ -0,0 +1,80 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-get-err.case +// - src/dstr-binding/error/cls-expr-meth-static-dflt.template +/*--- +description: Abrupt completion returned by GetIterator (static class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [Symbol.iterator, destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 method([x] = iter) {} +}; + +assert.throws(Test262Error, function() { + C.method(); +}); diff --git a/test/language/expressions/class/dstr-meth-static-dflt-ary-init-iter-no-close.js b/test/language/expressions/class/dstr-meth-static-dflt-ary-init-iter-no-close.js new file mode 100644 index 0000000000..971960e546 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-dflt-ary-init-iter-no-close.js @@ -0,0 +1,94 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-no-close.case +// - src/dstr-binding/default/cls-expr-meth-static-dflt.template +/*--- +description: Iterator is not closed when exhausted by pattern evaluation (static class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [Symbol.iterator, destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + [...] + 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator, + result). + [...] + +---*/ +var doneCallCount = 0; +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return { value: null, done: true }; + }, + return: function() { + doneCallCount += 1; + return {}; + } + }; +}; + +var callCount = 0; +var C = class { + static method([x] = iter) { + assert.sameValue(doneCallCount, 0); + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-static-dflt-ary-name-iter-val.js b/test/language/expressions/class/dstr-meth-static-dflt-ary-name-iter-val.js new file mode 100644 index 0000000000..3acd97eccb --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-dflt-ary-name-iter-val.js @@ -0,0 +1,93 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-name-iter-val.case +// - src/dstr-binding/default/cls-expr-meth-static-dflt.template +/*--- +description: SingleNameBinding with normal value iteration (static class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set + iteratorRecord.[[done]] to true. + iii. ReturnIfAbrupt(v). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var C = class { + static method([x, y, z] = [1, 2, 3]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 3); + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-elem-ary-elem-init.js b/test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-elem-ary-elem-init.js new file mode 100644 index 0000000000..eb85c0c26c --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-elem-ary-elem-init.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elem-init.case +// - src/dstr-binding/default/cls-expr-meth-static-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is used (static class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +var C = class { + static method([[x, y, z] = [4, 5, 6]] = []) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-elem-ary-elem-iter.js b/test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-elem-ary-elem-iter.js new file mode 100644 index 0000000000..ef7df19026 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-elem-ary-elem-iter.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elem-iter.case +// - src/dstr-binding/default/cls-expr-meth-static-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (static class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +var C = class { + static method([[x, y, z] = [4, 5, 6]] = [[7, 8, 9]]) { + assert.sameValue(x, 7); + assert.sameValue(y, 8); + assert.sameValue(z, 9); + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-elem-ary-elision-init.js b/test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-elem-ary-elision-init.js new file mode 100644 index 0000000000..1f46ed2603 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-elem-ary-elision-init.js @@ -0,0 +1,92 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elision-init.case +// - src/dstr-binding/default/cls-expr-meth-static-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is used (static class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [generators, destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var callCount = 0; +var C = class { + static method([[,] = g()] = []) { + assert.sameValue(first, 1); + assert.sameValue(second, 0); + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-elem-ary-elision-iter.js b/test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-elem-ary-elision-iter.js new file mode 100644 index 0000000000..648aa58717 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-elem-ary-elision-iter.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elision-iter.case +// - src/dstr-binding/default/cls-expr-meth-static-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (static class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [generators, destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var callCount = 0; +function* g() { + callCount += 1; +}; + +var callCount = 0; +var C = class { + static method([[,] = g()] = [[]]) { + assert.sameValue(callCount, 0); + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-elem-ary-empty-init.js b/test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-elem-ary-empty-init.js new file mode 100644 index 0000000000..8449f22212 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-elem-ary-empty-init.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-empty-init.case +// - src/dstr-binding/default/cls-expr-meth-static-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is used (static class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var initCount = 0; +var iterCount = 0; +var iter = function*() { iterCount += 1; }(); + +var callCount = 0; +var C = class { + static method([[] = function() { initCount += 1; return iter; }()] = []) { + assert.sameValue(initCount, 1); + assert.sameValue(iterCount, 0); + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-elem-ary-empty-iter.js b/test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-elem-ary-empty-iter.js new file mode 100644 index 0000000000..44858ced43 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-elem-ary-empty-iter.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-empty-iter.case +// - src/dstr-binding/default/cls-expr-meth-static-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (static class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var initCount = 0; + +var callCount = 0; +var C = class { + static method([[] = function() { initCount += 1; }()] = [[23]]) { + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-elem-ary-rest-init.js b/test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-elem-ary-rest-init.js new file mode 100644 index 0000000000..31ad10f7e9 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-elem-ary-rest-init.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-rest-init.case +// - src/dstr-binding/default/cls-expr-meth-static-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is used (static class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var values = [2, 1, 3]; + +var callCount = 0; +var C = class { + static method([[...x] = values] = []) { + assert(Array.isArray(x)); + assert.sameValue(x[0], 2); + assert.sameValue(x[1], 1); + assert.sameValue(x[2], 3); + assert.sameValue(x.length, 3); + assert.notSameValue(x, values); + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-elem-ary-rest-iter.js b/test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-elem-ary-rest-iter.js new file mode 100644 index 0000000000..20c54d48d5 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-elem-ary-rest-iter.js @@ -0,0 +1,92 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-rest-iter.case +// - src/dstr-binding/default/cls-expr-meth-static-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (static class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var values = [2, 1, 3]; +var initCount = 0; + +var callCount = 0; +var C = class { + static method([[...x] = function() { initCount += 1; }()] = [values]) { + assert(Array.isArray(x)); + assert.sameValue(x[0], 2); + assert.sameValue(x[1], 1); + assert.sameValue(x[2], 3); + assert.sameValue(x.length, 3); + assert.notSameValue(x, values); + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-elem-ary-val-null.js b/test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-elem-ary-val-null.js new file mode 100644 index 0000000000..368e60d36d --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-elem-ary-val-null.js @@ -0,0 +1,87 @@ +// 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-meth-static-dflt.template +/*--- +description: Nested array destructuring with a null value (static class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 method([[x]] = [null]) {} +}; + +assert.throws(TypeError, function() { + C.method(); +}); diff --git a/test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-elem-id-init-exhausted.js b/test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-elem-id-init-exhausted.js new file mode 100644 index 0000000000..0b6b97ad0d --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-elem-id-init-exhausted.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-exhausted.case +// - src/dstr-binding/default/cls-expr-meth-static-dflt.template +/*--- +description: Destructuring initializer with an exhausted iterator (static class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var C = class { + static method([x = 23] = []) { + assert.sameValue(x, 23); + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-arrow.js b/test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-arrow.js new file mode 100644 index 0000000000..6c77de3398 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-arrow.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-arrow.case +// - src/dstr-binding/default/cls-expr-meth-static-dflt.template +/*--- +description: SingleNameBinding does assign name to arrow functions (static class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var C = class { + static method([arrow = () => {}] = []) { + assert.sameValue(arrow.name, 'arrow'); + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-class.js b/test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-class.js new file mode 100644 index 0000000000..a0288aa2fe --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-class.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-class.case +// - src/dstr-binding/default/cls-expr-meth-static-dflt.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (static class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var C = class { + static method([cls = class {}, xCls = class X {}] = []) { + assert.sameValue(cls.name, 'cls'); + assert.notSameValue(xCls.name, 'xCls'); + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-cover.js b/test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-cover.js new file mode 100644 index 0000000000..ffc0277318 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-cover.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-cover.case +// - src/dstr-binding/default/cls-expr-meth-static-dflt.template +/*--- +description: SingleNameBinding does assign name to "anonymous" functions "through" cover grammar (static class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var C = class { + static method([cover = (function () {}), xCover = (0, function() {})] = []) { + assert.sameValue(cover.name, 'cover'); + assert.notSameValue(xCover.name, 'xCover'); + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-fn.js b/test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-fn.js new file mode 100644 index 0000000000..088e6c7c17 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-fn.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-fn.case +// - src/dstr-binding/default/cls-expr-meth-static-dflt.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (static class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var C = class { + static method([fn = function () {}, xFn = function x() {}] = []) { + assert.sameValue(fn.name, 'fn'); + assert.notSameValue(xFn.name, 'xFn'); + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-gen.js b/test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-gen.js new file mode 100644 index 0000000000..49fe105423 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-gen.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-gen.case +// - src/dstr-binding/default/cls-expr-meth-static-dflt.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (static class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var C = class { + static method([gen = function* () {}, xGen = function* x() {}] = []) { + assert.sameValue(gen.name, 'gen'); + assert.notSameValue(xGen.name, 'xGen'); + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-elem-id-init-hole.js b/test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-elem-id-init-hole.js new file mode 100644 index 0000000000..2839ee832f --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-elem-id-init-hole.js @@ -0,0 +1,80 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-hole.case +// - src/dstr-binding/default/cls-expr-meth-static-dflt.template +/*--- +description: Destructuring initializer with a "hole" (static class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + SingleNameBinding : BindingIdentifier Initializeropt + [...] 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + [...] + 7. If environment is undefined, return PutValue(lhs, v). 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var C = class { + static method([x = 23] = [,]) { + assert.sameValue(x, 23); + // another statement + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-elem-id-init-skipped.js b/test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-elem-id-init-skipped.js new file mode 100644 index 0000000000..e68650c9fb --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-elem-id-init-skipped.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-skipped.case +// - src/dstr-binding/default/cls-expr-meth-static-dflt.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (static class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var callCount = 0; +var C = class { + static method([w = counter(), x = counter(), y = counter(), z = counter()] = [null, 0, false, '']) { + assert.sameValue(w, null); + assert.sameValue(x, 0); + assert.sameValue(y, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-elem-id-init-throws.js b/test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-elem-id-init-throws.js new file mode 100644 index 0000000000..7fa8ea2d5d --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-elem-id-init-throws.js @@ -0,0 +1,78 @@ +// 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-meth-static-dflt.template +/*--- +description: Destructuring initializer returns an abrupt completion (static class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 method([x = (function() { throw new Test262Error(); })()] = [undefined]) {} +}; + +assert.throws(Test262Error, function() { + C.method(); +}); diff --git a/test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-elem-id-init-undef.js b/test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-elem-id-init-undef.js new file mode 100644 index 0000000000..ef4241839e --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-elem-id-init-undef.js @@ -0,0 +1,83 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-undef.case +// - src/dstr-binding/default/cls-expr-meth-static-dflt.template +/*--- +description: Destructuring initializer with an undefined value (static class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var C = class { + static method([x = 23] = [undefined]) { + assert.sameValue(x, 23); + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-elem-id-init-unresolvable.js b/test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-elem-id-init-unresolvable.js new file mode 100644 index 0000000000..7f500350a4 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-elem-id-init-unresolvable.js @@ -0,0 +1,85 @@ +// 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-meth-static-dflt.template +/*--- +description: Destructuring initializer is an unresolvable reference (static class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 method([ x = unresolvableReference ] = []) {} +}; + +assert.throws(ReferenceError, function() { + C.method(); +}); diff --git a/test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-elem-id-iter-complete.js b/test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-elem-id-iter-complete.js new file mode 100644 index 0000000000..687564366e --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-elem-id-iter-complete.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-complete.case +// - src/dstr-binding/default/cls-expr-meth-static-dflt.template +/*--- +description: SingleNameBinding when value iteration completes (static class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var C = class { + static method([x] = []) { + assert.sameValue(x, undefined); + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-elem-id-iter-done.js b/test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-elem-id-iter-done.js new file mode 100644 index 0000000000..48f9a726a0 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-elem-id-iter-done.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-done.case +// - src/dstr-binding/default/cls-expr-meth-static-dflt.template +/*--- +description: SingleNameBinding when value iteration was completed previously (static class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var C = class { + static method([_, x] = []) { + assert.sameValue(x, undefined); + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-elem-id-iter-step-err.js b/test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-elem-id-iter-step-err.js new file mode 100644 index 0000000000..f925788b9c --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-elem-id-iter-step-err.js @@ -0,0 +1,86 @@ +// 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-meth-static-dflt.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (static class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 method([x] = g) {} +}; + +assert.throws(Test262Error, function() { + C.method(); +}); diff --git a/test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-elem-id-iter-val-err.js b/test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-elem-id-iter-val-err.js new file mode 100644 index 0000000000..281e6af2b3 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-elem-id-iter-val-err.js @@ -0,0 +1,97 @@ +// 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-meth-static-dflt.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (static class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 method([x] = g) {} +}; + +assert.throws(Test262Error, function() { + C.method(); +}); diff --git a/test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-elem-id-iter-val.js b/test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-elem-id-iter-val.js new file mode 100644 index 0000000000..e938f65da8 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-elem-id-iter-val.js @@ -0,0 +1,93 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val.case +// - src/dstr-binding/default/cls-expr-meth-static-dflt.template +/*--- +description: SingleNameBinding when value iteration was completed previously (static class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set + iteratorRecord.[[done]] to true. + iii. ReturnIfAbrupt(v). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var C = class { + static method([x, y, z] = [1, 2, 3]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 3); + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-elem-obj-id-init.js b/test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-elem-obj-id-init.js new file mode 100644 index 0000000000..445823fe6d --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-elem-obj-id-init.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-id-init.case +// - src/dstr-binding/default/cls-expr-meth-static-dflt.template +/*--- +description: BindingElement with object binding pattern and initializer is used (static class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +var C = class { + static method([{ x, y, z } = { x: 44, y: 55, z: 66 }] = []) { + assert.sameValue(x, 44); + assert.sameValue(y, 55); + assert.sameValue(z, 66); + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-elem-obj-id.js b/test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-elem-obj-id.js new file mode 100644 index 0000000000..80e1213d58 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-elem-obj-id.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-id.case +// - src/dstr-binding/default/cls-expr-meth-static-dflt.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (static class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +var C = class { + static method([{ x, y, z } = { x: 44, y: 55, z: 66 }] = [{ x: 11, y: 22, z: 33 }]) { + assert.sameValue(x, 11); + assert.sameValue(y, 22); + assert.sameValue(z, 33); + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-elem-obj-prop-id-init.js b/test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-elem-obj-prop-id-init.js new file mode 100644 index 0000000000..580f4ac51e --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-elem-obj-prop-id-init.js @@ -0,0 +1,95 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-prop-id-init.case +// - src/dstr-binding/default/cls-expr-meth-static-dflt.template +/*--- +description: BindingElement with object binding pattern and initializer is used (static class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +var C = class { + static method([{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }] = []) { + assert.sameValue(v, 444); + assert.sameValue(x, 555); + assert.sameValue(z, 666); + + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-elem-obj-prop-id.js b/test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-elem-obj-prop-id.js new file mode 100644 index 0000000000..405e7399f9 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-elem-obj-prop-id.js @@ -0,0 +1,95 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-prop-id.case +// - src/dstr-binding/default/cls-expr-meth-static-dflt.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (static class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +var C = class { + static method([{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }] = [{ u: 777, w: 888, y: 999 }]) { + assert.sameValue(v, 777); + assert.sameValue(x, 888); + assert.sameValue(z, 999); + + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-elem-obj-val-null.js b/test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-elem-obj-val-null.js new file mode 100644 index 0000000000..b80eb2ae8f --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-elem-obj-val-null.js @@ -0,0 +1,87 @@ +// 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-meth-static-dflt.template +/*--- +description: Nested object destructuring with a null value (static class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 method([{ x }] = [null]) {} +}; + +assert.throws(TypeError, function() { + C.method(); +}); diff --git a/test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-elem-obj-val-undef.js b/test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-elem-obj-val-undef.js new file mode 100644 index 0000000000..b1dee6ac98 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-elem-obj-val-undef.js @@ -0,0 +1,87 @@ +// 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-meth-static-dflt.template +/*--- +description: Nested object destructuring with a value of `undefined` (static class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 method([{ x }] = []) {} +}; + +assert.throws(TypeError, function() { + C.method(); +}); diff --git a/test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-elision-exhausted.js b/test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-elision-exhausted.js new file mode 100644 index 0000000000..49d6a447c6 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-elision-exhausted.js @@ -0,0 +1,90 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-exhausted.case +// - src/dstr-binding/default/cls-expr-meth-static-dflt.template +/*--- +description: Elision accepts exhausted iterator (static class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [generator, destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + [...] + 2. Return NormalCompletion(empty). + +---*/ +var iter = function*() {}(); +iter.next(); + +var callCount = 0; +var C = class { + static method([,] = iter) { + + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-elision-step-err.js b/test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-elision-step-err.js new file mode 100644 index 0000000000..79de22c30b --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-elision-step-err.js @@ -0,0 +1,94 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-step-err.case +// - src/dstr-binding/error/cls-expr-meth-static-dflt.template +/*--- +description: Elision advances iterator and forwards abrupt completions (static class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [generator, destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 method([,] = iter) {} +}; + +assert.throws(Test262Error, function() { + C.method(); +}); + +iter.next(); +assert.sameValue(following, 0, 'Iterator was properly closed.'); diff --git a/test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-elision.js b/test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-elision.js new file mode 100644 index 0000000000..b98061594e --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-elision.js @@ -0,0 +1,99 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision.case +// - src/dstr-binding/default/cls-expr-meth-static-dflt.template +/*--- +description: Elision advances iterator (static class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [generator, destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + 2. Return NormalCompletion(empty). + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var callCount = 0; +var C = class { + static method([,] = g()) { + assert.sameValue(first, 1); + assert.sameValue(second, 0); + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-empty.js b/test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-empty.js new file mode 100644 index 0000000000..a8b7fa9153 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-empty.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-empty.case +// - src/dstr-binding/default/cls-expr-meth-static-dflt.template +/*--- +description: No iteration occurs for an "empty" array binding pattern (static class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [generators, destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ ] + + 1. Return NormalCompletion(empty). + +---*/ +var iterations = 0; +var iter = function*() { + iterations += 1; +}(); + +var callCount = 0; +var C = class { + static method([] = iter) { + assert.sameValue(iterations, 0); + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-rest-ary-elem.js b/test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-rest-ary-elem.js new file mode 100644 index 0000000000..f99f77b04c --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-rest-ary-elem.js @@ -0,0 +1,106 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-elem.case +// - src/dstr-binding/default/cls-expr-meth-static-dflt.template +/*--- +description: Rest element containing an array BindingElementList pattern (static class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set + iteratorRecord.[[done]] to true. + iii. ReturnIfAbrupt(v). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var C = class { + static method([...[x, y, z]] = [3, 4, 5]) { + assert.sameValue(x, 3); + assert.sameValue(y, 4); + assert.sameValue(z, 5); + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-rest-ary-elision.js b/test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-rest-ary-elision.js new file mode 100644 index 0000000000..fa81d3a2fc --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-rest-ary-elision.js @@ -0,0 +1,112 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-elision.case +// - src/dstr-binding/default/cls-expr-meth-static-dflt.template +/*--- +description: Rest element containing an elision (static class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [generators, destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + 2. Return NormalCompletion(empty). + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var callCount = 0; +var C = class { + static method([...[,]] = g()) { + assert.sameValue(first, 1); + assert.sameValue(second, 1); + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-rest-ary-empty.js b/test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-rest-ary-empty.js new file mode 100644 index 0000000000..84a9738486 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-rest-ary-empty.js @@ -0,0 +1,95 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-empty.case +// - src/dstr-binding/default/cls-expr-meth-static-dflt.template +/*--- +description: Rest element containing an "empty" array pattern (static class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [generators, destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ ] + + 1. Return NormalCompletion(empty). + +---*/ +var iterations = 0; +var iter = function*() { + iterations += 1; +}(); + +var callCount = 0; +var C = class { + static method([...[]] = iter) { + assert.sameValue(iterations, 1); + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-rest-ary-rest.js b/test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-rest-ary-rest.js new file mode 100644 index 0000000000..e480bd8a8b --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-rest-ary-rest.js @@ -0,0 +1,91 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-rest.case +// - src/dstr-binding/default/cls-expr-meth-static-dflt.template +/*--- +description: Rest element containing a rest element (static class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ +var values = [1, 2, 3]; + +var callCount = 0; +var C = class { + static method([...[...x]] = values) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 1); + assert.sameValue(x[1], 2); + assert.sameValue(x[2], 3); + assert.notSameValue(x, values); + + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-rest-id-elision-next-err.js b/test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-rest-id-elision-next-err.js new file mode 100644 index 0000000000..e340d45f07 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-rest-id-elision-next-err.js @@ -0,0 +1,80 @@ +// 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-meth-static-dflt.template +/*--- +description: Rest element following elision elements (static class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [generators, destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 method([, ...x] = iter) {} +}; + +assert.throws(Test262Error, function() { + C.method(); +}); diff --git a/test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-rest-id-elision.js b/test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-rest-id-elision.js new file mode 100644 index 0000000000..34d894a491 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-rest-id-elision.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision.case +// - src/dstr-binding/default/cls-expr-meth-static-dflt.template +/*--- +description: Rest element following elision elements (static class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + ArrayBindingPattern : [ Elisionopt BindingRestElement ] + 1. If Elision is present, then + a. Let status be the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with + iteratorRecord as the argument. + b. ReturnIfAbrupt(status). + 2. Return the result of performing IteratorBindingInitialization for + BindingRestElement with iteratorRecord and environment as arguments. +---*/ +var values = [1, 2, 3, 4, 5]; + +var callCount = 0; +var C = class { + static method([ , , ...x] = values) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 3); + assert.sameValue(x[1], 4); + assert.sameValue(x[2], 5); + assert.notSameValue(x, values); + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-rest-id-exhausted.js b/test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-rest-id-exhausted.js new file mode 100644 index 0000000000..f36f17d5ae --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-rest-id-exhausted.js @@ -0,0 +1,83 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-exhausted.case +// - src/dstr-binding/default/cls-expr-meth-static-dflt.template +/*--- +description: RestElement applied to an exhausted iterator (static class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [Symbol.iterator, destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier, + environment). + 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat, + [...] + b. If iteratorRecord.[[done]] is true, then + i. If environment is undefined, return PutValue(lhs, A). + ii. Return InitializeReferencedBinding(lhs, A). + +---*/ + +var callCount = 0; +var C = class { + static method([, , ...x] = [1, 2]) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 0); + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-rest-id-iter-step-err.js b/test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-rest-id-iter-step-err.js new file mode 100644 index 0000000000..7082b7b14b --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-rest-id-iter-step-err.js @@ -0,0 +1,91 @@ +// 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-meth-static-dflt.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (static class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [generators, destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 method([...x] = iter) {} +}; + +assert.throws(Test262Error, function() { + C.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-meth-static-dflt-ary-ptrn-rest-id-iter-val-err.js b/test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-rest-id-iter-val-err.js new file mode 100644 index 0000000000..fa719169e1 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-rest-id-iter-val-err.js @@ -0,0 +1,93 @@ +// 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-meth-static-dflt.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (static class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [Symbol.iterator, destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 method([...x] = iter) {} +}; + +assert.throws(Test262Error, function() { + C.method(); +}); diff --git a/test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-rest-id.js b/test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-rest-id.js new file mode 100644 index 0000000000..fc764301a9 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-rest-id.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id.case +// - src/dstr-binding/default/cls-expr-meth-static-dflt.template +/*--- +description: Lone rest element (static class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + [...] 3. Let A be ArrayCreate(0). [...] 5. Repeat + [...] + f. Let status be CreateDataProperty(A, ToString (n), nextValue). + [...] +---*/ +var values = [1, 2, 3]; + +var callCount = 0; +var C = class { + static method([...x] = values) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 1); + assert.sameValue(x[1], 2); + assert.sameValue(x[2], 3); + assert.notSameValue(x, values); + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-rest-init-ary.js b/test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-rest-init-ary.js new file mode 100644 index 0000000000..f0c231c163 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-rest-init-ary.js @@ -0,0 +1,78 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-ary.case +// - src/dstr-binding/default/cls-expr-meth-static-dflt.template +/*--- +description: Reset element (nested array pattern) does not support initializer (static class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +negative: SyntaxError +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +var C = class { + static method([...[ x ] = []] = []) { + + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-rest-init-id.js b/test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-rest-init-id.js new file mode 100644 index 0000000000..a415405973 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-rest-init-id.js @@ -0,0 +1,78 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-id.case +// - src/dstr-binding/default/cls-expr-meth-static-dflt.template +/*--- +description: Reset element (identifier) does not support initializer (static class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +negative: SyntaxError +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +var C = class { + static method([...x = []] = []) { + + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-rest-init-obj.js b/test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-rest-init-obj.js new file mode 100644 index 0000000000..f2a41ee688 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-rest-init-obj.js @@ -0,0 +1,78 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-obj.case +// - src/dstr-binding/default/cls-expr-meth-static-dflt.template +/*--- +description: Reset element (nested object pattern) does not support initializer (static class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +negative: SyntaxError +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +var C = class { + static method([...{ x } = []] = []) { + + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-rest-not-final-ary.js b/test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-rest-not-final-ary.js new file mode 100644 index 0000000000..0c60477e8b --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-rest-not-final-ary.js @@ -0,0 +1,78 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-ary.case +// - src/dstr-binding/default/cls-expr-meth-static-dflt.template +/*--- +description: Rest element (array binding pattern) may not be followed by any element (static class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +negative: SyntaxError +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +var C = class { + static method([...[x], y] = [1, 2, 3]) { + + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-rest-not-final-id.js b/test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-rest-not-final-id.js new file mode 100644 index 0000000000..be3b2675e3 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-rest-not-final-id.js @@ -0,0 +1,78 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-id.case +// - src/dstr-binding/default/cls-expr-meth-static-dflt.template +/*--- +description: Rest element (identifier) may not be followed by any element (static class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +negative: SyntaxError +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +var C = class { + static method([...x, y] = [1, 2, 3]) { + + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-rest-not-final-obj.js b/test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-rest-not-final-obj.js new file mode 100644 index 0000000000..9405e2430e --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-rest-not-final-obj.js @@ -0,0 +1,78 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-obj.case +// - src/dstr-binding/default/cls-expr-meth-static-dflt.template +/*--- +description: Rest element (object binding pattern) may not be followed by any element (static class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +negative: SyntaxError +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +var C = class { + static method([...{ x }, y] = [1, 2, 3]) { + + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-rest-obj-id.js b/test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-rest-obj-id.js new file mode 100644 index 0000000000..7af8a83a42 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-rest-obj-id.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-obj-id.case +// - src/dstr-binding/default/cls-expr-meth-static-dflt.template +/*--- +description: Rest element containing an object binding pattern (static class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ + +var callCount = 0; +var C = class { + static method([...{ length }] = [1, 2, 3]) { + assert.sameValue(length, 3); + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-rest-obj-prop-id.js b/test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-rest-obj-prop-id.js new file mode 100644 index 0000000000..103feca683 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-dflt-ary-ptrn-rest-obj-prop-id.js @@ -0,0 +1,92 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-obj-prop-id.case +// - src/dstr-binding/default/cls-expr-meth-static-dflt.template +/*--- +description: Rest element containing an object binding pattern (static class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ + +var callCount = 0; +var C = class { + static method([...{ 0: v, 1: w, 2: x, 3: y, length: z }] = [7, 8, 9]) { + assert.sameValue(v, 7); + assert.sameValue(w, 8); + assert.sameValue(x, 9); + assert.sameValue(y, undefined); + assert.sameValue(z, 3); + + assert.throws(ReferenceError, function() { + length; + }); + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-static-dflt-obj-init-null.js b/test/language/expressions/class/dstr-meth-static-dflt-obj-init-null.js new file mode 100644 index 0000000000..ed6abab839 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-dflt-obj-init-null.js @@ -0,0 +1,74 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-null.case +// - src/dstr-binding/error/cls-expr-meth-static-dflt.template +/*--- +description: Value specifed for object binding pattern must be object coercible (null) (static class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + +var C = class { + static method({} = null) {} +}; + +assert.throws(TypeError, function() { + C.method(); +}); diff --git a/test/language/expressions/class/dstr-meth-static-dflt-obj-init-undefined.js b/test/language/expressions/class/dstr-meth-static-dflt-obj-init-undefined.js new file mode 100644 index 0000000000..85849961b9 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-dflt-obj-init-undefined.js @@ -0,0 +1,74 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-undefined.case +// - src/dstr-binding/error/cls-expr-meth-static-dflt.template +/*--- +description: Value specifed for object binding pattern must be object coercible (undefined) (static class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + +var C = class { + static method({} = undefined) {} +}; + +assert.throws(TypeError, function() { + C.method(); +}); diff --git a/test/language/expressions/class/dstr-meth-static-dflt-obj-ptrn-empty.js b/test/language/expressions/class/dstr-meth-static-dflt-obj-ptrn-empty.js new file mode 100644 index 0000000000..bb6184f5a9 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-dflt-obj-ptrn-empty.js @@ -0,0 +1,83 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-empty.case +// - src/dstr-binding/default/cls-expr-meth-static-dflt.template +/*--- +description: No property access occurs for an "empty" object binding pattern (static class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ +var accessCount = 0; +var obj = Object.defineProperty({}, 'attr', { + get: function() { + accessCount += 1; + } +}); + +var callCount = 0; +var C = class { + static method({} = obj) { + assert.sameValue(accessCount, 0); + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-static-dflt-obj-ptrn-id-get-value-err.js b/test/language/expressions/class/dstr-meth-static-dflt-obj-ptrn-id-get-value-err.js new file mode 100644 index 0000000000..e33a08f45d --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-dflt-obj-ptrn-id-get-value-err.js @@ -0,0 +1,81 @@ +// 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-meth-static-dflt.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (static class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 method({ poisoned } = poisonedProperty) {} +}; + +assert.throws(Test262Error, function() { + C.method(); +}); diff --git a/test/language/expressions/class/dstr-meth-static-dflt-obj-ptrn-id-init-fn-name-arrow.js b/test/language/expressions/class/dstr-meth-static-dflt-obj-ptrn-id-init-fn-name-arrow.js new file mode 100644 index 0000000000..18752865cc --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-dflt-obj-ptrn-id-init-fn-name-arrow.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-arrow.case +// - src/dstr-binding/default/cls-expr-meth-static-dflt.template +/*--- +description: SingleNameBinding assigns `name` to arrow functions (static class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +var C = class { + static method({ arrow = () => {} } = {}) { + assert.sameValue(arrow.name, 'arrow'); + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-static-dflt-obj-ptrn-id-init-fn-name-class.js b/test/language/expressions/class/dstr-meth-static-dflt-obj-ptrn-id-init-fn-name-class.js new file mode 100644 index 0000000000..fb2f137356 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-dflt-obj-ptrn-id-init-fn-name-class.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-class.case +// - src/dstr-binding/default/cls-expr-meth-static-dflt.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (static class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +var C = class { + static method({ cls = class {}, xCls = class X {} } = {}) { + assert.sameValue(cls.name, 'cls'); + assert.notSameValue(xCls.name, 'xCls'); + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-static-dflt-obj-ptrn-id-init-fn-name-cover.js b/test/language/expressions/class/dstr-meth-static-dflt-obj-ptrn-id-init-fn-name-cover.js new file mode 100644 index 0000000000..1947a05f46 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-dflt-obj-ptrn-id-init-fn-name-cover.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-cover.case +// - src/dstr-binding/default/cls-expr-meth-static-dflt.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" functions "through" cover grammar (static class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +var C = class { + static method({ cover = (function () {}), xCover = (0, function() {}) } = {}) { + assert.sameValue(cover.name, 'cover'); + assert.notSameValue(xCover.name, 'xCover'); + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-static-dflt-obj-ptrn-id-init-fn-name-fn.js b/test/language/expressions/class/dstr-meth-static-dflt-obj-ptrn-id-init-fn-name-fn.js new file mode 100644 index 0000000000..260659b140 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-dflt-obj-ptrn-id-init-fn-name-fn.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-fn.case +// - src/dstr-binding/default/cls-expr-meth-static-dflt.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (static class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +var C = class { + static method({ fn = function () {}, xFn = function x() {} } = {}) { + assert.sameValue(fn.name, 'fn'); + assert.notSameValue(xFn.name, 'xFn'); + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-static-dflt-obj-ptrn-id-init-fn-name-gen.js b/test/language/expressions/class/dstr-meth-static-dflt-obj-ptrn-id-init-fn-name-gen.js new file mode 100644 index 0000000000..fd034e6d3c --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-dflt-obj-ptrn-id-init-fn-name-gen.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-gen.case +// - src/dstr-binding/default/cls-expr-meth-static-dflt.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (static class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +var C = class { + static method({ gen = function* () {}, xGen = function* x() {} } = {}) { + assert.sameValue(gen.name, 'gen'); + assert.notSameValue(xGen.name, 'xGen'); + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-static-dflt-obj-ptrn-id-init-skipped.js b/test/language/expressions/class/dstr-meth-static-dflt-obj-ptrn-id-init-skipped.js new file mode 100644 index 0000000000..dad3daca54 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-dflt-obj-ptrn-id-init-skipped.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-skipped.case +// - src/dstr-binding/default/cls-expr-meth-static-dflt.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (static class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + [...] +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var callCount = 0; +var C = class { + static method({ w = counter(), x = counter(), y = counter(), z = counter() } = { w: null, x: 0, y: false, z: '' }) { + assert.sameValue(w, null); + assert.sameValue(x, 0); + assert.sameValue(y, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-static-dflt-obj-ptrn-id-init-throws.js b/test/language/expressions/class/dstr-meth-static-dflt-obj-ptrn-id-init-throws.js new file mode 100644 index 0000000000..fcbbae5a42 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-dflt-obj-ptrn-id-init-throws.js @@ -0,0 +1,81 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-throws.case +// - src/dstr-binding/error/cls-expr-meth-static-dflt.template +/*--- +description: Error thrown when evaluating the initializer (static class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 method({ x = thrower() } = {}) {} +}; + +assert.throws(Test262Error, function() { + C.method(); +}); diff --git a/test/language/expressions/class/dstr-meth-static-dflt-obj-ptrn-id-init-unresolvable.js b/test/language/expressions/class/dstr-meth-static-dflt-obj-ptrn-id-init-unresolvable.js new file mode 100644 index 0000000000..1c7e7f44e4 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-dflt-obj-ptrn-id-init-unresolvable.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-unresolvable.case +// - src/dstr-binding/error/cls-expr-meth-static-dflt.template +/*--- +description: Destructuring initializer is an unresolvable reference (static class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 method({ x = unresolvableReference } = {}) {} +}; + +assert.throws(ReferenceError, function() { + C.method(); +}); diff --git a/test/language/expressions/class/dstr-meth-static-dflt-obj-ptrn-id-trailing-comma.js b/test/language/expressions/class/dstr-meth-static-dflt-obj-ptrn-id-trailing-comma.js new file mode 100644 index 0000000000..bf44827876 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-dflt-obj-ptrn-id-trailing-comma.js @@ -0,0 +1,78 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-trailing-comma.case +// - src/dstr-binding/default/cls-expr-meth-static-dflt.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (static class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var callCount = 0; +var C = class { + static method({ x, } = { x: 23 }) { + assert.sameValue(x, 23); + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-static-dflt-obj-ptrn-list-err.js b/test/language/expressions/class/dstr-meth-static-dflt-obj-ptrn-list-err.js new file mode 100644 index 0000000000..d7f55986bd --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-dflt-obj-ptrn-list-err.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-list-err.case +// - src/dstr-binding/error/cls-expr-meth-static-dflt.template +/*--- +description: Binding property list evaluation is interrupted by an abrupt completion (static class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 method({ a, b = thrower(), c = ++initCount } = {}) {} +}; + +assert.throws(Test262Error, function() { + C.method(); +}); + +assert.sameValue(initCount, 0); diff --git a/test/language/expressions/class/dstr-meth-static-dflt-obj-ptrn-prop-ary-init.js b/test/language/expressions/class/dstr-meth-static-dflt-obj-ptrn-prop-ary-init.js new file mode 100644 index 0000000000..67d6dfc5e9 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-dflt-obj-ptrn-prop-ary-init.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-init.case +// - src/dstr-binding/default/cls-expr-meth-static-dflt.template +/*--- +description: Object binding pattern with "nested" array binding pattern using initializer (static class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +var C = class { + static method({ w: [x, y, z] = [4, 5, 6] } = {}) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-static-dflt-obj-ptrn-prop-ary-trailing-comma.js b/test/language/expressions/class/dstr-meth-static-dflt-obj-ptrn-prop-ary-trailing-comma.js new file mode 100644 index 0000000000..c48b848e46 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-dflt-obj-ptrn-prop-ary-trailing-comma.js @@ -0,0 +1,78 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-trailing-comma.case +// - src/dstr-binding/default/cls-expr-meth-static-dflt.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (static class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var callCount = 0; +var C = class { + static method({ x: [y], } = { x: [45] }) { + assert.sameValue(y,45); + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-static-dflt-obj-ptrn-prop-ary-value-null.js b/test/language/expressions/class/dstr-meth-static-dflt-obj-ptrn-prop-ary-value-null.js new file mode 100644 index 0000000000..dc267a1c4a --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-dflt-obj-ptrn-prop-ary-value-null.js @@ -0,0 +1,76 @@ +// 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-meth-static-dflt.template +/*--- +description: Object binding pattern with "nested" array binding pattern taking the `null` value (static class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 method({ w: [x, y, z] = [4, 5, 6] } = { w: null }) {} +}; + +assert.throws(TypeError, function() { + C.method(); +}); diff --git a/test/language/expressions/class/dstr-meth-static-dflt-obj-ptrn-prop-ary.js b/test/language/expressions/class/dstr-meth-static-dflt-obj-ptrn-prop-ary.js new file mode 100644 index 0000000000..99d213df75 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-dflt-obj-ptrn-prop-ary.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary.case +// - src/dstr-binding/default/cls-expr-meth-static-dflt.template +/*--- +description: Object binding pattern with "nested" array binding pattern not using initializer (static class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +var C = class { + static method({ w: [x, y, z] = [4, 5, 6] } = { w: [7, undefined, ] }) { + assert.sameValue(x, 7); + assert.sameValue(y, undefined); + assert.sameValue(z, undefined); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-static-dflt-obj-ptrn-prop-eval-err.js b/test/language/expressions/class/dstr-meth-static-dflt-obj-ptrn-prop-eval-err.js new file mode 100644 index 0000000000..6c2f4d41c7 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-dflt-obj-ptrn-prop-eval-err.js @@ -0,0 +1,78 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-eval-err.case +// - src/dstr-binding/error/cls-expr-meth-static-dflt.template +/*--- +description: Evaluation of property name returns an abrupt completion (static class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 method({ [thrower()]: x } = {}) {} +}; + +assert.throws(Test262Error, function() { + C.method(); +}); diff --git a/test/language/expressions/class/dstr-meth-static-dflt-obj-ptrn-prop-id-get-value-err.js b/test/language/expressions/class/dstr-meth-static-dflt-obj-ptrn-prop-id-get-value-err.js new file mode 100644 index 0000000000..b5cde6af86 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-dflt-obj-ptrn-prop-id-get-value-err.js @@ -0,0 +1,83 @@ +// 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-meth-static-dflt.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (static class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 method({ poisoned: x = ++initEvalCount } = poisonedProperty) {} +}; + +assert.throws(Test262Error, function() { + C.method(); +}); + +assert.sameValue(initEvalCount, 0); diff --git a/test/language/expressions/class/dstr-meth-static-dflt-obj-ptrn-prop-id-init-skipped.js b/test/language/expressions/class/dstr-meth-static-dflt-obj-ptrn-prop-id-init-skipped.js new file mode 100644 index 0000000000..65bc9f2646 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-dflt-obj-ptrn-prop-id-init-skipped.js @@ -0,0 +1,100 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-skipped.case +// - src/dstr-binding/default/cls-expr-meth-static-dflt.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (static class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + [...] +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var callCount = 0; +var C = class { + static method({ s: t = counter(), u: v = counter(), w: x = counter(), y: z = counter() } = { s: null, u: 0, w: false, y: '' }) { + assert.sameValue(t, null); + assert.sameValue(v, 0); + assert.sameValue(x, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + + assert.throws(ReferenceError, function() { + s; + }); + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-static-dflt-obj-ptrn-prop-id-init-throws.js b/test/language/expressions/class/dstr-meth-static-dflt-obj-ptrn-prop-id-init-throws.js new file mode 100644 index 0000000000..61ec0cfaa2 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-dflt-obj-ptrn-prop-id-init-throws.js @@ -0,0 +1,81 @@ +// 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-meth-static-dflt.template +/*--- +description: Error thrown when evaluating the initializer (static class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 method({ x: y = thrower() } = {}) {} +}; + +assert.throws(Test262Error, function() { + C.method(); +}); diff --git a/test/language/expressions/class/dstr-meth-static-dflt-obj-ptrn-prop-id-init-unresolvable.js b/test/language/expressions/class/dstr-meth-static-dflt-obj-ptrn-prop-id-init-unresolvable.js new file mode 100644 index 0000000000..9518c430b6 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-dflt-obj-ptrn-prop-id-init-unresolvable.js @@ -0,0 +1,85 @@ +// 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-meth-static-dflt.template +/*--- +description: Destructuring initializer is an unresolvable reference (static class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 method({ x: y = unresolvableReference } = {}) {} +}; + +assert.throws(ReferenceError, function() { + C.method(); +}); diff --git a/test/language/expressions/class/dstr-meth-static-dflt-obj-ptrn-prop-id-init.js b/test/language/expressions/class/dstr-meth-static-dflt-obj-ptrn-prop-id-init.js new file mode 100644 index 0000000000..60c7d56c00 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-dflt-obj-ptrn-prop-id-init.js @@ -0,0 +1,81 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init.case +// - src/dstr-binding/default/cls-expr-meth-static-dflt.template +/*--- +description: Binding as specified via property name, identifier, and initializer (static class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var C = class { + static method({ x: y = 33 } = { }) { + assert.sameValue(y, 33); + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-static-dflt-obj-ptrn-prop-id-trailing-comma.js b/test/language/expressions/class/dstr-meth-static-dflt-obj-ptrn-prop-id-trailing-comma.js new file mode 100644 index 0000000000..42abd6e02a --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-dflt-obj-ptrn-prop-id-trailing-comma.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-trailing-comma.case +// - src/dstr-binding/default/cls-expr-meth-static-dflt.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (static class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var callCount = 0; +var C = class { + static method({ x: y, } = { x: 23 }) { + assert.sameValue(y, 23); + + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-static-dflt-obj-ptrn-prop-id.js b/test/language/expressions/class/dstr-meth-static-dflt-obj-ptrn-prop-id.js new file mode 100644 index 0000000000..b3fa74ac92 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-dflt-obj-ptrn-prop-id.js @@ -0,0 +1,81 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id.case +// - src/dstr-binding/default/cls-expr-meth-static-dflt.template +/*--- +description: Binding as specified via property name and identifier (static class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var C = class { + static method({ x: y } = { x: 23 }) { + assert.sameValue(y, 23); + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-static-dflt-obj-ptrn-prop-obj-init.js b/test/language/expressions/class/dstr-meth-static-dflt-obj-ptrn-prop-obj-init.js new file mode 100644 index 0000000000..dffcbf64fd --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-dflt-obj-ptrn-prop-obj-init.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-init.case +// - src/dstr-binding/default/cls-expr-meth-static-dflt.template +/*--- +description: Object binding pattern with "nested" object binding pattern using initializer (static class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +var C = class { + static method({ w: { x, y, z } = { x: 4, y: 5, z: 6 } } = { w: undefined }) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/dstr-meth-static-dflt-obj-ptrn-prop-obj-value-null.js b/test/language/expressions/class/dstr-meth-static-dflt-obj-ptrn-prop-obj-value-null.js new file mode 100644 index 0000000000..f2bc4be76e --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-dflt-obj-ptrn-prop-obj-value-null.js @@ -0,0 +1,76 @@ +// 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-meth-static-dflt.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (static class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 method({ w: { x, y, z } = { x: 4, y: 5, z: 6 } } = { w: null }) {} +}; + +assert.throws(TypeError, function() { + C.method(); +}); diff --git a/test/language/expressions/class/dstr-meth-static-dflt-obj-ptrn-prop-obj-value-undef.js b/test/language/expressions/class/dstr-meth-static-dflt-obj-ptrn-prop-obj-value-undef.js new file mode 100644 index 0000000000..48d8933af7 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-dflt-obj-ptrn-prop-obj-value-undef.js @@ -0,0 +1,76 @@ +// 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-meth-static-dflt.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (static class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 method({ w: { x, y, z } = undefined } = { }) {} +}; + +assert.throws(TypeError, function() { + C.method(); +}); diff --git a/test/language/expressions/class/dstr-meth-static-dflt-obj-ptrn-prop-obj.js b/test/language/expressions/class/dstr-meth-static-dflt-obj-ptrn-prop-obj.js new file mode 100644 index 0000000000..48c7c576a1 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-dflt-obj-ptrn-prop-obj.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj.case +// - src/dstr-binding/default/cls-expr-meth-static-dflt.template +/*--- +description: Object binding pattern with "nested" object binding pattern not using initializer (static class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +var C = class { + static method({ w: { x, y, z } = { x: 4, y: 5, z: 6 } } = { w: { x: undefined, z: 7 } }) { + assert.sameValue(x, undefined); + assert.sameValue(y, undefined); + assert.sameValue(z, 7); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/function/dstr-dflt-ary-init-iter-close.js b/test/language/expressions/function/dstr-dflt-ary-init-iter-close.js new file mode 100644 index 0000000000..61ec69fe8d --- /dev/null +++ b/test/language/expressions/function/dstr-dflt-ary-init-iter-close.js @@ -0,0 +1,73 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-close.case +// - src/dstr-binding/default/func-expr-dflt.template +/*--- +description: Iterator is closed when not exhausted by pattern evaluation (function expression (default parameter)) +esid: sec-function-definitions-runtime-semantics-evaluation +es6id: 14.1.20 +features: [Symbol.iterator, destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionExpression : function ( FormalParameters ) { FunctionBody } + + [...] + 3. Let closure be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + [...] + 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator, + result). + [...] + +---*/ +var doneCallCount = 0; +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return { value: null, done: false }; + }, + return: function() { + doneCallCount += 1; + return {}; + } + }; +}; + +var callCount = 0; +var f; +f = function([x] = iter) { + assert.sameValue(doneCallCount, 1); + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/expressions/function/dstr-dflt-ary-init-iter-get-err.js b/test/language/expressions/function/dstr-dflt-ary-init-iter-get-err.js new file mode 100644 index 0000000000..acac271e51 --- /dev/null +++ b/test/language/expressions/function/dstr-dflt-ary-init-iter-get-err.js @@ -0,0 +1,58 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-get-err.case +// - src/dstr-binding/error/func-expr-dflt.template +/*--- +description: Abrupt completion returned by GetIterator (function expression (default parameter)) +esid: sec-function-definitions-runtime-semantics-evaluation +es6id: 14.1.20 +features: [Symbol.iterator, destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionExpression : function ( FormalParameters ) { FunctionBody } + + [...] + 3. Let closure be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 = function([x] = iter) {}; + +assert.throws(Test262Error, function() { + f(); +}); diff --git a/test/language/expressions/function/dstr-dflt-ary-init-iter-no-close.js b/test/language/expressions/function/dstr-dflt-ary-init-iter-no-close.js new file mode 100644 index 0000000000..e4ff6e584d --- /dev/null +++ b/test/language/expressions/function/dstr-dflt-ary-init-iter-no-close.js @@ -0,0 +1,73 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-no-close.case +// - src/dstr-binding/default/func-expr-dflt.template +/*--- +description: Iterator is not closed when exhausted by pattern evaluation (function expression (default parameter)) +esid: sec-function-definitions-runtime-semantics-evaluation +es6id: 14.1.20 +features: [Symbol.iterator, destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionExpression : function ( FormalParameters ) { FunctionBody } + + [...] + 3. Let closure be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + [...] + 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator, + result). + [...] + +---*/ +var doneCallCount = 0; +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return { value: null, done: true }; + }, + return: function() { + doneCallCount += 1; + return {}; + } + }; +}; + +var callCount = 0; +var f; +f = function([x] = iter) { + assert.sameValue(doneCallCount, 0); + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/expressions/function/dstr-dflt-ary-name-iter-val.js b/test/language/expressions/function/dstr-dflt-ary-name-iter-val.js new file mode 100644 index 0000000000..5c38fee634 --- /dev/null +++ b/test/language/expressions/function/dstr-dflt-ary-name-iter-val.js @@ -0,0 +1,72 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-name-iter-val.case +// - src/dstr-binding/default/func-expr-dflt.template +/*--- +description: SingleNameBinding with normal value iteration (function expression (default parameter)) +esid: sec-function-definitions-runtime-semantics-evaluation +es6id: 14.1.20 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionExpression : function ( FormalParameters ) { FunctionBody } + + [...] + 3. Let closure be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set + iteratorRecord.[[done]] to true. + iii. ReturnIfAbrupt(v). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var f; +f = function([x, y, z] = [1, 2, 3]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 3); + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/expressions/function/dstr-dflt-ary-ptrn-elem-ary-elem-init.js b/test/language/expressions/function/dstr-dflt-ary-ptrn-elem-ary-elem-init.js new file mode 100644 index 0000000000..568ead28aa --- /dev/null +++ b/test/language/expressions/function/dstr-dflt-ary-ptrn-elem-ary-elem-init.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elem-init.case +// - src/dstr-binding/default/func-expr-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is used (function expression (default parameter)) +esid: sec-function-definitions-runtime-semantics-evaluation +es6id: 14.1.20 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionExpression : function ( FormalParameters ) { FunctionBody } + + [...] + 3. Let closure be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +var f; +f = function([[x, y, z] = [4, 5, 6]] = []) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/expressions/function/dstr-dflt-ary-ptrn-elem-ary-elem-iter.js b/test/language/expressions/function/dstr-dflt-ary-ptrn-elem-ary-elem-iter.js new file mode 100644 index 0000000000..89663d1062 --- /dev/null +++ b/test/language/expressions/function/dstr-dflt-ary-ptrn-elem-ary-elem-iter.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elem-iter.case +// - src/dstr-binding/default/func-expr-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (function expression (default parameter)) +esid: sec-function-definitions-runtime-semantics-evaluation +es6id: 14.1.20 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionExpression : function ( FormalParameters ) { FunctionBody } + + [...] + 3. Let closure be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +var f; +f = function([[x, y, z] = [4, 5, 6]] = [[7, 8, 9]]) { + assert.sameValue(x, 7); + assert.sameValue(y, 8); + assert.sameValue(z, 9); + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/expressions/function/dstr-dflt-ary-ptrn-elem-ary-elision-init.js b/test/language/expressions/function/dstr-dflt-ary-ptrn-elem-ary-elision-init.js new file mode 100644 index 0000000000..b34692e2d6 --- /dev/null +++ b/test/language/expressions/function/dstr-dflt-ary-ptrn-elem-ary-elision-init.js @@ -0,0 +1,71 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elision-init.case +// - src/dstr-binding/default/func-expr-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is used (function expression (default parameter)) +esid: sec-function-definitions-runtime-semantics-evaluation +es6id: 14.1.20 +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionExpression : function ( FormalParameters ) { FunctionBody } + + [...] + 3. Let closure be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var callCount = 0; +var f; +f = function([[,] = g()] = []) { + assert.sameValue(first, 1); + assert.sameValue(second, 0); + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/expressions/function/dstr-dflt-ary-ptrn-elem-ary-elision-iter.js b/test/language/expressions/function/dstr-dflt-ary-ptrn-elem-ary-elision-iter.js new file mode 100644 index 0000000000..f7f0362499 --- /dev/null +++ b/test/language/expressions/function/dstr-dflt-ary-ptrn-elem-ary-elision-iter.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elision-iter.case +// - src/dstr-binding/default/func-expr-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (function expression (default parameter)) +esid: sec-function-definitions-runtime-semantics-evaluation +es6id: 14.1.20 +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionExpression : function ( FormalParameters ) { FunctionBody } + + [...] + 3. Let closure be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var callCount = 0; +function* g() { + callCount += 1; +}; + +var callCount = 0; +var f; +f = function([[,] = g()] = [[]]) { + assert.sameValue(callCount, 0); + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/expressions/function/dstr-dflt-ary-ptrn-elem-ary-empty-init.js b/test/language/expressions/function/dstr-dflt-ary-ptrn-elem-ary-empty-init.js new file mode 100644 index 0000000000..f8103883b3 --- /dev/null +++ b/test/language/expressions/function/dstr-dflt-ary-ptrn-elem-ary-empty-init.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-empty-init.case +// - src/dstr-binding/default/func-expr-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is used (function expression (default parameter)) +esid: sec-function-definitions-runtime-semantics-evaluation +es6id: 14.1.20 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionExpression : function ( FormalParameters ) { FunctionBody } + + [...] + 3. Let closure be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var initCount = 0; +var iterCount = 0; +var iter = function*() { iterCount += 1; }(); + +var callCount = 0; +var f; +f = function([[] = function() { initCount += 1; return iter; }()] = []) { + assert.sameValue(initCount, 1); + assert.sameValue(iterCount, 0); + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/expressions/function/dstr-dflt-ary-ptrn-elem-ary-empty-iter.js b/test/language/expressions/function/dstr-dflt-ary-ptrn-elem-ary-empty-iter.js new file mode 100644 index 0000000000..f254bc9c69 --- /dev/null +++ b/test/language/expressions/function/dstr-dflt-ary-ptrn-elem-ary-empty-iter.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-empty-iter.case +// - src/dstr-binding/default/func-expr-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (function expression (default parameter)) +esid: sec-function-definitions-runtime-semantics-evaluation +es6id: 14.1.20 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionExpression : function ( FormalParameters ) { FunctionBody } + + [...] + 3. Let closure be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var initCount = 0; + +var callCount = 0; +var f; +f = function([[] = function() { initCount += 1; }()] = [[23]]) { + assert.sameValue(initCount, 0); + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/expressions/function/dstr-dflt-ary-ptrn-elem-ary-rest-init.js b/test/language/expressions/function/dstr-dflt-ary-ptrn-elem-ary-rest-init.js new file mode 100644 index 0000000000..edf0315712 --- /dev/null +++ b/test/language/expressions/function/dstr-dflt-ary-ptrn-elem-ary-rest-init.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-rest-init.case +// - src/dstr-binding/default/func-expr-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is used (function expression (default parameter)) +esid: sec-function-definitions-runtime-semantics-evaluation +es6id: 14.1.20 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionExpression : function ( FormalParameters ) { FunctionBody } + + [...] + 3. Let closure be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var values = [2, 1, 3]; + +var callCount = 0; +var f; +f = function([[...x] = values] = []) { + assert(Array.isArray(x)); + assert.sameValue(x[0], 2); + assert.sameValue(x[1], 1); + assert.sameValue(x[2], 3); + assert.sameValue(x.length, 3); + assert.notSameValue(x, values); + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/expressions/function/dstr-dflt-ary-ptrn-elem-ary-rest-iter.js b/test/language/expressions/function/dstr-dflt-ary-ptrn-elem-ary-rest-iter.js new file mode 100644 index 0000000000..34303bf126 --- /dev/null +++ b/test/language/expressions/function/dstr-dflt-ary-ptrn-elem-ary-rest-iter.js @@ -0,0 +1,71 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-rest-iter.case +// - src/dstr-binding/default/func-expr-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (function expression (default parameter)) +esid: sec-function-definitions-runtime-semantics-evaluation +es6id: 14.1.20 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionExpression : function ( FormalParameters ) { FunctionBody } + + [...] + 3. Let closure be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var values = [2, 1, 3]; +var initCount = 0; + +var callCount = 0; +var f; +f = function([[...x] = function() { initCount += 1; }()] = [values]) { + assert(Array.isArray(x)); + assert.sameValue(x[0], 2); + assert.sameValue(x[1], 1); + assert.sameValue(x[2], 3); + assert.sameValue(x.length, 3); + assert.notSameValue(x, values); + assert.sameValue(initCount, 0); + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/expressions/function/dstr-dflt-ary-ptrn-elem-ary-val-null.js b/test/language/expressions/function/dstr-dflt-ary-ptrn-elem-ary-val-null.js new file mode 100644 index 0000000000..39a2793d66 --- /dev/null +++ b/test/language/expressions/function/dstr-dflt-ary-ptrn-elem-ary-val-null.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-val-null.case +// - src/dstr-binding/error/func-expr-dflt.template +/*--- +description: Nested array destructuring with a null value (function expression (default parameter)) +esid: sec-function-definitions-runtime-semantics-evaluation +es6id: 14.1.20 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionExpression : function ( FormalParameters ) { FunctionBody } + + [...] + 3. Let closure be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 = function([[x]] = [null]) {}; + +assert.throws(TypeError, function() { + f(); +}); diff --git a/test/language/expressions/function/dstr-dflt-ary-ptrn-elem-id-init-exhausted.js b/test/language/expressions/function/dstr-dflt-ary-ptrn-elem-id-init-exhausted.js new file mode 100644 index 0000000000..469020ee4f --- /dev/null +++ b/test/language/expressions/function/dstr-dflt-ary-ptrn-elem-id-init-exhausted.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-exhausted.case +// - src/dstr-binding/default/func-expr-dflt.template +/*--- +description: Destructuring initializer with an exhausted iterator (function expression (default parameter)) +esid: sec-function-definitions-runtime-semantics-evaluation +es6id: 14.1.20 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionExpression : function ( FormalParameters ) { FunctionBody } + + [...] + 3. Let closure be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var f; +f = function([x = 23] = []) { + assert.sameValue(x, 23); + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/expressions/function/dstr-dflt-ary-ptrn-elem-id-init-fn-name-arrow.js b/test/language/expressions/function/dstr-dflt-ary-ptrn-elem-id-init-fn-name-arrow.js new file mode 100644 index 0000000000..8f5350408b --- /dev/null +++ b/test/language/expressions/function/dstr-dflt-ary-ptrn-elem-id-init-fn-name-arrow.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-arrow.case +// - src/dstr-binding/default/func-expr-dflt.template +/*--- +description: SingleNameBinding does assign name to arrow functions (function expression (default parameter)) +esid: sec-function-definitions-runtime-semantics-evaluation +es6id: 14.1.20 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionExpression : function ( FormalParameters ) { FunctionBody } + + [...] + 3. Let closure be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var f; +f = function([arrow = () => {}] = []) { + assert.sameValue(arrow.name, 'arrow'); + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/expressions/function/dstr-dflt-ary-ptrn-elem-id-init-fn-name-class.js b/test/language/expressions/function/dstr-dflt-ary-ptrn-elem-id-init-fn-name-class.js new file mode 100644 index 0000000000..3cbe731bb0 --- /dev/null +++ b/test/language/expressions/function/dstr-dflt-ary-ptrn-elem-id-init-fn-name-class.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-class.case +// - src/dstr-binding/default/func-expr-dflt.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (function expression (default parameter)) +esid: sec-function-definitions-runtime-semantics-evaluation +es6id: 14.1.20 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionExpression : function ( FormalParameters ) { FunctionBody } + + [...] + 3. Let closure be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var f; +f = function([cls = class {}, xCls = class X {}] = []) { + assert.sameValue(cls.name, 'cls'); + assert.notSameValue(xCls.name, 'xCls'); + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/expressions/function/dstr-dflt-ary-ptrn-elem-id-init-fn-name-cover.js b/test/language/expressions/function/dstr-dflt-ary-ptrn-elem-id-init-fn-name-cover.js new file mode 100644 index 0000000000..2bceb488f5 --- /dev/null +++ b/test/language/expressions/function/dstr-dflt-ary-ptrn-elem-id-init-fn-name-cover.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-cover.case +// - src/dstr-binding/default/func-expr-dflt.template +/*--- +description: SingleNameBinding does assign name to "anonymous" functions "through" cover grammar (function expression (default parameter)) +esid: sec-function-definitions-runtime-semantics-evaluation +es6id: 14.1.20 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionExpression : function ( FormalParameters ) { FunctionBody } + + [...] + 3. Let closure be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var f; +f = function([cover = (function () {}), xCover = (0, function() {})] = []) { + assert.sameValue(cover.name, 'cover'); + assert.notSameValue(xCover.name, 'xCover'); + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/expressions/function/dstr-dflt-ary-ptrn-elem-id-init-fn-name-fn.js b/test/language/expressions/function/dstr-dflt-ary-ptrn-elem-id-init-fn-name-fn.js new file mode 100644 index 0000000000..36115b5afd --- /dev/null +++ b/test/language/expressions/function/dstr-dflt-ary-ptrn-elem-id-init-fn-name-fn.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-fn.case +// - src/dstr-binding/default/func-expr-dflt.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (function expression (default parameter)) +esid: sec-function-definitions-runtime-semantics-evaluation +es6id: 14.1.20 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionExpression : function ( FormalParameters ) { FunctionBody } + + [...] + 3. Let closure be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var f; +f = function([fn = function () {}, xFn = function x() {}] = []) { + assert.sameValue(fn.name, 'fn'); + assert.notSameValue(xFn.name, 'xFn'); + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/expressions/function/dstr-dflt-ary-ptrn-elem-id-init-fn-name-gen.js b/test/language/expressions/function/dstr-dflt-ary-ptrn-elem-id-init-fn-name-gen.js new file mode 100644 index 0000000000..3bf148a168 --- /dev/null +++ b/test/language/expressions/function/dstr-dflt-ary-ptrn-elem-id-init-fn-name-gen.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-gen.case +// - src/dstr-binding/default/func-expr-dflt.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (function expression (default parameter)) +esid: sec-function-definitions-runtime-semantics-evaluation +es6id: 14.1.20 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionExpression : function ( FormalParameters ) { FunctionBody } + + [...] + 3. Let closure be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var f; +f = function([gen = function* () {}, xGen = function* x() {}] = []) { + assert.sameValue(gen.name, 'gen'); + assert.notSameValue(xGen.name, 'xGen'); + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/expressions/function/dstr-dflt-ary-ptrn-elem-id-init-hole.js b/test/language/expressions/function/dstr-dflt-ary-ptrn-elem-id-init-hole.js new file mode 100644 index 0000000000..28fd5e4d42 --- /dev/null +++ b/test/language/expressions/function/dstr-dflt-ary-ptrn-elem-id-init-hole.js @@ -0,0 +1,59 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-hole.case +// - src/dstr-binding/default/func-expr-dflt.template +/*--- +description: Destructuring initializer with a "hole" (function expression (default parameter)) +esid: sec-function-definitions-runtime-semantics-evaluation +es6id: 14.1.20 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionExpression : function ( FormalParameters ) { FunctionBody } + + [...] + 3. Let closure be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + SingleNameBinding : BindingIdentifier Initializeropt + [...] 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + [...] + 7. If environment is undefined, return PutValue(lhs, v). 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var f; +f = function([x = 23] = [,]) { + assert.sameValue(x, 23); + // another statement + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/expressions/function/dstr-dflt-ary-ptrn-elem-id-init-skipped.js b/test/language/expressions/function/dstr-dflt-ary-ptrn-elem-id-init-skipped.js new file mode 100644 index 0000000000..7822041a8a --- /dev/null +++ b/test/language/expressions/function/dstr-dflt-ary-ptrn-elem-id-init-skipped.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-skipped.case +// - src/dstr-binding/default/func-expr-dflt.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (function expression (default parameter)) +esid: sec-function-definitions-runtime-semantics-evaluation +es6id: 14.1.20 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionExpression : function ( FormalParameters ) { FunctionBody } + + [...] + 3. Let closure be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var callCount = 0; +var f; +f = function([w = counter(), x = counter(), y = counter(), z = counter()] = [null, 0, false, '']) { + assert.sameValue(w, null); + assert.sameValue(x, 0); + assert.sameValue(y, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/expressions/function/dstr-dflt-ary-ptrn-elem-id-init-throws.js b/test/language/expressions/function/dstr-dflt-ary-ptrn-elem-id-init-throws.js new file mode 100644 index 0000000000..135e42ec5c --- /dev/null +++ b/test/language/expressions/function/dstr-dflt-ary-ptrn-elem-id-init-throws.js @@ -0,0 +1,56 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-throws.case +// - src/dstr-binding/error/func-expr-dflt.template +/*--- +description: Destructuring initializer returns an abrupt completion (function expression (default parameter)) +esid: sec-function-definitions-runtime-semantics-evaluation +es6id: 14.1.20 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionExpression : function ( FormalParameters ) { FunctionBody } + + [...] + 3. Let closure be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 = function([x = (function() { throw new Test262Error(); })()] = [undefined]) {}; + +assert.throws(Test262Error, function() { + f(); +}); diff --git a/test/language/expressions/function/dstr-dflt-ary-ptrn-elem-id-init-undef.js b/test/language/expressions/function/dstr-dflt-ary-ptrn-elem-id-init-undef.js new file mode 100644 index 0000000000..a8a5783dbf --- /dev/null +++ b/test/language/expressions/function/dstr-dflt-ary-ptrn-elem-id-init-undef.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-undef.case +// - src/dstr-binding/default/func-expr-dflt.template +/*--- +description: Destructuring initializer with an undefined value (function expression (default parameter)) +esid: sec-function-definitions-runtime-semantics-evaluation +es6id: 14.1.20 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionExpression : function ( FormalParameters ) { FunctionBody } + + [...] + 3. Let closure be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var f; +f = function([x = 23] = [undefined]) { + assert.sameValue(x, 23); + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/expressions/function/dstr-dflt-ary-ptrn-elem-id-init-unresolvable.js b/test/language/expressions/function/dstr-dflt-ary-ptrn-elem-id-init-unresolvable.js new file mode 100644 index 0000000000..997715249a --- /dev/null +++ b/test/language/expressions/function/dstr-dflt-ary-ptrn-elem-id-init-unresolvable.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-unresolvable.case +// - src/dstr-binding/error/func-expr-dflt.template +/*--- +description: Destructuring initializer is an unresolvable reference (function expression (default parameter)) +esid: sec-function-definitions-runtime-semantics-evaluation +es6id: 14.1.20 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionExpression : function ( FormalParameters ) { FunctionBody } + + [...] + 3. Let closure be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 = function([ x = unresolvableReference ] = []) {}; + +assert.throws(ReferenceError, function() { + f(); +}); diff --git a/test/language/expressions/function/dstr-dflt-ary-ptrn-elem-id-iter-complete.js b/test/language/expressions/function/dstr-dflt-ary-ptrn-elem-id-iter-complete.js new file mode 100644 index 0000000000..0973207f3f --- /dev/null +++ b/test/language/expressions/function/dstr-dflt-ary-ptrn-elem-id-iter-complete.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-complete.case +// - src/dstr-binding/default/func-expr-dflt.template +/*--- +description: SingleNameBinding when value iteration completes (function expression (default parameter)) +esid: sec-function-definitions-runtime-semantics-evaluation +es6id: 14.1.20 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionExpression : function ( FormalParameters ) { FunctionBody } + + [...] + 3. Let closure be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var f; +f = function([x] = []) { + assert.sameValue(x, undefined); + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/expressions/function/dstr-dflt-ary-ptrn-elem-id-iter-done.js b/test/language/expressions/function/dstr-dflt-ary-ptrn-elem-id-iter-done.js new file mode 100644 index 0000000000..f308b8a522 --- /dev/null +++ b/test/language/expressions/function/dstr-dflt-ary-ptrn-elem-id-iter-done.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-done.case +// - src/dstr-binding/default/func-expr-dflt.template +/*--- +description: SingleNameBinding when value iteration was completed previously (function expression (default parameter)) +esid: sec-function-definitions-runtime-semantics-evaluation +es6id: 14.1.20 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionExpression : function ( FormalParameters ) { FunctionBody } + + [...] + 3. Let closure be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var f; +f = function([_, x] = []) { + assert.sameValue(x, undefined); + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/expressions/function/dstr-dflt-ary-ptrn-elem-id-iter-step-err.js b/test/language/expressions/function/dstr-dflt-ary-ptrn-elem-id-iter-step-err.js new file mode 100644 index 0000000000..784b52b19d --- /dev/null +++ b/test/language/expressions/function/dstr-dflt-ary-ptrn-elem-id-iter-step-err.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-step-err.case +// - src/dstr-binding/error/func-expr-dflt.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (function expression (default parameter)) +esid: sec-function-definitions-runtime-semantics-evaluation +es6id: 14.1.20 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionExpression : function ( FormalParameters ) { FunctionBody } + + [...] + 3. Let closure be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 = function([x] = g) {}; + +assert.throws(Test262Error, function() { + f(); +}); diff --git a/test/language/expressions/function/dstr-dflt-ary-ptrn-elem-id-iter-val-err.js b/test/language/expressions/function/dstr-dflt-ary-ptrn-elem-id-iter-val-err.js new file mode 100644 index 0000000000..f2a41b220b --- /dev/null +++ b/test/language/expressions/function/dstr-dflt-ary-ptrn-elem-id-iter-val-err.js @@ -0,0 +1,75 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val-err.case +// - src/dstr-binding/error/func-expr-dflt.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (function expression (default parameter)) +esid: sec-function-definitions-runtime-semantics-evaluation +es6id: 14.1.20 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionExpression : function ( FormalParameters ) { FunctionBody } + + [...] + 3. Let closure be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 = function([x] = g) {}; + +assert.throws(Test262Error, function() { + f(); +}); diff --git a/test/language/expressions/function/dstr-dflt-ary-ptrn-elem-id-iter-val.js b/test/language/expressions/function/dstr-dflt-ary-ptrn-elem-id-iter-val.js new file mode 100644 index 0000000000..bf4ec1b4f1 --- /dev/null +++ b/test/language/expressions/function/dstr-dflt-ary-ptrn-elem-id-iter-val.js @@ -0,0 +1,72 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val.case +// - src/dstr-binding/default/func-expr-dflt.template +/*--- +description: SingleNameBinding when value iteration was completed previously (function expression (default parameter)) +esid: sec-function-definitions-runtime-semantics-evaluation +es6id: 14.1.20 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionExpression : function ( FormalParameters ) { FunctionBody } + + [...] + 3. Let closure be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set + iteratorRecord.[[done]] to true. + iii. ReturnIfAbrupt(v). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var f; +f = function([x, y, z] = [1, 2, 3]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 3); + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/expressions/function/dstr-dflt-ary-ptrn-elem-obj-id-init.js b/test/language/expressions/function/dstr-dflt-ary-ptrn-elem-obj-id-init.js new file mode 100644 index 0000000000..50be24e8fd --- /dev/null +++ b/test/language/expressions/function/dstr-dflt-ary-ptrn-elem-obj-id-init.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-id-init.case +// - src/dstr-binding/default/func-expr-dflt.template +/*--- +description: BindingElement with object binding pattern and initializer is used (function expression (default parameter)) +esid: sec-function-definitions-runtime-semantics-evaluation +es6id: 14.1.20 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionExpression : function ( FormalParameters ) { FunctionBody } + + [...] + 3. Let closure be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +var f; +f = function([{ x, y, z } = { x: 44, y: 55, z: 66 }] = []) { + assert.sameValue(x, 44); + assert.sameValue(y, 55); + assert.sameValue(z, 66); + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/expressions/function/dstr-dflt-ary-ptrn-elem-obj-id.js b/test/language/expressions/function/dstr-dflt-ary-ptrn-elem-obj-id.js new file mode 100644 index 0000000000..e6154875bf --- /dev/null +++ b/test/language/expressions/function/dstr-dflt-ary-ptrn-elem-obj-id.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-id.case +// - src/dstr-binding/default/func-expr-dflt.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (function expression (default parameter)) +esid: sec-function-definitions-runtime-semantics-evaluation +es6id: 14.1.20 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionExpression : function ( FormalParameters ) { FunctionBody } + + [...] + 3. Let closure be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +var f; +f = function([{ x, y, z } = { x: 44, y: 55, z: 66 }] = [{ x: 11, y: 22, z: 33 }]) { + assert.sameValue(x, 11); + assert.sameValue(y, 22); + assert.sameValue(z, 33); + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/expressions/function/dstr-dflt-ary-ptrn-elem-obj-prop-id-init.js b/test/language/expressions/function/dstr-dflt-ary-ptrn-elem-obj-prop-id-init.js new file mode 100644 index 0000000000..d25433b1a0 --- /dev/null +++ b/test/language/expressions/function/dstr-dflt-ary-ptrn-elem-obj-prop-id-init.js @@ -0,0 +1,74 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-prop-id-init.case +// - src/dstr-binding/default/func-expr-dflt.template +/*--- +description: BindingElement with object binding pattern and initializer is used (function expression (default parameter)) +esid: sec-function-definitions-runtime-semantics-evaluation +es6id: 14.1.20 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionExpression : function ( FormalParameters ) { FunctionBody } + + [...] + 3. Let closure be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +var f; +f = function([{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }] = []) { + assert.sameValue(v, 444); + assert.sameValue(x, 555); + assert.sameValue(z, 666); + + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/expressions/function/dstr-dflt-ary-ptrn-elem-obj-prop-id.js b/test/language/expressions/function/dstr-dflt-ary-ptrn-elem-obj-prop-id.js new file mode 100644 index 0000000000..a4347ae540 --- /dev/null +++ b/test/language/expressions/function/dstr-dflt-ary-ptrn-elem-obj-prop-id.js @@ -0,0 +1,74 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-prop-id.case +// - src/dstr-binding/default/func-expr-dflt.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (function expression (default parameter)) +esid: sec-function-definitions-runtime-semantics-evaluation +es6id: 14.1.20 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionExpression : function ( FormalParameters ) { FunctionBody } + + [...] + 3. Let closure be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +var f; +f = function([{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }] = [{ u: 777, w: 888, y: 999 }]) { + assert.sameValue(v, 777); + assert.sameValue(x, 888); + assert.sameValue(z, 999); + + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/expressions/function/dstr-dflt-ary-ptrn-elem-obj-val-null.js b/test/language/expressions/function/dstr-dflt-ary-ptrn-elem-obj-val-null.js new file mode 100644 index 0000000000..da576a62de --- /dev/null +++ b/test/language/expressions/function/dstr-dflt-ary-ptrn-elem-obj-val-null.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-null.case +// - src/dstr-binding/error/func-expr-dflt.template +/*--- +description: Nested object destructuring with a null value (function expression (default parameter)) +esid: sec-function-definitions-runtime-semantics-evaluation +es6id: 14.1.20 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionExpression : function ( FormalParameters ) { FunctionBody } + + [...] + 3. Let closure be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 = function([{ x }] = [null]) {}; + +assert.throws(TypeError, function() { + f(); +}); diff --git a/test/language/expressions/function/dstr-dflt-ary-ptrn-elem-obj-val-undef.js b/test/language/expressions/function/dstr-dflt-ary-ptrn-elem-obj-val-undef.js new file mode 100644 index 0000000000..fdf9e2ca38 --- /dev/null +++ b/test/language/expressions/function/dstr-dflt-ary-ptrn-elem-obj-val-undef.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-undef.case +// - src/dstr-binding/error/func-expr-dflt.template +/*--- +description: Nested object destructuring with a value of `undefined` (function expression (default parameter)) +esid: sec-function-definitions-runtime-semantics-evaluation +es6id: 14.1.20 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionExpression : function ( FormalParameters ) { FunctionBody } + + [...] + 3. Let closure be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 = function([{ x }] = []) {}; + +assert.throws(TypeError, function() { + f(); +}); diff --git a/test/language/expressions/function/dstr-dflt-ary-ptrn-elision-exhausted.js b/test/language/expressions/function/dstr-dflt-ary-ptrn-elision-exhausted.js new file mode 100644 index 0000000000..01ccef9c51 --- /dev/null +++ b/test/language/expressions/function/dstr-dflt-ary-ptrn-elision-exhausted.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-exhausted.case +// - src/dstr-binding/default/func-expr-dflt.template +/*--- +description: Elision accepts exhausted iterator (function expression (default parameter)) +esid: sec-function-definitions-runtime-semantics-evaluation +es6id: 14.1.20 +features: [generator, destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionExpression : function ( FormalParameters ) { FunctionBody } + + [...] + 3. Let closure be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + [...] + 2. Return NormalCompletion(empty). + +---*/ +var iter = function*() {}(); +iter.next(); + +var callCount = 0; +var f; +f = function([,] = iter) { + + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/expressions/function/dstr-dflt-ary-ptrn-elision-step-err.js b/test/language/expressions/function/dstr-dflt-ary-ptrn-elision-step-err.js new file mode 100644 index 0000000000..a64145b66c --- /dev/null +++ b/test/language/expressions/function/dstr-dflt-ary-ptrn-elision-step-err.js @@ -0,0 +1,72 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-step-err.case +// - src/dstr-binding/error/func-expr-dflt.template +/*--- +description: Elision advances iterator and forwards abrupt completions (function expression (default parameter)) +esid: sec-function-definitions-runtime-semantics-evaluation +es6id: 14.1.20 +features: [generator, destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionExpression : function ( FormalParameters ) { FunctionBody } + + [...] + 3. Let closure be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 = function([,] = iter) {}; + +assert.throws(Test262Error, function() { + f(); +}); + +iter.next(); +assert.sameValue(following, 0, 'Iterator was properly closed.'); diff --git a/test/language/expressions/function/dstr-dflt-ary-ptrn-elision.js b/test/language/expressions/function/dstr-dflt-ary-ptrn-elision.js new file mode 100644 index 0000000000..f176ccdcc2 --- /dev/null +++ b/test/language/expressions/function/dstr-dflt-ary-ptrn-elision.js @@ -0,0 +1,78 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision.case +// - src/dstr-binding/default/func-expr-dflt.template +/*--- +description: Elision advances iterator (function expression (default parameter)) +esid: sec-function-definitions-runtime-semantics-evaluation +es6id: 14.1.20 +features: [generator, destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionExpression : function ( FormalParameters ) { FunctionBody } + + [...] + 3. Let closure be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + 2. Return NormalCompletion(empty). + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var callCount = 0; +var f; +f = function([,] = g()) { + assert.sameValue(first, 1); + assert.sameValue(second, 0); + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/expressions/function/dstr-dflt-ary-ptrn-empty.js b/test/language/expressions/function/dstr-dflt-ary-ptrn-empty.js new file mode 100644 index 0000000000..81450e9a7b --- /dev/null +++ b/test/language/expressions/function/dstr-dflt-ary-ptrn-empty.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-empty.case +// - src/dstr-binding/default/func-expr-dflt.template +/*--- +description: No iteration occurs for an "empty" array binding pattern (function expression (default parameter)) +esid: sec-function-definitions-runtime-semantics-evaluation +es6id: 14.1.20 +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionExpression : function ( FormalParameters ) { FunctionBody } + + [...] + 3. Let closure be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ ] + + 1. Return NormalCompletion(empty). + +---*/ +var iterations = 0; +var iter = function*() { + iterations += 1; +}(); + +var callCount = 0; +var f; +f = function([] = iter) { + assert.sameValue(iterations, 0); + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/expressions/function/dstr-dflt-ary-ptrn-rest-ary-elem.js b/test/language/expressions/function/dstr-dflt-ary-ptrn-rest-ary-elem.js new file mode 100644 index 0000000000..692dcf2e06 --- /dev/null +++ b/test/language/expressions/function/dstr-dflt-ary-ptrn-rest-ary-elem.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-elem.case +// - src/dstr-binding/default/func-expr-dflt.template +/*--- +description: Rest element containing an array BindingElementList pattern (function expression (default parameter)) +esid: sec-function-definitions-runtime-semantics-evaluation +es6id: 14.1.20 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionExpression : function ( FormalParameters ) { FunctionBody } + + [...] + 3. Let closure be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set + iteratorRecord.[[done]] to true. + iii. ReturnIfAbrupt(v). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var f; +f = function([...[x, y, z]] = [3, 4, 5]) { + assert.sameValue(x, 3); + assert.sameValue(y, 4); + assert.sameValue(z, 5); + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/expressions/function/dstr-dflt-ary-ptrn-rest-ary-elision.js b/test/language/expressions/function/dstr-dflt-ary-ptrn-rest-ary-elision.js new file mode 100644 index 0000000000..8c7ec5482b --- /dev/null +++ b/test/language/expressions/function/dstr-dflt-ary-ptrn-rest-ary-elision.js @@ -0,0 +1,91 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-elision.case +// - src/dstr-binding/default/func-expr-dflt.template +/*--- +description: Rest element containing an elision (function expression (default parameter)) +esid: sec-function-definitions-runtime-semantics-evaluation +es6id: 14.1.20 +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionExpression : function ( FormalParameters ) { FunctionBody } + + [...] + 3. Let closure be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + 2. Return NormalCompletion(empty). + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var callCount = 0; +var f; +f = function([...[,]] = g()) { + assert.sameValue(first, 1); + assert.sameValue(second, 1); + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/expressions/function/dstr-dflt-ary-ptrn-rest-ary-empty.js b/test/language/expressions/function/dstr-dflt-ary-ptrn-rest-ary-empty.js new file mode 100644 index 0000000000..11a9a2fba4 --- /dev/null +++ b/test/language/expressions/function/dstr-dflt-ary-ptrn-rest-ary-empty.js @@ -0,0 +1,74 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-empty.case +// - src/dstr-binding/default/func-expr-dflt.template +/*--- +description: Rest element containing an "empty" array pattern (function expression (default parameter)) +esid: sec-function-definitions-runtime-semantics-evaluation +es6id: 14.1.20 +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionExpression : function ( FormalParameters ) { FunctionBody } + + [...] + 3. Let closure be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ ] + + 1. Return NormalCompletion(empty). + +---*/ +var iterations = 0; +var iter = function*() { + iterations += 1; +}(); + +var callCount = 0; +var f; +f = function([...[]] = iter) { + assert.sameValue(iterations, 1); + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/expressions/function/dstr-dflt-ary-ptrn-rest-ary-rest.js b/test/language/expressions/function/dstr-dflt-ary-ptrn-rest-ary-rest.js new file mode 100644 index 0000000000..c2270afc0d --- /dev/null +++ b/test/language/expressions/function/dstr-dflt-ary-ptrn-rest-ary-rest.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-rest.case +// - src/dstr-binding/default/func-expr-dflt.template +/*--- +description: Rest element containing a rest element (function expression (default parameter)) +esid: sec-function-definitions-runtime-semantics-evaluation +es6id: 14.1.20 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionExpression : function ( FormalParameters ) { FunctionBody } + + [...] + 3. Let closure be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ +var values = [1, 2, 3]; + +var callCount = 0; +var f; +f = function([...[...x]] = values) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 1); + assert.sameValue(x[1], 2); + assert.sameValue(x[2], 3); + assert.notSameValue(x, values); + + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/expressions/function/dstr-dflt-ary-ptrn-rest-id-elision-next-err.js b/test/language/expressions/function/dstr-dflt-ary-ptrn-rest-id-elision-next-err.js new file mode 100644 index 0000000000..b9376e410e --- /dev/null +++ b/test/language/expressions/function/dstr-dflt-ary-ptrn-rest-id-elision-next-err.js @@ -0,0 +1,58 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision-next-err.case +// - src/dstr-binding/error/func-expr-dflt.template +/*--- +description: Rest element following elision elements (function expression (default parameter)) +esid: sec-function-definitions-runtime-semantics-evaluation +es6id: 14.1.20 +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionExpression : function ( FormalParameters ) { FunctionBody } + + [...] + 3. Let closure be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 = function([, ...x] = iter) {}; + +assert.throws(Test262Error, function() { + f(); +}); diff --git a/test/language/expressions/function/dstr-dflt-ary-ptrn-rest-id-elision.js b/test/language/expressions/function/dstr-dflt-ary-ptrn-rest-id-elision.js new file mode 100644 index 0000000000..21401ec829 --- /dev/null +++ b/test/language/expressions/function/dstr-dflt-ary-ptrn-rest-id-elision.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision.case +// - src/dstr-binding/default/func-expr-dflt.template +/*--- +description: Rest element following elision elements (function expression (default parameter)) +esid: sec-function-definitions-runtime-semantics-evaluation +es6id: 14.1.20 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionExpression : function ( FormalParameters ) { FunctionBody } + + [...] + 3. Let closure be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + ArrayBindingPattern : [ Elisionopt BindingRestElement ] + 1. If Elision is present, then + a. Let status be the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with + iteratorRecord as the argument. + b. ReturnIfAbrupt(status). + 2. Return the result of performing IteratorBindingInitialization for + BindingRestElement with iteratorRecord and environment as arguments. +---*/ +var values = [1, 2, 3, 4, 5]; + +var callCount = 0; +var f; +f = function([ , , ...x] = values) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 3); + assert.sameValue(x[1], 4); + assert.sameValue(x[2], 5); + assert.notSameValue(x, values); + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/expressions/function/dstr-dflt-ary-ptrn-rest-id-exhausted.js b/test/language/expressions/function/dstr-dflt-ary-ptrn-rest-id-exhausted.js new file mode 100644 index 0000000000..91ddab3d91 --- /dev/null +++ b/test/language/expressions/function/dstr-dflt-ary-ptrn-rest-id-exhausted.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-exhausted.case +// - src/dstr-binding/default/func-expr-dflt.template +/*--- +description: RestElement applied to an exhausted iterator (function expression (default parameter)) +esid: sec-function-definitions-runtime-semantics-evaluation +es6id: 14.1.20 +features: [Symbol.iterator, destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionExpression : function ( FormalParameters ) { FunctionBody } + + [...] + 3. Let closure be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier, + environment). + 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat, + [...] + b. If iteratorRecord.[[done]] is true, then + i. If environment is undefined, return PutValue(lhs, A). + ii. Return InitializeReferencedBinding(lhs, A). + +---*/ + +var callCount = 0; +var f; +f = function([, , ...x] = [1, 2]) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 0); + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/expressions/function/dstr-dflt-ary-ptrn-rest-id-iter-step-err.js b/test/language/expressions/function/dstr-dflt-ary-ptrn-rest-id-iter-step-err.js new file mode 100644 index 0000000000..4e348580b2 --- /dev/null +++ b/test/language/expressions/function/dstr-dflt-ary-ptrn-rest-id-iter-step-err.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-step-err.case +// - src/dstr-binding/error/func-expr-dflt.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (function expression (default parameter)) +esid: sec-function-definitions-runtime-semantics-evaluation +es6id: 14.1.20 +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionExpression : function ( FormalParameters ) { FunctionBody } + + [...] + 3. Let closure be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 = 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/function/dstr-dflt-ary-ptrn-rest-id-iter-val-err.js b/test/language/expressions/function/dstr-dflt-ary-ptrn-rest-id-iter-val-err.js new file mode 100644 index 0000000000..2559daa84e --- /dev/null +++ b/test/language/expressions/function/dstr-dflt-ary-ptrn-rest-id-iter-val-err.js @@ -0,0 +1,71 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-val-err.case +// - src/dstr-binding/error/func-expr-dflt.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (function expression (default parameter)) +esid: sec-function-definitions-runtime-semantics-evaluation +es6id: 14.1.20 +features: [Symbol.iterator, destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionExpression : function ( FormalParameters ) { FunctionBody } + + [...] + 3. Let closure be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 = function([...x] = iter) {}; + +assert.throws(Test262Error, function() { + f(); +}); diff --git a/test/language/expressions/function/dstr-dflt-ary-ptrn-rest-id.js b/test/language/expressions/function/dstr-dflt-ary-ptrn-rest-id.js new file mode 100644 index 0000000000..63bf1a58f2 --- /dev/null +++ b/test/language/expressions/function/dstr-dflt-ary-ptrn-rest-id.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id.case +// - src/dstr-binding/default/func-expr-dflt.template +/*--- +description: Lone rest element (function expression (default parameter)) +esid: sec-function-definitions-runtime-semantics-evaluation +es6id: 14.1.20 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionExpression : function ( FormalParameters ) { FunctionBody } + + [...] + 3. Let closure be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + [...] 3. Let A be ArrayCreate(0). [...] 5. Repeat + [...] + f. Let status be CreateDataProperty(A, ToString (n), nextValue). + [...] +---*/ +var values = [1, 2, 3]; + +var callCount = 0; +var f; +f = function([...x] = values) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 1); + assert.sameValue(x[1], 2); + assert.sameValue(x[2], 3); + assert.notSameValue(x, values); + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/expressions/function/dstr-dflt-ary-ptrn-rest-init-ary.js b/test/language/expressions/function/dstr-dflt-ary-ptrn-rest-init-ary.js new file mode 100644 index 0000000000..e2535ee958 --- /dev/null +++ b/test/language/expressions/function/dstr-dflt-ary-ptrn-rest-init-ary.js @@ -0,0 +1,57 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-ary.case +// - src/dstr-binding/default/func-expr-dflt.template +/*--- +description: Reset element (nested array pattern) does not support initializer (function expression (default parameter)) +esid: sec-function-definitions-runtime-semantics-evaluation +es6id: 14.1.20 +features: [destructuring-binding, default-parameters] +flags: [generated] +negative: SyntaxError +info: | + FunctionExpression : function ( FormalParameters ) { FunctionBody } + + [...] + 3. Let closure be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +var f; +f = function([...[ x ] = []] = []) { + + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/expressions/function/dstr-dflt-ary-ptrn-rest-init-id.js b/test/language/expressions/function/dstr-dflt-ary-ptrn-rest-init-id.js new file mode 100644 index 0000000000..3f913f8821 --- /dev/null +++ b/test/language/expressions/function/dstr-dflt-ary-ptrn-rest-init-id.js @@ -0,0 +1,57 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-id.case +// - src/dstr-binding/default/func-expr-dflt.template +/*--- +description: Reset element (identifier) does not support initializer (function expression (default parameter)) +esid: sec-function-definitions-runtime-semantics-evaluation +es6id: 14.1.20 +features: [destructuring-binding, default-parameters] +flags: [generated] +negative: SyntaxError +info: | + FunctionExpression : function ( FormalParameters ) { FunctionBody } + + [...] + 3. Let closure be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +var f; +f = function([...x = []] = []) { + + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/expressions/function/dstr-dflt-ary-ptrn-rest-init-obj.js b/test/language/expressions/function/dstr-dflt-ary-ptrn-rest-init-obj.js new file mode 100644 index 0000000000..7b9879f061 --- /dev/null +++ b/test/language/expressions/function/dstr-dflt-ary-ptrn-rest-init-obj.js @@ -0,0 +1,57 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-obj.case +// - src/dstr-binding/default/func-expr-dflt.template +/*--- +description: Reset element (nested object pattern) does not support initializer (function expression (default parameter)) +esid: sec-function-definitions-runtime-semantics-evaluation +es6id: 14.1.20 +features: [destructuring-binding, default-parameters] +flags: [generated] +negative: SyntaxError +info: | + FunctionExpression : function ( FormalParameters ) { FunctionBody } + + [...] + 3. Let closure be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +var f; +f = function([...{ x } = []] = []) { + + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/expressions/function/dstr-dflt-ary-ptrn-rest-not-final-ary.js b/test/language/expressions/function/dstr-dflt-ary-ptrn-rest-not-final-ary.js new file mode 100644 index 0000000000..51e0acb07e --- /dev/null +++ b/test/language/expressions/function/dstr-dflt-ary-ptrn-rest-not-final-ary.js @@ -0,0 +1,57 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-ary.case +// - src/dstr-binding/default/func-expr-dflt.template +/*--- +description: Rest element (array binding pattern) may not be followed by any element (function expression (default parameter)) +esid: sec-function-definitions-runtime-semantics-evaluation +es6id: 14.1.20 +features: [destructuring-binding, default-parameters] +flags: [generated] +negative: SyntaxError +info: | + FunctionExpression : function ( FormalParameters ) { FunctionBody } + + [...] + 3. Let closure be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +var f; +f = function([...[x], y] = [1, 2, 3]) { + + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/expressions/function/dstr-dflt-ary-ptrn-rest-not-final-id.js b/test/language/expressions/function/dstr-dflt-ary-ptrn-rest-not-final-id.js new file mode 100644 index 0000000000..8f448f18ae --- /dev/null +++ b/test/language/expressions/function/dstr-dflt-ary-ptrn-rest-not-final-id.js @@ -0,0 +1,57 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-id.case +// - src/dstr-binding/default/func-expr-dflt.template +/*--- +description: Rest element (identifier) may not be followed by any element (function expression (default parameter)) +esid: sec-function-definitions-runtime-semantics-evaluation +es6id: 14.1.20 +features: [destructuring-binding, default-parameters] +flags: [generated] +negative: SyntaxError +info: | + FunctionExpression : function ( FormalParameters ) { FunctionBody } + + [...] + 3. Let closure be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +var f; +f = function([...x, y] = [1, 2, 3]) { + + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/expressions/function/dstr-dflt-ary-ptrn-rest-not-final-obj.js b/test/language/expressions/function/dstr-dflt-ary-ptrn-rest-not-final-obj.js new file mode 100644 index 0000000000..957dc771d5 --- /dev/null +++ b/test/language/expressions/function/dstr-dflt-ary-ptrn-rest-not-final-obj.js @@ -0,0 +1,57 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-obj.case +// - src/dstr-binding/default/func-expr-dflt.template +/*--- +description: Rest element (object binding pattern) may not be followed by any element (function expression (default parameter)) +esid: sec-function-definitions-runtime-semantics-evaluation +es6id: 14.1.20 +features: [destructuring-binding, default-parameters] +flags: [generated] +negative: SyntaxError +info: | + FunctionExpression : function ( FormalParameters ) { FunctionBody } + + [...] + 3. Let closure be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +var f; +f = function([...{ x }, y] = [1, 2, 3]) { + + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/expressions/function/dstr-dflt-ary-ptrn-rest-obj-id.js b/test/language/expressions/function/dstr-dflt-ary-ptrn-rest-obj-id.js new file mode 100644 index 0000000000..5ffc1767b6 --- /dev/null +++ b/test/language/expressions/function/dstr-dflt-ary-ptrn-rest-obj-id.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-obj-id.case +// - src/dstr-binding/default/func-expr-dflt.template +/*--- +description: Rest element containing an object binding pattern (function expression (default parameter)) +esid: sec-function-definitions-runtime-semantics-evaluation +es6id: 14.1.20 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionExpression : function ( FormalParameters ) { FunctionBody } + + [...] + 3. Let closure be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ + +var callCount = 0; +var f; +f = function([...{ length }] = [1, 2, 3]) { + assert.sameValue(length, 3); + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/expressions/function/dstr-dflt-ary-ptrn-rest-obj-prop-id.js b/test/language/expressions/function/dstr-dflt-ary-ptrn-rest-obj-prop-id.js new file mode 100644 index 0000000000..aeedc5c860 --- /dev/null +++ b/test/language/expressions/function/dstr-dflt-ary-ptrn-rest-obj-prop-id.js @@ -0,0 +1,71 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-obj-prop-id.case +// - src/dstr-binding/default/func-expr-dflt.template +/*--- +description: Rest element containing an object binding pattern (function expression (default parameter)) +esid: sec-function-definitions-runtime-semantics-evaluation +es6id: 14.1.20 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionExpression : function ( FormalParameters ) { FunctionBody } + + [...] + 3. Let closure be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ + +var callCount = 0; +var f; +f = function([...{ 0: v, 1: w, 2: x, 3: y, length: z }] = [7, 8, 9]) { + assert.sameValue(v, 7); + assert.sameValue(w, 8); + assert.sameValue(x, 9); + assert.sameValue(y, undefined); + assert.sameValue(z, 3); + + assert.throws(ReferenceError, function() { + length; + }); + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/expressions/function/dstr-dflt-obj-init-null.js b/test/language/expressions/function/dstr-dflt-obj-init-null.js new file mode 100644 index 0000000000..7dadf07082 --- /dev/null +++ b/test/language/expressions/function/dstr-dflt-obj-init-null.js @@ -0,0 +1,52 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-null.case +// - src/dstr-binding/error/func-expr-dflt.template +/*--- +description: Value specifed for object binding pattern must be object coercible (null) (function expression (default parameter)) +esid: sec-function-definitions-runtime-semantics-evaluation +es6id: 14.1.20 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionExpression : function ( FormalParameters ) { FunctionBody } + + [...] + 3. Let closure be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + +var f = function({} = null) {}; + +assert.throws(TypeError, function() { + f(); +}); diff --git a/test/language/expressions/function/dstr-dflt-obj-init-undefined.js b/test/language/expressions/function/dstr-dflt-obj-init-undefined.js new file mode 100644 index 0000000000..f022a53f9d --- /dev/null +++ b/test/language/expressions/function/dstr-dflt-obj-init-undefined.js @@ -0,0 +1,52 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-undefined.case +// - src/dstr-binding/error/func-expr-dflt.template +/*--- +description: Value specifed for object binding pattern must be object coercible (undefined) (function expression (default parameter)) +esid: sec-function-definitions-runtime-semantics-evaluation +es6id: 14.1.20 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionExpression : function ( FormalParameters ) { FunctionBody } + + [...] + 3. Let closure be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + +var f = function({} = undefined) {}; + +assert.throws(TypeError, function() { + f(); +}); diff --git a/test/language/expressions/function/dstr-dflt-obj-ptrn-empty.js b/test/language/expressions/function/dstr-dflt-obj-ptrn-empty.js new file mode 100644 index 0000000000..9b6f547e5e --- /dev/null +++ b/test/language/expressions/function/dstr-dflt-obj-ptrn-empty.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-empty.case +// - src/dstr-binding/default/func-expr-dflt.template +/*--- +description: No property access occurs for an "empty" object binding pattern (function expression (default parameter)) +esid: sec-function-definitions-runtime-semantics-evaluation +es6id: 14.1.20 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionExpression : function ( FormalParameters ) { FunctionBody } + + [...] + 3. Let closure be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ +var accessCount = 0; +var obj = Object.defineProperty({}, 'attr', { + get: function() { + accessCount += 1; + } +}); + +var callCount = 0; +var f; +f = function({} = obj) { + assert.sameValue(accessCount, 0); + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/expressions/function/dstr-dflt-obj-ptrn-id-get-value-err.js b/test/language/expressions/function/dstr-dflt-obj-ptrn-id-get-value-err.js new file mode 100644 index 0000000000..4c77e0730d --- /dev/null +++ b/test/language/expressions/function/dstr-dflt-obj-ptrn-id-get-value-err.js @@ -0,0 +1,59 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-get-value-err.case +// - src/dstr-binding/error/func-expr-dflt.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (function expression (default parameter)) +esid: sec-function-definitions-runtime-semantics-evaluation +es6id: 14.1.20 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionExpression : function ( FormalParameters ) { FunctionBody } + + [...] + 3. Let closure be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 = function({ poisoned } = poisonedProperty) {}; + +assert.throws(Test262Error, function() { + f(); +}); diff --git a/test/language/expressions/function/dstr-dflt-obj-ptrn-id-init-fn-name-arrow.js b/test/language/expressions/function/dstr-dflt-obj-ptrn-id-init-fn-name-arrow.js new file mode 100644 index 0000000000..c4e977a14e --- /dev/null +++ b/test/language/expressions/function/dstr-dflt-obj-ptrn-id-init-fn-name-arrow.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-arrow.case +// - src/dstr-binding/default/func-expr-dflt.template +/*--- +description: SingleNameBinding assigns `name` to arrow functions (function expression (default parameter)) +esid: sec-function-definitions-runtime-semantics-evaluation +es6id: 14.1.20 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionExpression : function ( FormalParameters ) { FunctionBody } + + [...] + 3. Let closure be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +var f; +f = function({ arrow = () => {} } = {}) { + assert.sameValue(arrow.name, 'arrow'); + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/expressions/function/dstr-dflt-obj-ptrn-id-init-fn-name-class.js b/test/language/expressions/function/dstr-dflt-obj-ptrn-id-init-fn-name-class.js new file mode 100644 index 0000000000..80638d75e7 --- /dev/null +++ b/test/language/expressions/function/dstr-dflt-obj-ptrn-id-init-fn-name-class.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-class.case +// - src/dstr-binding/default/func-expr-dflt.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (function expression (default parameter)) +esid: sec-function-definitions-runtime-semantics-evaluation +es6id: 14.1.20 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionExpression : function ( FormalParameters ) { FunctionBody } + + [...] + 3. Let closure be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +var f; +f = function({ cls = class {}, xCls = class X {} } = {}) { + assert.sameValue(cls.name, 'cls'); + assert.notSameValue(xCls.name, 'xCls'); + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/expressions/function/dstr-dflt-obj-ptrn-id-init-fn-name-cover.js b/test/language/expressions/function/dstr-dflt-obj-ptrn-id-init-fn-name-cover.js new file mode 100644 index 0000000000..daf709642c --- /dev/null +++ b/test/language/expressions/function/dstr-dflt-obj-ptrn-id-init-fn-name-cover.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-cover.case +// - src/dstr-binding/default/func-expr-dflt.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" functions "through" cover grammar (function expression (default parameter)) +esid: sec-function-definitions-runtime-semantics-evaluation +es6id: 14.1.20 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionExpression : function ( FormalParameters ) { FunctionBody } + + [...] + 3. Let closure be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +var f; +f = function({ cover = (function () {}), xCover = (0, function() {}) } = {}) { + assert.sameValue(cover.name, 'cover'); + assert.notSameValue(xCover.name, 'xCover'); + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/expressions/function/dstr-dflt-obj-ptrn-id-init-fn-name-fn.js b/test/language/expressions/function/dstr-dflt-obj-ptrn-id-init-fn-name-fn.js new file mode 100644 index 0000000000..8b01f2e7db --- /dev/null +++ b/test/language/expressions/function/dstr-dflt-obj-ptrn-id-init-fn-name-fn.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-fn.case +// - src/dstr-binding/default/func-expr-dflt.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (function expression (default parameter)) +esid: sec-function-definitions-runtime-semantics-evaluation +es6id: 14.1.20 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionExpression : function ( FormalParameters ) { FunctionBody } + + [...] + 3. Let closure be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +var f; +f = function({ fn = function () {}, xFn = function x() {} } = {}) { + assert.sameValue(fn.name, 'fn'); + assert.notSameValue(xFn.name, 'xFn'); + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/expressions/function/dstr-dflt-obj-ptrn-id-init-fn-name-gen.js b/test/language/expressions/function/dstr-dflt-obj-ptrn-id-init-fn-name-gen.js new file mode 100644 index 0000000000..08add1ee82 --- /dev/null +++ b/test/language/expressions/function/dstr-dflt-obj-ptrn-id-init-fn-name-gen.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-gen.case +// - src/dstr-binding/default/func-expr-dflt.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (function expression (default parameter)) +esid: sec-function-definitions-runtime-semantics-evaluation +es6id: 14.1.20 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionExpression : function ( FormalParameters ) { FunctionBody } + + [...] + 3. Let closure be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +var f; +f = function({ gen = function* () {}, xGen = function* x() {} } = {}) { + assert.sameValue(gen.name, 'gen'); + assert.notSameValue(xGen.name, 'xGen'); + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/expressions/function/dstr-dflt-obj-ptrn-id-init-skipped.js b/test/language/expressions/function/dstr-dflt-obj-ptrn-id-init-skipped.js new file mode 100644 index 0000000000..5b92ad43f4 --- /dev/null +++ b/test/language/expressions/function/dstr-dflt-obj-ptrn-id-init-skipped.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-skipped.case +// - src/dstr-binding/default/func-expr-dflt.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (function expression (default parameter)) +esid: sec-function-definitions-runtime-semantics-evaluation +es6id: 14.1.20 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionExpression : function ( FormalParameters ) { FunctionBody } + + [...] + 3. Let closure be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + [...] +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var callCount = 0; +var f; +f = function({ w = counter(), x = counter(), y = counter(), z = counter() } = { w: null, x: 0, y: false, z: '' }) { + assert.sameValue(w, null); + assert.sameValue(x, 0); + assert.sameValue(y, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/expressions/function/dstr-dflt-obj-ptrn-id-init-throws.js b/test/language/expressions/function/dstr-dflt-obj-ptrn-id-init-throws.js new file mode 100644 index 0000000000..60c01f2173 --- /dev/null +++ b/test/language/expressions/function/dstr-dflt-obj-ptrn-id-init-throws.js @@ -0,0 +1,59 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-throws.case +// - src/dstr-binding/error/func-expr-dflt.template +/*--- +description: Error thrown when evaluating the initializer (function expression (default parameter)) +esid: sec-function-definitions-runtime-semantics-evaluation +es6id: 14.1.20 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionExpression : function ( FormalParameters ) { FunctionBody } + + [...] + 3. Let closure be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 = function({ x = thrower() } = {}) {}; + +assert.throws(Test262Error, function() { + f(); +}); diff --git a/test/language/expressions/function/dstr-dflt-obj-ptrn-id-init-unresolvable.js b/test/language/expressions/function/dstr-dflt-obj-ptrn-id-init-unresolvable.js new file mode 100644 index 0000000000..2c21026936 --- /dev/null +++ b/test/language/expressions/function/dstr-dflt-obj-ptrn-id-init-unresolvable.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-unresolvable.case +// - src/dstr-binding/error/func-expr-dflt.template +/*--- +description: Destructuring initializer is an unresolvable reference (function expression (default parameter)) +esid: sec-function-definitions-runtime-semantics-evaluation +es6id: 14.1.20 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionExpression : function ( FormalParameters ) { FunctionBody } + + [...] + 3. Let closure be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 = function({ x = unresolvableReference } = {}) {}; + +assert.throws(ReferenceError, function() { + f(); +}); diff --git a/test/language/expressions/function/dstr-dflt-obj-ptrn-id-trailing-comma.js b/test/language/expressions/function/dstr-dflt-obj-ptrn-id-trailing-comma.js new file mode 100644 index 0000000000..ea34c1388d --- /dev/null +++ b/test/language/expressions/function/dstr-dflt-obj-ptrn-id-trailing-comma.js @@ -0,0 +1,57 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-trailing-comma.case +// - src/dstr-binding/default/func-expr-dflt.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (function expression (default parameter)) +esid: sec-function-definitions-runtime-semantics-evaluation +es6id: 14.1.20 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionExpression : function ( FormalParameters ) { FunctionBody } + + [...] + 3. Let closure be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var callCount = 0; +var f; +f = function({ x, } = { x: 23 }) { + assert.sameValue(x, 23); + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/expressions/function/dstr-dflt-obj-ptrn-list-err.js b/test/language/expressions/function/dstr-dflt-obj-ptrn-list-err.js new file mode 100644 index 0000000000..c36d7edc34 --- /dev/null +++ b/test/language/expressions/function/dstr-dflt-obj-ptrn-list-err.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-list-err.case +// - src/dstr-binding/error/func-expr-dflt.template +/*--- +description: Binding property list evaluation is interrupted by an abrupt completion (function expression (default parameter)) +esid: sec-function-definitions-runtime-semantics-evaluation +es6id: 14.1.20 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionExpression : function ( FormalParameters ) { FunctionBody } + + [...] + 3. Let closure be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 = function({ a, b = thrower(), c = ++initCount } = {}) {}; + +assert.throws(Test262Error, function() { + f(); +}); + +assert.sameValue(initCount, 0); diff --git a/test/language/expressions/function/dstr-dflt-obj-ptrn-prop-ary-init.js b/test/language/expressions/function/dstr-dflt-obj-ptrn-prop-ary-init.js new file mode 100644 index 0000000000..9fb238e644 --- /dev/null +++ b/test/language/expressions/function/dstr-dflt-obj-ptrn-prop-ary-init.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-init.case +// - src/dstr-binding/default/func-expr-dflt.template +/*--- +description: Object binding pattern with "nested" array binding pattern using initializer (function expression (default parameter)) +esid: sec-function-definitions-runtime-semantics-evaluation +es6id: 14.1.20 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionExpression : function ( FormalParameters ) { FunctionBody } + + [...] + 3. Let closure be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +var f; +f = function({ w: [x, y, z] = [4, 5, 6] } = {}) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/expressions/function/dstr-dflt-obj-ptrn-prop-ary-trailing-comma.js b/test/language/expressions/function/dstr-dflt-obj-ptrn-prop-ary-trailing-comma.js new file mode 100644 index 0000000000..238c09e3f9 --- /dev/null +++ b/test/language/expressions/function/dstr-dflt-obj-ptrn-prop-ary-trailing-comma.js @@ -0,0 +1,57 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-trailing-comma.case +// - src/dstr-binding/default/func-expr-dflt.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (function expression (default parameter)) +esid: sec-function-definitions-runtime-semantics-evaluation +es6id: 14.1.20 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionExpression : function ( FormalParameters ) { FunctionBody } + + [...] + 3. Let closure be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var callCount = 0; +var f; +f = function({ x: [y], } = { x: [45] }) { + assert.sameValue(y,45); + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/expressions/function/dstr-dflt-obj-ptrn-prop-ary-value-null.js b/test/language/expressions/function/dstr-dflt-obj-ptrn-prop-ary-value-null.js new file mode 100644 index 0000000000..0d103e4670 --- /dev/null +++ b/test/language/expressions/function/dstr-dflt-obj-ptrn-prop-ary-value-null.js @@ -0,0 +1,54 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-value-null.case +// - src/dstr-binding/error/func-expr-dflt.template +/*--- +description: Object binding pattern with "nested" array binding pattern taking the `null` value (function expression (default parameter)) +esid: sec-function-definitions-runtime-semantics-evaluation +es6id: 14.1.20 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionExpression : function ( FormalParameters ) { FunctionBody } + + [...] + 3. Let closure be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 = function({ w: [x, y, z] = [4, 5, 6] } = { w: null }) {}; + +assert.throws(TypeError, function() { + f(); +}); diff --git a/test/language/expressions/function/dstr-dflt-obj-ptrn-prop-ary.js b/test/language/expressions/function/dstr-dflt-obj-ptrn-prop-ary.js new file mode 100644 index 0000000000..ac572cfde4 --- /dev/null +++ b/test/language/expressions/function/dstr-dflt-obj-ptrn-prop-ary.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary.case +// - src/dstr-binding/default/func-expr-dflt.template +/*--- +description: Object binding pattern with "nested" array binding pattern not using initializer (function expression (default parameter)) +esid: sec-function-definitions-runtime-semantics-evaluation +es6id: 14.1.20 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionExpression : function ( FormalParameters ) { FunctionBody } + + [...] + 3. Let closure be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +var f; +f = function({ w: [x, y, z] = [4, 5, 6] } = { w: [7, undefined, ] }) { + assert.sameValue(x, 7); + assert.sameValue(y, undefined); + assert.sameValue(z, undefined); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/expressions/function/dstr-dflt-obj-ptrn-prop-eval-err.js b/test/language/expressions/function/dstr-dflt-obj-ptrn-prop-eval-err.js new file mode 100644 index 0000000000..104d38db44 --- /dev/null +++ b/test/language/expressions/function/dstr-dflt-obj-ptrn-prop-eval-err.js @@ -0,0 +1,56 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-eval-err.case +// - src/dstr-binding/error/func-expr-dflt.template +/*--- +description: Evaluation of property name returns an abrupt completion (function expression (default parameter)) +esid: sec-function-definitions-runtime-semantics-evaluation +es6id: 14.1.20 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionExpression : function ( FormalParameters ) { FunctionBody } + + [...] + 3. Let closure be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 = function({ [thrower()]: x } = {}) {}; + +assert.throws(Test262Error, function() { + f(); +}); diff --git a/test/language/expressions/function/dstr-dflt-obj-ptrn-prop-id-get-value-err.js b/test/language/expressions/function/dstr-dflt-obj-ptrn-prop-id-get-value-err.js new file mode 100644 index 0000000000..3493f4075c --- /dev/null +++ b/test/language/expressions/function/dstr-dflt-obj-ptrn-prop-id-get-value-err.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-get-value-err.case +// - src/dstr-binding/error/func-expr-dflt.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (function expression (default parameter)) +esid: sec-function-definitions-runtime-semantics-evaluation +es6id: 14.1.20 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionExpression : function ( FormalParameters ) { FunctionBody } + + [...] + 3. Let closure be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 = function({ poisoned: x = ++initEvalCount } = poisonedProperty) {}; + +assert.throws(Test262Error, function() { + f(); +}); + +assert.sameValue(initEvalCount, 0); diff --git a/test/language/expressions/function/dstr-dflt-obj-ptrn-prop-id-init-skipped.js b/test/language/expressions/function/dstr-dflt-obj-ptrn-prop-id-init-skipped.js new file mode 100644 index 0000000000..2f2ff162af --- /dev/null +++ b/test/language/expressions/function/dstr-dflt-obj-ptrn-prop-id-init-skipped.js @@ -0,0 +1,79 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-skipped.case +// - src/dstr-binding/default/func-expr-dflt.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (function expression (default parameter)) +esid: sec-function-definitions-runtime-semantics-evaluation +es6id: 14.1.20 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionExpression : function ( FormalParameters ) { FunctionBody } + + [...] + 3. Let closure be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + [...] +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var callCount = 0; +var f; +f = function({ s: t = counter(), u: v = counter(), w: x = counter(), y: z = counter() } = { s: null, u: 0, w: false, y: '' }) { + assert.sameValue(t, null); + assert.sameValue(v, 0); + assert.sameValue(x, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + + assert.throws(ReferenceError, function() { + s; + }); + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/expressions/function/dstr-dflt-obj-ptrn-prop-id-init-throws.js b/test/language/expressions/function/dstr-dflt-obj-ptrn-prop-id-init-throws.js new file mode 100644 index 0000000000..e1f52790a2 --- /dev/null +++ b/test/language/expressions/function/dstr-dflt-obj-ptrn-prop-id-init-throws.js @@ -0,0 +1,59 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-throws.case +// - src/dstr-binding/error/func-expr-dflt.template +/*--- +description: Error thrown when evaluating the initializer (function expression (default parameter)) +esid: sec-function-definitions-runtime-semantics-evaluation +es6id: 14.1.20 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionExpression : function ( FormalParameters ) { FunctionBody } + + [...] + 3. Let closure be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 = function({ x: y = thrower() } = {}) {}; + +assert.throws(Test262Error, function() { + f(); +}); diff --git a/test/language/expressions/function/dstr-dflt-obj-ptrn-prop-id-init-unresolvable.js b/test/language/expressions/function/dstr-dflt-obj-ptrn-prop-id-init-unresolvable.js new file mode 100644 index 0000000000..23fd0eea98 --- /dev/null +++ b/test/language/expressions/function/dstr-dflt-obj-ptrn-prop-id-init-unresolvable.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-unresolvable.case +// - src/dstr-binding/error/func-expr-dflt.template +/*--- +description: Destructuring initializer is an unresolvable reference (function expression (default parameter)) +esid: sec-function-definitions-runtime-semantics-evaluation +es6id: 14.1.20 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionExpression : function ( FormalParameters ) { FunctionBody } + + [...] + 3. Let closure be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 = function({ x: y = unresolvableReference } = {}) {}; + +assert.throws(ReferenceError, function() { + f(); +}); diff --git a/test/language/expressions/function/dstr-dflt-obj-ptrn-prop-id-init.js b/test/language/expressions/function/dstr-dflt-obj-ptrn-prop-id-init.js new file mode 100644 index 0000000000..b312d6335a --- /dev/null +++ b/test/language/expressions/function/dstr-dflt-obj-ptrn-prop-id-init.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init.case +// - src/dstr-binding/default/func-expr-dflt.template +/*--- +description: Binding as specified via property name, identifier, and initializer (function expression (default parameter)) +esid: sec-function-definitions-runtime-semantics-evaluation +es6id: 14.1.20 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionExpression : function ( FormalParameters ) { FunctionBody } + + [...] + 3. Let closure be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var f; +f = function({ x: y = 33 } = { }) { + assert.sameValue(y, 33); + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/expressions/function/dstr-dflt-obj-ptrn-prop-id-trailing-comma.js b/test/language/expressions/function/dstr-dflt-obj-ptrn-prop-id-trailing-comma.js new file mode 100644 index 0000000000..84005d96df --- /dev/null +++ b/test/language/expressions/function/dstr-dflt-obj-ptrn-prop-id-trailing-comma.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-trailing-comma.case +// - src/dstr-binding/default/func-expr-dflt.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (function expression (default parameter)) +esid: sec-function-definitions-runtime-semantics-evaluation +es6id: 14.1.20 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionExpression : function ( FormalParameters ) { FunctionBody } + + [...] + 3. Let closure be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var callCount = 0; +var f; +f = function({ x: y, } = { x: 23 }) { + assert.sameValue(y, 23); + + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/expressions/function/dstr-dflt-obj-ptrn-prop-id.js b/test/language/expressions/function/dstr-dflt-obj-ptrn-prop-id.js new file mode 100644 index 0000000000..cc4addabe3 --- /dev/null +++ b/test/language/expressions/function/dstr-dflt-obj-ptrn-prop-id.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id.case +// - src/dstr-binding/default/func-expr-dflt.template +/*--- +description: Binding as specified via property name and identifier (function expression (default parameter)) +esid: sec-function-definitions-runtime-semantics-evaluation +es6id: 14.1.20 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionExpression : function ( FormalParameters ) { FunctionBody } + + [...] + 3. Let closure be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var f; +f = function({ x: y } = { x: 23 }) { + assert.sameValue(y, 23); + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/expressions/function/dstr-dflt-obj-ptrn-prop-obj-init.js b/test/language/expressions/function/dstr-dflt-obj-ptrn-prop-obj-init.js new file mode 100644 index 0000000000..991f1252e0 --- /dev/null +++ b/test/language/expressions/function/dstr-dflt-obj-ptrn-prop-obj-init.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-init.case +// - src/dstr-binding/default/func-expr-dflt.template +/*--- +description: Object binding pattern with "nested" object binding pattern using initializer (function expression (default parameter)) +esid: sec-function-definitions-runtime-semantics-evaluation +es6id: 14.1.20 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionExpression : function ( FormalParameters ) { FunctionBody } + + [...] + 3. Let closure be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +var f; +f = function({ w: { x, y, z } = { x: 4, y: 5, z: 6 } } = { w: undefined }) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/expressions/function/dstr-dflt-obj-ptrn-prop-obj-value-null.js b/test/language/expressions/function/dstr-dflt-obj-ptrn-prop-obj-value-null.js new file mode 100644 index 0000000000..98799968eb --- /dev/null +++ b/test/language/expressions/function/dstr-dflt-obj-ptrn-prop-obj-value-null.js @@ -0,0 +1,54 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-null.case +// - src/dstr-binding/error/func-expr-dflt.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (function expression (default parameter)) +esid: sec-function-definitions-runtime-semantics-evaluation +es6id: 14.1.20 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionExpression : function ( FormalParameters ) { FunctionBody } + + [...] + 3. Let closure be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 = function({ w: { x, y, z } = { x: 4, y: 5, z: 6 } } = { w: null }) {}; + +assert.throws(TypeError, function() { + f(); +}); diff --git a/test/language/expressions/function/dstr-dflt-obj-ptrn-prop-obj-value-undef.js b/test/language/expressions/function/dstr-dflt-obj-ptrn-prop-obj-value-undef.js new file mode 100644 index 0000000000..6f2641d15c --- /dev/null +++ b/test/language/expressions/function/dstr-dflt-obj-ptrn-prop-obj-value-undef.js @@ -0,0 +1,54 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-undef.case +// - src/dstr-binding/error/func-expr-dflt.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (function expression (default parameter)) +esid: sec-function-definitions-runtime-semantics-evaluation +es6id: 14.1.20 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionExpression : function ( FormalParameters ) { FunctionBody } + + [...] + 3. Let closure be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 = function({ w: { x, y, z } = undefined } = { }) {}; + +assert.throws(TypeError, function() { + f(); +}); diff --git a/test/language/expressions/function/dstr-dflt-obj-ptrn-prop-obj.js b/test/language/expressions/function/dstr-dflt-obj-ptrn-prop-obj.js new file mode 100644 index 0000000000..bc199a1265 --- /dev/null +++ b/test/language/expressions/function/dstr-dflt-obj-ptrn-prop-obj.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj.case +// - src/dstr-binding/default/func-expr-dflt.template +/*--- +description: Object binding pattern with "nested" object binding pattern not using initializer (function expression (default parameter)) +esid: sec-function-definitions-runtime-semantics-evaluation +es6id: 14.1.20 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionExpression : function ( FormalParameters ) { FunctionBody } + + [...] + 3. Let closure be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +var f; +f = function({ w: { x, y, z } = { x: 4, y: 5, z: 6 } } = { w: { x: undefined, z: 7 } }) { + assert.sameValue(x, undefined); + assert.sameValue(y, undefined); + assert.sameValue(z, 7); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; +}; + +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/expressions/generators/dstr-dflt-ary-init-iter-close.js b/test/language/expressions/generators/dstr-dflt-ary-init-iter-close.js new file mode 100644 index 0000000000..7d1631f70a --- /dev/null +++ b/test/language/expressions/generators/dstr-dflt-ary-init-iter-close.js @@ -0,0 +1,73 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-close.case +// - src/dstr-binding/default/gen-func-expr-dflt.template +/*--- +description: Iterator is closed when not exhausted by pattern evaluation (generator function expression (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-evaluation +es6id: 14.4.14 +features: [Symbol.iterator, destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorExpression : function * ( FormalParameters ) { GeneratorBody } + + [...] + 3. Let closure be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + [...] + 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator, + result). + [...] + +---*/ +var doneCallCount = 0; +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return { value: null, done: false }; + }, + return: function() { + doneCallCount += 1; + return {}; + } + }; +}; + +var callCount = 0; +var f; +f = function*([x] = iter) { + assert.sameValue(doneCallCount, 1); + callCount = callCount + 1; +}; + +f().next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/expressions/generators/dstr-dflt-ary-init-iter-get-err.js b/test/language/expressions/generators/dstr-dflt-ary-init-iter-get-err.js new file mode 100644 index 0000000000..eb15ac9b40 --- /dev/null +++ b/test/language/expressions/generators/dstr-dflt-ary-init-iter-get-err.js @@ -0,0 +1,58 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-get-err.case +// - src/dstr-binding/error/gen-func-expr-dflt.template +/*--- +description: Abrupt completion returned by GetIterator (generator function expression (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-evaluation +es6id: 14.4.14 +features: [Symbol.iterator, destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorExpression : function * ( FormalParameters ) { GeneratorBody } + + [...] + 3. Let closure be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 = function*([x] = iter) {}; + +assert.throws(Test262Error, function() { + f(); +}); diff --git a/test/language/expressions/generators/dstr-dflt-ary-init-iter-no-close.js b/test/language/expressions/generators/dstr-dflt-ary-init-iter-no-close.js new file mode 100644 index 0000000000..5d81c1bf4f --- /dev/null +++ b/test/language/expressions/generators/dstr-dflt-ary-init-iter-no-close.js @@ -0,0 +1,73 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-no-close.case +// - src/dstr-binding/default/gen-func-expr-dflt.template +/*--- +description: Iterator is not closed when exhausted by pattern evaluation (generator function expression (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-evaluation +es6id: 14.4.14 +features: [Symbol.iterator, destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorExpression : function * ( FormalParameters ) { GeneratorBody } + + [...] + 3. Let closure be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + [...] + 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator, + result). + [...] + +---*/ +var doneCallCount = 0; +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return { value: null, done: true }; + }, + return: function() { + doneCallCount += 1; + return {}; + } + }; +}; + +var callCount = 0; +var f; +f = function*([x] = iter) { + assert.sameValue(doneCallCount, 0); + callCount = callCount + 1; +}; + +f().next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/expressions/generators/dstr-dflt-ary-name-iter-val.js b/test/language/expressions/generators/dstr-dflt-ary-name-iter-val.js new file mode 100644 index 0000000000..944761d578 --- /dev/null +++ b/test/language/expressions/generators/dstr-dflt-ary-name-iter-val.js @@ -0,0 +1,72 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-name-iter-val.case +// - src/dstr-binding/default/gen-func-expr-dflt.template +/*--- +description: SingleNameBinding with normal value iteration (generator function expression (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-evaluation +es6id: 14.4.14 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorExpression : function * ( FormalParameters ) { GeneratorBody } + + [...] + 3. Let closure be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set + iteratorRecord.[[done]] to true. + iii. ReturnIfAbrupt(v). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var f; +f = function*([x, y, z] = [1, 2, 3]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 3); + callCount = callCount + 1; +}; + +f().next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/expressions/generators/dstr-dflt-ary-ptrn-elem-ary-elem-init.js b/test/language/expressions/generators/dstr-dflt-ary-ptrn-elem-ary-elem-init.js new file mode 100644 index 0000000000..6916f60479 --- /dev/null +++ b/test/language/expressions/generators/dstr-dflt-ary-ptrn-elem-ary-elem-init.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elem-init.case +// - src/dstr-binding/default/gen-func-expr-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is used (generator function expression (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-evaluation +es6id: 14.4.14 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorExpression : function * ( FormalParameters ) { GeneratorBody } + + [...] + 3. Let closure be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +var f; +f = function*([[x, y, z] = [4, 5, 6]] = []) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + callCount = callCount + 1; +}; + +f().next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/expressions/generators/dstr-dflt-ary-ptrn-elem-ary-elem-iter.js b/test/language/expressions/generators/dstr-dflt-ary-ptrn-elem-ary-elem-iter.js new file mode 100644 index 0000000000..5dcf7c2cc0 --- /dev/null +++ b/test/language/expressions/generators/dstr-dflt-ary-ptrn-elem-ary-elem-iter.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elem-iter.case +// - src/dstr-binding/default/gen-func-expr-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (generator function expression (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-evaluation +es6id: 14.4.14 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorExpression : function * ( FormalParameters ) { GeneratorBody } + + [...] + 3. Let closure be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +var f; +f = function*([[x, y, z] = [4, 5, 6]] = [[7, 8, 9]]) { + assert.sameValue(x, 7); + assert.sameValue(y, 8); + assert.sameValue(z, 9); + callCount = callCount + 1; +}; + +f().next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/expressions/generators/dstr-dflt-ary-ptrn-elem-ary-elision-init.js b/test/language/expressions/generators/dstr-dflt-ary-ptrn-elem-ary-elision-init.js new file mode 100644 index 0000000000..592ed62c6d --- /dev/null +++ b/test/language/expressions/generators/dstr-dflt-ary-ptrn-elem-ary-elision-init.js @@ -0,0 +1,71 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elision-init.case +// - src/dstr-binding/default/gen-func-expr-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is used (generator function expression (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-evaluation +es6id: 14.4.14 +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorExpression : function * ( FormalParameters ) { GeneratorBody } + + [...] + 3. Let closure be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var callCount = 0; +var f; +f = function*([[,] = g()] = []) { + assert.sameValue(first, 1); + assert.sameValue(second, 0); + callCount = callCount + 1; +}; + +f().next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/expressions/generators/dstr-dflt-ary-ptrn-elem-ary-elision-iter.js b/test/language/expressions/generators/dstr-dflt-ary-ptrn-elem-ary-elision-iter.js new file mode 100644 index 0000000000..a607059e7a --- /dev/null +++ b/test/language/expressions/generators/dstr-dflt-ary-ptrn-elem-ary-elision-iter.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elision-iter.case +// - src/dstr-binding/default/gen-func-expr-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (generator function expression (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-evaluation +es6id: 14.4.14 +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorExpression : function * ( FormalParameters ) { GeneratorBody } + + [...] + 3. Let closure be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var callCount = 0; +function* g() { + callCount += 1; +}; + +var callCount = 0; +var f; +f = function*([[,] = g()] = [[]]) { + assert.sameValue(callCount, 0); + callCount = callCount + 1; +}; + +f().next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/expressions/generators/dstr-dflt-ary-ptrn-elem-ary-empty-init.js b/test/language/expressions/generators/dstr-dflt-ary-ptrn-elem-ary-empty-init.js new file mode 100644 index 0000000000..ed0046f243 --- /dev/null +++ b/test/language/expressions/generators/dstr-dflt-ary-ptrn-elem-ary-empty-init.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-empty-init.case +// - src/dstr-binding/default/gen-func-expr-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is used (generator function expression (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-evaluation +es6id: 14.4.14 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorExpression : function * ( FormalParameters ) { GeneratorBody } + + [...] + 3. Let closure be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var initCount = 0; +var iterCount = 0; +var iter = function*() { iterCount += 1; }(); + +var callCount = 0; +var f; +f = function*([[] = function() { initCount += 1; return iter; }()] = []) { + assert.sameValue(initCount, 1); + assert.sameValue(iterCount, 0); + callCount = callCount + 1; +}; + +f().next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/expressions/generators/dstr-dflt-ary-ptrn-elem-ary-empty-iter.js b/test/language/expressions/generators/dstr-dflt-ary-ptrn-elem-ary-empty-iter.js new file mode 100644 index 0000000000..d37226113f --- /dev/null +++ b/test/language/expressions/generators/dstr-dflt-ary-ptrn-elem-ary-empty-iter.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-empty-iter.case +// - src/dstr-binding/default/gen-func-expr-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (generator function expression (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-evaluation +es6id: 14.4.14 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorExpression : function * ( FormalParameters ) { GeneratorBody } + + [...] + 3. Let closure be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var initCount = 0; + +var callCount = 0; +var f; +f = function*([[] = function() { initCount += 1; }()] = [[23]]) { + assert.sameValue(initCount, 0); + callCount = callCount + 1; +}; + +f().next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/expressions/generators/dstr-dflt-ary-ptrn-elem-ary-rest-init.js b/test/language/expressions/generators/dstr-dflt-ary-ptrn-elem-ary-rest-init.js new file mode 100644 index 0000000000..fd6a3f4784 --- /dev/null +++ b/test/language/expressions/generators/dstr-dflt-ary-ptrn-elem-ary-rest-init.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-rest-init.case +// - src/dstr-binding/default/gen-func-expr-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is used (generator function expression (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-evaluation +es6id: 14.4.14 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorExpression : function * ( FormalParameters ) { GeneratorBody } + + [...] + 3. Let closure be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var values = [2, 1, 3]; + +var callCount = 0; +var f; +f = function*([[...x] = values] = []) { + assert(Array.isArray(x)); + assert.sameValue(x[0], 2); + assert.sameValue(x[1], 1); + assert.sameValue(x[2], 3); + assert.sameValue(x.length, 3); + assert.notSameValue(x, values); + callCount = callCount + 1; +}; + +f().next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/expressions/generators/dstr-dflt-ary-ptrn-elem-ary-rest-iter.js b/test/language/expressions/generators/dstr-dflt-ary-ptrn-elem-ary-rest-iter.js new file mode 100644 index 0000000000..13003c7c88 --- /dev/null +++ b/test/language/expressions/generators/dstr-dflt-ary-ptrn-elem-ary-rest-iter.js @@ -0,0 +1,71 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-rest-iter.case +// - src/dstr-binding/default/gen-func-expr-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (generator function expression (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-evaluation +es6id: 14.4.14 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorExpression : function * ( FormalParameters ) { GeneratorBody } + + [...] + 3. Let closure be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var values = [2, 1, 3]; +var initCount = 0; + +var callCount = 0; +var f; +f = function*([[...x] = function() { initCount += 1; }()] = [values]) { + assert(Array.isArray(x)); + assert.sameValue(x[0], 2); + assert.sameValue(x[1], 1); + assert.sameValue(x[2], 3); + assert.sameValue(x.length, 3); + assert.notSameValue(x, values); + assert.sameValue(initCount, 0); + callCount = callCount + 1; +}; + +f().next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/expressions/generators/dstr-dflt-ary-ptrn-elem-ary-val-null.js b/test/language/expressions/generators/dstr-dflt-ary-ptrn-elem-ary-val-null.js new file mode 100644 index 0000000000..cb75906384 --- /dev/null +++ b/test/language/expressions/generators/dstr-dflt-ary-ptrn-elem-ary-val-null.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-val-null.case +// - src/dstr-binding/error/gen-func-expr-dflt.template +/*--- +description: Nested array destructuring with a null value (generator function expression (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-evaluation +es6id: 14.4.14 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorExpression : function * ( FormalParameters ) { GeneratorBody } + + [...] + 3. Let closure be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 = function*([[x]] = [null]) {}; + +assert.throws(TypeError, function() { + f(); +}); diff --git a/test/language/expressions/generators/dstr-dflt-ary-ptrn-elem-id-init-exhausted.js b/test/language/expressions/generators/dstr-dflt-ary-ptrn-elem-id-init-exhausted.js new file mode 100644 index 0000000000..72e82b7901 --- /dev/null +++ b/test/language/expressions/generators/dstr-dflt-ary-ptrn-elem-id-init-exhausted.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-exhausted.case +// - src/dstr-binding/default/gen-func-expr-dflt.template +/*--- +description: Destructuring initializer with an exhausted iterator (generator function expression (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-evaluation +es6id: 14.4.14 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorExpression : function * ( FormalParameters ) { GeneratorBody } + + [...] + 3. Let closure be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var f; +f = function*([x = 23] = []) { + assert.sameValue(x, 23); + callCount = callCount + 1; +}; + +f().next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/expressions/generators/dstr-dflt-ary-ptrn-elem-id-init-fn-name-arrow.js b/test/language/expressions/generators/dstr-dflt-ary-ptrn-elem-id-init-fn-name-arrow.js new file mode 100644 index 0000000000..df14df54e1 --- /dev/null +++ b/test/language/expressions/generators/dstr-dflt-ary-ptrn-elem-id-init-fn-name-arrow.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-arrow.case +// - src/dstr-binding/default/gen-func-expr-dflt.template +/*--- +description: SingleNameBinding does assign name to arrow functions (generator function expression (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-evaluation +es6id: 14.4.14 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorExpression : function * ( FormalParameters ) { GeneratorBody } + + [...] + 3. Let closure be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var f; +f = function*([arrow = () => {}] = []) { + assert.sameValue(arrow.name, 'arrow'); + callCount = callCount + 1; +}; + +f().next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/expressions/generators/dstr-dflt-ary-ptrn-elem-id-init-fn-name-class.js b/test/language/expressions/generators/dstr-dflt-ary-ptrn-elem-id-init-fn-name-class.js new file mode 100644 index 0000000000..2e1f87ddb4 --- /dev/null +++ b/test/language/expressions/generators/dstr-dflt-ary-ptrn-elem-id-init-fn-name-class.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-class.case +// - src/dstr-binding/default/gen-func-expr-dflt.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (generator function expression (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-evaluation +es6id: 14.4.14 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorExpression : function * ( FormalParameters ) { GeneratorBody } + + [...] + 3. Let closure be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var f; +f = function*([cls = class {}, xCls = class X {}] = []) { + assert.sameValue(cls.name, 'cls'); + assert.notSameValue(xCls.name, 'xCls'); + callCount = callCount + 1; +}; + +f().next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/expressions/generators/dstr-dflt-ary-ptrn-elem-id-init-fn-name-cover.js b/test/language/expressions/generators/dstr-dflt-ary-ptrn-elem-id-init-fn-name-cover.js new file mode 100644 index 0000000000..01ea45a27f --- /dev/null +++ b/test/language/expressions/generators/dstr-dflt-ary-ptrn-elem-id-init-fn-name-cover.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-cover.case +// - src/dstr-binding/default/gen-func-expr-dflt.template +/*--- +description: SingleNameBinding does assign name to "anonymous" functions "through" cover grammar (generator function expression (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-evaluation +es6id: 14.4.14 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorExpression : function * ( FormalParameters ) { GeneratorBody } + + [...] + 3. Let closure be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var f; +f = function*([cover = (function () {}), xCover = (0, function() {})] = []) { + assert.sameValue(cover.name, 'cover'); + assert.notSameValue(xCover.name, 'xCover'); + callCount = callCount + 1; +}; + +f().next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/expressions/generators/dstr-dflt-ary-ptrn-elem-id-init-fn-name-fn.js b/test/language/expressions/generators/dstr-dflt-ary-ptrn-elem-id-init-fn-name-fn.js new file mode 100644 index 0000000000..28e4c130d0 --- /dev/null +++ b/test/language/expressions/generators/dstr-dflt-ary-ptrn-elem-id-init-fn-name-fn.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-fn.case +// - src/dstr-binding/default/gen-func-expr-dflt.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (generator function expression (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-evaluation +es6id: 14.4.14 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorExpression : function * ( FormalParameters ) { GeneratorBody } + + [...] + 3. Let closure be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var f; +f = function*([fn = function () {}, xFn = function x() {}] = []) { + assert.sameValue(fn.name, 'fn'); + assert.notSameValue(xFn.name, 'xFn'); + callCount = callCount + 1; +}; + +f().next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/expressions/generators/dstr-dflt-ary-ptrn-elem-id-init-fn-name-gen.js b/test/language/expressions/generators/dstr-dflt-ary-ptrn-elem-id-init-fn-name-gen.js new file mode 100644 index 0000000000..0f86aa51ee --- /dev/null +++ b/test/language/expressions/generators/dstr-dflt-ary-ptrn-elem-id-init-fn-name-gen.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-gen.case +// - src/dstr-binding/default/gen-func-expr-dflt.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (generator function expression (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-evaluation +es6id: 14.4.14 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorExpression : function * ( FormalParameters ) { GeneratorBody } + + [...] + 3. Let closure be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var f; +f = function*([gen = function* () {}, xGen = function* x() {}] = []) { + assert.sameValue(gen.name, 'gen'); + assert.notSameValue(xGen.name, 'xGen'); + callCount = callCount + 1; +}; + +f().next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/expressions/generators/dstr-dflt-ary-ptrn-elem-id-init-hole.js b/test/language/expressions/generators/dstr-dflt-ary-ptrn-elem-id-init-hole.js new file mode 100644 index 0000000000..bb1b7d1090 --- /dev/null +++ b/test/language/expressions/generators/dstr-dflt-ary-ptrn-elem-id-init-hole.js @@ -0,0 +1,59 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-hole.case +// - src/dstr-binding/default/gen-func-expr-dflt.template +/*--- +description: Destructuring initializer with a "hole" (generator function expression (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-evaluation +es6id: 14.4.14 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorExpression : function * ( FormalParameters ) { GeneratorBody } + + [...] + 3. Let closure be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + SingleNameBinding : BindingIdentifier Initializeropt + [...] 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + [...] + 7. If environment is undefined, return PutValue(lhs, v). 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var f; +f = function*([x = 23] = [,]) { + assert.sameValue(x, 23); + // another statement + callCount = callCount + 1; +}; + +f().next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/expressions/generators/dstr-dflt-ary-ptrn-elem-id-init-skipped.js b/test/language/expressions/generators/dstr-dflt-ary-ptrn-elem-id-init-skipped.js new file mode 100644 index 0000000000..ba78f7213d --- /dev/null +++ b/test/language/expressions/generators/dstr-dflt-ary-ptrn-elem-id-init-skipped.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-skipped.case +// - src/dstr-binding/default/gen-func-expr-dflt.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (generator function expression (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-evaluation +es6id: 14.4.14 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorExpression : function * ( FormalParameters ) { GeneratorBody } + + [...] + 3. Let closure be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var callCount = 0; +var f; +f = function*([w = counter(), x = counter(), y = counter(), z = counter()] = [null, 0, false, '']) { + assert.sameValue(w, null); + assert.sameValue(x, 0); + assert.sameValue(y, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + callCount = callCount + 1; +}; + +f().next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/expressions/generators/dstr-dflt-ary-ptrn-elem-id-init-throws.js b/test/language/expressions/generators/dstr-dflt-ary-ptrn-elem-id-init-throws.js new file mode 100644 index 0000000000..d53269e637 --- /dev/null +++ b/test/language/expressions/generators/dstr-dflt-ary-ptrn-elem-id-init-throws.js @@ -0,0 +1,56 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-throws.case +// - src/dstr-binding/error/gen-func-expr-dflt.template +/*--- +description: Destructuring initializer returns an abrupt completion (generator function expression (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-evaluation +es6id: 14.4.14 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorExpression : function * ( FormalParameters ) { GeneratorBody } + + [...] + 3. Let closure be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 = function*([x = (function() { throw new Test262Error(); })()] = [undefined]) {}; + +assert.throws(Test262Error, function() { + f(); +}); diff --git a/test/language/expressions/generators/dstr-dflt-ary-ptrn-elem-id-init-undef.js b/test/language/expressions/generators/dstr-dflt-ary-ptrn-elem-id-init-undef.js new file mode 100644 index 0000000000..1c08f8df0a --- /dev/null +++ b/test/language/expressions/generators/dstr-dflt-ary-ptrn-elem-id-init-undef.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-undef.case +// - src/dstr-binding/default/gen-func-expr-dflt.template +/*--- +description: Destructuring initializer with an undefined value (generator function expression (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-evaluation +es6id: 14.4.14 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorExpression : function * ( FormalParameters ) { GeneratorBody } + + [...] + 3. Let closure be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var f; +f = function*([x = 23] = [undefined]) { + assert.sameValue(x, 23); + callCount = callCount + 1; +}; + +f().next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/expressions/generators/dstr-dflt-ary-ptrn-elem-id-init-unresolvable.js b/test/language/expressions/generators/dstr-dflt-ary-ptrn-elem-id-init-unresolvable.js new file mode 100644 index 0000000000..31d6c57a23 --- /dev/null +++ b/test/language/expressions/generators/dstr-dflt-ary-ptrn-elem-id-init-unresolvable.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-unresolvable.case +// - src/dstr-binding/error/gen-func-expr-dflt.template +/*--- +description: Destructuring initializer is an unresolvable reference (generator function expression (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-evaluation +es6id: 14.4.14 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorExpression : function * ( FormalParameters ) { GeneratorBody } + + [...] + 3. Let closure be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 = function*([ x = unresolvableReference ] = []) {}; + +assert.throws(ReferenceError, function() { + f(); +}); diff --git a/test/language/expressions/generators/dstr-dflt-ary-ptrn-elem-id-iter-complete.js b/test/language/expressions/generators/dstr-dflt-ary-ptrn-elem-id-iter-complete.js new file mode 100644 index 0000000000..3e3a2e9279 --- /dev/null +++ b/test/language/expressions/generators/dstr-dflt-ary-ptrn-elem-id-iter-complete.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-complete.case +// - src/dstr-binding/default/gen-func-expr-dflt.template +/*--- +description: SingleNameBinding when value iteration completes (generator function expression (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-evaluation +es6id: 14.4.14 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorExpression : function * ( FormalParameters ) { GeneratorBody } + + [...] + 3. Let closure be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var f; +f = function*([x] = []) { + assert.sameValue(x, undefined); + callCount = callCount + 1; +}; + +f().next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/expressions/generators/dstr-dflt-ary-ptrn-elem-id-iter-done.js b/test/language/expressions/generators/dstr-dflt-ary-ptrn-elem-id-iter-done.js new file mode 100644 index 0000000000..f411e1e4e9 --- /dev/null +++ b/test/language/expressions/generators/dstr-dflt-ary-ptrn-elem-id-iter-done.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-done.case +// - src/dstr-binding/default/gen-func-expr-dflt.template +/*--- +description: SingleNameBinding when value iteration was completed previously (generator function expression (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-evaluation +es6id: 14.4.14 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorExpression : function * ( FormalParameters ) { GeneratorBody } + + [...] + 3. Let closure be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var f; +f = function*([_, x] = []) { + assert.sameValue(x, undefined); + callCount = callCount + 1; +}; + +f().next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/expressions/generators/dstr-dflt-ary-ptrn-elem-id-iter-step-err.js b/test/language/expressions/generators/dstr-dflt-ary-ptrn-elem-id-iter-step-err.js new file mode 100644 index 0000000000..b04aaa0a90 --- /dev/null +++ b/test/language/expressions/generators/dstr-dflt-ary-ptrn-elem-id-iter-step-err.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-step-err.case +// - src/dstr-binding/error/gen-func-expr-dflt.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (generator function expression (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-evaluation +es6id: 14.4.14 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorExpression : function * ( FormalParameters ) { GeneratorBody } + + [...] + 3. Let closure be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 = function*([x] = g) {}; + +assert.throws(Test262Error, function() { + f(); +}); diff --git a/test/language/expressions/generators/dstr-dflt-ary-ptrn-elem-id-iter-val-err.js b/test/language/expressions/generators/dstr-dflt-ary-ptrn-elem-id-iter-val-err.js new file mode 100644 index 0000000000..790a8fefa2 --- /dev/null +++ b/test/language/expressions/generators/dstr-dflt-ary-ptrn-elem-id-iter-val-err.js @@ -0,0 +1,75 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val-err.case +// - src/dstr-binding/error/gen-func-expr-dflt.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (generator function expression (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-evaluation +es6id: 14.4.14 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorExpression : function * ( FormalParameters ) { GeneratorBody } + + [...] + 3. Let closure be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 = function*([x] = g) {}; + +assert.throws(Test262Error, function() { + f(); +}); diff --git a/test/language/expressions/generators/dstr-dflt-ary-ptrn-elem-id-iter-val.js b/test/language/expressions/generators/dstr-dflt-ary-ptrn-elem-id-iter-val.js new file mode 100644 index 0000000000..74f9122e70 --- /dev/null +++ b/test/language/expressions/generators/dstr-dflt-ary-ptrn-elem-id-iter-val.js @@ -0,0 +1,72 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val.case +// - src/dstr-binding/default/gen-func-expr-dflt.template +/*--- +description: SingleNameBinding when value iteration was completed previously (generator function expression (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-evaluation +es6id: 14.4.14 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorExpression : function * ( FormalParameters ) { GeneratorBody } + + [...] + 3. Let closure be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set + iteratorRecord.[[done]] to true. + iii. ReturnIfAbrupt(v). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var f; +f = function*([x, y, z] = [1, 2, 3]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 3); + callCount = callCount + 1; +}; + +f().next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/expressions/generators/dstr-dflt-ary-ptrn-elem-obj-id-init.js b/test/language/expressions/generators/dstr-dflt-ary-ptrn-elem-obj-id-init.js new file mode 100644 index 0000000000..d8b4d188cd --- /dev/null +++ b/test/language/expressions/generators/dstr-dflt-ary-ptrn-elem-obj-id-init.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-id-init.case +// - src/dstr-binding/default/gen-func-expr-dflt.template +/*--- +description: BindingElement with object binding pattern and initializer is used (generator function expression (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-evaluation +es6id: 14.4.14 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorExpression : function * ( FormalParameters ) { GeneratorBody } + + [...] + 3. Let closure be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +var f; +f = function*([{ x, y, z } = { x: 44, y: 55, z: 66 }] = []) { + assert.sameValue(x, 44); + assert.sameValue(y, 55); + assert.sameValue(z, 66); + callCount = callCount + 1; +}; + +f().next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/expressions/generators/dstr-dflt-ary-ptrn-elem-obj-id.js b/test/language/expressions/generators/dstr-dflt-ary-ptrn-elem-obj-id.js new file mode 100644 index 0000000000..1913c0915d --- /dev/null +++ b/test/language/expressions/generators/dstr-dflt-ary-ptrn-elem-obj-id.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-id.case +// - src/dstr-binding/default/gen-func-expr-dflt.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (generator function expression (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-evaluation +es6id: 14.4.14 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorExpression : function * ( FormalParameters ) { GeneratorBody } + + [...] + 3. Let closure be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +var f; +f = function*([{ x, y, z } = { x: 44, y: 55, z: 66 }] = [{ x: 11, y: 22, z: 33 }]) { + assert.sameValue(x, 11); + assert.sameValue(y, 22); + assert.sameValue(z, 33); + callCount = callCount + 1; +}; + +f().next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/expressions/generators/dstr-dflt-ary-ptrn-elem-obj-prop-id-init.js b/test/language/expressions/generators/dstr-dflt-ary-ptrn-elem-obj-prop-id-init.js new file mode 100644 index 0000000000..c5971e7173 --- /dev/null +++ b/test/language/expressions/generators/dstr-dflt-ary-ptrn-elem-obj-prop-id-init.js @@ -0,0 +1,74 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-prop-id-init.case +// - src/dstr-binding/default/gen-func-expr-dflt.template +/*--- +description: BindingElement with object binding pattern and initializer is used (generator function expression (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-evaluation +es6id: 14.4.14 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorExpression : function * ( FormalParameters ) { GeneratorBody } + + [...] + 3. Let closure be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +var f; +f = function*([{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }] = []) { + assert.sameValue(v, 444); + assert.sameValue(x, 555); + assert.sameValue(z, 666); + + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; +}; + +f().next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/expressions/generators/dstr-dflt-ary-ptrn-elem-obj-prop-id.js b/test/language/expressions/generators/dstr-dflt-ary-ptrn-elem-obj-prop-id.js new file mode 100644 index 0000000000..1883135f4c --- /dev/null +++ b/test/language/expressions/generators/dstr-dflt-ary-ptrn-elem-obj-prop-id.js @@ -0,0 +1,74 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-prop-id.case +// - src/dstr-binding/default/gen-func-expr-dflt.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (generator function expression (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-evaluation +es6id: 14.4.14 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorExpression : function * ( FormalParameters ) { GeneratorBody } + + [...] + 3. Let closure be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +var f; +f = function*([{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }] = [{ u: 777, w: 888, y: 999 }]) { + assert.sameValue(v, 777); + assert.sameValue(x, 888); + assert.sameValue(z, 999); + + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; +}; + +f().next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/expressions/generators/dstr-dflt-ary-ptrn-elem-obj-val-null.js b/test/language/expressions/generators/dstr-dflt-ary-ptrn-elem-obj-val-null.js new file mode 100644 index 0000000000..7e21b8b34b --- /dev/null +++ b/test/language/expressions/generators/dstr-dflt-ary-ptrn-elem-obj-val-null.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-null.case +// - src/dstr-binding/error/gen-func-expr-dflt.template +/*--- +description: Nested object destructuring with a null value (generator function expression (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-evaluation +es6id: 14.4.14 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorExpression : function * ( FormalParameters ) { GeneratorBody } + + [...] + 3. Let closure be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 = function*([{ x }] = [null]) {}; + +assert.throws(TypeError, function() { + f(); +}); diff --git a/test/language/expressions/generators/dstr-dflt-ary-ptrn-elem-obj-val-undef.js b/test/language/expressions/generators/dstr-dflt-ary-ptrn-elem-obj-val-undef.js new file mode 100644 index 0000000000..8514cb8df0 --- /dev/null +++ b/test/language/expressions/generators/dstr-dflt-ary-ptrn-elem-obj-val-undef.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-undef.case +// - src/dstr-binding/error/gen-func-expr-dflt.template +/*--- +description: Nested object destructuring with a value of `undefined` (generator function expression (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-evaluation +es6id: 14.4.14 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorExpression : function * ( FormalParameters ) { GeneratorBody } + + [...] + 3. Let closure be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 = function*([{ x }] = []) {}; + +assert.throws(TypeError, function() { + f(); +}); diff --git a/test/language/expressions/generators/dstr-dflt-ary-ptrn-elision-exhausted.js b/test/language/expressions/generators/dstr-dflt-ary-ptrn-elision-exhausted.js new file mode 100644 index 0000000000..b760fc16b8 --- /dev/null +++ b/test/language/expressions/generators/dstr-dflt-ary-ptrn-elision-exhausted.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-exhausted.case +// - src/dstr-binding/default/gen-func-expr-dflt.template +/*--- +description: Elision accepts exhausted iterator (generator function expression (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-evaluation +es6id: 14.4.14 +features: [generator, destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorExpression : function * ( FormalParameters ) { GeneratorBody } + + [...] + 3. Let closure be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + [...] + 2. Return NormalCompletion(empty). + +---*/ +var iter = function*() {}(); +iter.next(); + +var callCount = 0; +var f; +f = function*([,] = iter) { + + callCount = callCount + 1; +}; + +f().next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/expressions/generators/dstr-dflt-ary-ptrn-elision-step-err.js b/test/language/expressions/generators/dstr-dflt-ary-ptrn-elision-step-err.js new file mode 100644 index 0000000000..e563fffc7e --- /dev/null +++ b/test/language/expressions/generators/dstr-dflt-ary-ptrn-elision-step-err.js @@ -0,0 +1,72 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-step-err.case +// - src/dstr-binding/error/gen-func-expr-dflt.template +/*--- +description: Elision advances iterator and forwards abrupt completions (generator function expression (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-evaluation +es6id: 14.4.14 +features: [generator, destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorExpression : function * ( FormalParameters ) { GeneratorBody } + + [...] + 3. Let closure be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 = function*([,] = iter) {}; + +assert.throws(Test262Error, function() { + f(); +}); + +iter.next(); +assert.sameValue(following, 0, 'Iterator was properly closed.'); diff --git a/test/language/expressions/generators/dstr-dflt-ary-ptrn-elision.js b/test/language/expressions/generators/dstr-dflt-ary-ptrn-elision.js new file mode 100644 index 0000000000..3e2d66a56d --- /dev/null +++ b/test/language/expressions/generators/dstr-dflt-ary-ptrn-elision.js @@ -0,0 +1,78 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision.case +// - src/dstr-binding/default/gen-func-expr-dflt.template +/*--- +description: Elision advances iterator (generator function expression (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-evaluation +es6id: 14.4.14 +features: [generator, destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorExpression : function * ( FormalParameters ) { GeneratorBody } + + [...] + 3. Let closure be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + 2. Return NormalCompletion(empty). + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var callCount = 0; +var f; +f = function*([,] = g()) { + assert.sameValue(first, 1); + assert.sameValue(second, 0); + callCount = callCount + 1; +}; + +f().next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/expressions/generators/dstr-dflt-ary-ptrn-empty.js b/test/language/expressions/generators/dstr-dflt-ary-ptrn-empty.js new file mode 100644 index 0000000000..116dd47f1e --- /dev/null +++ b/test/language/expressions/generators/dstr-dflt-ary-ptrn-empty.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-empty.case +// - src/dstr-binding/default/gen-func-expr-dflt.template +/*--- +description: No iteration occurs for an "empty" array binding pattern (generator function expression (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-evaluation +es6id: 14.4.14 +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorExpression : function * ( FormalParameters ) { GeneratorBody } + + [...] + 3. Let closure be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ ] + + 1. Return NormalCompletion(empty). + +---*/ +var iterations = 0; +var iter = function*() { + iterations += 1; +}(); + +var callCount = 0; +var f; +f = function*([] = iter) { + assert.sameValue(iterations, 0); + callCount = callCount + 1; +}; + +f().next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/expressions/generators/dstr-dflt-ary-ptrn-rest-ary-elem.js b/test/language/expressions/generators/dstr-dflt-ary-ptrn-rest-ary-elem.js new file mode 100644 index 0000000000..011b8ff709 --- /dev/null +++ b/test/language/expressions/generators/dstr-dflt-ary-ptrn-rest-ary-elem.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-elem.case +// - src/dstr-binding/default/gen-func-expr-dflt.template +/*--- +description: Rest element containing an array BindingElementList pattern (generator function expression (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-evaluation +es6id: 14.4.14 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorExpression : function * ( FormalParameters ) { GeneratorBody } + + [...] + 3. Let closure be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set + iteratorRecord.[[done]] to true. + iii. ReturnIfAbrupt(v). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var f; +f = function*([...[x, y, z]] = [3, 4, 5]) { + assert.sameValue(x, 3); + assert.sameValue(y, 4); + assert.sameValue(z, 5); + callCount = callCount + 1; +}; + +f().next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/expressions/generators/dstr-dflt-ary-ptrn-rest-ary-elision.js b/test/language/expressions/generators/dstr-dflt-ary-ptrn-rest-ary-elision.js new file mode 100644 index 0000000000..43ec6865a7 --- /dev/null +++ b/test/language/expressions/generators/dstr-dflt-ary-ptrn-rest-ary-elision.js @@ -0,0 +1,91 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-elision.case +// - src/dstr-binding/default/gen-func-expr-dflt.template +/*--- +description: Rest element containing an elision (generator function expression (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-evaluation +es6id: 14.4.14 +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorExpression : function * ( FormalParameters ) { GeneratorBody } + + [...] + 3. Let closure be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + 2. Return NormalCompletion(empty). + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var callCount = 0; +var f; +f = function*([...[,]] = g()) { + assert.sameValue(first, 1); + assert.sameValue(second, 1); + callCount = callCount + 1; +}; + +f().next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/expressions/generators/dstr-dflt-ary-ptrn-rest-ary-empty.js b/test/language/expressions/generators/dstr-dflt-ary-ptrn-rest-ary-empty.js new file mode 100644 index 0000000000..b5f40f95c8 --- /dev/null +++ b/test/language/expressions/generators/dstr-dflt-ary-ptrn-rest-ary-empty.js @@ -0,0 +1,74 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-empty.case +// - src/dstr-binding/default/gen-func-expr-dflt.template +/*--- +description: Rest element containing an "empty" array pattern (generator function expression (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-evaluation +es6id: 14.4.14 +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorExpression : function * ( FormalParameters ) { GeneratorBody } + + [...] + 3. Let closure be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ ] + + 1. Return NormalCompletion(empty). + +---*/ +var iterations = 0; +var iter = function*() { + iterations += 1; +}(); + +var callCount = 0; +var f; +f = function*([...[]] = iter) { + assert.sameValue(iterations, 1); + callCount = callCount + 1; +}; + +f().next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/expressions/generators/dstr-dflt-ary-ptrn-rest-ary-rest.js b/test/language/expressions/generators/dstr-dflt-ary-ptrn-rest-ary-rest.js new file mode 100644 index 0000000000..4d5334cf2c --- /dev/null +++ b/test/language/expressions/generators/dstr-dflt-ary-ptrn-rest-ary-rest.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-rest.case +// - src/dstr-binding/default/gen-func-expr-dflt.template +/*--- +description: Rest element containing a rest element (generator function expression (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-evaluation +es6id: 14.4.14 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorExpression : function * ( FormalParameters ) { GeneratorBody } + + [...] + 3. Let closure be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ +var values = [1, 2, 3]; + +var callCount = 0; +var f; +f = function*([...[...x]] = values) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 1); + assert.sameValue(x[1], 2); + assert.sameValue(x[2], 3); + assert.notSameValue(x, values); + + callCount = callCount + 1; +}; + +f().next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/expressions/generators/dstr-dflt-ary-ptrn-rest-id-elision-next-err.js b/test/language/expressions/generators/dstr-dflt-ary-ptrn-rest-id-elision-next-err.js new file mode 100644 index 0000000000..83f38f8ed3 --- /dev/null +++ b/test/language/expressions/generators/dstr-dflt-ary-ptrn-rest-id-elision-next-err.js @@ -0,0 +1,58 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision-next-err.case +// - src/dstr-binding/error/gen-func-expr-dflt.template +/*--- +description: Rest element following elision elements (generator function expression (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-evaluation +es6id: 14.4.14 +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorExpression : function * ( FormalParameters ) { GeneratorBody } + + [...] + 3. Let closure be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 = function*([, ...x] = iter) {}; + +assert.throws(Test262Error, function() { + f(); +}); diff --git a/test/language/expressions/generators/dstr-dflt-ary-ptrn-rest-id-elision.js b/test/language/expressions/generators/dstr-dflt-ary-ptrn-rest-id-elision.js new file mode 100644 index 0000000000..7c462f574f --- /dev/null +++ b/test/language/expressions/generators/dstr-dflt-ary-ptrn-rest-id-elision.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision.case +// - src/dstr-binding/default/gen-func-expr-dflt.template +/*--- +description: Rest element following elision elements (generator function expression (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-evaluation +es6id: 14.4.14 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorExpression : function * ( FormalParameters ) { GeneratorBody } + + [...] + 3. Let closure be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + ArrayBindingPattern : [ Elisionopt BindingRestElement ] + 1. If Elision is present, then + a. Let status be the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with + iteratorRecord as the argument. + b. ReturnIfAbrupt(status). + 2. Return the result of performing IteratorBindingInitialization for + BindingRestElement with iteratorRecord and environment as arguments. +---*/ +var values = [1, 2, 3, 4, 5]; + +var callCount = 0; +var f; +f = function*([ , , ...x] = values) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 3); + assert.sameValue(x[1], 4); + assert.sameValue(x[2], 5); + assert.notSameValue(x, values); + callCount = callCount + 1; +}; + +f().next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/expressions/generators/dstr-dflt-ary-ptrn-rest-id-exhausted.js b/test/language/expressions/generators/dstr-dflt-ary-ptrn-rest-id-exhausted.js new file mode 100644 index 0000000000..89a1566103 --- /dev/null +++ b/test/language/expressions/generators/dstr-dflt-ary-ptrn-rest-id-exhausted.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-exhausted.case +// - src/dstr-binding/default/gen-func-expr-dflt.template +/*--- +description: RestElement applied to an exhausted iterator (generator function expression (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-evaluation +es6id: 14.4.14 +features: [Symbol.iterator, destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorExpression : function * ( FormalParameters ) { GeneratorBody } + + [...] + 3. Let closure be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier, + environment). + 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat, + [...] + b. If iteratorRecord.[[done]] is true, then + i. If environment is undefined, return PutValue(lhs, A). + ii. Return InitializeReferencedBinding(lhs, A). + +---*/ + +var callCount = 0; +var f; +f = function*([, , ...x] = [1, 2]) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 0); + callCount = callCount + 1; +}; + +f().next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/expressions/generators/dstr-dflt-ary-ptrn-rest-id-iter-step-err.js b/test/language/expressions/generators/dstr-dflt-ary-ptrn-rest-id-iter-step-err.js new file mode 100644 index 0000000000..10fabaf8fe --- /dev/null +++ b/test/language/expressions/generators/dstr-dflt-ary-ptrn-rest-id-iter-step-err.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-step-err.case +// - src/dstr-binding/error/gen-func-expr-dflt.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (generator function expression (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-evaluation +es6id: 14.4.14 +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorExpression : function * ( FormalParameters ) { GeneratorBody } + + [...] + 3. Let closure be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 = 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/generators/dstr-dflt-ary-ptrn-rest-id-iter-val-err.js b/test/language/expressions/generators/dstr-dflt-ary-ptrn-rest-id-iter-val-err.js new file mode 100644 index 0000000000..4128e7b732 --- /dev/null +++ b/test/language/expressions/generators/dstr-dflt-ary-ptrn-rest-id-iter-val-err.js @@ -0,0 +1,71 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-val-err.case +// - src/dstr-binding/error/gen-func-expr-dflt.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (generator function expression (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-evaluation +es6id: 14.4.14 +features: [Symbol.iterator, destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorExpression : function * ( FormalParameters ) { GeneratorBody } + + [...] + 3. Let closure be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 = function*([...x] = iter) {}; + +assert.throws(Test262Error, function() { + f(); +}); diff --git a/test/language/expressions/generators/dstr-dflt-ary-ptrn-rest-id.js b/test/language/expressions/generators/dstr-dflt-ary-ptrn-rest-id.js new file mode 100644 index 0000000000..fdc046cfb2 --- /dev/null +++ b/test/language/expressions/generators/dstr-dflt-ary-ptrn-rest-id.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id.case +// - src/dstr-binding/default/gen-func-expr-dflt.template +/*--- +description: Lone rest element (generator function expression (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-evaluation +es6id: 14.4.14 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorExpression : function * ( FormalParameters ) { GeneratorBody } + + [...] + 3. Let closure be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + [...] 3. Let A be ArrayCreate(0). [...] 5. Repeat + [...] + f. Let status be CreateDataProperty(A, ToString (n), nextValue). + [...] +---*/ +var values = [1, 2, 3]; + +var callCount = 0; +var f; +f = function*([...x] = values) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 1); + assert.sameValue(x[1], 2); + assert.sameValue(x[2], 3); + assert.notSameValue(x, values); + callCount = callCount + 1; +}; + +f().next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/expressions/generators/dstr-dflt-ary-ptrn-rest-init-ary.js b/test/language/expressions/generators/dstr-dflt-ary-ptrn-rest-init-ary.js new file mode 100644 index 0000000000..820d7a0f69 --- /dev/null +++ b/test/language/expressions/generators/dstr-dflt-ary-ptrn-rest-init-ary.js @@ -0,0 +1,57 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-ary.case +// - src/dstr-binding/default/gen-func-expr-dflt.template +/*--- +description: Reset element (nested array pattern) does not support initializer (generator function expression (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-evaluation +es6id: 14.4.14 +features: [destructuring-binding, default-parameters] +flags: [generated] +negative: SyntaxError +info: | + GeneratorExpression : function * ( FormalParameters ) { GeneratorBody } + + [...] + 3. Let closure be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +var f; +f = function*([...[ x ] = []] = []) { + + callCount = callCount + 1; +}; + +f().next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/expressions/generators/dstr-dflt-ary-ptrn-rest-init-id.js b/test/language/expressions/generators/dstr-dflt-ary-ptrn-rest-init-id.js new file mode 100644 index 0000000000..9c5eada2b5 --- /dev/null +++ b/test/language/expressions/generators/dstr-dflt-ary-ptrn-rest-init-id.js @@ -0,0 +1,57 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-id.case +// - src/dstr-binding/default/gen-func-expr-dflt.template +/*--- +description: Reset element (identifier) does not support initializer (generator function expression (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-evaluation +es6id: 14.4.14 +features: [destructuring-binding, default-parameters] +flags: [generated] +negative: SyntaxError +info: | + GeneratorExpression : function * ( FormalParameters ) { GeneratorBody } + + [...] + 3. Let closure be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +var f; +f = function*([...x = []] = []) { + + callCount = callCount + 1; +}; + +f().next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/expressions/generators/dstr-dflt-ary-ptrn-rest-init-obj.js b/test/language/expressions/generators/dstr-dflt-ary-ptrn-rest-init-obj.js new file mode 100644 index 0000000000..66e9c0440d --- /dev/null +++ b/test/language/expressions/generators/dstr-dflt-ary-ptrn-rest-init-obj.js @@ -0,0 +1,57 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-obj.case +// - src/dstr-binding/default/gen-func-expr-dflt.template +/*--- +description: Reset element (nested object pattern) does not support initializer (generator function expression (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-evaluation +es6id: 14.4.14 +features: [destructuring-binding, default-parameters] +flags: [generated] +negative: SyntaxError +info: | + GeneratorExpression : function * ( FormalParameters ) { GeneratorBody } + + [...] + 3. Let closure be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +var f; +f = function*([...{ x } = []] = []) { + + callCount = callCount + 1; +}; + +f().next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/expressions/generators/dstr-dflt-ary-ptrn-rest-not-final-ary.js b/test/language/expressions/generators/dstr-dflt-ary-ptrn-rest-not-final-ary.js new file mode 100644 index 0000000000..94c31adaad --- /dev/null +++ b/test/language/expressions/generators/dstr-dflt-ary-ptrn-rest-not-final-ary.js @@ -0,0 +1,57 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-ary.case +// - src/dstr-binding/default/gen-func-expr-dflt.template +/*--- +description: Rest element (array binding pattern) may not be followed by any element (generator function expression (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-evaluation +es6id: 14.4.14 +features: [destructuring-binding, default-parameters] +flags: [generated] +negative: SyntaxError +info: | + GeneratorExpression : function * ( FormalParameters ) { GeneratorBody } + + [...] + 3. Let closure be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +var f; +f = function*([...[x], y] = [1, 2, 3]) { + + callCount = callCount + 1; +}; + +f().next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/expressions/generators/dstr-dflt-ary-ptrn-rest-not-final-id.js b/test/language/expressions/generators/dstr-dflt-ary-ptrn-rest-not-final-id.js new file mode 100644 index 0000000000..2b0bb88a00 --- /dev/null +++ b/test/language/expressions/generators/dstr-dflt-ary-ptrn-rest-not-final-id.js @@ -0,0 +1,57 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-id.case +// - src/dstr-binding/default/gen-func-expr-dflt.template +/*--- +description: Rest element (identifier) may not be followed by any element (generator function expression (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-evaluation +es6id: 14.4.14 +features: [destructuring-binding, default-parameters] +flags: [generated] +negative: SyntaxError +info: | + GeneratorExpression : function * ( FormalParameters ) { GeneratorBody } + + [...] + 3. Let closure be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +var f; +f = function*([...x, y] = [1, 2, 3]) { + + callCount = callCount + 1; +}; + +f().next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/expressions/generators/dstr-dflt-ary-ptrn-rest-not-final-obj.js b/test/language/expressions/generators/dstr-dflt-ary-ptrn-rest-not-final-obj.js new file mode 100644 index 0000000000..d7410ed621 --- /dev/null +++ b/test/language/expressions/generators/dstr-dflt-ary-ptrn-rest-not-final-obj.js @@ -0,0 +1,57 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-obj.case +// - src/dstr-binding/default/gen-func-expr-dflt.template +/*--- +description: Rest element (object binding pattern) may not be followed by any element (generator function expression (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-evaluation +es6id: 14.4.14 +features: [destructuring-binding, default-parameters] +flags: [generated] +negative: SyntaxError +info: | + GeneratorExpression : function * ( FormalParameters ) { GeneratorBody } + + [...] + 3. Let closure be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +var f; +f = function*([...{ x }, y] = [1, 2, 3]) { + + callCount = callCount + 1; +}; + +f().next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/expressions/generators/dstr-dflt-ary-ptrn-rest-obj-id.js b/test/language/expressions/generators/dstr-dflt-ary-ptrn-rest-obj-id.js new file mode 100644 index 0000000000..9bf74f72bb --- /dev/null +++ b/test/language/expressions/generators/dstr-dflt-ary-ptrn-rest-obj-id.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-obj-id.case +// - src/dstr-binding/default/gen-func-expr-dflt.template +/*--- +description: Rest element containing an object binding pattern (generator function expression (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-evaluation +es6id: 14.4.14 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorExpression : function * ( FormalParameters ) { GeneratorBody } + + [...] + 3. Let closure be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ + +var callCount = 0; +var f; +f = function*([...{ length }] = [1, 2, 3]) { + assert.sameValue(length, 3); + callCount = callCount + 1; +}; + +f().next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/expressions/generators/dstr-dflt-ary-ptrn-rest-obj-prop-id.js b/test/language/expressions/generators/dstr-dflt-ary-ptrn-rest-obj-prop-id.js new file mode 100644 index 0000000000..0df9cd4e21 --- /dev/null +++ b/test/language/expressions/generators/dstr-dflt-ary-ptrn-rest-obj-prop-id.js @@ -0,0 +1,71 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-obj-prop-id.case +// - src/dstr-binding/default/gen-func-expr-dflt.template +/*--- +description: Rest element containing an object binding pattern (generator function expression (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-evaluation +es6id: 14.4.14 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorExpression : function * ( FormalParameters ) { GeneratorBody } + + [...] + 3. Let closure be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ + +var callCount = 0; +var f; +f = function*([...{ 0: v, 1: w, 2: x, 3: y, length: z }] = [7, 8, 9]) { + assert.sameValue(v, 7); + assert.sameValue(w, 8); + assert.sameValue(x, 9); + assert.sameValue(y, undefined); + assert.sameValue(z, 3); + + assert.throws(ReferenceError, function() { + length; + }); + callCount = callCount + 1; +}; + +f().next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/expressions/generators/dstr-dflt-obj-init-null.js b/test/language/expressions/generators/dstr-dflt-obj-init-null.js new file mode 100644 index 0000000000..b7e66b3f1a --- /dev/null +++ b/test/language/expressions/generators/dstr-dflt-obj-init-null.js @@ -0,0 +1,52 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-null.case +// - src/dstr-binding/error/gen-func-expr-dflt.template +/*--- +description: Value specifed for object binding pattern must be object coercible (null) (generator function expression (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-evaluation +es6id: 14.4.14 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorExpression : function * ( FormalParameters ) { GeneratorBody } + + [...] + 3. Let closure be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + +var f = function*({} = null) {}; + +assert.throws(TypeError, function() { + f(); +}); diff --git a/test/language/expressions/generators/dstr-dflt-obj-init-undefined.js b/test/language/expressions/generators/dstr-dflt-obj-init-undefined.js new file mode 100644 index 0000000000..89a1deefaa --- /dev/null +++ b/test/language/expressions/generators/dstr-dflt-obj-init-undefined.js @@ -0,0 +1,52 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-undefined.case +// - src/dstr-binding/error/gen-func-expr-dflt.template +/*--- +description: Value specifed for object binding pattern must be object coercible (undefined) (generator function expression (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-evaluation +es6id: 14.4.14 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorExpression : function * ( FormalParameters ) { GeneratorBody } + + [...] + 3. Let closure be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + +var f = function*({} = undefined) {}; + +assert.throws(TypeError, function() { + f(); +}); diff --git a/test/language/expressions/generators/dstr-dflt-obj-ptrn-empty.js b/test/language/expressions/generators/dstr-dflt-obj-ptrn-empty.js new file mode 100644 index 0000000000..cb59ebe21a --- /dev/null +++ b/test/language/expressions/generators/dstr-dflt-obj-ptrn-empty.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-empty.case +// - src/dstr-binding/default/gen-func-expr-dflt.template +/*--- +description: No property access occurs for an "empty" object binding pattern (generator function expression (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-evaluation +es6id: 14.4.14 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorExpression : function * ( FormalParameters ) { GeneratorBody } + + [...] + 3. Let closure be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ +var accessCount = 0; +var obj = Object.defineProperty({}, 'attr', { + get: function() { + accessCount += 1; + } +}); + +var callCount = 0; +var f; +f = function*({} = obj) { + assert.sameValue(accessCount, 0); + callCount = callCount + 1; +}; + +f().next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/expressions/generators/dstr-dflt-obj-ptrn-id-get-value-err.js b/test/language/expressions/generators/dstr-dflt-obj-ptrn-id-get-value-err.js new file mode 100644 index 0000000000..aae92df13e --- /dev/null +++ b/test/language/expressions/generators/dstr-dflt-obj-ptrn-id-get-value-err.js @@ -0,0 +1,59 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-get-value-err.case +// - src/dstr-binding/error/gen-func-expr-dflt.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (generator function expression (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-evaluation +es6id: 14.4.14 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorExpression : function * ( FormalParameters ) { GeneratorBody } + + [...] + 3. Let closure be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 = function*({ poisoned } = poisonedProperty) {}; + +assert.throws(Test262Error, function() { + f(); +}); diff --git a/test/language/expressions/generators/dstr-dflt-obj-ptrn-id-init-fn-name-arrow.js b/test/language/expressions/generators/dstr-dflt-obj-ptrn-id-init-fn-name-arrow.js new file mode 100644 index 0000000000..7b68171e5b --- /dev/null +++ b/test/language/expressions/generators/dstr-dflt-obj-ptrn-id-init-fn-name-arrow.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-arrow.case +// - src/dstr-binding/default/gen-func-expr-dflt.template +/*--- +description: SingleNameBinding assigns `name` to arrow functions (generator function expression (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-evaluation +es6id: 14.4.14 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorExpression : function * ( FormalParameters ) { GeneratorBody } + + [...] + 3. Let closure be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +var f; +f = function*({ arrow = () => {} } = {}) { + assert.sameValue(arrow.name, 'arrow'); + callCount = callCount + 1; +}; + +f().next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/expressions/generators/dstr-dflt-obj-ptrn-id-init-fn-name-class.js b/test/language/expressions/generators/dstr-dflt-obj-ptrn-id-init-fn-name-class.js new file mode 100644 index 0000000000..ede0ce051e --- /dev/null +++ b/test/language/expressions/generators/dstr-dflt-obj-ptrn-id-init-fn-name-class.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-class.case +// - src/dstr-binding/default/gen-func-expr-dflt.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (generator function expression (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-evaluation +es6id: 14.4.14 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorExpression : function * ( FormalParameters ) { GeneratorBody } + + [...] + 3. Let closure be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +var f; +f = function*({ cls = class {}, xCls = class X {} } = {}) { + assert.sameValue(cls.name, 'cls'); + assert.notSameValue(xCls.name, 'xCls'); + callCount = callCount + 1; +}; + +f().next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/expressions/generators/dstr-dflt-obj-ptrn-id-init-fn-name-cover.js b/test/language/expressions/generators/dstr-dflt-obj-ptrn-id-init-fn-name-cover.js new file mode 100644 index 0000000000..761d917844 --- /dev/null +++ b/test/language/expressions/generators/dstr-dflt-obj-ptrn-id-init-fn-name-cover.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-cover.case +// - src/dstr-binding/default/gen-func-expr-dflt.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" functions "through" cover grammar (generator function expression (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-evaluation +es6id: 14.4.14 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorExpression : function * ( FormalParameters ) { GeneratorBody } + + [...] + 3. Let closure be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +var f; +f = function*({ cover = (function () {}), xCover = (0, function() {}) } = {}) { + assert.sameValue(cover.name, 'cover'); + assert.notSameValue(xCover.name, 'xCover'); + callCount = callCount + 1; +}; + +f().next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/expressions/generators/dstr-dflt-obj-ptrn-id-init-fn-name-fn.js b/test/language/expressions/generators/dstr-dflt-obj-ptrn-id-init-fn-name-fn.js new file mode 100644 index 0000000000..b1191972b0 --- /dev/null +++ b/test/language/expressions/generators/dstr-dflt-obj-ptrn-id-init-fn-name-fn.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-fn.case +// - src/dstr-binding/default/gen-func-expr-dflt.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (generator function expression (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-evaluation +es6id: 14.4.14 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorExpression : function * ( FormalParameters ) { GeneratorBody } + + [...] + 3. Let closure be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +var f; +f = function*({ fn = function () {}, xFn = function x() {} } = {}) { + assert.sameValue(fn.name, 'fn'); + assert.notSameValue(xFn.name, 'xFn'); + callCount = callCount + 1; +}; + +f().next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/expressions/generators/dstr-dflt-obj-ptrn-id-init-fn-name-gen.js b/test/language/expressions/generators/dstr-dflt-obj-ptrn-id-init-fn-name-gen.js new file mode 100644 index 0000000000..a5815cdc46 --- /dev/null +++ b/test/language/expressions/generators/dstr-dflt-obj-ptrn-id-init-fn-name-gen.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-gen.case +// - src/dstr-binding/default/gen-func-expr-dflt.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (generator function expression (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-evaluation +es6id: 14.4.14 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorExpression : function * ( FormalParameters ) { GeneratorBody } + + [...] + 3. Let closure be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +var f; +f = function*({ gen = function* () {}, xGen = function* x() {} } = {}) { + assert.sameValue(gen.name, 'gen'); + assert.notSameValue(xGen.name, 'xGen'); + callCount = callCount + 1; +}; + +f().next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/expressions/generators/dstr-dflt-obj-ptrn-id-init-skipped.js b/test/language/expressions/generators/dstr-dflt-obj-ptrn-id-init-skipped.js new file mode 100644 index 0000000000..849ad490c2 --- /dev/null +++ b/test/language/expressions/generators/dstr-dflt-obj-ptrn-id-init-skipped.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-skipped.case +// - src/dstr-binding/default/gen-func-expr-dflt.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (generator function expression (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-evaluation +es6id: 14.4.14 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorExpression : function * ( FormalParameters ) { GeneratorBody } + + [...] + 3. Let closure be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + [...] +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var callCount = 0; +var f; +f = function*({ w = counter(), x = counter(), y = counter(), z = counter() } = { w: null, x: 0, y: false, z: '' }) { + assert.sameValue(w, null); + assert.sameValue(x, 0); + assert.sameValue(y, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + callCount = callCount + 1; +}; + +f().next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/expressions/generators/dstr-dflt-obj-ptrn-id-init-throws.js b/test/language/expressions/generators/dstr-dflt-obj-ptrn-id-init-throws.js new file mode 100644 index 0000000000..58193b66aa --- /dev/null +++ b/test/language/expressions/generators/dstr-dflt-obj-ptrn-id-init-throws.js @@ -0,0 +1,59 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-throws.case +// - src/dstr-binding/error/gen-func-expr-dflt.template +/*--- +description: Error thrown when evaluating the initializer (generator function expression (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-evaluation +es6id: 14.4.14 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorExpression : function * ( FormalParameters ) { GeneratorBody } + + [...] + 3. Let closure be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 = function*({ x = thrower() } = {}) {}; + +assert.throws(Test262Error, function() { + f(); +}); diff --git a/test/language/expressions/generators/dstr-dflt-obj-ptrn-id-init-unresolvable.js b/test/language/expressions/generators/dstr-dflt-obj-ptrn-id-init-unresolvable.js new file mode 100644 index 0000000000..f5fe5074dd --- /dev/null +++ b/test/language/expressions/generators/dstr-dflt-obj-ptrn-id-init-unresolvable.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-unresolvable.case +// - src/dstr-binding/error/gen-func-expr-dflt.template +/*--- +description: Destructuring initializer is an unresolvable reference (generator function expression (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-evaluation +es6id: 14.4.14 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorExpression : function * ( FormalParameters ) { GeneratorBody } + + [...] + 3. Let closure be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 = function*({ x = unresolvableReference } = {}) {}; + +assert.throws(ReferenceError, function() { + f(); +}); diff --git a/test/language/expressions/generators/dstr-dflt-obj-ptrn-id-trailing-comma.js b/test/language/expressions/generators/dstr-dflt-obj-ptrn-id-trailing-comma.js new file mode 100644 index 0000000000..5185cd6de3 --- /dev/null +++ b/test/language/expressions/generators/dstr-dflt-obj-ptrn-id-trailing-comma.js @@ -0,0 +1,57 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-trailing-comma.case +// - src/dstr-binding/default/gen-func-expr-dflt.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (generator function expression (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-evaluation +es6id: 14.4.14 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorExpression : function * ( FormalParameters ) { GeneratorBody } + + [...] + 3. Let closure be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var callCount = 0; +var f; +f = function*({ x, } = { x: 23 }) { + assert.sameValue(x, 23); + callCount = callCount + 1; +}; + +f().next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/expressions/generators/dstr-dflt-obj-ptrn-list-err.js b/test/language/expressions/generators/dstr-dflt-obj-ptrn-list-err.js new file mode 100644 index 0000000000..2a8aef33ef --- /dev/null +++ b/test/language/expressions/generators/dstr-dflt-obj-ptrn-list-err.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-list-err.case +// - src/dstr-binding/error/gen-func-expr-dflt.template +/*--- +description: Binding property list evaluation is interrupted by an abrupt completion (generator function expression (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-evaluation +es6id: 14.4.14 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorExpression : function * ( FormalParameters ) { GeneratorBody } + + [...] + 3. Let closure be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 = function*({ a, b = thrower(), c = ++initCount } = {}) {}; + +assert.throws(Test262Error, function() { + f(); +}); + +assert.sameValue(initCount, 0); diff --git a/test/language/expressions/generators/dstr-dflt-obj-ptrn-prop-ary-init.js b/test/language/expressions/generators/dstr-dflt-obj-ptrn-prop-ary-init.js new file mode 100644 index 0000000000..73b40f601b --- /dev/null +++ b/test/language/expressions/generators/dstr-dflt-obj-ptrn-prop-ary-init.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-init.case +// - src/dstr-binding/default/gen-func-expr-dflt.template +/*--- +description: Object binding pattern with "nested" array binding pattern using initializer (generator function expression (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-evaluation +es6id: 14.4.14 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorExpression : function * ( FormalParameters ) { GeneratorBody } + + [...] + 3. Let closure be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +var f; +f = function*({ w: [x, y, z] = [4, 5, 6] } = {}) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; +}; + +f().next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/expressions/generators/dstr-dflt-obj-ptrn-prop-ary-trailing-comma.js b/test/language/expressions/generators/dstr-dflt-obj-ptrn-prop-ary-trailing-comma.js new file mode 100644 index 0000000000..ff5184c4dc --- /dev/null +++ b/test/language/expressions/generators/dstr-dflt-obj-ptrn-prop-ary-trailing-comma.js @@ -0,0 +1,57 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-trailing-comma.case +// - src/dstr-binding/default/gen-func-expr-dflt.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (generator function expression (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-evaluation +es6id: 14.4.14 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorExpression : function * ( FormalParameters ) { GeneratorBody } + + [...] + 3. Let closure be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var callCount = 0; +var f; +f = function*({ x: [y], } = { x: [45] }) { + assert.sameValue(y,45); + callCount = callCount + 1; +}; + +f().next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/expressions/generators/dstr-dflt-obj-ptrn-prop-ary-value-null.js b/test/language/expressions/generators/dstr-dflt-obj-ptrn-prop-ary-value-null.js new file mode 100644 index 0000000000..efd1c8ed34 --- /dev/null +++ b/test/language/expressions/generators/dstr-dflt-obj-ptrn-prop-ary-value-null.js @@ -0,0 +1,54 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-value-null.case +// - src/dstr-binding/error/gen-func-expr-dflt.template +/*--- +description: Object binding pattern with "nested" array binding pattern taking the `null` value (generator function expression (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-evaluation +es6id: 14.4.14 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorExpression : function * ( FormalParameters ) { GeneratorBody } + + [...] + 3. Let closure be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 = function*({ w: [x, y, z] = [4, 5, 6] } = { w: null }) {}; + +assert.throws(TypeError, function() { + f(); +}); diff --git a/test/language/expressions/generators/dstr-dflt-obj-ptrn-prop-ary.js b/test/language/expressions/generators/dstr-dflt-obj-ptrn-prop-ary.js new file mode 100644 index 0000000000..91c69d990b --- /dev/null +++ b/test/language/expressions/generators/dstr-dflt-obj-ptrn-prop-ary.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary.case +// - src/dstr-binding/default/gen-func-expr-dflt.template +/*--- +description: Object binding pattern with "nested" array binding pattern not using initializer (generator function expression (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-evaluation +es6id: 14.4.14 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorExpression : function * ( FormalParameters ) { GeneratorBody } + + [...] + 3. Let closure be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +var f; +f = function*({ w: [x, y, z] = [4, 5, 6] } = { w: [7, undefined, ] }) { + assert.sameValue(x, 7); + assert.sameValue(y, undefined); + assert.sameValue(z, undefined); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; +}; + +f().next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/expressions/generators/dstr-dflt-obj-ptrn-prop-eval-err.js b/test/language/expressions/generators/dstr-dflt-obj-ptrn-prop-eval-err.js new file mode 100644 index 0000000000..b1ffb43ebc --- /dev/null +++ b/test/language/expressions/generators/dstr-dflt-obj-ptrn-prop-eval-err.js @@ -0,0 +1,56 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-eval-err.case +// - src/dstr-binding/error/gen-func-expr-dflt.template +/*--- +description: Evaluation of property name returns an abrupt completion (generator function expression (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-evaluation +es6id: 14.4.14 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorExpression : function * ( FormalParameters ) { GeneratorBody } + + [...] + 3. Let closure be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 = function*({ [thrower()]: x } = {}) {}; + +assert.throws(Test262Error, function() { + f(); +}); diff --git a/test/language/expressions/generators/dstr-dflt-obj-ptrn-prop-id-get-value-err.js b/test/language/expressions/generators/dstr-dflt-obj-ptrn-prop-id-get-value-err.js new file mode 100644 index 0000000000..6a13794dcc --- /dev/null +++ b/test/language/expressions/generators/dstr-dflt-obj-ptrn-prop-id-get-value-err.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-get-value-err.case +// - src/dstr-binding/error/gen-func-expr-dflt.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (generator function expression (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-evaluation +es6id: 14.4.14 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorExpression : function * ( FormalParameters ) { GeneratorBody } + + [...] + 3. Let closure be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 = function*({ poisoned: x = ++initEvalCount } = poisonedProperty) {}; + +assert.throws(Test262Error, function() { + f(); +}); + +assert.sameValue(initEvalCount, 0); diff --git a/test/language/expressions/generators/dstr-dflt-obj-ptrn-prop-id-init-skipped.js b/test/language/expressions/generators/dstr-dflt-obj-ptrn-prop-id-init-skipped.js new file mode 100644 index 0000000000..3740ccf3ce --- /dev/null +++ b/test/language/expressions/generators/dstr-dflt-obj-ptrn-prop-id-init-skipped.js @@ -0,0 +1,79 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-skipped.case +// - src/dstr-binding/default/gen-func-expr-dflt.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (generator function expression (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-evaluation +es6id: 14.4.14 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorExpression : function * ( FormalParameters ) { GeneratorBody } + + [...] + 3. Let closure be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + [...] +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var callCount = 0; +var f; +f = function*({ s: t = counter(), u: v = counter(), w: x = counter(), y: z = counter() } = { s: null, u: 0, w: false, y: '' }) { + assert.sameValue(t, null); + assert.sameValue(v, 0); + assert.sameValue(x, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + + assert.throws(ReferenceError, function() { + s; + }); + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; +}; + +f().next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/expressions/generators/dstr-dflt-obj-ptrn-prop-id-init-throws.js b/test/language/expressions/generators/dstr-dflt-obj-ptrn-prop-id-init-throws.js new file mode 100644 index 0000000000..70badd6c70 --- /dev/null +++ b/test/language/expressions/generators/dstr-dflt-obj-ptrn-prop-id-init-throws.js @@ -0,0 +1,59 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-throws.case +// - src/dstr-binding/error/gen-func-expr-dflt.template +/*--- +description: Error thrown when evaluating the initializer (generator function expression (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-evaluation +es6id: 14.4.14 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorExpression : function * ( FormalParameters ) { GeneratorBody } + + [...] + 3. Let closure be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 = function*({ x: y = thrower() } = {}) {}; + +assert.throws(Test262Error, function() { + f(); +}); diff --git a/test/language/expressions/generators/dstr-dflt-obj-ptrn-prop-id-init-unresolvable.js b/test/language/expressions/generators/dstr-dflt-obj-ptrn-prop-id-init-unresolvable.js new file mode 100644 index 0000000000..6f2ee07c4a --- /dev/null +++ b/test/language/expressions/generators/dstr-dflt-obj-ptrn-prop-id-init-unresolvable.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-unresolvable.case +// - src/dstr-binding/error/gen-func-expr-dflt.template +/*--- +description: Destructuring initializer is an unresolvable reference (generator function expression (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-evaluation +es6id: 14.4.14 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorExpression : function * ( FormalParameters ) { GeneratorBody } + + [...] + 3. Let closure be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 = function*({ x: y = unresolvableReference } = {}) {}; + +assert.throws(ReferenceError, function() { + f(); +}); diff --git a/test/language/expressions/generators/dstr-dflt-obj-ptrn-prop-id-init.js b/test/language/expressions/generators/dstr-dflt-obj-ptrn-prop-id-init.js new file mode 100644 index 0000000000..51c4d71130 --- /dev/null +++ b/test/language/expressions/generators/dstr-dflt-obj-ptrn-prop-id-init.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init.case +// - src/dstr-binding/default/gen-func-expr-dflt.template +/*--- +description: Binding as specified via property name, identifier, and initializer (generator function expression (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-evaluation +es6id: 14.4.14 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorExpression : function * ( FormalParameters ) { GeneratorBody } + + [...] + 3. Let closure be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var f; +f = function*({ x: y = 33 } = { }) { + assert.sameValue(y, 33); + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; +}; + +f().next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/expressions/generators/dstr-dflt-obj-ptrn-prop-id-trailing-comma.js b/test/language/expressions/generators/dstr-dflt-obj-ptrn-prop-id-trailing-comma.js new file mode 100644 index 0000000000..d5bbb481bb --- /dev/null +++ b/test/language/expressions/generators/dstr-dflt-obj-ptrn-prop-id-trailing-comma.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-trailing-comma.case +// - src/dstr-binding/default/gen-func-expr-dflt.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (generator function expression (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-evaluation +es6id: 14.4.14 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorExpression : function * ( FormalParameters ) { GeneratorBody } + + [...] + 3. Let closure be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var callCount = 0; +var f; +f = function*({ x: y, } = { x: 23 }) { + assert.sameValue(y, 23); + + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; +}; + +f().next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/expressions/generators/dstr-dflt-obj-ptrn-prop-id.js b/test/language/expressions/generators/dstr-dflt-obj-ptrn-prop-id.js new file mode 100644 index 0000000000..b29981eb3c --- /dev/null +++ b/test/language/expressions/generators/dstr-dflt-obj-ptrn-prop-id.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id.case +// - src/dstr-binding/default/gen-func-expr-dflt.template +/*--- +description: Binding as specified via property name and identifier (generator function expression (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-evaluation +es6id: 14.4.14 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorExpression : function * ( FormalParameters ) { GeneratorBody } + + [...] + 3. Let closure be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var f; +f = function*({ x: y } = { x: 23 }) { + assert.sameValue(y, 23); + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; +}; + +f().next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/expressions/generators/dstr-dflt-obj-ptrn-prop-obj-init.js b/test/language/expressions/generators/dstr-dflt-obj-ptrn-prop-obj-init.js new file mode 100644 index 0000000000..ee8e5221fd --- /dev/null +++ b/test/language/expressions/generators/dstr-dflt-obj-ptrn-prop-obj-init.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-init.case +// - src/dstr-binding/default/gen-func-expr-dflt.template +/*--- +description: Object binding pattern with "nested" object binding pattern using initializer (generator function expression (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-evaluation +es6id: 14.4.14 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorExpression : function * ( FormalParameters ) { GeneratorBody } + + [...] + 3. Let closure be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +var f; +f = function*({ w: { x, y, z } = { x: 4, y: 5, z: 6 } } = { w: undefined }) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; +}; + +f().next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/expressions/generators/dstr-dflt-obj-ptrn-prop-obj-value-null.js b/test/language/expressions/generators/dstr-dflt-obj-ptrn-prop-obj-value-null.js new file mode 100644 index 0000000000..2d1c92683f --- /dev/null +++ b/test/language/expressions/generators/dstr-dflt-obj-ptrn-prop-obj-value-null.js @@ -0,0 +1,54 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-null.case +// - src/dstr-binding/error/gen-func-expr-dflt.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (generator function expression (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-evaluation +es6id: 14.4.14 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorExpression : function * ( FormalParameters ) { GeneratorBody } + + [...] + 3. Let closure be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 = function*({ w: { x, y, z } = { x: 4, y: 5, z: 6 } } = { w: null }) {}; + +assert.throws(TypeError, function() { + f(); +}); diff --git a/test/language/expressions/generators/dstr-dflt-obj-ptrn-prop-obj-value-undef.js b/test/language/expressions/generators/dstr-dflt-obj-ptrn-prop-obj-value-undef.js new file mode 100644 index 0000000000..2e69443b48 --- /dev/null +++ b/test/language/expressions/generators/dstr-dflt-obj-ptrn-prop-obj-value-undef.js @@ -0,0 +1,54 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-undef.case +// - src/dstr-binding/error/gen-func-expr-dflt.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (generator function expression (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-evaluation +es6id: 14.4.14 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorExpression : function * ( FormalParameters ) { GeneratorBody } + + [...] + 3. Let closure be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 = function*({ w: { x, y, z } = undefined } = { }) {}; + +assert.throws(TypeError, function() { + f(); +}); diff --git a/test/language/expressions/generators/dstr-dflt-obj-ptrn-prop-obj.js b/test/language/expressions/generators/dstr-dflt-obj-ptrn-prop-obj.js new file mode 100644 index 0000000000..71167c9a6c --- /dev/null +++ b/test/language/expressions/generators/dstr-dflt-obj-ptrn-prop-obj.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj.case +// - src/dstr-binding/default/gen-func-expr-dflt.template +/*--- +description: Object binding pattern with "nested" object binding pattern not using initializer (generator function expression (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-evaluation +es6id: 14.4.14 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorExpression : function * ( FormalParameters ) { GeneratorBody } + + [...] + 3. Let closure be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +var f; +f = function*({ w: { x, y, z } = { x: 4, y: 5, z: 6 } } = { w: { x: undefined, z: 7 } }) { + assert.sameValue(x, undefined); + assert.sameValue(y, undefined); + assert.sameValue(z, 7); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; +}; + +f().next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/expressions/object/dstr-gen-meth-dflt-ary-init-iter-close.js b/test/language/expressions/object/dstr-gen-meth-dflt-ary-init-iter-close.js new file mode 100644 index 0000000000..c17349e261 --- /dev/null +++ b/test/language/expressions/object/dstr-gen-meth-dflt-ary-init-iter-close.js @@ -0,0 +1,79 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-close.case +// - src/dstr-binding/default/gen-method-dflt.template +/*--- +description: Iterator is closed when not exhausted by pattern evaluation (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +es6id: 14.4.13 +features: [Symbol.iterator, destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + [...] + 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator, + result). + [...] + +---*/ +var doneCallCount = 0; +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return { value: null, done: false }; + }, + return: function() { + doneCallCount += 1; + return {}; + } + }; +}; + +var callCount = 0; +var obj = { + *method([x] = iter) { + assert.sameValue(doneCallCount, 1); + callCount = callCount + 1; + } +}; + +obj.method().next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-gen-meth-dflt-ary-init-iter-get-err.js b/test/language/expressions/object/dstr-gen-meth-dflt-ary-init-iter-get-err.js new file mode 100644 index 0000000000..6508245309 --- /dev/null +++ b/test/language/expressions/object/dstr-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/gen-meth-dflt.template +/*--- +description: Abrupt completion returned by GetIterator (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +es6id: 14.4.13 +features: [Symbol.iterator, destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 = { + *method([x] = iter) {} +}; + +assert.throws(Test262Error, function() { + obj.method(); +}); diff --git a/test/language/expressions/object/dstr-gen-meth-dflt-ary-init-iter-no-close.js b/test/language/expressions/object/dstr-gen-meth-dflt-ary-init-iter-no-close.js new file mode 100644 index 0000000000..9874fa38f6 --- /dev/null +++ b/test/language/expressions/object/dstr-gen-meth-dflt-ary-init-iter-no-close.js @@ -0,0 +1,79 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-no-close.case +// - src/dstr-binding/default/gen-method-dflt.template +/*--- +description: Iterator is not closed when exhausted by pattern evaluation (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +es6id: 14.4.13 +features: [Symbol.iterator, destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + [...] + 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator, + result). + [...] + +---*/ +var doneCallCount = 0; +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return { value: null, done: true }; + }, + return: function() { + doneCallCount += 1; + return {}; + } + }; +}; + +var callCount = 0; +var obj = { + *method([x] = iter) { + assert.sameValue(doneCallCount, 0); + callCount = callCount + 1; + } +}; + +obj.method().next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-gen-meth-dflt-ary-name-iter-val.js b/test/language/expressions/object/dstr-gen-meth-dflt-ary-name-iter-val.js new file mode 100644 index 0000000000..2c73ff64b4 --- /dev/null +++ b/test/language/expressions/object/dstr-gen-meth-dflt-ary-name-iter-val.js @@ -0,0 +1,78 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-name-iter-val.case +// - src/dstr-binding/default/gen-method-dflt.template +/*--- +description: SingleNameBinding with normal value iteration (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +es6id: 14.4.13 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set + iteratorRecord.[[done]] to true. + iii. ReturnIfAbrupt(v). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var obj = { + *method([x, y, z] = [1, 2, 3]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 3); + callCount = callCount + 1; + } +}; + +obj.method().next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-elem-ary-elem-init.js b/test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-elem-ary-elem-init.js new file mode 100644 index 0000000000..c49eeff539 --- /dev/null +++ b/test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-elem-ary-elem-init.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elem-init.case +// - src/dstr-binding/default/gen-method-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is used (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +es6id: 14.4.13 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +var obj = { + *method([[x, y, z] = [4, 5, 6]] = []) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + callCount = callCount + 1; + } +}; + +obj.method().next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-elem-ary-elem-iter.js b/test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-elem-ary-elem-iter.js new file mode 100644 index 0000000000..112aefd8dc --- /dev/null +++ b/test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-elem-ary-elem-iter.js @@ -0,0 +1,71 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elem-iter.case +// - src/dstr-binding/default/gen-method-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +es6id: 14.4.13 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +var obj = { + *method([[x, y, z] = [4, 5, 6]] = [[7, 8, 9]]) { + assert.sameValue(x, 7); + assert.sameValue(y, 8); + assert.sameValue(z, 9); + callCount = callCount + 1; + } +}; + +obj.method().next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-elem-ary-elision-init.js b/test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-elem-ary-elision-init.js new file mode 100644 index 0000000000..db0809fc64 --- /dev/null +++ b/test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-elem-ary-elision-init.js @@ -0,0 +1,77 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elision-init.case +// - src/dstr-binding/default/gen-method-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is used (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +es6id: 14.4.13 +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var callCount = 0; +var obj = { + *method([[,] = g()] = []) { + assert.sameValue(first, 1); + assert.sameValue(second, 0); + callCount = callCount + 1; + } +}; + +obj.method().next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-elem-ary-elision-iter.js b/test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-elem-ary-elision-iter.js new file mode 100644 index 0000000000..f6a39a69bb --- /dev/null +++ b/test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-elem-ary-elision-iter.js @@ -0,0 +1,74 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elision-iter.case +// - src/dstr-binding/default/gen-method-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +es6id: 14.4.13 +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var callCount = 0; +function* g() { + callCount += 1; +}; + +var callCount = 0; +var obj = { + *method([[,] = g()] = [[]]) { + assert.sameValue(callCount, 0); + callCount = callCount + 1; + } +}; + +obj.method().next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-elem-ary-empty-init.js b/test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-elem-ary-empty-init.js new file mode 100644 index 0000000000..fa8cc68cb0 --- /dev/null +++ b/test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-elem-ary-empty-init.js @@ -0,0 +1,72 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-empty-init.case +// - src/dstr-binding/default/gen-method-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is used (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +es6id: 14.4.13 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var initCount = 0; +var iterCount = 0; +var iter = function*() { iterCount += 1; }(); + +var callCount = 0; +var obj = { + *method([[] = function() { initCount += 1; return iter; }()] = []) { + assert.sameValue(initCount, 1); + assert.sameValue(iterCount, 0); + callCount = callCount + 1; + } +}; + +obj.method().next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-elem-ary-empty-iter.js b/test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-elem-ary-empty-iter.js new file mode 100644 index 0000000000..da2aff3934 --- /dev/null +++ b/test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-elem-ary-empty-iter.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-empty-iter.case +// - src/dstr-binding/default/gen-method-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +es6id: 14.4.13 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var initCount = 0; + +var callCount = 0; +var obj = { + *method([[] = function() { initCount += 1; }()] = [[23]]) { + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } +}; + +obj.method().next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-elem-ary-rest-init.js b/test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-elem-ary-rest-init.js new file mode 100644 index 0000000000..6b1d6ba122 --- /dev/null +++ b/test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-elem-ary-rest-init.js @@ -0,0 +1,74 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-rest-init.case +// - src/dstr-binding/default/gen-method-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is used (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +es6id: 14.4.13 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var values = [2, 1, 3]; + +var callCount = 0; +var obj = { + *method([[...x] = values] = []) { + assert(Array.isArray(x)); + assert.sameValue(x[0], 2); + assert.sameValue(x[1], 1); + assert.sameValue(x[2], 3); + assert.sameValue(x.length, 3); + assert.notSameValue(x, values); + callCount = callCount + 1; + } +}; + +obj.method().next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-elem-ary-rest-iter.js b/test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-elem-ary-rest-iter.js new file mode 100644 index 0000000000..fe6b182df1 --- /dev/null +++ b/test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-elem-ary-rest-iter.js @@ -0,0 +1,77 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-rest-iter.case +// - src/dstr-binding/default/gen-method-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +es6id: 14.4.13 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var values = [2, 1, 3]; +var initCount = 0; + +var callCount = 0; +var obj = { + *method([[...x] = function() { initCount += 1; }()] = [values]) { + assert(Array.isArray(x)); + assert.sameValue(x[0], 2); + assert.sameValue(x[1], 1); + assert.sameValue(x[2], 3); + assert.sameValue(x.length, 3); + assert.notSameValue(x, values); + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } +}; + +obj.method().next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-elem-ary-val-null.js b/test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-elem-ary-val-null.js new file mode 100644 index 0000000000..f957343695 --- /dev/null +++ b/test/language/expressions/object/dstr-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/gen-meth-dflt.template +/*--- +description: Nested array destructuring with a null value (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +es6id: 14.4.13 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 = { + *method([[x]] = [null]) {} +}; + +assert.throws(TypeError, function() { + obj.method(); +}); diff --git a/test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-elem-id-init-exhausted.js b/test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-elem-id-init-exhausted.js new file mode 100644 index 0000000000..0217ce2536 --- /dev/null +++ b/test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-elem-id-init-exhausted.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-exhausted.case +// - src/dstr-binding/default/gen-method-dflt.template +/*--- +description: Destructuring initializer with an exhausted iterator (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +es6id: 14.4.13 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var obj = { + *method([x = 23] = []) { + assert.sameValue(x, 23); + callCount = callCount + 1; + } +}; + +obj.method().next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-arrow.js b/test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-arrow.js new file mode 100644 index 0000000000..6071504fcc --- /dev/null +++ b/test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-arrow.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-arrow.case +// - src/dstr-binding/default/gen-method-dflt.template +/*--- +description: SingleNameBinding does assign name to arrow functions (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +es6id: 14.4.13 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var obj = { + *method([arrow = () => {}] = []) { + assert.sameValue(arrow.name, 'arrow'); + callCount = callCount + 1; + } +}; + +obj.method().next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-class.js b/test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-class.js new file mode 100644 index 0000000000..7852dc8156 --- /dev/null +++ b/test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-class.js @@ -0,0 +1,71 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-class.case +// - src/dstr-binding/default/gen-method-dflt.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +es6id: 14.4.13 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var obj = { + *method([cls = class {}, xCls = class X {}] = []) { + assert.sameValue(cls.name, 'cls'); + assert.notSameValue(xCls.name, 'xCls'); + callCount = callCount + 1; + } +}; + +obj.method().next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-cover.js b/test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-cover.js new file mode 100644 index 0000000000..255a97d8f4 --- /dev/null +++ b/test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-cover.js @@ -0,0 +1,71 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-cover.case +// - src/dstr-binding/default/gen-method-dflt.template +/*--- +description: SingleNameBinding does assign name to "anonymous" functions "through" cover grammar (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +es6id: 14.4.13 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var obj = { + *method([cover = (function () {}), xCover = (0, function() {})] = []) { + assert.sameValue(cover.name, 'cover'); + assert.notSameValue(xCover.name, 'xCover'); + callCount = callCount + 1; + } +}; + +obj.method().next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-fn.js b/test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-fn.js new file mode 100644 index 0000000000..b047d963ce --- /dev/null +++ b/test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-fn.js @@ -0,0 +1,71 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-fn.case +// - src/dstr-binding/default/gen-method-dflt.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +es6id: 14.4.13 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var obj = { + *method([fn = function () {}, xFn = function x() {}] = []) { + assert.sameValue(fn.name, 'fn'); + assert.notSameValue(xFn.name, 'xFn'); + callCount = callCount + 1; + } +}; + +obj.method().next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-gen.js b/test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-gen.js new file mode 100644 index 0000000000..2c0b110277 --- /dev/null +++ b/test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-gen.js @@ -0,0 +1,71 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-gen.case +// - src/dstr-binding/default/gen-method-dflt.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +es6id: 14.4.13 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var obj = { + *method([gen = function* () {}, xGen = function* x() {}] = []) { + assert.sameValue(gen.name, 'gen'); + assert.notSameValue(xGen.name, 'xGen'); + callCount = callCount + 1; + } +}; + +obj.method().next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-elem-id-init-hole.js b/test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-elem-id-init-hole.js new file mode 100644 index 0000000000..79587da441 --- /dev/null +++ b/test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-elem-id-init-hole.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-hole.case +// - src/dstr-binding/default/gen-method-dflt.template +/*--- +description: Destructuring initializer with a "hole" (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +es6id: 14.4.13 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + SingleNameBinding : BindingIdentifier Initializeropt + [...] 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + [...] + 7. If environment is undefined, return PutValue(lhs, v). 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var obj = { + *method([x = 23] = [,]) { + assert.sameValue(x, 23); + // another statement + callCount = callCount + 1; + } +}; + +obj.method().next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-elem-id-init-skipped.js b/test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-elem-id-init-skipped.js new file mode 100644 index 0000000000..70ee82784a --- /dev/null +++ b/test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-elem-id-init-skipped.js @@ -0,0 +1,74 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-skipped.case +// - src/dstr-binding/default/gen-method-dflt.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +es6id: 14.4.13 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var callCount = 0; +var obj = { + *method([w = counter(), x = counter(), y = counter(), z = counter()] = [null, 0, false, '']) { + assert.sameValue(w, null); + assert.sameValue(x, 0); + assert.sameValue(y, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } +}; + +obj.method().next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-elem-id-init-throws.js b/test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-elem-id-init-throws.js new file mode 100644 index 0000000000..bc7dc3c020 --- /dev/null +++ b/test/language/expressions/object/dstr-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/gen-meth-dflt.template +/*--- +description: Destructuring initializer returns an abrupt completion (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +es6id: 14.4.13 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 = { + *method([x = (function() { throw new Test262Error(); })()] = [undefined]) {} +}; + +assert.throws(Test262Error, function() { + obj.method(); +}); diff --git a/test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-elem-id-init-undef.js b/test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-elem-id-init-undef.js new file mode 100644 index 0000000000..55591fb3ed --- /dev/null +++ b/test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-elem-id-init-undef.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-undef.case +// - src/dstr-binding/default/gen-method-dflt.template +/*--- +description: Destructuring initializer with an undefined value (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +es6id: 14.4.13 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var obj = { + *method([x = 23] = [undefined]) { + assert.sameValue(x, 23); + callCount = callCount + 1; + } +}; + +obj.method().next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-elem-id-init-unresolvable.js b/test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-elem-id-init-unresolvable.js new file mode 100644 index 0000000000..70200e550b --- /dev/null +++ b/test/language/expressions/object/dstr-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/gen-meth-dflt.template +/*--- +description: Destructuring initializer is an unresolvable reference (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +es6id: 14.4.13 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 = { + *method([ x = unresolvableReference ] = []) {} +}; + +assert.throws(ReferenceError, function() { + obj.method(); +}); diff --git a/test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-elem-id-iter-complete.js b/test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-elem-id-iter-complete.js new file mode 100644 index 0000000000..8f67d5fc47 --- /dev/null +++ b/test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-elem-id-iter-complete.js @@ -0,0 +1,72 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-complete.case +// - src/dstr-binding/default/gen-method-dflt.template +/*--- +description: SingleNameBinding when value iteration completes (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +es6id: 14.4.13 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var obj = { + *method([x] = []) { + assert.sameValue(x, undefined); + callCount = callCount + 1; + } +}; + +obj.method().next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-elem-id-iter-done.js b/test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-elem-id-iter-done.js new file mode 100644 index 0000000000..7bd2493e40 --- /dev/null +++ b/test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-elem-id-iter-done.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-done.case +// - src/dstr-binding/default/gen-method-dflt.template +/*--- +description: SingleNameBinding when value iteration was completed previously (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +es6id: 14.4.13 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var obj = { + *method([_, x] = []) { + assert.sameValue(x, undefined); + callCount = callCount + 1; + } +}; + +obj.method().next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-elem-id-iter-step-err.js b/test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-elem-id-iter-step-err.js new file mode 100644 index 0000000000..3c84a98a81 --- /dev/null +++ b/test/language/expressions/object/dstr-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/gen-meth-dflt.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +es6id: 14.4.13 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 = { + *method([x] = g) {} +}; + +assert.throws(Test262Error, function() { + obj.method(); +}); diff --git a/test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-elem-id-iter-val-err.js b/test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-elem-id-iter-val-err.js new file mode 100644 index 0000000000..5bb89b278f --- /dev/null +++ b/test/language/expressions/object/dstr-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/gen-meth-dflt.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +es6id: 14.4.13 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 = { + *method([x] = g) {} +}; + +assert.throws(Test262Error, function() { + obj.method(); +}); diff --git a/test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-elem-id-iter-val.js b/test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-elem-id-iter-val.js new file mode 100644 index 0000000000..a6af5ecc24 --- /dev/null +++ b/test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-elem-id-iter-val.js @@ -0,0 +1,78 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val.case +// - src/dstr-binding/default/gen-method-dflt.template +/*--- +description: SingleNameBinding when value iteration was completed previously (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +es6id: 14.4.13 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set + iteratorRecord.[[done]] to true. + iii. ReturnIfAbrupt(v). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var obj = { + *method([x, y, z] = [1, 2, 3]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 3); + callCount = callCount + 1; + } +}; + +obj.method().next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-elem-obj-id-init.js b/test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-elem-obj-id-init.js new file mode 100644 index 0000000000..7954d02670 --- /dev/null +++ b/test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-elem-obj-id-init.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-id-init.case +// - src/dstr-binding/default/gen-method-dflt.template +/*--- +description: BindingElement with object binding pattern and initializer is used (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +es6id: 14.4.13 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +var obj = { + *method([{ x, y, z } = { x: 44, y: 55, z: 66 }] = []) { + assert.sameValue(x, 44); + assert.sameValue(y, 55); + assert.sameValue(z, 66); + callCount = callCount + 1; + } +}; + +obj.method().next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-elem-obj-id.js b/test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-elem-obj-id.js new file mode 100644 index 0000000000..5660a67064 --- /dev/null +++ b/test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-elem-obj-id.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-id.case +// - src/dstr-binding/default/gen-method-dflt.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +es6id: 14.4.13 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +var obj = { + *method([{ x, y, z } = { x: 44, y: 55, z: 66 }] = [{ x: 11, y: 22, z: 33 }]) { + assert.sameValue(x, 11); + assert.sameValue(y, 22); + assert.sameValue(z, 33); + callCount = callCount + 1; + } +}; + +obj.method().next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-elem-obj-prop-id-init.js b/test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-elem-obj-prop-id-init.js new file mode 100644 index 0000000000..9ee29e36e1 --- /dev/null +++ b/test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-elem-obj-prop-id-init.js @@ -0,0 +1,80 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-prop-id-init.case +// - src/dstr-binding/default/gen-method-dflt.template +/*--- +description: BindingElement with object binding pattern and initializer is used (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +es6id: 14.4.13 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +var obj = { + *method([{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }] = []) { + assert.sameValue(v, 444); + assert.sameValue(x, 555); + assert.sameValue(z, 666); + + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; + } +}; + +obj.method().next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-elem-obj-prop-id.js b/test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-elem-obj-prop-id.js new file mode 100644 index 0000000000..c34a744275 --- /dev/null +++ b/test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-elem-obj-prop-id.js @@ -0,0 +1,80 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-prop-id.case +// - src/dstr-binding/default/gen-method-dflt.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +es6id: 14.4.13 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +var obj = { + *method([{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }] = [{ u: 777, w: 888, y: 999 }]) { + assert.sameValue(v, 777); + assert.sameValue(x, 888); + assert.sameValue(z, 999); + + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; + } +}; + +obj.method().next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-elem-obj-val-null.js b/test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-elem-obj-val-null.js new file mode 100644 index 0000000000..a2a380fab4 --- /dev/null +++ b/test/language/expressions/object/dstr-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/gen-meth-dflt.template +/*--- +description: Nested object destructuring with a null value (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +es6id: 14.4.13 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 = { + *method([{ x }] = [null]) {} +}; + +assert.throws(TypeError, function() { + obj.method(); +}); diff --git a/test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-elem-obj-val-undef.js b/test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-elem-obj-val-undef.js new file mode 100644 index 0000000000..fb4be8e848 --- /dev/null +++ b/test/language/expressions/object/dstr-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/gen-meth-dflt.template +/*--- +description: Nested object destructuring with a value of `undefined` (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +es6id: 14.4.13 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 = { + *method([{ x }] = []) {} +}; + +assert.throws(TypeError, function() { + obj.method(); +}); diff --git a/test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-elision-exhausted.js b/test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-elision-exhausted.js new file mode 100644 index 0000000000..d33d0d77f0 --- /dev/null +++ b/test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-elision-exhausted.js @@ -0,0 +1,75 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-exhausted.case +// - src/dstr-binding/default/gen-method-dflt.template +/*--- +description: Elision accepts exhausted iterator (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +es6id: 14.4.13 +features: [generator, destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + [...] + 2. Return NormalCompletion(empty). + +---*/ +var iter = function*() {}(); +iter.next(); + +var callCount = 0; +var obj = { + *method([,] = iter) { + + callCount = callCount + 1; + } +}; + +obj.method().next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-elision-step-err.js b/test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-elision-step-err.js new file mode 100644 index 0000000000..99790d0dea --- /dev/null +++ b/test/language/expressions/object/dstr-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/gen-meth-dflt.template +/*--- +description: Elision advances iterator and forwards abrupt completions (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +es6id: 14.4.13 +features: [generator, destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 = { + *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-gen-meth-dflt-ary-ptrn-elision.js b/test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-elision.js new file mode 100644 index 0000000000..ce2856ff0d --- /dev/null +++ b/test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-elision.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision.case +// - src/dstr-binding/default/gen-method-dflt.template +/*--- +description: Elision advances iterator (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +es6id: 14.4.13 +features: [generator, destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + 2. Return NormalCompletion(empty). + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var callCount = 0; +var obj = { + *method([,] = g()) { + assert.sameValue(first, 1); + assert.sameValue(second, 0); + callCount = callCount + 1; + } +}; + +obj.method().next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-empty.js b/test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-empty.js new file mode 100644 index 0000000000..d97c5f0041 --- /dev/null +++ b/test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-empty.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-empty.case +// - src/dstr-binding/default/gen-method-dflt.template +/*--- +description: No iteration occurs for an "empty" array binding pattern (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +es6id: 14.4.13 +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ ] + + 1. Return NormalCompletion(empty). + +---*/ +var iterations = 0; +var iter = function*() { + iterations += 1; +}(); + +var callCount = 0; +var obj = { + *method([] = iter) { + assert.sameValue(iterations, 0); + callCount = callCount + 1; + } +}; + +obj.method().next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-rest-ary-elem.js b/test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-rest-ary-elem.js new file mode 100644 index 0000000000..ed92312f10 --- /dev/null +++ b/test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-rest-ary-elem.js @@ -0,0 +1,91 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-elem.case +// - src/dstr-binding/default/gen-method-dflt.template +/*--- +description: Rest element containing an array BindingElementList pattern (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +es6id: 14.4.13 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set + iteratorRecord.[[done]] to true. + iii. ReturnIfAbrupt(v). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var obj = { + *method([...[x, y, z]] = [3, 4, 5]) { + assert.sameValue(x, 3); + assert.sameValue(y, 4); + assert.sameValue(z, 5); + callCount = callCount + 1; + } +}; + +obj.method().next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-rest-ary-elision.js b/test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-rest-ary-elision.js new file mode 100644 index 0000000000..264e1e8293 --- /dev/null +++ b/test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-rest-ary-elision.js @@ -0,0 +1,97 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-elision.case +// - src/dstr-binding/default/gen-method-dflt.template +/*--- +description: Rest element containing an elision (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +es6id: 14.4.13 +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + 2. Return NormalCompletion(empty). + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var callCount = 0; +var obj = { + *method([...[,]] = g()) { + assert.sameValue(first, 1); + assert.sameValue(second, 1); + callCount = callCount + 1; + } +}; + +obj.method().next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-rest-ary-empty.js b/test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-rest-ary-empty.js new file mode 100644 index 0000000000..86ab5680c6 --- /dev/null +++ b/test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-rest-ary-empty.js @@ -0,0 +1,80 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-empty.case +// - src/dstr-binding/default/gen-method-dflt.template +/*--- +description: Rest element containing an "empty" array pattern (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +es6id: 14.4.13 +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ ] + + 1. Return NormalCompletion(empty). + +---*/ +var iterations = 0; +var iter = function*() { + iterations += 1; +}(); + +var callCount = 0; +var obj = { + *method([...[]] = iter) { + assert.sameValue(iterations, 1); + callCount = callCount + 1; + } +}; + +obj.method().next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-rest-ary-rest.js b/test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-rest-ary-rest.js new file mode 100644 index 0000000000..18719a9c0c --- /dev/null +++ b/test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-rest-ary-rest.js @@ -0,0 +1,76 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-rest.case +// - src/dstr-binding/default/gen-method-dflt.template +/*--- +description: Rest element containing a rest element (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +es6id: 14.4.13 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ +var values = [1, 2, 3]; + +var callCount = 0; +var obj = { + *method([...[...x]] = values) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 1); + assert.sameValue(x[1], 2); + assert.sameValue(x[2], 3); + assert.notSameValue(x, values); + + callCount = callCount + 1; + } +}; + +obj.method().next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-rest-id-elision-next-err.js b/test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-rest-id-elision-next-err.js new file mode 100644 index 0000000000..91453619b4 --- /dev/null +++ b/test/language/expressions/object/dstr-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/gen-meth-dflt.template +/*--- +description: Rest element following elision elements (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +es6id: 14.4.13 +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 = { + *method([, ...x] = iter) {} +}; + +assert.throws(Test262Error, function() { + obj.method(); +}); diff --git a/test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-rest-id-elision.js b/test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-rest-id-elision.js new file mode 100644 index 0000000000..b413c87fc1 --- /dev/null +++ b/test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-rest-id-elision.js @@ -0,0 +1,72 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision.case +// - src/dstr-binding/default/gen-method-dflt.template +/*--- +description: Rest element following elision elements (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +es6id: 14.4.13 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + ArrayBindingPattern : [ Elisionopt BindingRestElement ] + 1. If Elision is present, then + a. Let status be the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with + iteratorRecord as the argument. + b. ReturnIfAbrupt(status). + 2. Return the result of performing IteratorBindingInitialization for + BindingRestElement with iteratorRecord and environment as arguments. +---*/ +var values = [1, 2, 3, 4, 5]; + +var callCount = 0; +var obj = { + *method([ , , ...x] = values) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 3); + assert.sameValue(x[1], 4); + assert.sameValue(x[2], 5); + assert.notSameValue(x, values); + callCount = callCount + 1; + } +}; + +obj.method().next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-rest-id-exhausted.js b/test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-rest-id-exhausted.js new file mode 100644 index 0000000000..f56505d66c --- /dev/null +++ b/test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-rest-id-exhausted.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-exhausted.case +// - src/dstr-binding/default/gen-method-dflt.template +/*--- +description: RestElement applied to an exhausted iterator (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +es6id: 14.4.13 +features: [Symbol.iterator, destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier, + environment). + 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat, + [...] + b. If iteratorRecord.[[done]] is true, then + i. If environment is undefined, return PutValue(lhs, A). + ii. Return InitializeReferencedBinding(lhs, A). + +---*/ + +var callCount = 0; +var obj = { + *method([, , ...x] = [1, 2]) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 0); + callCount = callCount + 1; + } +}; + +obj.method().next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-rest-id-iter-step-err.js b/test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-rest-id-iter-step-err.js new file mode 100644 index 0000000000..cd7ad05b89 --- /dev/null +++ b/test/language/expressions/object/dstr-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/gen-meth-dflt.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +es6id: 14.4.13 +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 = { + *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-gen-meth-dflt-ary-ptrn-rest-id-iter-val-err.js b/test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-rest-id-iter-val-err.js new file mode 100644 index 0000000000..7df0ee2c46 --- /dev/null +++ b/test/language/expressions/object/dstr-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/gen-meth-dflt.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +es6id: 14.4.13 +features: [Symbol.iterator, destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 = { + *method([...x] = iter) {} +}; + +assert.throws(Test262Error, function() { + obj.method(); +}); diff --git a/test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-rest-id.js b/test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-rest-id.js new file mode 100644 index 0000000000..166cdef523 --- /dev/null +++ b/test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-rest-id.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id.case +// - src/dstr-binding/default/gen-method-dflt.template +/*--- +description: Lone rest element (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +es6id: 14.4.13 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + [...] 3. Let A be ArrayCreate(0). [...] 5. Repeat + [...] + f. Let status be CreateDataProperty(A, ToString (n), nextValue). + [...] +---*/ +var values = [1, 2, 3]; + +var callCount = 0; +var obj = { + *method([...x] = values) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 1); + assert.sameValue(x[1], 2); + assert.sameValue(x[2], 3); + assert.notSameValue(x, values); + callCount = callCount + 1; + } +}; + +obj.method().next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-rest-init-ary.js b/test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-rest-init-ary.js new file mode 100644 index 0000000000..fc64797f94 --- /dev/null +++ b/test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-rest-init-ary.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-ary.case +// - src/dstr-binding/default/gen-method-dflt.template +/*--- +description: Reset element (nested array pattern) does not support initializer (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +es6id: 14.4.13 +features: [destructuring-binding, default-parameters] +flags: [generated] +negative: SyntaxError +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +var obj = { + *method([...[ x ] = []] = []) { + + callCount = callCount + 1; + } +}; + +obj.method().next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-rest-init-id.js b/test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-rest-init-id.js new file mode 100644 index 0000000000..ef7048267e --- /dev/null +++ b/test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-rest-init-id.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-id.case +// - src/dstr-binding/default/gen-method-dflt.template +/*--- +description: Reset element (identifier) does not support initializer (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +es6id: 14.4.13 +features: [destructuring-binding, default-parameters] +flags: [generated] +negative: SyntaxError +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +var obj = { + *method([...x = []] = []) { + + callCount = callCount + 1; + } +}; + +obj.method().next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-rest-init-obj.js b/test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-rest-init-obj.js new file mode 100644 index 0000000000..14875b7428 --- /dev/null +++ b/test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-rest-init-obj.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-obj.case +// - src/dstr-binding/default/gen-method-dflt.template +/*--- +description: Reset element (nested object pattern) does not support initializer (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +es6id: 14.4.13 +features: [destructuring-binding, default-parameters] +flags: [generated] +negative: SyntaxError +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +var obj = { + *method([...{ x } = []] = []) { + + callCount = callCount + 1; + } +}; + +obj.method().next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-rest-not-final-ary.js b/test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-rest-not-final-ary.js new file mode 100644 index 0000000000..0901fdc1ce --- /dev/null +++ b/test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-rest-not-final-ary.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-ary.case +// - src/dstr-binding/default/gen-method-dflt.template +/*--- +description: Rest element (array binding pattern) may not be followed by any element (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +es6id: 14.4.13 +features: [destructuring-binding, default-parameters] +flags: [generated] +negative: SyntaxError +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +var obj = { + *method([...[x], y] = [1, 2, 3]) { + + callCount = callCount + 1; + } +}; + +obj.method().next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-rest-not-final-id.js b/test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-rest-not-final-id.js new file mode 100644 index 0000000000..bbe133b41c --- /dev/null +++ b/test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-rest-not-final-id.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-id.case +// - src/dstr-binding/default/gen-method-dflt.template +/*--- +description: Rest element (identifier) may not be followed by any element (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +es6id: 14.4.13 +features: [destructuring-binding, default-parameters] +flags: [generated] +negative: SyntaxError +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +var obj = { + *method([...x, y] = [1, 2, 3]) { + + callCount = callCount + 1; + } +}; + +obj.method().next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-rest-not-final-obj.js b/test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-rest-not-final-obj.js new file mode 100644 index 0000000000..0ba6470e0e --- /dev/null +++ b/test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-rest-not-final-obj.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-obj.case +// - src/dstr-binding/default/gen-method-dflt.template +/*--- +description: Rest element (object binding pattern) may not be followed by any element (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +es6id: 14.4.13 +features: [destructuring-binding, default-parameters] +flags: [generated] +negative: SyntaxError +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +var obj = { + *method([...{ x }, y] = [1, 2, 3]) { + + callCount = callCount + 1; + } +}; + +obj.method().next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-rest-obj-id.js b/test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-rest-obj-id.js new file mode 100644 index 0000000000..72cd270b74 --- /dev/null +++ b/test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-rest-obj-id.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-obj-id.case +// - src/dstr-binding/default/gen-method-dflt.template +/*--- +description: Rest element containing an object binding pattern (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +es6id: 14.4.13 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ + +var callCount = 0; +var obj = { + *method([...{ length }] = [1, 2, 3]) { + assert.sameValue(length, 3); + callCount = callCount + 1; + } +}; + +obj.method().next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-rest-obj-prop-id.js b/test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-rest-obj-prop-id.js new file mode 100644 index 0000000000..29bc12f334 --- /dev/null +++ b/test/language/expressions/object/dstr-gen-meth-dflt-ary-ptrn-rest-obj-prop-id.js @@ -0,0 +1,77 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-obj-prop-id.case +// - src/dstr-binding/default/gen-method-dflt.template +/*--- +description: Rest element containing an object binding pattern (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +es6id: 14.4.13 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ + +var callCount = 0; +var obj = { + *method([...{ 0: v, 1: w, 2: x, 3: y, length: z }] = [7, 8, 9]) { + assert.sameValue(v, 7); + assert.sameValue(w, 8); + assert.sameValue(x, 9); + assert.sameValue(y, undefined); + assert.sameValue(z, 3); + + assert.throws(ReferenceError, function() { + length; + }); + callCount = callCount + 1; + } +}; + +obj.method().next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-gen-meth-dflt-obj-init-null.js b/test/language/expressions/object/dstr-gen-meth-dflt-obj-init-null.js new file mode 100644 index 0000000000..1a84aa8163 --- /dev/null +++ b/test/language/expressions/object/dstr-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/gen-meth-dflt.template +/*--- +description: Value specifed for object binding pattern must be object coercible (null) (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +es6id: 14.4.13 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + +var obj = { + *method({} = null) {} +}; + +assert.throws(TypeError, function() { + obj.method(); +}); diff --git a/test/language/expressions/object/dstr-gen-meth-dflt-obj-init-undefined.js b/test/language/expressions/object/dstr-gen-meth-dflt-obj-init-undefined.js new file mode 100644 index 0000000000..bcfb0b1566 --- /dev/null +++ b/test/language/expressions/object/dstr-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/gen-meth-dflt.template +/*--- +description: Value specifed for object binding pattern must be object coercible (undefined) (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +es6id: 14.4.13 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + +var obj = { + *method({} = undefined) {} +}; + +assert.throws(TypeError, function() { + obj.method(); +}); diff --git a/test/language/expressions/object/dstr-gen-meth-dflt-obj-ptrn-empty.js b/test/language/expressions/object/dstr-gen-meth-dflt-obj-ptrn-empty.js new file mode 100644 index 0000000000..78e1374dc0 --- /dev/null +++ b/test/language/expressions/object/dstr-gen-meth-dflt-obj-ptrn-empty.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-empty.case +// - src/dstr-binding/default/gen-method-dflt.template +/*--- +description: No property access occurs for an "empty" object binding pattern (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +es6id: 14.4.13 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ +var accessCount = 0; +var obj = Object.defineProperty({}, 'attr', { + get: function() { + accessCount += 1; + } +}); + +var callCount = 0; +var obj = { + *method({} = obj) { + assert.sameValue(accessCount, 0); + callCount = callCount + 1; + } +}; + +obj.method().next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-gen-meth-dflt-obj-ptrn-id-get-value-err.js b/test/language/expressions/object/dstr-gen-meth-dflt-obj-ptrn-id-get-value-err.js new file mode 100644 index 0000000000..3178fb93f2 --- /dev/null +++ b/test/language/expressions/object/dstr-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/gen-meth-dflt.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +es6id: 14.4.13 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 = { + *method({ poisoned } = poisonedProperty) {} +}; + +assert.throws(Test262Error, function() { + obj.method(); +}); diff --git a/test/language/expressions/object/dstr-gen-meth-dflt-obj-ptrn-id-init-fn-name-arrow.js b/test/language/expressions/object/dstr-gen-meth-dflt-obj-ptrn-id-init-fn-name-arrow.js new file mode 100644 index 0000000000..d24b86b971 --- /dev/null +++ b/test/language/expressions/object/dstr-gen-meth-dflt-obj-ptrn-id-init-fn-name-arrow.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-arrow.case +// - src/dstr-binding/default/gen-method-dflt.template +/*--- +description: SingleNameBinding assigns `name` to arrow functions (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +es6id: 14.4.13 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +var obj = { + *method({ arrow = () => {} } = {}) { + assert.sameValue(arrow.name, 'arrow'); + callCount = callCount + 1; + } +}; + +obj.method().next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-gen-meth-dflt-obj-ptrn-id-init-fn-name-class.js b/test/language/expressions/object/dstr-gen-meth-dflt-obj-ptrn-id-init-fn-name-class.js new file mode 100644 index 0000000000..1f2cb2aa25 --- /dev/null +++ b/test/language/expressions/object/dstr-gen-meth-dflt-obj-ptrn-id-init-fn-name-class.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-class.case +// - src/dstr-binding/default/gen-method-dflt.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +es6id: 14.4.13 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +var obj = { + *method({ cls = class {}, xCls = class X {} } = {}) { + assert.sameValue(cls.name, 'cls'); + assert.notSameValue(xCls.name, 'xCls'); + callCount = callCount + 1; + } +}; + +obj.method().next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-gen-meth-dflt-obj-ptrn-id-init-fn-name-cover.js b/test/language/expressions/object/dstr-gen-meth-dflt-obj-ptrn-id-init-fn-name-cover.js new file mode 100644 index 0000000000..11e3d4740e --- /dev/null +++ b/test/language/expressions/object/dstr-gen-meth-dflt-obj-ptrn-id-init-fn-name-cover.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-cover.case +// - src/dstr-binding/default/gen-method-dflt.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" functions "through" cover grammar (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +es6id: 14.4.13 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +var obj = { + *method({ cover = (function () {}), xCover = (0, function() {}) } = {}) { + assert.sameValue(cover.name, 'cover'); + assert.notSameValue(xCover.name, 'xCover'); + callCount = callCount + 1; + } +}; + +obj.method().next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-gen-meth-dflt-obj-ptrn-id-init-fn-name-fn.js b/test/language/expressions/object/dstr-gen-meth-dflt-obj-ptrn-id-init-fn-name-fn.js new file mode 100644 index 0000000000..d4b56a08e5 --- /dev/null +++ b/test/language/expressions/object/dstr-gen-meth-dflt-obj-ptrn-id-init-fn-name-fn.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-fn.case +// - src/dstr-binding/default/gen-method-dflt.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +es6id: 14.4.13 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +var obj = { + *method({ fn = function () {}, xFn = function x() {} } = {}) { + assert.sameValue(fn.name, 'fn'); + assert.notSameValue(xFn.name, 'xFn'); + callCount = callCount + 1; + } +}; + +obj.method().next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-gen-meth-dflt-obj-ptrn-id-init-fn-name-gen.js b/test/language/expressions/object/dstr-gen-meth-dflt-obj-ptrn-id-init-fn-name-gen.js new file mode 100644 index 0000000000..b94afac017 --- /dev/null +++ b/test/language/expressions/object/dstr-gen-meth-dflt-obj-ptrn-id-init-fn-name-gen.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-gen.case +// - src/dstr-binding/default/gen-method-dflt.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +es6id: 14.4.13 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +var obj = { + *method({ gen = function* () {}, xGen = function* x() {} } = {}) { + assert.sameValue(gen.name, 'gen'); + assert.notSameValue(xGen.name, 'xGen'); + callCount = callCount + 1; + } +}; + +obj.method().next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-gen-meth-dflt-obj-ptrn-id-init-skipped.js b/test/language/expressions/object/dstr-gen-meth-dflt-obj-ptrn-id-init-skipped.js new file mode 100644 index 0000000000..f9daee5fea --- /dev/null +++ b/test/language/expressions/object/dstr-gen-meth-dflt-obj-ptrn-id-init-skipped.js @@ -0,0 +1,73 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-skipped.case +// - src/dstr-binding/default/gen-method-dflt.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +es6id: 14.4.13 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + [...] +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var callCount = 0; +var obj = { + *method({ w = counter(), x = counter(), y = counter(), z = counter() } = { w: null, x: 0, y: false, z: '' }) { + assert.sameValue(w, null); + assert.sameValue(x, 0); + assert.sameValue(y, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } +}; + +obj.method().next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-gen-meth-dflt-obj-ptrn-id-init-throws.js b/test/language/expressions/object/dstr-gen-meth-dflt-obj-ptrn-id-init-throws.js new file mode 100644 index 0000000000..d1f4546e20 --- /dev/null +++ b/test/language/expressions/object/dstr-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/gen-meth-dflt.template +/*--- +description: Error thrown when evaluating the initializer (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +es6id: 14.4.13 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 = { + *method({ x = thrower() } = {}) {} +}; + +assert.throws(Test262Error, function() { + obj.method(); +}); diff --git a/test/language/expressions/object/dstr-gen-meth-dflt-obj-ptrn-id-init-unresolvable.js b/test/language/expressions/object/dstr-gen-meth-dflt-obj-ptrn-id-init-unresolvable.js new file mode 100644 index 0000000000..3e162bd434 --- /dev/null +++ b/test/language/expressions/object/dstr-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/gen-meth-dflt.template +/*--- +description: Destructuring initializer is an unresolvable reference (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +es6id: 14.4.13 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 = { + *method({ x = unresolvableReference } = {}) {} +}; + +assert.throws(ReferenceError, function() { + obj.method(); +}); diff --git a/test/language/expressions/object/dstr-gen-meth-dflt-obj-ptrn-id-trailing-comma.js b/test/language/expressions/object/dstr-gen-meth-dflt-obj-ptrn-id-trailing-comma.js new file mode 100644 index 0000000000..898ff96ffd --- /dev/null +++ b/test/language/expressions/object/dstr-gen-meth-dflt-obj-ptrn-id-trailing-comma.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-trailing-comma.case +// - src/dstr-binding/default/gen-method-dflt.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +es6id: 14.4.13 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var callCount = 0; +var obj = { + *method({ x, } = { x: 23 }) { + assert.sameValue(x, 23); + callCount = callCount + 1; + } +}; + +obj.method().next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-gen-meth-dflt-obj-ptrn-list-err.js b/test/language/expressions/object/dstr-gen-meth-dflt-obj-ptrn-list-err.js new file mode 100644 index 0000000000..e67a41dae1 --- /dev/null +++ b/test/language/expressions/object/dstr-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/gen-meth-dflt.template +/*--- +description: Binding property list evaluation is interrupted by an abrupt completion (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +es6id: 14.4.13 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 = { + *method({ a, b = thrower(), c = ++initCount } = {}) {} +}; + +assert.throws(Test262Error, function() { + obj.method(); +}); + +assert.sameValue(initCount, 0); diff --git a/test/language/expressions/object/dstr-gen-meth-dflt-obj-ptrn-prop-ary-init.js b/test/language/expressions/object/dstr-gen-meth-dflt-obj-ptrn-prop-ary-init.js new file mode 100644 index 0000000000..e954fca517 --- /dev/null +++ b/test/language/expressions/object/dstr-gen-meth-dflt-obj-ptrn-prop-ary-init.js @@ -0,0 +1,72 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-init.case +// - src/dstr-binding/default/gen-method-dflt.template +/*--- +description: Object binding pattern with "nested" array binding pattern using initializer (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +es6id: 14.4.13 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +var obj = { + *method({ w: [x, y, z] = [4, 5, 6] } = {}) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } +}; + +obj.method().next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-gen-meth-dflt-obj-ptrn-prop-ary-trailing-comma.js b/test/language/expressions/object/dstr-gen-meth-dflt-obj-ptrn-prop-ary-trailing-comma.js new file mode 100644 index 0000000000..5ecb5f2dff --- /dev/null +++ b/test/language/expressions/object/dstr-gen-meth-dflt-obj-ptrn-prop-ary-trailing-comma.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-trailing-comma.case +// - src/dstr-binding/default/gen-method-dflt.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +es6id: 14.4.13 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var callCount = 0; +var obj = { + *method({ x: [y], } = { x: [45] }) { + assert.sameValue(y,45); + callCount = callCount + 1; + } +}; + +obj.method().next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-gen-meth-dflt-obj-ptrn-prop-ary-value-null.js b/test/language/expressions/object/dstr-gen-meth-dflt-obj-ptrn-prop-ary-value-null.js new file mode 100644 index 0000000000..cfcf333dfd --- /dev/null +++ b/test/language/expressions/object/dstr-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/gen-meth-dflt.template +/*--- +description: Object binding pattern with "nested" array binding pattern taking the `null` value (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +es6id: 14.4.13 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 = { + *method({ w: [x, y, z] = [4, 5, 6] } = { w: null }) {} +}; + +assert.throws(TypeError, function() { + obj.method(); +}); diff --git a/test/language/expressions/object/dstr-gen-meth-dflt-obj-ptrn-prop-ary.js b/test/language/expressions/object/dstr-gen-meth-dflt-obj-ptrn-prop-ary.js new file mode 100644 index 0000000000..93a94bb734 --- /dev/null +++ b/test/language/expressions/object/dstr-gen-meth-dflt-obj-ptrn-prop-ary.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary.case +// - src/dstr-binding/default/gen-method-dflt.template +/*--- +description: Object binding pattern with "nested" array binding pattern not using initializer (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +es6id: 14.4.13 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +var obj = { + *method({ w: [x, y, z] = [4, 5, 6] } = { w: [7, undefined, ] }) { + assert.sameValue(x, 7); + assert.sameValue(y, undefined); + assert.sameValue(z, undefined); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } +}; + +obj.method().next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-gen-meth-dflt-obj-ptrn-prop-eval-err.js b/test/language/expressions/object/dstr-gen-meth-dflt-obj-ptrn-prop-eval-err.js new file mode 100644 index 0000000000..1a42d8dc48 --- /dev/null +++ b/test/language/expressions/object/dstr-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/gen-meth-dflt.template +/*--- +description: Evaluation of property name returns an abrupt completion (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +es6id: 14.4.13 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 = { + *method({ [thrower()]: x } = {}) {} +}; + +assert.throws(Test262Error, function() { + obj.method(); +}); diff --git a/test/language/expressions/object/dstr-gen-meth-dflt-obj-ptrn-prop-id-get-value-err.js b/test/language/expressions/object/dstr-gen-meth-dflt-obj-ptrn-prop-id-get-value-err.js new file mode 100644 index 0000000000..5ef7dab0cf --- /dev/null +++ b/test/language/expressions/object/dstr-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/gen-meth-dflt.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +es6id: 14.4.13 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 = { + *method({ poisoned: x = ++initEvalCount } = poisonedProperty) {} +}; + +assert.throws(Test262Error, function() { + obj.method(); +}); + +assert.sameValue(initEvalCount, 0); diff --git a/test/language/expressions/object/dstr-gen-meth-dflt-obj-ptrn-prop-id-init-skipped.js b/test/language/expressions/object/dstr-gen-meth-dflt-obj-ptrn-prop-id-init-skipped.js new file mode 100644 index 0000000000..fc13547f05 --- /dev/null +++ b/test/language/expressions/object/dstr-gen-meth-dflt-obj-ptrn-prop-id-init-skipped.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-skipped.case +// - src/dstr-binding/default/gen-method-dflt.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +es6id: 14.4.13 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + [...] +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var callCount = 0; +var obj = { + *method({ s: t = counter(), u: v = counter(), w: x = counter(), y: z = counter() } = { s: null, u: 0, w: false, y: '' }) { + assert.sameValue(t, null); + assert.sameValue(v, 0); + assert.sameValue(x, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + + assert.throws(ReferenceError, function() { + s; + }); + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; + } +}; + +obj.method().next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-gen-meth-dflt-obj-ptrn-prop-id-init-throws.js b/test/language/expressions/object/dstr-gen-meth-dflt-obj-ptrn-prop-id-init-throws.js new file mode 100644 index 0000000000..3bc55df00d --- /dev/null +++ b/test/language/expressions/object/dstr-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/gen-meth-dflt.template +/*--- +description: Error thrown when evaluating the initializer (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +es6id: 14.4.13 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 = { + *method({ x: y = thrower() } = {}) {} +}; + +assert.throws(Test262Error, function() { + obj.method(); +}); diff --git a/test/language/expressions/object/dstr-gen-meth-dflt-obj-ptrn-prop-id-init-unresolvable.js b/test/language/expressions/object/dstr-gen-meth-dflt-obj-ptrn-prop-id-init-unresolvable.js new file mode 100644 index 0000000000..6be5da422a --- /dev/null +++ b/test/language/expressions/object/dstr-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/gen-meth-dflt.template +/*--- +description: Destructuring initializer is an unresolvable reference (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +es6id: 14.4.13 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 = { + *method({ x: y = unresolvableReference } = {}) {} +}; + +assert.throws(ReferenceError, function() { + obj.method(); +}); diff --git a/test/language/expressions/object/dstr-gen-meth-dflt-obj-ptrn-prop-id-init.js b/test/language/expressions/object/dstr-gen-meth-dflt-obj-ptrn-prop-id-init.js new file mode 100644 index 0000000000..d7cab302b9 --- /dev/null +++ b/test/language/expressions/object/dstr-gen-meth-dflt-obj-ptrn-prop-id-init.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init.case +// - src/dstr-binding/default/gen-method-dflt.template +/*--- +description: Binding as specified via property name, identifier, and initializer (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +es6id: 14.4.13 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var obj = { + *method({ x: y = 33 } = { }) { + assert.sameValue(y, 33); + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; + } +}; + +obj.method().next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-gen-meth-dflt-obj-ptrn-prop-id-trailing-comma.js b/test/language/expressions/object/dstr-gen-meth-dflt-obj-ptrn-prop-id-trailing-comma.js new file mode 100644 index 0000000000..9e4fe14b86 --- /dev/null +++ b/test/language/expressions/object/dstr-gen-meth-dflt-obj-ptrn-prop-id-trailing-comma.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-trailing-comma.case +// - src/dstr-binding/default/gen-method-dflt.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +es6id: 14.4.13 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var callCount = 0; +var obj = { + *method({ x: y, } = { x: 23 }) { + assert.sameValue(y, 23); + + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; + } +}; + +obj.method().next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-gen-meth-dflt-obj-ptrn-prop-id.js b/test/language/expressions/object/dstr-gen-meth-dflt-obj-ptrn-prop-id.js new file mode 100644 index 0000000000..25b2a9b67d --- /dev/null +++ b/test/language/expressions/object/dstr-gen-meth-dflt-obj-ptrn-prop-id.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id.case +// - src/dstr-binding/default/gen-method-dflt.template +/*--- +description: Binding as specified via property name and identifier (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +es6id: 14.4.13 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var obj = { + *method({ x: y } = { x: 23 }) { + assert.sameValue(y, 23); + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; + } +}; + +obj.method().next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-gen-meth-dflt-obj-ptrn-prop-obj-init.js b/test/language/expressions/object/dstr-gen-meth-dflt-obj-ptrn-prop-obj-init.js new file mode 100644 index 0000000000..2896eaf42b --- /dev/null +++ b/test/language/expressions/object/dstr-gen-meth-dflt-obj-ptrn-prop-obj-init.js @@ -0,0 +1,72 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-init.case +// - src/dstr-binding/default/gen-method-dflt.template +/*--- +description: Object binding pattern with "nested" object binding pattern using initializer (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +es6id: 14.4.13 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +var obj = { + *method({ w: { x, y, z } = { x: 4, y: 5, z: 6 } } = { w: undefined }) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } +}; + +obj.method().next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-gen-meth-dflt-obj-ptrn-prop-obj-value-null.js b/test/language/expressions/object/dstr-gen-meth-dflt-obj-ptrn-prop-obj-value-null.js new file mode 100644 index 0000000000..5f195983f3 --- /dev/null +++ b/test/language/expressions/object/dstr-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/gen-meth-dflt.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +es6id: 14.4.13 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 = { + *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-gen-meth-dflt-obj-ptrn-prop-obj-value-undef.js b/test/language/expressions/object/dstr-gen-meth-dflt-obj-ptrn-prop-obj-value-undef.js new file mode 100644 index 0000000000..650e69d6f3 --- /dev/null +++ b/test/language/expressions/object/dstr-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/gen-meth-dflt.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +es6id: 14.4.13 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 = { + *method({ w: { x, y, z } = undefined } = { }) {} +}; + +assert.throws(TypeError, function() { + obj.method(); +}); diff --git a/test/language/expressions/object/dstr-gen-meth-dflt-obj-ptrn-prop-obj.js b/test/language/expressions/object/dstr-gen-meth-dflt-obj-ptrn-prop-obj.js new file mode 100644 index 0000000000..760137a722 --- /dev/null +++ b/test/language/expressions/object/dstr-gen-meth-dflt-obj-ptrn-prop-obj.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj.case +// - src/dstr-binding/default/gen-method-dflt.template +/*--- +description: Object binding pattern with "nested" object binding pattern not using initializer (generator method (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +es6id: 14.4.13 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +var obj = { + *method({ w: { x, y, z } = { x: 4, y: 5, z: 6 } } = { w: { x: undefined, z: 7 } }) { + assert.sameValue(x, undefined); + assert.sameValue(y, undefined); + assert.sameValue(z, 7); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } +}; + +obj.method().next(); +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-meth-dflt-ary-init-iter-close.js b/test/language/expressions/object/dstr-meth-dflt-ary-init-iter-close.js new file mode 100644 index 0000000000..4e92ae28ce --- /dev/null +++ b/test/language/expressions/object/dstr-meth-dflt-ary-init-iter-close.js @@ -0,0 +1,76 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-close.case +// - src/dstr-binding/default/meth-dflt.template +/*--- +description: Iterator is closed when not exhausted by pattern evaluation (method (default parameter)) +esid: sec-runtime-semantics-definemethod +es6id: 14.3.8 +features: [Symbol.iterator, destructuring-binding, default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + [...] + 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator, + result). + [...] + +---*/ +var doneCallCount = 0; +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return { value: null, done: false }; + }, + return: function() { + doneCallCount += 1; + return {}; + } + }; +}; + +var callCount = 0; +var obj = { + method([x] = iter) { + assert.sameValue(doneCallCount, 1); + callCount = callCount + 1; + } +}; + +obj.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-meth-dflt-ary-init-iter-get-err.js b/test/language/expressions/object/dstr-meth-dflt-ary-init-iter-get-err.js new file mode 100644 index 0000000000..4167ace3f9 --- /dev/null +++ b/test/language/expressions/object/dstr-meth-dflt-ary-init-iter-get-err.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-get-err.case +// - src/dstr-binding/error/meth-dflt.template +/*--- +description: Abrupt completion returned by GetIterator (method (default parameter)) +esid: sec-runtime-semantics-definemethod +es6id: 14.3.8 +features: [Symbol.iterator, destructuring-binding, default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 = { + method([x] = iter) {} +}; + +assert.throws(Test262Error, function() { + obj.method(); +}); diff --git a/test/language/expressions/object/dstr-meth-dflt-ary-init-iter-no-close.js b/test/language/expressions/object/dstr-meth-dflt-ary-init-iter-no-close.js new file mode 100644 index 0000000000..18d82d81a9 --- /dev/null +++ b/test/language/expressions/object/dstr-meth-dflt-ary-init-iter-no-close.js @@ -0,0 +1,76 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-no-close.case +// - src/dstr-binding/default/meth-dflt.template +/*--- +description: Iterator is not closed when exhausted by pattern evaluation (method (default parameter)) +esid: sec-runtime-semantics-definemethod +es6id: 14.3.8 +features: [Symbol.iterator, destructuring-binding, default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + [...] + 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator, + result). + [...] + +---*/ +var doneCallCount = 0; +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return { value: null, done: true }; + }, + return: function() { + doneCallCount += 1; + return {}; + } + }; +}; + +var callCount = 0; +var obj = { + method([x] = iter) { + assert.sameValue(doneCallCount, 0); + callCount = callCount + 1; + } +}; + +obj.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-meth-dflt-ary-name-iter-val.js b/test/language/expressions/object/dstr-meth-dflt-ary-name-iter-val.js new file mode 100644 index 0000000000..ed6412c684 --- /dev/null +++ b/test/language/expressions/object/dstr-meth-dflt-ary-name-iter-val.js @@ -0,0 +1,75 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-name-iter-val.case +// - src/dstr-binding/default/meth-dflt.template +/*--- +description: SingleNameBinding with normal value iteration (method (default parameter)) +esid: sec-runtime-semantics-definemethod +es6id: 14.3.8 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set + iteratorRecord.[[done]] to true. + iii. ReturnIfAbrupt(v). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var obj = { + method([x, y, z] = [1, 2, 3]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 3); + callCount = callCount + 1; + } +}; + +obj.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-meth-dflt-ary-ptrn-elem-ary-elem-init.js b/test/language/expressions/object/dstr-meth-dflt-ary-ptrn-elem-ary-elem-init.js new file mode 100644 index 0000000000..9a034968df --- /dev/null +++ b/test/language/expressions/object/dstr-meth-dflt-ary-ptrn-elem-ary-elem-init.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elem-init.case +// - src/dstr-binding/default/meth-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is used (method (default parameter)) +esid: sec-runtime-semantics-definemethod +es6id: 14.3.8 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +var obj = { + method([[x, y, z] = [4, 5, 6]] = []) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + callCount = callCount + 1; + } +}; + +obj.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-meth-dflt-ary-ptrn-elem-ary-elem-iter.js b/test/language/expressions/object/dstr-meth-dflt-ary-ptrn-elem-ary-elem-iter.js new file mode 100644 index 0000000000..2424d25562 --- /dev/null +++ b/test/language/expressions/object/dstr-meth-dflt-ary-ptrn-elem-ary-elem-iter.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elem-iter.case +// - src/dstr-binding/default/meth-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (method (default parameter)) +esid: sec-runtime-semantics-definemethod +es6id: 14.3.8 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +var obj = { + method([[x, y, z] = [4, 5, 6]] = [[7, 8, 9]]) { + assert.sameValue(x, 7); + assert.sameValue(y, 8); + assert.sameValue(z, 9); + callCount = callCount + 1; + } +}; + +obj.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-meth-dflt-ary-ptrn-elem-ary-elision-init.js b/test/language/expressions/object/dstr-meth-dflt-ary-ptrn-elem-ary-elision-init.js new file mode 100644 index 0000000000..139c79b4e0 --- /dev/null +++ b/test/language/expressions/object/dstr-meth-dflt-ary-ptrn-elem-ary-elision-init.js @@ -0,0 +1,74 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elision-init.case +// - src/dstr-binding/default/meth-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is used (method (default parameter)) +esid: sec-runtime-semantics-definemethod +es6id: 14.3.8 +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var callCount = 0; +var obj = { + method([[,] = g()] = []) { + assert.sameValue(first, 1); + assert.sameValue(second, 0); + callCount = callCount + 1; + } +}; + +obj.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-meth-dflt-ary-ptrn-elem-ary-elision-iter.js b/test/language/expressions/object/dstr-meth-dflt-ary-ptrn-elem-ary-elision-iter.js new file mode 100644 index 0000000000..c09df91888 --- /dev/null +++ b/test/language/expressions/object/dstr-meth-dflt-ary-ptrn-elem-ary-elision-iter.js @@ -0,0 +1,71 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elision-iter.case +// - src/dstr-binding/default/meth-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (method (default parameter)) +esid: sec-runtime-semantics-definemethod +es6id: 14.3.8 +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var callCount = 0; +function* g() { + callCount += 1; +}; + +var callCount = 0; +var obj = { + method([[,] = g()] = [[]]) { + assert.sameValue(callCount, 0); + callCount = callCount + 1; + } +}; + +obj.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-meth-dflt-ary-ptrn-elem-ary-empty-init.js b/test/language/expressions/object/dstr-meth-dflt-ary-ptrn-elem-ary-empty-init.js new file mode 100644 index 0000000000..a4271ebe28 --- /dev/null +++ b/test/language/expressions/object/dstr-meth-dflt-ary-ptrn-elem-ary-empty-init.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-empty-init.case +// - src/dstr-binding/default/meth-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is used (method (default parameter)) +esid: sec-runtime-semantics-definemethod +es6id: 14.3.8 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var initCount = 0; +var iterCount = 0; +var iter = function*() { iterCount += 1; }(); + +var callCount = 0; +var obj = { + method([[] = function() { initCount += 1; return iter; }()] = []) { + assert.sameValue(initCount, 1); + assert.sameValue(iterCount, 0); + callCount = callCount + 1; + } +}; + +obj.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-meth-dflt-ary-ptrn-elem-ary-empty-iter.js b/test/language/expressions/object/dstr-meth-dflt-ary-ptrn-elem-ary-empty-iter.js new file mode 100644 index 0000000000..2c5ae3f4c5 --- /dev/null +++ b/test/language/expressions/object/dstr-meth-dflt-ary-ptrn-elem-ary-empty-iter.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-empty-iter.case +// - src/dstr-binding/default/meth-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (method (default parameter)) +esid: sec-runtime-semantics-definemethod +es6id: 14.3.8 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var initCount = 0; + +var callCount = 0; +var obj = { + method([[] = function() { initCount += 1; }()] = [[23]]) { + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } +}; + +obj.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-meth-dflt-ary-ptrn-elem-ary-rest-init.js b/test/language/expressions/object/dstr-meth-dflt-ary-ptrn-elem-ary-rest-init.js new file mode 100644 index 0000000000..211e239477 --- /dev/null +++ b/test/language/expressions/object/dstr-meth-dflt-ary-ptrn-elem-ary-rest-init.js @@ -0,0 +1,71 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-rest-init.case +// - src/dstr-binding/default/meth-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is used (method (default parameter)) +esid: sec-runtime-semantics-definemethod +es6id: 14.3.8 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var values = [2, 1, 3]; + +var callCount = 0; +var obj = { + method([[...x] = values] = []) { + assert(Array.isArray(x)); + assert.sameValue(x[0], 2); + assert.sameValue(x[1], 1); + assert.sameValue(x[2], 3); + assert.sameValue(x.length, 3); + assert.notSameValue(x, values); + callCount = callCount + 1; + } +}; + +obj.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-meth-dflt-ary-ptrn-elem-ary-rest-iter.js b/test/language/expressions/object/dstr-meth-dflt-ary-ptrn-elem-ary-rest-iter.js new file mode 100644 index 0000000000..68ea80d3b4 --- /dev/null +++ b/test/language/expressions/object/dstr-meth-dflt-ary-ptrn-elem-ary-rest-iter.js @@ -0,0 +1,74 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-rest-iter.case +// - src/dstr-binding/default/meth-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (method (default parameter)) +esid: sec-runtime-semantics-definemethod +es6id: 14.3.8 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var values = [2, 1, 3]; +var initCount = 0; + +var callCount = 0; +var obj = { + method([[...x] = function() { initCount += 1; }()] = [values]) { + assert(Array.isArray(x)); + assert.sameValue(x[0], 2); + assert.sameValue(x[1], 1); + assert.sameValue(x[2], 3); + assert.sameValue(x.length, 3); + assert.notSameValue(x, values); + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } +}; + +obj.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-meth-dflt-ary-ptrn-elem-ary-val-null.js b/test/language/expressions/object/dstr-meth-dflt-ary-ptrn-elem-ary-val-null.js new file mode 100644 index 0000000000..29b45ef301 --- /dev/null +++ b/test/language/expressions/object/dstr-meth-dflt-ary-ptrn-elem-ary-val-null.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-val-null.case +// - src/dstr-binding/error/meth-dflt.template +/*--- +description: Nested array destructuring with a null value (method (default parameter)) +esid: sec-runtime-semantics-definemethod +es6id: 14.3.8 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 = { + method([[x]] = [null]) {} +}; + +assert.throws(TypeError, function() { + obj.method(); +}); diff --git a/test/language/expressions/object/dstr-meth-dflt-ary-ptrn-elem-id-init-exhausted.js b/test/language/expressions/object/dstr-meth-dflt-ary-ptrn-elem-id-init-exhausted.js new file mode 100644 index 0000000000..c899e32c42 --- /dev/null +++ b/test/language/expressions/object/dstr-meth-dflt-ary-ptrn-elem-id-init-exhausted.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-exhausted.case +// - src/dstr-binding/default/meth-dflt.template +/*--- +description: Destructuring initializer with an exhausted iterator (method (default parameter)) +esid: sec-runtime-semantics-definemethod +es6id: 14.3.8 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var obj = { + method([x = 23] = []) { + assert.sameValue(x, 23); + callCount = callCount + 1; + } +}; + +obj.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-meth-dflt-ary-ptrn-elem-id-init-fn-name-arrow.js b/test/language/expressions/object/dstr-meth-dflt-ary-ptrn-elem-id-init-fn-name-arrow.js new file mode 100644 index 0000000000..e6612a3b85 --- /dev/null +++ b/test/language/expressions/object/dstr-meth-dflt-ary-ptrn-elem-id-init-fn-name-arrow.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-arrow.case +// - src/dstr-binding/default/meth-dflt.template +/*--- +description: SingleNameBinding does assign name to arrow functions (method (default parameter)) +esid: sec-runtime-semantics-definemethod +es6id: 14.3.8 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var obj = { + method([arrow = () => {}] = []) { + assert.sameValue(arrow.name, 'arrow'); + callCount = callCount + 1; + } +}; + +obj.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-meth-dflt-ary-ptrn-elem-id-init-fn-name-class.js b/test/language/expressions/object/dstr-meth-dflt-ary-ptrn-elem-id-init-fn-name-class.js new file mode 100644 index 0000000000..2dc0802506 --- /dev/null +++ b/test/language/expressions/object/dstr-meth-dflt-ary-ptrn-elem-id-init-fn-name-class.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-class.case +// - src/dstr-binding/default/meth-dflt.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (method (default parameter)) +esid: sec-runtime-semantics-definemethod +es6id: 14.3.8 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var obj = { + method([cls = class {}, xCls = class X {}] = []) { + assert.sameValue(cls.name, 'cls'); + assert.notSameValue(xCls.name, 'xCls'); + callCount = callCount + 1; + } +}; + +obj.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-meth-dflt-ary-ptrn-elem-id-init-fn-name-cover.js b/test/language/expressions/object/dstr-meth-dflt-ary-ptrn-elem-id-init-fn-name-cover.js new file mode 100644 index 0000000000..074c0f686e --- /dev/null +++ b/test/language/expressions/object/dstr-meth-dflt-ary-ptrn-elem-id-init-fn-name-cover.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-cover.case +// - src/dstr-binding/default/meth-dflt.template +/*--- +description: SingleNameBinding does assign name to "anonymous" functions "through" cover grammar (method (default parameter)) +esid: sec-runtime-semantics-definemethod +es6id: 14.3.8 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var obj = { + method([cover = (function () {}), xCover = (0, function() {})] = []) { + assert.sameValue(cover.name, 'cover'); + assert.notSameValue(xCover.name, 'xCover'); + callCount = callCount + 1; + } +}; + +obj.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-meth-dflt-ary-ptrn-elem-id-init-fn-name-fn.js b/test/language/expressions/object/dstr-meth-dflt-ary-ptrn-elem-id-init-fn-name-fn.js new file mode 100644 index 0000000000..b6293cb063 --- /dev/null +++ b/test/language/expressions/object/dstr-meth-dflt-ary-ptrn-elem-id-init-fn-name-fn.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-fn.case +// - src/dstr-binding/default/meth-dflt.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (method (default parameter)) +esid: sec-runtime-semantics-definemethod +es6id: 14.3.8 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var obj = { + method([fn = function () {}, xFn = function x() {}] = []) { + assert.sameValue(fn.name, 'fn'); + assert.notSameValue(xFn.name, 'xFn'); + callCount = callCount + 1; + } +}; + +obj.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-meth-dflt-ary-ptrn-elem-id-init-fn-name-gen.js b/test/language/expressions/object/dstr-meth-dflt-ary-ptrn-elem-id-init-fn-name-gen.js new file mode 100644 index 0000000000..e035e7cf5a --- /dev/null +++ b/test/language/expressions/object/dstr-meth-dflt-ary-ptrn-elem-id-init-fn-name-gen.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-gen.case +// - src/dstr-binding/default/meth-dflt.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (method (default parameter)) +esid: sec-runtime-semantics-definemethod +es6id: 14.3.8 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var obj = { + method([gen = function* () {}, xGen = function* x() {}] = []) { + assert.sameValue(gen.name, 'gen'); + assert.notSameValue(xGen.name, 'xGen'); + callCount = callCount + 1; + } +}; + +obj.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-meth-dflt-ary-ptrn-elem-id-init-hole.js b/test/language/expressions/object/dstr-meth-dflt-ary-ptrn-elem-id-init-hole.js new file mode 100644 index 0000000000..f1887d0378 --- /dev/null +++ b/test/language/expressions/object/dstr-meth-dflt-ary-ptrn-elem-id-init-hole.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-hole.case +// - src/dstr-binding/default/meth-dflt.template +/*--- +description: Destructuring initializer with a "hole" (method (default parameter)) +esid: sec-runtime-semantics-definemethod +es6id: 14.3.8 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + SingleNameBinding : BindingIdentifier Initializeropt + [...] 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + [...] + 7. If environment is undefined, return PutValue(lhs, v). 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var obj = { + method([x = 23] = [,]) { + assert.sameValue(x, 23); + // another statement + callCount = callCount + 1; + } +}; + +obj.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-meth-dflt-ary-ptrn-elem-id-init-skipped.js b/test/language/expressions/object/dstr-meth-dflt-ary-ptrn-elem-id-init-skipped.js new file mode 100644 index 0000000000..20bca78715 --- /dev/null +++ b/test/language/expressions/object/dstr-meth-dflt-ary-ptrn-elem-id-init-skipped.js @@ -0,0 +1,71 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-skipped.case +// - src/dstr-binding/default/meth-dflt.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (method (default parameter)) +esid: sec-runtime-semantics-definemethod +es6id: 14.3.8 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var callCount = 0; +var obj = { + method([w = counter(), x = counter(), y = counter(), z = counter()] = [null, 0, false, '']) { + assert.sameValue(w, null); + assert.sameValue(x, 0); + assert.sameValue(y, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } +}; + +obj.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-meth-dflt-ary-ptrn-elem-id-init-throws.js b/test/language/expressions/object/dstr-meth-dflt-ary-ptrn-elem-id-init-throws.js new file mode 100644 index 0000000000..347c0c9622 --- /dev/null +++ b/test/language/expressions/object/dstr-meth-dflt-ary-ptrn-elem-id-init-throws.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-throws.case +// - src/dstr-binding/error/meth-dflt.template +/*--- +description: Destructuring initializer returns an abrupt completion (method (default parameter)) +esid: sec-runtime-semantics-definemethod +es6id: 14.3.8 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 = { + method([x = (function() { throw new Test262Error(); })()] = [undefined]) {} +}; + +assert.throws(Test262Error, function() { + obj.method(); +}); diff --git a/test/language/expressions/object/dstr-meth-dflt-ary-ptrn-elem-id-init-undef.js b/test/language/expressions/object/dstr-meth-dflt-ary-ptrn-elem-id-init-undef.js new file mode 100644 index 0000000000..cff07467d7 --- /dev/null +++ b/test/language/expressions/object/dstr-meth-dflt-ary-ptrn-elem-id-init-undef.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-undef.case +// - src/dstr-binding/default/meth-dflt.template +/*--- +description: Destructuring initializer with an undefined value (method (default parameter)) +esid: sec-runtime-semantics-definemethod +es6id: 14.3.8 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var obj = { + method([x = 23] = [undefined]) { + assert.sameValue(x, 23); + callCount = callCount + 1; + } +}; + +obj.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-meth-dflt-ary-ptrn-elem-id-init-unresolvable.js b/test/language/expressions/object/dstr-meth-dflt-ary-ptrn-elem-id-init-unresolvable.js new file mode 100644 index 0000000000..fcd7e7eccf --- /dev/null +++ b/test/language/expressions/object/dstr-meth-dflt-ary-ptrn-elem-id-init-unresolvable.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-unresolvable.case +// - src/dstr-binding/error/meth-dflt.template +/*--- +description: Destructuring initializer is an unresolvable reference (method (default parameter)) +esid: sec-runtime-semantics-definemethod +es6id: 14.3.8 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 = { + method([ x = unresolvableReference ] = []) {} +}; + +assert.throws(ReferenceError, function() { + obj.method(); +}); diff --git a/test/language/expressions/object/dstr-meth-dflt-ary-ptrn-elem-id-iter-complete.js b/test/language/expressions/object/dstr-meth-dflt-ary-ptrn-elem-id-iter-complete.js new file mode 100644 index 0000000000..34f91b07c7 --- /dev/null +++ b/test/language/expressions/object/dstr-meth-dflt-ary-ptrn-elem-id-iter-complete.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-complete.case +// - src/dstr-binding/default/meth-dflt.template +/*--- +description: SingleNameBinding when value iteration completes (method (default parameter)) +esid: sec-runtime-semantics-definemethod +es6id: 14.3.8 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var obj = { + method([x] = []) { + assert.sameValue(x, undefined); + callCount = callCount + 1; + } +}; + +obj.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-meth-dflt-ary-ptrn-elem-id-iter-done.js b/test/language/expressions/object/dstr-meth-dflt-ary-ptrn-elem-id-iter-done.js new file mode 100644 index 0000000000..70c39753e6 --- /dev/null +++ b/test/language/expressions/object/dstr-meth-dflt-ary-ptrn-elem-id-iter-done.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-done.case +// - src/dstr-binding/default/meth-dflt.template +/*--- +description: SingleNameBinding when value iteration was completed previously (method (default parameter)) +esid: sec-runtime-semantics-definemethod +es6id: 14.3.8 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var obj = { + method([_, x] = []) { + assert.sameValue(x, undefined); + callCount = callCount + 1; + } +}; + +obj.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-meth-dflt-ary-ptrn-elem-id-iter-step-err.js b/test/language/expressions/object/dstr-meth-dflt-ary-ptrn-elem-id-iter-step-err.js new file mode 100644 index 0000000000..1a72354afc --- /dev/null +++ b/test/language/expressions/object/dstr-meth-dflt-ary-ptrn-elem-id-iter-step-err.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-step-err.case +// - src/dstr-binding/error/meth-dflt.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (method (default parameter)) +esid: sec-runtime-semantics-definemethod +es6id: 14.3.8 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 = { + method([x] = g) {} +}; + +assert.throws(Test262Error, function() { + obj.method(); +}); diff --git a/test/language/expressions/object/dstr-meth-dflt-ary-ptrn-elem-id-iter-val-err.js b/test/language/expressions/object/dstr-meth-dflt-ary-ptrn-elem-id-iter-val-err.js new file mode 100644 index 0000000000..b8191868a7 --- /dev/null +++ b/test/language/expressions/object/dstr-meth-dflt-ary-ptrn-elem-id-iter-val-err.js @@ -0,0 +1,79 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val-err.case +// - src/dstr-binding/error/meth-dflt.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (method (default parameter)) +esid: sec-runtime-semantics-definemethod +es6id: 14.3.8 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 = { + method([x] = g) {} +}; + +assert.throws(Test262Error, function() { + obj.method(); +}); diff --git a/test/language/expressions/object/dstr-meth-dflt-ary-ptrn-elem-id-iter-val.js b/test/language/expressions/object/dstr-meth-dflt-ary-ptrn-elem-id-iter-val.js new file mode 100644 index 0000000000..6c452803a4 --- /dev/null +++ b/test/language/expressions/object/dstr-meth-dflt-ary-ptrn-elem-id-iter-val.js @@ -0,0 +1,75 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val.case +// - src/dstr-binding/default/meth-dflt.template +/*--- +description: SingleNameBinding when value iteration was completed previously (method (default parameter)) +esid: sec-runtime-semantics-definemethod +es6id: 14.3.8 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set + iteratorRecord.[[done]] to true. + iii. ReturnIfAbrupt(v). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var obj = { + method([x, y, z] = [1, 2, 3]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 3); + callCount = callCount + 1; + } +}; + +obj.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-meth-dflt-ary-ptrn-elem-obj-id-init.js b/test/language/expressions/object/dstr-meth-dflt-ary-ptrn-elem-obj-id-init.js new file mode 100644 index 0000000000..6e9dced290 --- /dev/null +++ b/test/language/expressions/object/dstr-meth-dflt-ary-ptrn-elem-obj-id-init.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-id-init.case +// - src/dstr-binding/default/meth-dflt.template +/*--- +description: BindingElement with object binding pattern and initializer is used (method (default parameter)) +esid: sec-runtime-semantics-definemethod +es6id: 14.3.8 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +var obj = { + method([{ x, y, z } = { x: 44, y: 55, z: 66 }] = []) { + assert.sameValue(x, 44); + assert.sameValue(y, 55); + assert.sameValue(z, 66); + callCount = callCount + 1; + } +}; + +obj.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-meth-dflt-ary-ptrn-elem-obj-id.js b/test/language/expressions/object/dstr-meth-dflt-ary-ptrn-elem-obj-id.js new file mode 100644 index 0000000000..c0a88a767d --- /dev/null +++ b/test/language/expressions/object/dstr-meth-dflt-ary-ptrn-elem-obj-id.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-id.case +// - src/dstr-binding/default/meth-dflt.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (method (default parameter)) +esid: sec-runtime-semantics-definemethod +es6id: 14.3.8 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +var obj = { + method([{ x, y, z } = { x: 44, y: 55, z: 66 }] = [{ x: 11, y: 22, z: 33 }]) { + assert.sameValue(x, 11); + assert.sameValue(y, 22); + assert.sameValue(z, 33); + callCount = callCount + 1; + } +}; + +obj.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-meth-dflt-ary-ptrn-elem-obj-prop-id-init.js b/test/language/expressions/object/dstr-meth-dflt-ary-ptrn-elem-obj-prop-id-init.js new file mode 100644 index 0000000000..a48b46df10 --- /dev/null +++ b/test/language/expressions/object/dstr-meth-dflt-ary-ptrn-elem-obj-prop-id-init.js @@ -0,0 +1,77 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-prop-id-init.case +// - src/dstr-binding/default/meth-dflt.template +/*--- +description: BindingElement with object binding pattern and initializer is used (method (default parameter)) +esid: sec-runtime-semantics-definemethod +es6id: 14.3.8 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +var obj = { + method([{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }] = []) { + assert.sameValue(v, 444); + assert.sameValue(x, 555); + assert.sameValue(z, 666); + + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; + } +}; + +obj.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-meth-dflt-ary-ptrn-elem-obj-prop-id.js b/test/language/expressions/object/dstr-meth-dflt-ary-ptrn-elem-obj-prop-id.js new file mode 100644 index 0000000000..fc5d3a3256 --- /dev/null +++ b/test/language/expressions/object/dstr-meth-dflt-ary-ptrn-elem-obj-prop-id.js @@ -0,0 +1,77 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-prop-id.case +// - src/dstr-binding/default/meth-dflt.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (method (default parameter)) +esid: sec-runtime-semantics-definemethod +es6id: 14.3.8 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +var obj = { + method([{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }] = [{ u: 777, w: 888, y: 999 }]) { + assert.sameValue(v, 777); + assert.sameValue(x, 888); + assert.sameValue(z, 999); + + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; + } +}; + +obj.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-meth-dflt-ary-ptrn-elem-obj-val-null.js b/test/language/expressions/object/dstr-meth-dflt-ary-ptrn-elem-obj-val-null.js new file mode 100644 index 0000000000..8fce74b23a --- /dev/null +++ b/test/language/expressions/object/dstr-meth-dflt-ary-ptrn-elem-obj-val-null.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-null.case +// - src/dstr-binding/error/meth-dflt.template +/*--- +description: Nested object destructuring with a null value (method (default parameter)) +esid: sec-runtime-semantics-definemethod +es6id: 14.3.8 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 = { + method([{ x }] = [null]) {} +}; + +assert.throws(TypeError, function() { + obj.method(); +}); diff --git a/test/language/expressions/object/dstr-meth-dflt-ary-ptrn-elem-obj-val-undef.js b/test/language/expressions/object/dstr-meth-dflt-ary-ptrn-elem-obj-val-undef.js new file mode 100644 index 0000000000..6b404d59cf --- /dev/null +++ b/test/language/expressions/object/dstr-meth-dflt-ary-ptrn-elem-obj-val-undef.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-undef.case +// - src/dstr-binding/error/meth-dflt.template +/*--- +description: Nested object destructuring with a value of `undefined` (method (default parameter)) +esid: sec-runtime-semantics-definemethod +es6id: 14.3.8 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 = { + method([{ x }] = []) {} +}; + +assert.throws(TypeError, function() { + obj.method(); +}); diff --git a/test/language/expressions/object/dstr-meth-dflt-ary-ptrn-elision-exhausted.js b/test/language/expressions/object/dstr-meth-dflt-ary-ptrn-elision-exhausted.js new file mode 100644 index 0000000000..99f056699f --- /dev/null +++ b/test/language/expressions/object/dstr-meth-dflt-ary-ptrn-elision-exhausted.js @@ -0,0 +1,72 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-exhausted.case +// - src/dstr-binding/default/meth-dflt.template +/*--- +description: Elision accepts exhausted iterator (method (default parameter)) +esid: sec-runtime-semantics-definemethod +es6id: 14.3.8 +features: [generator, destructuring-binding, default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + [...] + 2. Return NormalCompletion(empty). + +---*/ +var iter = function*() {}(); +iter.next(); + +var callCount = 0; +var obj = { + method([,] = iter) { + + callCount = callCount + 1; + } +}; + +obj.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-meth-dflt-ary-ptrn-elision-step-err.js b/test/language/expressions/object/dstr-meth-dflt-ary-ptrn-elision-step-err.js new file mode 100644 index 0000000000..ff5ef6865b --- /dev/null +++ b/test/language/expressions/object/dstr-meth-dflt-ary-ptrn-elision-step-err.js @@ -0,0 +1,76 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-step-err.case +// - src/dstr-binding/error/meth-dflt.template +/*--- +description: Elision advances iterator and forwards abrupt completions (method (default parameter)) +esid: sec-runtime-semantics-definemethod +es6id: 14.3.8 +features: [generator, destructuring-binding, default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 = { + 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-meth-dflt-ary-ptrn-elision.js b/test/language/expressions/object/dstr-meth-dflt-ary-ptrn-elision.js new file mode 100644 index 0000000000..c896bb64d9 --- /dev/null +++ b/test/language/expressions/object/dstr-meth-dflt-ary-ptrn-elision.js @@ -0,0 +1,81 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision.case +// - src/dstr-binding/default/meth-dflt.template +/*--- +description: Elision advances iterator (method (default parameter)) +esid: sec-runtime-semantics-definemethod +es6id: 14.3.8 +features: [generator, destructuring-binding, default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + 2. Return NormalCompletion(empty). + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var callCount = 0; +var obj = { + method([,] = g()) { + assert.sameValue(first, 1); + assert.sameValue(second, 0); + callCount = callCount + 1; + } +}; + +obj.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-meth-dflt-ary-ptrn-empty.js b/test/language/expressions/object/dstr-meth-dflt-ary-ptrn-empty.js new file mode 100644 index 0000000000..306c948104 --- /dev/null +++ b/test/language/expressions/object/dstr-meth-dflt-ary-ptrn-empty.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-empty.case +// - src/dstr-binding/default/meth-dflt.template +/*--- +description: No iteration occurs for an "empty" array binding pattern (method (default parameter)) +esid: sec-runtime-semantics-definemethod +es6id: 14.3.8 +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ ] + + 1. Return NormalCompletion(empty). + +---*/ +var iterations = 0; +var iter = function*() { + iterations += 1; +}(); + +var callCount = 0; +var obj = { + method([] = iter) { + assert.sameValue(iterations, 0); + callCount = callCount + 1; + } +}; + +obj.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-meth-dflt-ary-ptrn-rest-ary-elem.js b/test/language/expressions/object/dstr-meth-dflt-ary-ptrn-rest-ary-elem.js new file mode 100644 index 0000000000..8d064b332e --- /dev/null +++ b/test/language/expressions/object/dstr-meth-dflt-ary-ptrn-rest-ary-elem.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-elem.case +// - src/dstr-binding/default/meth-dflt.template +/*--- +description: Rest element containing an array BindingElementList pattern (method (default parameter)) +esid: sec-runtime-semantics-definemethod +es6id: 14.3.8 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set + iteratorRecord.[[done]] to true. + iii. ReturnIfAbrupt(v). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var obj = { + method([...[x, y, z]] = [3, 4, 5]) { + assert.sameValue(x, 3); + assert.sameValue(y, 4); + assert.sameValue(z, 5); + callCount = callCount + 1; + } +}; + +obj.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-meth-dflt-ary-ptrn-rest-ary-elision.js b/test/language/expressions/object/dstr-meth-dflt-ary-ptrn-rest-ary-elision.js new file mode 100644 index 0000000000..94dfcb97ca --- /dev/null +++ b/test/language/expressions/object/dstr-meth-dflt-ary-ptrn-rest-ary-elision.js @@ -0,0 +1,94 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-elision.case +// - src/dstr-binding/default/meth-dflt.template +/*--- +description: Rest element containing an elision (method (default parameter)) +esid: sec-runtime-semantics-definemethod +es6id: 14.3.8 +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + 2. Return NormalCompletion(empty). + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var callCount = 0; +var obj = { + method([...[,]] = g()) { + assert.sameValue(first, 1); + assert.sameValue(second, 1); + callCount = callCount + 1; + } +}; + +obj.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-meth-dflt-ary-ptrn-rest-ary-empty.js b/test/language/expressions/object/dstr-meth-dflt-ary-ptrn-rest-ary-empty.js new file mode 100644 index 0000000000..fc5c46e316 --- /dev/null +++ b/test/language/expressions/object/dstr-meth-dflt-ary-ptrn-rest-ary-empty.js @@ -0,0 +1,77 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-empty.case +// - src/dstr-binding/default/meth-dflt.template +/*--- +description: Rest element containing an "empty" array pattern (method (default parameter)) +esid: sec-runtime-semantics-definemethod +es6id: 14.3.8 +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ ] + + 1. Return NormalCompletion(empty). + +---*/ +var iterations = 0; +var iter = function*() { + iterations += 1; +}(); + +var callCount = 0; +var obj = { + method([...[]] = iter) { + assert.sameValue(iterations, 1); + callCount = callCount + 1; + } +}; + +obj.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-meth-dflt-ary-ptrn-rest-ary-rest.js b/test/language/expressions/object/dstr-meth-dflt-ary-ptrn-rest-ary-rest.js new file mode 100644 index 0000000000..d49d8ce033 --- /dev/null +++ b/test/language/expressions/object/dstr-meth-dflt-ary-ptrn-rest-ary-rest.js @@ -0,0 +1,73 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-rest.case +// - src/dstr-binding/default/meth-dflt.template +/*--- +description: Rest element containing a rest element (method (default parameter)) +esid: sec-runtime-semantics-definemethod +es6id: 14.3.8 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ +var values = [1, 2, 3]; + +var callCount = 0; +var obj = { + method([...[...x]] = values) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 1); + assert.sameValue(x[1], 2); + assert.sameValue(x[2], 3); + assert.notSameValue(x, values); + + callCount = callCount + 1; + } +}; + +obj.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-meth-dflt-ary-ptrn-rest-id-elision-next-err.js b/test/language/expressions/object/dstr-meth-dflt-ary-ptrn-rest-id-elision-next-err.js new file mode 100644 index 0000000000..8958518bb2 --- /dev/null +++ b/test/language/expressions/object/dstr-meth-dflt-ary-ptrn-rest-id-elision-next-err.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision-next-err.case +// - src/dstr-binding/error/meth-dflt.template +/*--- +description: Rest element following elision elements (method (default parameter)) +esid: sec-runtime-semantics-definemethod +es6id: 14.3.8 +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 = { + method([, ...x] = iter) {} +}; + +assert.throws(Test262Error, function() { + obj.method(); +}); diff --git a/test/language/expressions/object/dstr-meth-dflt-ary-ptrn-rest-id-elision.js b/test/language/expressions/object/dstr-meth-dflt-ary-ptrn-rest-id-elision.js new file mode 100644 index 0000000000..bde5be7ace --- /dev/null +++ b/test/language/expressions/object/dstr-meth-dflt-ary-ptrn-rest-id-elision.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision.case +// - src/dstr-binding/default/meth-dflt.template +/*--- +description: Rest element following elision elements (method (default parameter)) +esid: sec-runtime-semantics-definemethod +es6id: 14.3.8 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + ArrayBindingPattern : [ Elisionopt BindingRestElement ] + 1. If Elision is present, then + a. Let status be the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with + iteratorRecord as the argument. + b. ReturnIfAbrupt(status). + 2. Return the result of performing IteratorBindingInitialization for + BindingRestElement with iteratorRecord and environment as arguments. +---*/ +var values = [1, 2, 3, 4, 5]; + +var callCount = 0; +var obj = { + method([ , , ...x] = values) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 3); + assert.sameValue(x[1], 4); + assert.sameValue(x[2], 5); + assert.notSameValue(x, values); + callCount = callCount + 1; + } +}; + +obj.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-meth-dflt-ary-ptrn-rest-id-exhausted.js b/test/language/expressions/object/dstr-meth-dflt-ary-ptrn-rest-id-exhausted.js new file mode 100644 index 0000000000..6b19dafbb2 --- /dev/null +++ b/test/language/expressions/object/dstr-meth-dflt-ary-ptrn-rest-id-exhausted.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-exhausted.case +// - src/dstr-binding/default/meth-dflt.template +/*--- +description: RestElement applied to an exhausted iterator (method (default parameter)) +esid: sec-runtime-semantics-definemethod +es6id: 14.3.8 +features: [Symbol.iterator, destructuring-binding, default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier, + environment). + 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat, + [...] + b. If iteratorRecord.[[done]] is true, then + i. If environment is undefined, return PutValue(lhs, A). + ii. Return InitializeReferencedBinding(lhs, A). + +---*/ + +var callCount = 0; +var obj = { + method([, , ...x] = [1, 2]) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 0); + callCount = callCount + 1; + } +}; + +obj.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-meth-dflt-ary-ptrn-rest-id-iter-step-err.js b/test/language/expressions/object/dstr-meth-dflt-ary-ptrn-rest-id-iter-step-err.js new file mode 100644 index 0000000000..d13f8bddc9 --- /dev/null +++ b/test/language/expressions/object/dstr-meth-dflt-ary-ptrn-rest-id-iter-step-err.js @@ -0,0 +1,73 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-step-err.case +// - src/dstr-binding/error/meth-dflt.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (method (default parameter)) +esid: sec-runtime-semantics-definemethod +es6id: 14.3.8 +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 = { + 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-meth-dflt-ary-ptrn-rest-id-iter-val-err.js b/test/language/expressions/object/dstr-meth-dflt-ary-ptrn-rest-id-iter-val-err.js new file mode 100644 index 0000000000..66218f6282 --- /dev/null +++ b/test/language/expressions/object/dstr-meth-dflt-ary-ptrn-rest-id-iter-val-err.js @@ -0,0 +1,75 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-val-err.case +// - src/dstr-binding/error/meth-dflt.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (method (default parameter)) +esid: sec-runtime-semantics-definemethod +es6id: 14.3.8 +features: [Symbol.iterator, destructuring-binding, default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 = { + method([...x] = iter) {} +}; + +assert.throws(Test262Error, function() { + obj.method(); +}); diff --git a/test/language/expressions/object/dstr-meth-dflt-ary-ptrn-rest-id.js b/test/language/expressions/object/dstr-meth-dflt-ary-ptrn-rest-id.js new file mode 100644 index 0000000000..08aa482ea9 --- /dev/null +++ b/test/language/expressions/object/dstr-meth-dflt-ary-ptrn-rest-id.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id.case +// - src/dstr-binding/default/meth-dflt.template +/*--- +description: Lone rest element (method (default parameter)) +esid: sec-runtime-semantics-definemethod +es6id: 14.3.8 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + [...] 3. Let A be ArrayCreate(0). [...] 5. Repeat + [...] + f. Let status be CreateDataProperty(A, ToString (n), nextValue). + [...] +---*/ +var values = [1, 2, 3]; + +var callCount = 0; +var obj = { + method([...x] = values) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 1); + assert.sameValue(x[1], 2); + assert.sameValue(x[2], 3); + assert.notSameValue(x, values); + callCount = callCount + 1; + } +}; + +obj.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-meth-dflt-ary-ptrn-rest-init-ary.js b/test/language/expressions/object/dstr-meth-dflt-ary-ptrn-rest-init-ary.js new file mode 100644 index 0000000000..9e929a4f9f --- /dev/null +++ b/test/language/expressions/object/dstr-meth-dflt-ary-ptrn-rest-init-ary.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-ary.case +// - src/dstr-binding/default/meth-dflt.template +/*--- +description: Reset element (nested array pattern) does not support initializer (method (default parameter)) +esid: sec-runtime-semantics-definemethod +es6id: 14.3.8 +features: [destructuring-binding, default-parameters] +flags: [generated] +negative: SyntaxError +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +var obj = { + method([...[ x ] = []] = []) { + + callCount = callCount + 1; + } +}; + +obj.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-meth-dflt-ary-ptrn-rest-init-id.js b/test/language/expressions/object/dstr-meth-dflt-ary-ptrn-rest-init-id.js new file mode 100644 index 0000000000..56edab5975 --- /dev/null +++ b/test/language/expressions/object/dstr-meth-dflt-ary-ptrn-rest-init-id.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-id.case +// - src/dstr-binding/default/meth-dflt.template +/*--- +description: Reset element (identifier) does not support initializer (method (default parameter)) +esid: sec-runtime-semantics-definemethod +es6id: 14.3.8 +features: [destructuring-binding, default-parameters] +flags: [generated] +negative: SyntaxError +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +var obj = { + method([...x = []] = []) { + + callCount = callCount + 1; + } +}; + +obj.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-meth-dflt-ary-ptrn-rest-init-obj.js b/test/language/expressions/object/dstr-meth-dflt-ary-ptrn-rest-init-obj.js new file mode 100644 index 0000000000..21c0c22844 --- /dev/null +++ b/test/language/expressions/object/dstr-meth-dflt-ary-ptrn-rest-init-obj.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-obj.case +// - src/dstr-binding/default/meth-dflt.template +/*--- +description: Reset element (nested object pattern) does not support initializer (method (default parameter)) +esid: sec-runtime-semantics-definemethod +es6id: 14.3.8 +features: [destructuring-binding, default-parameters] +flags: [generated] +negative: SyntaxError +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +var obj = { + method([...{ x } = []] = []) { + + callCount = callCount + 1; + } +}; + +obj.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-meth-dflt-ary-ptrn-rest-not-final-ary.js b/test/language/expressions/object/dstr-meth-dflt-ary-ptrn-rest-not-final-ary.js new file mode 100644 index 0000000000..a52f4769a9 --- /dev/null +++ b/test/language/expressions/object/dstr-meth-dflt-ary-ptrn-rest-not-final-ary.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-ary.case +// - src/dstr-binding/default/meth-dflt.template +/*--- +description: Rest element (array binding pattern) may not be followed by any element (method (default parameter)) +esid: sec-runtime-semantics-definemethod +es6id: 14.3.8 +features: [destructuring-binding, default-parameters] +flags: [generated] +negative: SyntaxError +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +var obj = { + method([...[x], y] = [1, 2, 3]) { + + callCount = callCount + 1; + } +}; + +obj.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-meth-dflt-ary-ptrn-rest-not-final-id.js b/test/language/expressions/object/dstr-meth-dflt-ary-ptrn-rest-not-final-id.js new file mode 100644 index 0000000000..5fe8826d5e --- /dev/null +++ b/test/language/expressions/object/dstr-meth-dflt-ary-ptrn-rest-not-final-id.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-id.case +// - src/dstr-binding/default/meth-dflt.template +/*--- +description: Rest element (identifier) may not be followed by any element (method (default parameter)) +esid: sec-runtime-semantics-definemethod +es6id: 14.3.8 +features: [destructuring-binding, default-parameters] +flags: [generated] +negative: SyntaxError +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +var obj = { + method([...x, y] = [1, 2, 3]) { + + callCount = callCount + 1; + } +}; + +obj.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-meth-dflt-ary-ptrn-rest-not-final-obj.js b/test/language/expressions/object/dstr-meth-dflt-ary-ptrn-rest-not-final-obj.js new file mode 100644 index 0000000000..6dc54a3411 --- /dev/null +++ b/test/language/expressions/object/dstr-meth-dflt-ary-ptrn-rest-not-final-obj.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-obj.case +// - src/dstr-binding/default/meth-dflt.template +/*--- +description: Rest element (object binding pattern) may not be followed by any element (method (default parameter)) +esid: sec-runtime-semantics-definemethod +es6id: 14.3.8 +features: [destructuring-binding, default-parameters] +flags: [generated] +negative: SyntaxError +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +var obj = { + method([...{ x }, y] = [1, 2, 3]) { + + callCount = callCount + 1; + } +}; + +obj.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-meth-dflt-ary-ptrn-rest-obj-id.js b/test/language/expressions/object/dstr-meth-dflt-ary-ptrn-rest-obj-id.js new file mode 100644 index 0000000000..cf7b89c40c --- /dev/null +++ b/test/language/expressions/object/dstr-meth-dflt-ary-ptrn-rest-obj-id.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-obj-id.case +// - src/dstr-binding/default/meth-dflt.template +/*--- +description: Rest element containing an object binding pattern (method (default parameter)) +esid: sec-runtime-semantics-definemethod +es6id: 14.3.8 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ + +var callCount = 0; +var obj = { + method([...{ length }] = [1, 2, 3]) { + assert.sameValue(length, 3); + callCount = callCount + 1; + } +}; + +obj.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-meth-dflt-ary-ptrn-rest-obj-prop-id.js b/test/language/expressions/object/dstr-meth-dflt-ary-ptrn-rest-obj-prop-id.js new file mode 100644 index 0000000000..f2853d38e7 --- /dev/null +++ b/test/language/expressions/object/dstr-meth-dflt-ary-ptrn-rest-obj-prop-id.js @@ -0,0 +1,74 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-obj-prop-id.case +// - src/dstr-binding/default/meth-dflt.template +/*--- +description: Rest element containing an object binding pattern (method (default parameter)) +esid: sec-runtime-semantics-definemethod +es6id: 14.3.8 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ + +var callCount = 0; +var obj = { + method([...{ 0: v, 1: w, 2: x, 3: y, length: z }] = [7, 8, 9]) { + assert.sameValue(v, 7); + assert.sameValue(w, 8); + assert.sameValue(x, 9); + assert.sameValue(y, undefined); + assert.sameValue(z, 3); + + assert.throws(ReferenceError, function() { + length; + }); + callCount = callCount + 1; + } +}; + +obj.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-meth-dflt-obj-init-null.js b/test/language/expressions/object/dstr-meth-dflt-obj-init-null.js new file mode 100644 index 0000000000..14922afb94 --- /dev/null +++ b/test/language/expressions/object/dstr-meth-dflt-obj-init-null.js @@ -0,0 +1,56 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-null.case +// - src/dstr-binding/error/meth-dflt.template +/*--- +description: Value specifed for object binding pattern must be object coercible (null) (method (default parameter)) +esid: sec-runtime-semantics-definemethod +es6id: 14.3.8 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + +var obj = { + method({} = null) {} +}; + +assert.throws(TypeError, function() { + obj.method(); +}); diff --git a/test/language/expressions/object/dstr-meth-dflt-obj-init-undefined.js b/test/language/expressions/object/dstr-meth-dflt-obj-init-undefined.js new file mode 100644 index 0000000000..25760a9473 --- /dev/null +++ b/test/language/expressions/object/dstr-meth-dflt-obj-init-undefined.js @@ -0,0 +1,56 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-undefined.case +// - src/dstr-binding/error/meth-dflt.template +/*--- +description: Value specifed for object binding pattern must be object coercible (undefined) (method (default parameter)) +esid: sec-runtime-semantics-definemethod +es6id: 14.3.8 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + +var obj = { + method({} = undefined) {} +}; + +assert.throws(TypeError, function() { + obj.method(); +}); diff --git a/test/language/expressions/object/dstr-meth-dflt-obj-ptrn-empty.js b/test/language/expressions/object/dstr-meth-dflt-obj-ptrn-empty.js new file mode 100644 index 0000000000..e93ddf6fb0 --- /dev/null +++ b/test/language/expressions/object/dstr-meth-dflt-obj-ptrn-empty.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-empty.case +// - src/dstr-binding/default/meth-dflt.template +/*--- +description: No property access occurs for an "empty" object binding pattern (method (default parameter)) +esid: sec-runtime-semantics-definemethod +es6id: 14.3.8 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ +var accessCount = 0; +var obj = Object.defineProperty({}, 'attr', { + get: function() { + accessCount += 1; + } +}); + +var callCount = 0; +var obj = { + method({} = obj) { + assert.sameValue(accessCount, 0); + callCount = callCount + 1; + } +}; + +obj.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-meth-dflt-obj-ptrn-id-get-value-err.js b/test/language/expressions/object/dstr-meth-dflt-obj-ptrn-id-get-value-err.js new file mode 100644 index 0000000000..ba50328a36 --- /dev/null +++ b/test/language/expressions/object/dstr-meth-dflt-obj-ptrn-id-get-value-err.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-get-value-err.case +// - src/dstr-binding/error/meth-dflt.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (method (default parameter)) +esid: sec-runtime-semantics-definemethod +es6id: 14.3.8 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 = { + method({ poisoned } = poisonedProperty) {} +}; + +assert.throws(Test262Error, function() { + obj.method(); +}); diff --git a/test/language/expressions/object/dstr-meth-dflt-obj-ptrn-id-init-fn-name-arrow.js b/test/language/expressions/object/dstr-meth-dflt-obj-ptrn-id-init-fn-name-arrow.js new file mode 100644 index 0000000000..f427553a19 --- /dev/null +++ b/test/language/expressions/object/dstr-meth-dflt-obj-ptrn-id-init-fn-name-arrow.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-arrow.case +// - src/dstr-binding/default/meth-dflt.template +/*--- +description: SingleNameBinding assigns `name` to arrow functions (method (default parameter)) +esid: sec-runtime-semantics-definemethod +es6id: 14.3.8 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +var obj = { + method({ arrow = () => {} } = {}) { + assert.sameValue(arrow.name, 'arrow'); + callCount = callCount + 1; + } +}; + +obj.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-meth-dflt-obj-ptrn-id-init-fn-name-class.js b/test/language/expressions/object/dstr-meth-dflt-obj-ptrn-id-init-fn-name-class.js new file mode 100644 index 0000000000..6ea8850334 --- /dev/null +++ b/test/language/expressions/object/dstr-meth-dflt-obj-ptrn-id-init-fn-name-class.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-class.case +// - src/dstr-binding/default/meth-dflt.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (method (default parameter)) +esid: sec-runtime-semantics-definemethod +es6id: 14.3.8 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +var obj = { + method({ cls = class {}, xCls = class X {} } = {}) { + assert.sameValue(cls.name, 'cls'); + assert.notSameValue(xCls.name, 'xCls'); + callCount = callCount + 1; + } +}; + +obj.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-meth-dflt-obj-ptrn-id-init-fn-name-cover.js b/test/language/expressions/object/dstr-meth-dflt-obj-ptrn-id-init-fn-name-cover.js new file mode 100644 index 0000000000..ee75a23017 --- /dev/null +++ b/test/language/expressions/object/dstr-meth-dflt-obj-ptrn-id-init-fn-name-cover.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-cover.case +// - src/dstr-binding/default/meth-dflt.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" functions "through" cover grammar (method (default parameter)) +esid: sec-runtime-semantics-definemethod +es6id: 14.3.8 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +var obj = { + method({ cover = (function () {}), xCover = (0, function() {}) } = {}) { + assert.sameValue(cover.name, 'cover'); + assert.notSameValue(xCover.name, 'xCover'); + callCount = callCount + 1; + } +}; + +obj.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-meth-dflt-obj-ptrn-id-init-fn-name-fn.js b/test/language/expressions/object/dstr-meth-dflt-obj-ptrn-id-init-fn-name-fn.js new file mode 100644 index 0000000000..d3cb03e408 --- /dev/null +++ b/test/language/expressions/object/dstr-meth-dflt-obj-ptrn-id-init-fn-name-fn.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-fn.case +// - src/dstr-binding/default/meth-dflt.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (method (default parameter)) +esid: sec-runtime-semantics-definemethod +es6id: 14.3.8 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +var obj = { + method({ fn = function () {}, xFn = function x() {} } = {}) { + assert.sameValue(fn.name, 'fn'); + assert.notSameValue(xFn.name, 'xFn'); + callCount = callCount + 1; + } +}; + +obj.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-meth-dflt-obj-ptrn-id-init-fn-name-gen.js b/test/language/expressions/object/dstr-meth-dflt-obj-ptrn-id-init-fn-name-gen.js new file mode 100644 index 0000000000..5cd76dd549 --- /dev/null +++ b/test/language/expressions/object/dstr-meth-dflt-obj-ptrn-id-init-fn-name-gen.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-gen.case +// - src/dstr-binding/default/meth-dflt.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (method (default parameter)) +esid: sec-runtime-semantics-definemethod +es6id: 14.3.8 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +var obj = { + method({ gen = function* () {}, xGen = function* x() {} } = {}) { + assert.sameValue(gen.name, 'gen'); + assert.notSameValue(xGen.name, 'xGen'); + callCount = callCount + 1; + } +}; + +obj.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-meth-dflt-obj-ptrn-id-init-skipped.js b/test/language/expressions/object/dstr-meth-dflt-obj-ptrn-id-init-skipped.js new file mode 100644 index 0000000000..e23f8be8c5 --- /dev/null +++ b/test/language/expressions/object/dstr-meth-dflt-obj-ptrn-id-init-skipped.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-skipped.case +// - src/dstr-binding/default/meth-dflt.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (method (default parameter)) +esid: sec-runtime-semantics-definemethod +es6id: 14.3.8 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + [...] +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var callCount = 0; +var obj = { + method({ w = counter(), x = counter(), y = counter(), z = counter() } = { w: null, x: 0, y: false, z: '' }) { + assert.sameValue(w, null); + assert.sameValue(x, 0); + assert.sameValue(y, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } +}; + +obj.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-meth-dflt-obj-ptrn-id-init-throws.js b/test/language/expressions/object/dstr-meth-dflt-obj-ptrn-id-init-throws.js new file mode 100644 index 0000000000..1ee6b3937a --- /dev/null +++ b/test/language/expressions/object/dstr-meth-dflt-obj-ptrn-id-init-throws.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-throws.case +// - src/dstr-binding/error/meth-dflt.template +/*--- +description: Error thrown when evaluating the initializer (method (default parameter)) +esid: sec-runtime-semantics-definemethod +es6id: 14.3.8 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 = { + method({ x = thrower() } = {}) {} +}; + +assert.throws(Test262Error, function() { + obj.method(); +}); diff --git a/test/language/expressions/object/dstr-meth-dflt-obj-ptrn-id-init-unresolvable.js b/test/language/expressions/object/dstr-meth-dflt-obj-ptrn-id-init-unresolvable.js new file mode 100644 index 0000000000..6bc5191979 --- /dev/null +++ b/test/language/expressions/object/dstr-meth-dflt-obj-ptrn-id-init-unresolvable.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-unresolvable.case +// - src/dstr-binding/error/meth-dflt.template +/*--- +description: Destructuring initializer is an unresolvable reference (method (default parameter)) +esid: sec-runtime-semantics-definemethod +es6id: 14.3.8 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 = { + method({ x = unresolvableReference } = {}) {} +}; + +assert.throws(ReferenceError, function() { + obj.method(); +}); diff --git a/test/language/expressions/object/dstr-meth-dflt-obj-ptrn-id-trailing-comma.js b/test/language/expressions/object/dstr-meth-dflt-obj-ptrn-id-trailing-comma.js new file mode 100644 index 0000000000..dbf4dd62d6 --- /dev/null +++ b/test/language/expressions/object/dstr-meth-dflt-obj-ptrn-id-trailing-comma.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-trailing-comma.case +// - src/dstr-binding/default/meth-dflt.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (method (default parameter)) +esid: sec-runtime-semantics-definemethod +es6id: 14.3.8 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var callCount = 0; +var obj = { + method({ x, } = { x: 23 }) { + assert.sameValue(x, 23); + callCount = callCount + 1; + } +}; + +obj.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-meth-dflt-obj-ptrn-list-err.js b/test/language/expressions/object/dstr-meth-dflt-obj-ptrn-list-err.js new file mode 100644 index 0000000000..6db684bb73 --- /dev/null +++ b/test/language/expressions/object/dstr-meth-dflt-obj-ptrn-list-err.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-list-err.case +// - src/dstr-binding/error/meth-dflt.template +/*--- +description: Binding property list evaluation is interrupted by an abrupt completion (method (default parameter)) +esid: sec-runtime-semantics-definemethod +es6id: 14.3.8 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 = { + method({ a, b = thrower(), c = ++initCount } = {}) {} +}; + +assert.throws(Test262Error, function() { + obj.method(); +}); + +assert.sameValue(initCount, 0); diff --git a/test/language/expressions/object/dstr-meth-dflt-obj-ptrn-prop-ary-init.js b/test/language/expressions/object/dstr-meth-dflt-obj-ptrn-prop-ary-init.js new file mode 100644 index 0000000000..aa0c777380 --- /dev/null +++ b/test/language/expressions/object/dstr-meth-dflt-obj-ptrn-prop-ary-init.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-init.case +// - src/dstr-binding/default/meth-dflt.template +/*--- +description: Object binding pattern with "nested" array binding pattern using initializer (method (default parameter)) +esid: sec-runtime-semantics-definemethod +es6id: 14.3.8 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +var obj = { + method({ w: [x, y, z] = [4, 5, 6] } = {}) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } +}; + +obj.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-meth-dflt-obj-ptrn-prop-ary-trailing-comma.js b/test/language/expressions/object/dstr-meth-dflt-obj-ptrn-prop-ary-trailing-comma.js new file mode 100644 index 0000000000..10e8b68b9f --- /dev/null +++ b/test/language/expressions/object/dstr-meth-dflt-obj-ptrn-prop-ary-trailing-comma.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-trailing-comma.case +// - src/dstr-binding/default/meth-dflt.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (method (default parameter)) +esid: sec-runtime-semantics-definemethod +es6id: 14.3.8 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var callCount = 0; +var obj = { + method({ x: [y], } = { x: [45] }) { + assert.sameValue(y,45); + callCount = callCount + 1; + } +}; + +obj.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-meth-dflt-obj-ptrn-prop-ary-value-null.js b/test/language/expressions/object/dstr-meth-dflt-obj-ptrn-prop-ary-value-null.js new file mode 100644 index 0000000000..d1b6ae7c86 --- /dev/null +++ b/test/language/expressions/object/dstr-meth-dflt-obj-ptrn-prop-ary-value-null.js @@ -0,0 +1,58 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-value-null.case +// - src/dstr-binding/error/meth-dflt.template +/*--- +description: Object binding pattern with "nested" array binding pattern taking the `null` value (method (default parameter)) +esid: sec-runtime-semantics-definemethod +es6id: 14.3.8 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 = { + method({ w: [x, y, z] = [4, 5, 6] } = { w: null }) {} +}; + +assert.throws(TypeError, function() { + obj.method(); +}); diff --git a/test/language/expressions/object/dstr-meth-dflt-obj-ptrn-prop-ary.js b/test/language/expressions/object/dstr-meth-dflt-obj-ptrn-prop-ary.js new file mode 100644 index 0000000000..abab62f63a --- /dev/null +++ b/test/language/expressions/object/dstr-meth-dflt-obj-ptrn-prop-ary.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary.case +// - src/dstr-binding/default/meth-dflt.template +/*--- +description: Object binding pattern with "nested" array binding pattern not using initializer (method (default parameter)) +esid: sec-runtime-semantics-definemethod +es6id: 14.3.8 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +var obj = { + method({ w: [x, y, z] = [4, 5, 6] } = { w: [7, undefined, ] }) { + assert.sameValue(x, 7); + assert.sameValue(y, undefined); + assert.sameValue(z, undefined); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } +}; + +obj.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-meth-dflt-obj-ptrn-prop-eval-err.js b/test/language/expressions/object/dstr-meth-dflt-obj-ptrn-prop-eval-err.js new file mode 100644 index 0000000000..3b88c94711 --- /dev/null +++ b/test/language/expressions/object/dstr-meth-dflt-obj-ptrn-prop-eval-err.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-eval-err.case +// - src/dstr-binding/error/meth-dflt.template +/*--- +description: Evaluation of property name returns an abrupt completion (method (default parameter)) +esid: sec-runtime-semantics-definemethod +es6id: 14.3.8 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 = { + method({ [thrower()]: x } = {}) {} +}; + +assert.throws(Test262Error, function() { + obj.method(); +}); diff --git a/test/language/expressions/object/dstr-meth-dflt-obj-ptrn-prop-id-get-value-err.js b/test/language/expressions/object/dstr-meth-dflt-obj-ptrn-prop-id-get-value-err.js new file mode 100644 index 0000000000..5d18f9c6f9 --- /dev/null +++ b/test/language/expressions/object/dstr-meth-dflt-obj-ptrn-prop-id-get-value-err.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-get-value-err.case +// - src/dstr-binding/error/meth-dflt.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (method (default parameter)) +esid: sec-runtime-semantics-definemethod +es6id: 14.3.8 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 = { + method({ poisoned: x = ++initEvalCount } = poisonedProperty) {} +}; + +assert.throws(Test262Error, function() { + obj.method(); +}); + +assert.sameValue(initEvalCount, 0); diff --git a/test/language/expressions/object/dstr-meth-dflt-obj-ptrn-prop-id-init-skipped.js b/test/language/expressions/object/dstr-meth-dflt-obj-ptrn-prop-id-init-skipped.js new file mode 100644 index 0000000000..30154e8990 --- /dev/null +++ b/test/language/expressions/object/dstr-meth-dflt-obj-ptrn-prop-id-init-skipped.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-skipped.case +// - src/dstr-binding/default/meth-dflt.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (method (default parameter)) +esid: sec-runtime-semantics-definemethod +es6id: 14.3.8 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + [...] +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var callCount = 0; +var obj = { + method({ s: t = counter(), u: v = counter(), w: x = counter(), y: z = counter() } = { s: null, u: 0, w: false, y: '' }) { + assert.sameValue(t, null); + assert.sameValue(v, 0); + assert.sameValue(x, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + + assert.throws(ReferenceError, function() { + s; + }); + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; + } +}; + +obj.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-meth-dflt-obj-ptrn-prop-id-init-throws.js b/test/language/expressions/object/dstr-meth-dflt-obj-ptrn-prop-id-init-throws.js new file mode 100644 index 0000000000..d07a459f44 --- /dev/null +++ b/test/language/expressions/object/dstr-meth-dflt-obj-ptrn-prop-id-init-throws.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-throws.case +// - src/dstr-binding/error/meth-dflt.template +/*--- +description: Error thrown when evaluating the initializer (method (default parameter)) +esid: sec-runtime-semantics-definemethod +es6id: 14.3.8 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 = { + method({ x: y = thrower() } = {}) {} +}; + +assert.throws(Test262Error, function() { + obj.method(); +}); diff --git a/test/language/expressions/object/dstr-meth-dflt-obj-ptrn-prop-id-init-unresolvable.js b/test/language/expressions/object/dstr-meth-dflt-obj-ptrn-prop-id-init-unresolvable.js new file mode 100644 index 0000000000..25591b4804 --- /dev/null +++ b/test/language/expressions/object/dstr-meth-dflt-obj-ptrn-prop-id-init-unresolvable.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-unresolvable.case +// - src/dstr-binding/error/meth-dflt.template +/*--- +description: Destructuring initializer is an unresolvable reference (method (default parameter)) +esid: sec-runtime-semantics-definemethod +es6id: 14.3.8 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 = { + method({ x: y = unresolvableReference } = {}) {} +}; + +assert.throws(ReferenceError, function() { + obj.method(); +}); diff --git a/test/language/expressions/object/dstr-meth-dflt-obj-ptrn-prop-id-init.js b/test/language/expressions/object/dstr-meth-dflt-obj-ptrn-prop-id-init.js new file mode 100644 index 0000000000..f380475e70 --- /dev/null +++ b/test/language/expressions/object/dstr-meth-dflt-obj-ptrn-prop-id-init.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init.case +// - src/dstr-binding/default/meth-dflt.template +/*--- +description: Binding as specified via property name, identifier, and initializer (method (default parameter)) +esid: sec-runtime-semantics-definemethod +es6id: 14.3.8 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var obj = { + method({ x: y = 33 } = { }) { + assert.sameValue(y, 33); + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; + } +}; + +obj.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-meth-dflt-obj-ptrn-prop-id-trailing-comma.js b/test/language/expressions/object/dstr-meth-dflt-obj-ptrn-prop-id-trailing-comma.js new file mode 100644 index 0000000000..065ca04442 --- /dev/null +++ b/test/language/expressions/object/dstr-meth-dflt-obj-ptrn-prop-id-trailing-comma.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-trailing-comma.case +// - src/dstr-binding/default/meth-dflt.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (method (default parameter)) +esid: sec-runtime-semantics-definemethod +es6id: 14.3.8 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var callCount = 0; +var obj = { + method({ x: y, } = { x: 23 }) { + assert.sameValue(y, 23); + + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; + } +}; + +obj.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-meth-dflt-obj-ptrn-prop-id.js b/test/language/expressions/object/dstr-meth-dflt-obj-ptrn-prop-id.js new file mode 100644 index 0000000000..bf82246b82 --- /dev/null +++ b/test/language/expressions/object/dstr-meth-dflt-obj-ptrn-prop-id.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id.case +// - src/dstr-binding/default/meth-dflt.template +/*--- +description: Binding as specified via property name and identifier (method (default parameter)) +esid: sec-runtime-semantics-definemethod +es6id: 14.3.8 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +var obj = { + method({ x: y } = { x: 23 }) { + assert.sameValue(y, 23); + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; + } +}; + +obj.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-meth-dflt-obj-ptrn-prop-obj-init.js b/test/language/expressions/object/dstr-meth-dflt-obj-ptrn-prop-obj-init.js new file mode 100644 index 0000000000..43236d4d94 --- /dev/null +++ b/test/language/expressions/object/dstr-meth-dflt-obj-ptrn-prop-obj-init.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-init.case +// - src/dstr-binding/default/meth-dflt.template +/*--- +description: Object binding pattern with "nested" object binding pattern using initializer (method (default parameter)) +esid: sec-runtime-semantics-definemethod +es6id: 14.3.8 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +var obj = { + method({ w: { x, y, z } = { x: 4, y: 5, z: 6 } } = { w: undefined }) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } +}; + +obj.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/object/dstr-meth-dflt-obj-ptrn-prop-obj-value-null.js b/test/language/expressions/object/dstr-meth-dflt-obj-ptrn-prop-obj-value-null.js new file mode 100644 index 0000000000..4f432d7d13 --- /dev/null +++ b/test/language/expressions/object/dstr-meth-dflt-obj-ptrn-prop-obj-value-null.js @@ -0,0 +1,58 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-null.case +// - src/dstr-binding/error/meth-dflt.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (method (default parameter)) +esid: sec-runtime-semantics-definemethod +es6id: 14.3.8 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 = { + 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-meth-dflt-obj-ptrn-prop-obj-value-undef.js b/test/language/expressions/object/dstr-meth-dflt-obj-ptrn-prop-obj-value-undef.js new file mode 100644 index 0000000000..13edb25fc5 --- /dev/null +++ b/test/language/expressions/object/dstr-meth-dflt-obj-ptrn-prop-obj-value-undef.js @@ -0,0 +1,58 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-undef.case +// - src/dstr-binding/error/meth-dflt.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (method (default parameter)) +esid: sec-runtime-semantics-definemethod +es6id: 14.3.8 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 = { + method({ w: { x, y, z } = undefined } = { }) {} +}; + +assert.throws(TypeError, function() { + obj.method(); +}); diff --git a/test/language/expressions/object/dstr-meth-dflt-obj-ptrn-prop-obj.js b/test/language/expressions/object/dstr-meth-dflt-obj-ptrn-prop-obj.js new file mode 100644 index 0000000000..3e36fd72a7 --- /dev/null +++ b/test/language/expressions/object/dstr-meth-dflt-obj-ptrn-prop-obj.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj.case +// - src/dstr-binding/default/meth-dflt.template +/*--- +description: Object binding pattern with "nested" object binding pattern not using initializer (method (default parameter)) +esid: sec-runtime-semantics-definemethod +es6id: 14.3.8 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +var obj = { + method({ w: { x, y, z } = { x: 4, y: 5, z: 6 } } = { w: { x: undefined, z: 7 } }) { + assert.sameValue(x, undefined); + assert.sameValue(y, undefined); + assert.sameValue(z, 7); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } +}; + +obj.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-dflt-ary-init-iter-close.js b/test/language/statements/class/dstr-gen-meth-dflt-ary-init-iter-close.js new file mode 100644 index 0000000000..4d9916385a --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-dflt-ary-init-iter-close.js @@ -0,0 +1,95 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-close.case +// - src/dstr-binding/default/cls-decl-gen-meth-dflt.template +/*--- +description: Iterator is closed when not exhausted by pattern evaluation (class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [Symbol.iterator, destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + [...] + 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator, + result). + [...] + +---*/ +var doneCallCount = 0; +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return { value: null, done: false }; + }, + return: function() { + doneCallCount += 1; + return {}; + } + }; +}; + +var callCount = 0; +class C { + *method([x] = iter) { + assert.sameValue(doneCallCount, 1); + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-dflt-ary-init-iter-get-err.js b/test/language/statements/class/dstr-gen-meth-dflt-ary-init-iter-get-err.js new file mode 100644 index 0000000000..990850a42b --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-dflt-ary-init-iter-get-err.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-get-err.case +// - src/dstr-binding/error/cls-decl-gen-meth-dflt.template +/*--- +description: Abrupt completion returned by GetIterator (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [Symbol.iterator, destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 { + *method([x] = iter) {} +}; +var c = new C(); + +assert.throws(Test262Error, function() { + c.method(); +}); diff --git a/test/language/statements/class/dstr-gen-meth-dflt-ary-init-iter-no-close.js b/test/language/statements/class/dstr-gen-meth-dflt-ary-init-iter-no-close.js new file mode 100644 index 0000000000..c4513294fc --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-dflt-ary-init-iter-no-close.js @@ -0,0 +1,95 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-no-close.case +// - src/dstr-binding/default/cls-decl-gen-meth-dflt.template +/*--- +description: Iterator is not closed when exhausted by pattern evaluation (class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [Symbol.iterator, destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + [...] + 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator, + result). + [...] + +---*/ +var doneCallCount = 0; +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return { value: null, done: true }; + }, + return: function() { + doneCallCount += 1; + return {}; + } + }; +}; + +var callCount = 0; +class C { + *method([x] = iter) { + assert.sameValue(doneCallCount, 0); + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-dflt-ary-name-iter-val.js b/test/language/statements/class/dstr-gen-meth-dflt-ary-name-iter-val.js new file mode 100644 index 0000000000..614c63cec5 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-dflt-ary-name-iter-val.js @@ -0,0 +1,94 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-name-iter-val.case +// - src/dstr-binding/default/cls-decl-gen-meth-dflt.template +/*--- +description: SingleNameBinding with normal value iteration (class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set + iteratorRecord.[[done]] to true. + iii. ReturnIfAbrupt(v). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + *method([x, y, z] = [1, 2, 3]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 3); + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-elem-ary-elem-init.js b/test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-elem-ary-elem-init.js new file mode 100644 index 0000000000..a451f70ce2 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-elem-ary-elem-init.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elem-init.case +// - src/dstr-binding/default/cls-decl-gen-meth-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is used (class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +class C { + *method([[x, y, z] = [4, 5, 6]] = []) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-elem-ary-elem-iter.js b/test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-elem-ary-elem-iter.js new file mode 100644 index 0000000000..264664f22c --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-elem-ary-elem-iter.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elem-iter.case +// - src/dstr-binding/default/cls-decl-gen-meth-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +class C { + *method([[x, y, z] = [4, 5, 6]] = [[7, 8, 9]]) { + assert.sameValue(x, 7); + assert.sameValue(y, 8); + assert.sameValue(z, 9); + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-elem-ary-elision-init.js b/test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-elem-ary-elision-init.js new file mode 100644 index 0000000000..4929f77911 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-elem-ary-elision-init.js @@ -0,0 +1,93 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elision-init.case +// - src/dstr-binding/default/cls-decl-gen-meth-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is used (class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [generators, destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var callCount = 0; +class C { + *method([[,] = g()] = []) { + assert.sameValue(first, 1); + assert.sameValue(second, 0); + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-elem-ary-elision-iter.js b/test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-elem-ary-elision-iter.js new file mode 100644 index 0000000000..42679bed28 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-elem-ary-elision-iter.js @@ -0,0 +1,90 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elision-iter.case +// - src/dstr-binding/default/cls-decl-gen-meth-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [generators, destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var callCount = 0; +function* g() { + callCount += 1; +}; + +var callCount = 0; +class C { + *method([[,] = g()] = [[]]) { + assert.sameValue(callCount, 0); + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-elem-ary-empty-init.js b/test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-elem-ary-empty-init.js new file mode 100644 index 0000000000..16d76875c7 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-elem-ary-empty-init.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-empty-init.case +// - src/dstr-binding/default/cls-decl-gen-meth-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is used (class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var initCount = 0; +var iterCount = 0; +var iter = function*() { iterCount += 1; }(); + +var callCount = 0; +class C { + *method([[] = function() { initCount += 1; return iter; }()] = []) { + assert.sameValue(initCount, 1); + assert.sameValue(iterCount, 0); + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-elem-ary-empty-iter.js b/test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-elem-ary-empty-iter.js new file mode 100644 index 0000000000..a9278583c4 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-elem-ary-empty-iter.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-empty-iter.case +// - src/dstr-binding/default/cls-decl-gen-meth-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var initCount = 0; + +var callCount = 0; +class C { + *method([[] = function() { initCount += 1; }()] = [[23]]) { + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-elem-ary-rest-init.js b/test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-elem-ary-rest-init.js new file mode 100644 index 0000000000..698692b5ea --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-elem-ary-rest-init.js @@ -0,0 +1,90 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-rest-init.case +// - src/dstr-binding/default/cls-decl-gen-meth-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is used (class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var values = [2, 1, 3]; + +var callCount = 0; +class C { + *method([[...x] = values] = []) { + assert(Array.isArray(x)); + assert.sameValue(x[0], 2); + assert.sameValue(x[1], 1); + assert.sameValue(x[2], 3); + assert.sameValue(x.length, 3); + assert.notSameValue(x, values); + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-elem-ary-rest-iter.js b/test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-elem-ary-rest-iter.js new file mode 100644 index 0000000000..d8866ef973 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-elem-ary-rest-iter.js @@ -0,0 +1,93 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-rest-iter.case +// - src/dstr-binding/default/cls-decl-gen-meth-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var values = [2, 1, 3]; +var initCount = 0; + +var callCount = 0; +class C { + *method([[...x] = function() { initCount += 1; }()] = [values]) { + assert(Array.isArray(x)); + assert.sameValue(x[0], 2); + assert.sameValue(x[1], 1); + assert.sameValue(x[2], 3); + assert.sameValue(x.length, 3); + assert.notSameValue(x, values); + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-elem-ary-val-null.js b/test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-elem-ary-val-null.js new file mode 100644 index 0000000000..397f660958 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-elem-ary-val-null.js @@ -0,0 +1,89 @@ +// 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-gen-meth-dflt.template +/*--- +description: Nested array destructuring with a null value (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 { + *method([[x]] = [null]) {} +}; +var c = new C(); + +assert.throws(TypeError, function() { + c.method(); +}); diff --git a/test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-elem-id-init-exhausted.js b/test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-elem-id-init-exhausted.js new file mode 100644 index 0000000000..6ed7902b3e --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-elem-id-init-exhausted.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-exhausted.case +// - src/dstr-binding/default/cls-decl-gen-meth-dflt.template +/*--- +description: Destructuring initializer with an exhausted iterator (class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + *method([x = 23] = []) { + assert.sameValue(x, 23); + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-arrow.js b/test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-arrow.js new file mode 100644 index 0000000000..3e2d646a17 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-arrow.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-arrow.case +// - src/dstr-binding/default/cls-decl-gen-meth-dflt.template +/*--- +description: SingleNameBinding does assign name to arrow functions (class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + *method([arrow = () => {}] = []) { + assert.sameValue(arrow.name, 'arrow'); + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-class.js b/test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-class.js new file mode 100644 index 0000000000..3d993f32f3 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-class.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-class.case +// - src/dstr-binding/default/cls-decl-gen-meth-dflt.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + *method([cls = class {}, xCls = class X {}] = []) { + assert.sameValue(cls.name, 'cls'); + assert.notSameValue(xCls.name, 'xCls'); + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-cover.js b/test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-cover.js new file mode 100644 index 0000000000..4b224eb5d5 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-cover.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-cover.case +// - src/dstr-binding/default/cls-decl-gen-meth-dflt.template +/*--- +description: SingleNameBinding does assign name to "anonymous" functions "through" cover grammar (class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + *method([cover = (function () {}), xCover = (0, function() {})] = []) { + assert.sameValue(cover.name, 'cover'); + assert.notSameValue(xCover.name, 'xCover'); + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-fn.js b/test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-fn.js new file mode 100644 index 0000000000..be878d1fd4 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-fn.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-fn.case +// - src/dstr-binding/default/cls-decl-gen-meth-dflt.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + *method([fn = function () {}, xFn = function x() {}] = []) { + assert.sameValue(fn.name, 'fn'); + assert.notSameValue(xFn.name, 'xFn'); + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-gen.js b/test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-gen.js new file mode 100644 index 0000000000..a57729770f --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-elem-id-init-fn-name-gen.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-gen.case +// - src/dstr-binding/default/cls-decl-gen-meth-dflt.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + *method([gen = function* () {}, xGen = function* x() {}] = []) { + assert.sameValue(gen.name, 'gen'); + assert.notSameValue(xGen.name, 'xGen'); + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-elem-id-init-hole.js b/test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-elem-id-init-hole.js new file mode 100644 index 0000000000..f0abc3340c --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-elem-id-init-hole.js @@ -0,0 +1,81 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-hole.case +// - src/dstr-binding/default/cls-decl-gen-meth-dflt.template +/*--- +description: Destructuring initializer with a "hole" (class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + SingleNameBinding : BindingIdentifier Initializeropt + [...] 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + [...] + 7. If environment is undefined, return PutValue(lhs, v). 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + *method([x = 23] = [,]) { + assert.sameValue(x, 23); + // another statement + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-elem-id-init-skipped.js b/test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-elem-id-init-skipped.js new file mode 100644 index 0000000000..c5be49d674 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-elem-id-init-skipped.js @@ -0,0 +1,90 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-skipped.case +// - src/dstr-binding/default/cls-decl-gen-meth-dflt.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var callCount = 0; +class C { + *method([w = counter(), x = counter(), y = counter(), z = counter()] = [null, 0, false, '']) { + assert.sameValue(w, null); + assert.sameValue(x, 0); + assert.sameValue(y, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-elem-id-init-throws.js b/test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-elem-id-init-throws.js new file mode 100644 index 0000000000..5d7f17814c --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-elem-id-init-throws.js @@ -0,0 +1,80 @@ +// 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-gen-meth-dflt.template +/*--- +description: Destructuring initializer returns an abrupt completion (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 { + *method([x = (function() { throw new Test262Error(); })()] = [undefined]) {} +}; +var c = new C(); + +assert.throws(Test262Error, function() { + c.method(); +}); diff --git a/test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-elem-id-init-undef.js b/test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-elem-id-init-undef.js new file mode 100644 index 0000000000..5d78bb294b --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-elem-id-init-undef.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-undef.case +// - src/dstr-binding/default/cls-decl-gen-meth-dflt.template +/*--- +description: Destructuring initializer with an undefined value (class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + *method([x = 23] = [undefined]) { + assert.sameValue(x, 23); + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-elem-id-init-unresolvable.js b/test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-elem-id-init-unresolvable.js new file mode 100644 index 0000000000..4deb19958f --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-elem-id-init-unresolvable.js @@ -0,0 +1,87 @@ +// 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-gen-meth-dflt.template +/*--- +description: Destructuring initializer is an unresolvable reference (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 { + *method([ x = unresolvableReference ] = []) {} +}; +var c = new C(); + +assert.throws(ReferenceError, function() { + c.method(); +}); diff --git a/test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-elem-id-iter-complete.js b/test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-elem-id-iter-complete.js new file mode 100644 index 0000000000..df16b83fd4 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-elem-id-iter-complete.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-complete.case +// - src/dstr-binding/default/cls-decl-gen-meth-dflt.template +/*--- +description: SingleNameBinding when value iteration completes (class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + *method([x] = []) { + assert.sameValue(x, undefined); + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-elem-id-iter-done.js b/test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-elem-id-iter-done.js new file mode 100644 index 0000000000..160066037b --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-elem-id-iter-done.js @@ -0,0 +1,83 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-done.case +// - src/dstr-binding/default/cls-decl-gen-meth-dflt.template +/*--- +description: SingleNameBinding when value iteration was completed previously (class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + *method([_, x] = []) { + assert.sameValue(x, undefined); + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-elem-id-iter-step-err.js b/test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-elem-id-iter-step-err.js new file mode 100644 index 0000000000..3993aafd84 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-elem-id-iter-step-err.js @@ -0,0 +1,88 @@ +// 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-gen-meth-dflt.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 { + *method([x] = g) {} +}; +var c = new C(); + +assert.throws(Test262Error, function() { + c.method(); +}); diff --git a/test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-elem-id-iter-val-err.js b/test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-elem-id-iter-val-err.js new file mode 100644 index 0000000000..4ed92cc891 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-elem-id-iter-val-err.js @@ -0,0 +1,99 @@ +// 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-gen-meth-dflt.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 { + *method([x] = g) {} +}; +var c = new C(); + +assert.throws(Test262Error, function() { + c.method(); +}); diff --git a/test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-elem-id-iter-val.js b/test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-elem-id-iter-val.js new file mode 100644 index 0000000000..aa886dfb03 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-elem-id-iter-val.js @@ -0,0 +1,94 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val.case +// - src/dstr-binding/default/cls-decl-gen-meth-dflt.template +/*--- +description: SingleNameBinding when value iteration was completed previously (class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set + iteratorRecord.[[done]] to true. + iii. ReturnIfAbrupt(v). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + *method([x, y, z] = [1, 2, 3]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 3); + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-elem-obj-id-init.js b/test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-elem-obj-id-init.js new file mode 100644 index 0000000000..b149df6b4b --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-elem-obj-id-init.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-id-init.case +// - src/dstr-binding/default/cls-decl-gen-meth-dflt.template +/*--- +description: BindingElement with object binding pattern and initializer is used (class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +class C { + *method([{ x, y, z } = { x: 44, y: 55, z: 66 }] = []) { + assert.sameValue(x, 44); + assert.sameValue(y, 55); + assert.sameValue(z, 66); + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-elem-obj-id.js b/test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-elem-obj-id.js new file mode 100644 index 0000000000..2404b1a5e2 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-elem-obj-id.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-id.case +// - src/dstr-binding/default/cls-decl-gen-meth-dflt.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +class C { + *method([{ x, y, z } = { x: 44, y: 55, z: 66 }] = [{ x: 11, y: 22, z: 33 }]) { + assert.sameValue(x, 11); + assert.sameValue(y, 22); + assert.sameValue(z, 33); + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-elem-obj-prop-id-init.js b/test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-elem-obj-prop-id-init.js new file mode 100644 index 0000000000..5a7174f0d6 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-elem-obj-prop-id-init.js @@ -0,0 +1,96 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-prop-id-init.case +// - src/dstr-binding/default/cls-decl-gen-meth-dflt.template +/*--- +description: BindingElement with object binding pattern and initializer is used (class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +class C { + *method([{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }] = []) { + assert.sameValue(v, 444); + assert.sameValue(x, 555); + assert.sameValue(z, 666); + + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-elem-obj-prop-id.js b/test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-elem-obj-prop-id.js new file mode 100644 index 0000000000..307e8f716c --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-elem-obj-prop-id.js @@ -0,0 +1,96 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-prop-id.case +// - src/dstr-binding/default/cls-decl-gen-meth-dflt.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +class C { + *method([{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }] = [{ u: 777, w: 888, y: 999 }]) { + assert.sameValue(v, 777); + assert.sameValue(x, 888); + assert.sameValue(z, 999); + + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-elem-obj-val-null.js b/test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-elem-obj-val-null.js new file mode 100644 index 0000000000..c47247518b --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-elem-obj-val-null.js @@ -0,0 +1,89 @@ +// 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-gen-meth-dflt.template +/*--- +description: Nested object destructuring with a null value (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 { + *method([{ x }] = [null]) {} +}; +var c = new C(); + +assert.throws(TypeError, function() { + c.method(); +}); diff --git a/test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-elem-obj-val-undef.js b/test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-elem-obj-val-undef.js new file mode 100644 index 0000000000..ab9cfe873a --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-elem-obj-val-undef.js @@ -0,0 +1,89 @@ +// 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-gen-meth-dflt.template +/*--- +description: Nested object destructuring with a value of `undefined` (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 { + *method([{ x }] = []) {} +}; +var c = new C(); + +assert.throws(TypeError, function() { + c.method(); +}); diff --git a/test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-elision-exhausted.js b/test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-elision-exhausted.js new file mode 100644 index 0000000000..583ccd71f2 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-elision-exhausted.js @@ -0,0 +1,91 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-exhausted.case +// - src/dstr-binding/default/cls-decl-gen-meth-dflt.template +/*--- +description: Elision accepts exhausted iterator (class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [generator, destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + [...] + 2. Return NormalCompletion(empty). + +---*/ +var iter = function*() {}(); +iter.next(); + +var callCount = 0; +class C { + *method([,] = iter) { + + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-elision-step-err.js b/test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-elision-step-err.js new file mode 100644 index 0000000000..b39cc0ffa4 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-elision-step-err.js @@ -0,0 +1,96 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-step-err.case +// - src/dstr-binding/error/cls-decl-gen-meth-dflt.template +/*--- +description: Elision advances iterator and forwards abrupt completions (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [generator, destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 { + *method([,] = iter) {} +}; +var c = new C(); + +assert.throws(Test262Error, function() { + c.method(); +}); + +iter.next(); +assert.sameValue(following, 0, 'Iterator was properly closed.'); diff --git a/test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-elision.js b/test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-elision.js new file mode 100644 index 0000000000..2b30427238 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-elision.js @@ -0,0 +1,100 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision.case +// - src/dstr-binding/default/cls-decl-gen-meth-dflt.template +/*--- +description: Elision advances iterator (class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [generator, destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + 2. Return NormalCompletion(empty). + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var callCount = 0; +class C { + *method([,] = g()) { + assert.sameValue(first, 1); + assert.sameValue(second, 0); + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-empty.js b/test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-empty.js new file mode 100644 index 0000000000..09cb65b879 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-empty.js @@ -0,0 +1,83 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-empty.case +// - src/dstr-binding/default/cls-decl-gen-meth-dflt.template +/*--- +description: No iteration occurs for an "empty" array binding pattern (class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [generators, destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ ] + + 1. Return NormalCompletion(empty). + +---*/ +var iterations = 0; +var iter = function*() { + iterations += 1; +}(); + +var callCount = 0; +class C { + *method([] = iter) { + assert.sameValue(iterations, 0); + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-rest-ary-elem.js b/test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-rest-ary-elem.js new file mode 100644 index 0000000000..5c4624342d --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-rest-ary-elem.js @@ -0,0 +1,107 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-elem.case +// - src/dstr-binding/default/cls-decl-gen-meth-dflt.template +/*--- +description: Rest element containing an array BindingElementList pattern (class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set + iteratorRecord.[[done]] to true. + iii. ReturnIfAbrupt(v). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + *method([...[x, y, z]] = [3, 4, 5]) { + assert.sameValue(x, 3); + assert.sameValue(y, 4); + assert.sameValue(z, 5); + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-rest-ary-elision.js b/test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-rest-ary-elision.js new file mode 100644 index 0000000000..6d22c8fe8f --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-rest-ary-elision.js @@ -0,0 +1,113 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-elision.case +// - src/dstr-binding/default/cls-decl-gen-meth-dflt.template +/*--- +description: Rest element containing an elision (class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [generators, destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + 2. Return NormalCompletion(empty). + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var callCount = 0; +class C { + *method([...[,]] = g()) { + assert.sameValue(first, 1); + assert.sameValue(second, 1); + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-rest-ary-empty.js b/test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-rest-ary-empty.js new file mode 100644 index 0000000000..312248079a --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-rest-ary-empty.js @@ -0,0 +1,96 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-empty.case +// - src/dstr-binding/default/cls-decl-gen-meth-dflt.template +/*--- +description: Rest element containing an "empty" array pattern (class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [generators, destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ ] + + 1. Return NormalCompletion(empty). + +---*/ +var iterations = 0; +var iter = function*() { + iterations += 1; +}(); + +var callCount = 0; +class C { + *method([...[]] = iter) { + assert.sameValue(iterations, 1); + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-rest-ary-rest.js b/test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-rest-ary-rest.js new file mode 100644 index 0000000000..fe29b68ede --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-rest-ary-rest.js @@ -0,0 +1,92 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-rest.case +// - src/dstr-binding/default/cls-decl-gen-meth-dflt.template +/*--- +description: Rest element containing a rest element (class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ +var values = [1, 2, 3]; + +var callCount = 0; +class C { + *method([...[...x]] = values) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 1); + assert.sameValue(x[1], 2); + assert.sameValue(x[2], 3); + assert.notSameValue(x, values); + + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-rest-id-elision-next-err.js b/test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-rest-id-elision-next-err.js new file mode 100644 index 0000000000..6abc67381e --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-rest-id-elision-next-err.js @@ -0,0 +1,82 @@ +// 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-gen-meth-dflt.template +/*--- +description: Rest element following elision elements (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [generators, destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 { + *method([, ...x] = iter) {} +}; +var c = new C(); + +assert.throws(Test262Error, function() { + c.method(); +}); diff --git a/test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-rest-id-elision.js b/test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-rest-id-elision.js new file mode 100644 index 0000000000..343145947f --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-rest-id-elision.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision.case +// - src/dstr-binding/default/cls-decl-gen-meth-dflt.template +/*--- +description: Rest element following elision elements (class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + ArrayBindingPattern : [ Elisionopt BindingRestElement ] + 1. If Elision is present, then + a. Let status be the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with + iteratorRecord as the argument. + b. ReturnIfAbrupt(status). + 2. Return the result of performing IteratorBindingInitialization for + BindingRestElement with iteratorRecord and environment as arguments. +---*/ +var values = [1, 2, 3, 4, 5]; + +var callCount = 0; +class C { + *method([ , , ...x] = values) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 3); + assert.sameValue(x[1], 4); + assert.sameValue(x[2], 5); + assert.notSameValue(x, values); + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-rest-id-exhausted.js b/test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-rest-id-exhausted.js new file mode 100644 index 0000000000..cfaf8ab6d2 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-rest-id-exhausted.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-exhausted.case +// - src/dstr-binding/default/cls-decl-gen-meth-dflt.template +/*--- +description: RestElement applied to an exhausted iterator (class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [Symbol.iterator, destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier, + environment). + 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat, + [...] + b. If iteratorRecord.[[done]] is true, then + i. If environment is undefined, return PutValue(lhs, A). + ii. Return InitializeReferencedBinding(lhs, A). + +---*/ + +var callCount = 0; +class C { + *method([, , ...x] = [1, 2]) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 0); + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-rest-id-iter-step-err.js b/test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-rest-id-iter-step-err.js new file mode 100644 index 0000000000..1ab4a9f499 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-rest-id-iter-step-err.js @@ -0,0 +1,93 @@ +// 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-gen-meth-dflt.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [generators, destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 { + *method([...x] = iter) {} +}; +var c = new C(); + +assert.throws(Test262Error, function() { + c.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-gen-meth-dflt-ary-ptrn-rest-id-iter-val-err.js b/test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-rest-id-iter-val-err.js new file mode 100644 index 0000000000..a54bb04edf --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-rest-id-iter-val-err.js @@ -0,0 +1,95 @@ +// 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-gen-meth-dflt.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [Symbol.iterator, destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 { + *method([...x] = iter) {} +}; +var c = new C(); + +assert.throws(Test262Error, function() { + c.method(); +}); diff --git a/test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-rest-id.js b/test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-rest-id.js new file mode 100644 index 0000000000..8ebe8caca7 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-rest-id.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id.case +// - src/dstr-binding/default/cls-decl-gen-meth-dflt.template +/*--- +description: Lone rest element (class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + [...] 3. Let A be ArrayCreate(0). [...] 5. Repeat + [...] + f. Let status be CreateDataProperty(A, ToString (n), nextValue). + [...] +---*/ +var values = [1, 2, 3]; + +var callCount = 0; +class C { + *method([...x] = values) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 1); + assert.sameValue(x[1], 2); + assert.sameValue(x[2], 3); + assert.notSameValue(x, values); + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-rest-init-ary.js b/test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-rest-init-ary.js new file mode 100644 index 0000000000..5cabe9a492 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-rest-init-ary.js @@ -0,0 +1,79 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-ary.case +// - src/dstr-binding/default/cls-decl-gen-meth-dflt.template +/*--- +description: Reset element (nested array pattern) does not support initializer (class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +negative: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +class C { + *method([...[ x ] = []] = []) { + + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-rest-init-id.js b/test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-rest-init-id.js new file mode 100644 index 0000000000..b915845505 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-rest-init-id.js @@ -0,0 +1,79 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-id.case +// - src/dstr-binding/default/cls-decl-gen-meth-dflt.template +/*--- +description: Reset element (identifier) does not support initializer (class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +negative: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +class C { + *method([...x = []] = []) { + + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-rest-init-obj.js b/test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-rest-init-obj.js new file mode 100644 index 0000000000..142e800d9a --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-rest-init-obj.js @@ -0,0 +1,79 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-obj.case +// - src/dstr-binding/default/cls-decl-gen-meth-dflt.template +/*--- +description: Reset element (nested object pattern) does not support initializer (class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +negative: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +class C { + *method([...{ x } = []] = []) { + + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-rest-not-final-ary.js b/test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-rest-not-final-ary.js new file mode 100644 index 0000000000..2d9fb7cbf3 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-rest-not-final-ary.js @@ -0,0 +1,79 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-ary.case +// - src/dstr-binding/default/cls-decl-gen-meth-dflt.template +/*--- +description: Rest element (array binding pattern) may not be followed by any element (class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +negative: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +class C { + *method([...[x], y] = [1, 2, 3]) { + + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-rest-not-final-id.js b/test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-rest-not-final-id.js new file mode 100644 index 0000000000..5492d74aec --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-rest-not-final-id.js @@ -0,0 +1,79 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-id.case +// - src/dstr-binding/default/cls-decl-gen-meth-dflt.template +/*--- +description: Rest element (identifier) may not be followed by any element (class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +negative: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +class C { + *method([...x, y] = [1, 2, 3]) { + + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-rest-not-final-obj.js b/test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-rest-not-final-obj.js new file mode 100644 index 0000000000..fc802c0f8d --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-rest-not-final-obj.js @@ -0,0 +1,79 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-obj.case +// - src/dstr-binding/default/cls-decl-gen-meth-dflt.template +/*--- +description: Rest element (object binding pattern) may not be followed by any element (class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +flags: [generated] +negative: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +class C { + *method([...{ x }, y] = [1, 2, 3]) { + + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-rest-obj-id.js b/test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-rest-obj-id.js new file mode 100644 index 0000000000..91c799be32 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-rest-obj-id.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-obj-id.case +// - src/dstr-binding/default/cls-decl-gen-meth-dflt.template +/*--- +description: Rest element containing an object binding pattern (class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ + +var callCount = 0; +class C { + *method([...{ length }] = [1, 2, 3]) { + assert.sameValue(length, 3); + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-rest-obj-prop-id.js b/test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-rest-obj-prop-id.js new file mode 100644 index 0000000000..112830090b --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-dflt-ary-ptrn-rest-obj-prop-id.js @@ -0,0 +1,93 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-obj-prop-id.case +// - src/dstr-binding/default/cls-decl-gen-meth-dflt.template +/*--- +description: Rest element containing an object binding pattern (class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ + +var callCount = 0; +class C { + *method([...{ 0: v, 1: w, 2: x, 3: y, length: z }] = [7, 8, 9]) { + assert.sameValue(v, 7); + assert.sameValue(w, 8); + assert.sameValue(x, 9); + assert.sameValue(y, undefined); + assert.sameValue(z, 3); + + assert.throws(ReferenceError, function() { + length; + }); + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-dflt-obj-init-null.js b/test/language/statements/class/dstr-gen-meth-dflt-obj-init-null.js new file mode 100644 index 0000000000..b56c1afa56 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-dflt-obj-init-null.js @@ -0,0 +1,76 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-null.case +// - src/dstr-binding/error/cls-decl-gen-meth-dflt.template +/*--- +description: Value specifed for object binding pattern must be object coercible (null) (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + +class C { + *method({} = null) {} +}; +var c = new C(); + +assert.throws(TypeError, function() { + c.method(); +}); diff --git a/test/language/statements/class/dstr-gen-meth-dflt-obj-init-undefined.js b/test/language/statements/class/dstr-gen-meth-dflt-obj-init-undefined.js new file mode 100644 index 0000000000..3fdb2a2277 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-dflt-obj-init-undefined.js @@ -0,0 +1,76 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-undefined.case +// - src/dstr-binding/error/cls-decl-gen-meth-dflt.template +/*--- +description: Value specifed for object binding pattern must be object coercible (undefined) (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + +class C { + *method({} = undefined) {} +}; +var c = new C(); + +assert.throws(TypeError, function() { + c.method(); +}); diff --git a/test/language/statements/class/dstr-gen-meth-dflt-obj-ptrn-empty.js b/test/language/statements/class/dstr-gen-meth-dflt-obj-ptrn-empty.js new file mode 100644 index 0000000000..b1f09a2674 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-dflt-obj-ptrn-empty.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-empty.case +// - src/dstr-binding/default/cls-decl-gen-meth-dflt.template +/*--- +description: No property access occurs for an "empty" object binding pattern (class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ +var accessCount = 0; +var obj = Object.defineProperty({}, 'attr', { + get: function() { + accessCount += 1; + } +}); + +var callCount = 0; +class C { + *method({} = obj) { + assert.sameValue(accessCount, 0); + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-dflt-obj-ptrn-id-get-value-err.js b/test/language/statements/class/dstr-gen-meth-dflt-obj-ptrn-id-get-value-err.js new file mode 100644 index 0000000000..a57087e8fb --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-dflt-obj-ptrn-id-get-value-err.js @@ -0,0 +1,83 @@ +// 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-gen-meth-dflt.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 { + *method({ poisoned } = poisonedProperty) {} +}; +var c = new C(); + +assert.throws(Test262Error, function() { + c.method(); +}); diff --git a/test/language/statements/class/dstr-gen-meth-dflt-obj-ptrn-id-init-fn-name-arrow.js b/test/language/statements/class/dstr-gen-meth-dflt-obj-ptrn-id-init-fn-name-arrow.js new file mode 100644 index 0000000000..e6a99275dd --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-dflt-obj-ptrn-id-init-fn-name-arrow.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-arrow.case +// - src/dstr-binding/default/cls-decl-gen-meth-dflt.template +/*--- +description: SingleNameBinding assigns `name` to arrow functions (class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +class C { + *method({ arrow = () => {} } = {}) { + assert.sameValue(arrow.name, 'arrow'); + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-dflt-obj-ptrn-id-init-fn-name-class.js b/test/language/statements/class/dstr-gen-meth-dflt-obj-ptrn-id-init-fn-name-class.js new file mode 100644 index 0000000000..46aa7918fa --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-dflt-obj-ptrn-id-init-fn-name-class.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-class.case +// - src/dstr-binding/default/cls-decl-gen-meth-dflt.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +class C { + *method({ cls = class {}, xCls = class X {} } = {}) { + assert.sameValue(cls.name, 'cls'); + assert.notSameValue(xCls.name, 'xCls'); + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-dflt-obj-ptrn-id-init-fn-name-cover.js b/test/language/statements/class/dstr-gen-meth-dflt-obj-ptrn-id-init-fn-name-cover.js new file mode 100644 index 0000000000..bea1d40ffd --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-dflt-obj-ptrn-id-init-fn-name-cover.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-cover.case +// - src/dstr-binding/default/cls-decl-gen-meth-dflt.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" functions "through" cover grammar (class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +class C { + *method({ cover = (function () {}), xCover = (0, function() {}) } = {}) { + assert.sameValue(cover.name, 'cover'); + assert.notSameValue(xCover.name, 'xCover'); + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-dflt-obj-ptrn-id-init-fn-name-fn.js b/test/language/statements/class/dstr-gen-meth-dflt-obj-ptrn-id-init-fn-name-fn.js new file mode 100644 index 0000000000..e041b88c36 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-dflt-obj-ptrn-id-init-fn-name-fn.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-fn.case +// - src/dstr-binding/default/cls-decl-gen-meth-dflt.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +class C { + *method({ fn = function () {}, xFn = function x() {} } = {}) { + assert.sameValue(fn.name, 'fn'); + assert.notSameValue(xFn.name, 'xFn'); + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-dflt-obj-ptrn-id-init-fn-name-gen.js b/test/language/statements/class/dstr-gen-meth-dflt-obj-ptrn-id-init-fn-name-gen.js new file mode 100644 index 0000000000..1b202b57f4 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-dflt-obj-ptrn-id-init-fn-name-gen.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-gen.case +// - src/dstr-binding/default/cls-decl-gen-meth-dflt.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +class C { + *method({ gen = function* () {}, xGen = function* x() {} } = {}) { + assert.sameValue(gen.name, 'gen'); + assert.notSameValue(xGen.name, 'xGen'); + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-dflt-obj-ptrn-id-init-skipped.js b/test/language/statements/class/dstr-gen-meth-dflt-obj-ptrn-id-init-skipped.js new file mode 100644 index 0000000000..b37d0b7e4b --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-dflt-obj-ptrn-id-init-skipped.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-skipped.case +// - src/dstr-binding/default/cls-decl-gen-meth-dflt.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + [...] +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var callCount = 0; +class C { + *method({ w = counter(), x = counter(), y = counter(), z = counter() } = { w: null, x: 0, y: false, z: '' }) { + assert.sameValue(w, null); + assert.sameValue(x, 0); + assert.sameValue(y, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-dflt-obj-ptrn-id-init-throws.js b/test/language/statements/class/dstr-gen-meth-dflt-obj-ptrn-id-init-throws.js new file mode 100644 index 0000000000..ea00ae2aca --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-dflt-obj-ptrn-id-init-throws.js @@ -0,0 +1,83 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-throws.case +// - src/dstr-binding/error/cls-decl-gen-meth-dflt.template +/*--- +description: Error thrown when evaluating the initializer (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 { + *method({ x = thrower() } = {}) {} +}; +var c = new C(); + +assert.throws(Test262Error, function() { + c.method(); +}); diff --git a/test/language/statements/class/dstr-gen-meth-dflt-obj-ptrn-id-init-unresolvable.js b/test/language/statements/class/dstr-gen-meth-dflt-obj-ptrn-id-init-unresolvable.js new file mode 100644 index 0000000000..041425052c --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-dflt-obj-ptrn-id-init-unresolvable.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-unresolvable.case +// - src/dstr-binding/error/cls-decl-gen-meth-dflt.template +/*--- +description: Destructuring initializer is an unresolvable reference (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 { + *method({ x = unresolvableReference } = {}) {} +}; +var c = new C(); + +assert.throws(ReferenceError, function() { + c.method(); +}); diff --git a/test/language/statements/class/dstr-gen-meth-dflt-obj-ptrn-id-trailing-comma.js b/test/language/statements/class/dstr-gen-meth-dflt-obj-ptrn-id-trailing-comma.js new file mode 100644 index 0000000000..0d2be4c769 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-dflt-obj-ptrn-id-trailing-comma.js @@ -0,0 +1,79 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-trailing-comma.case +// - src/dstr-binding/default/cls-decl-gen-meth-dflt.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var callCount = 0; +class C { + *method({ x, } = { x: 23 }) { + assert.sameValue(x, 23); + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-dflt-obj-ptrn-list-err.js b/test/language/statements/class/dstr-gen-meth-dflt-obj-ptrn-list-err.js new file mode 100644 index 0000000000..1d7ef5922a --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-dflt-obj-ptrn-list-err.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-list-err.case +// - src/dstr-binding/error/cls-decl-gen-meth-dflt.template +/*--- +description: Binding property list evaluation is interrupted by an abrupt completion (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 { + *method({ a, b = thrower(), c = ++initCount } = {}) {} +}; +var c = new C(); + +assert.throws(Test262Error, function() { + c.method(); +}); + +assert.sameValue(initCount, 0); diff --git a/test/language/statements/class/dstr-gen-meth-dflt-obj-ptrn-prop-ary-init.js b/test/language/statements/class/dstr-gen-meth-dflt-obj-ptrn-prop-ary-init.js new file mode 100644 index 0000000000..2ebe8b030e --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-dflt-obj-ptrn-prop-ary-init.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-init.case +// - src/dstr-binding/default/cls-decl-gen-meth-dflt.template +/*--- +description: Object binding pattern with "nested" array binding pattern using initializer (class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +class C { + *method({ w: [x, y, z] = [4, 5, 6] } = {}) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-dflt-obj-ptrn-prop-ary-trailing-comma.js b/test/language/statements/class/dstr-gen-meth-dflt-obj-ptrn-prop-ary-trailing-comma.js new file mode 100644 index 0000000000..e05985d3ec --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-dflt-obj-ptrn-prop-ary-trailing-comma.js @@ -0,0 +1,79 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-trailing-comma.case +// - src/dstr-binding/default/cls-decl-gen-meth-dflt.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var callCount = 0; +class C { + *method({ x: [y], } = { x: [45] }) { + assert.sameValue(y,45); + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-dflt-obj-ptrn-prop-ary-value-null.js b/test/language/statements/class/dstr-gen-meth-dflt-obj-ptrn-prop-ary-value-null.js new file mode 100644 index 0000000000..57ec5d5cdd --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-dflt-obj-ptrn-prop-ary-value-null.js @@ -0,0 +1,78 @@ +// 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-gen-meth-dflt.template +/*--- +description: Object binding pattern with "nested" array binding pattern taking the `null` value (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 { + *method({ w: [x, y, z] = [4, 5, 6] } = { w: null }) {} +}; +var c = new C(); + +assert.throws(TypeError, function() { + c.method(); +}); diff --git a/test/language/statements/class/dstr-gen-meth-dflt-obj-ptrn-prop-ary.js b/test/language/statements/class/dstr-gen-meth-dflt-obj-ptrn-prop-ary.js new file mode 100644 index 0000000000..14485d0dc7 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-dflt-obj-ptrn-prop-ary.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary.case +// - src/dstr-binding/default/cls-decl-gen-meth-dflt.template +/*--- +description: Object binding pattern with "nested" array binding pattern not using initializer (class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +class C { + *method({ w: [x, y, z] = [4, 5, 6] } = { w: [7, undefined, ] }) { + assert.sameValue(x, 7); + assert.sameValue(y, undefined); + assert.sameValue(z, undefined); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-dflt-obj-ptrn-prop-eval-err.js b/test/language/statements/class/dstr-gen-meth-dflt-obj-ptrn-prop-eval-err.js new file mode 100644 index 0000000000..019a247989 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-dflt-obj-ptrn-prop-eval-err.js @@ -0,0 +1,80 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-eval-err.case +// - src/dstr-binding/error/cls-decl-gen-meth-dflt.template +/*--- +description: Evaluation of property name returns an abrupt completion (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 { + *method({ [thrower()]: x } = {}) {} +}; +var c = new C(); + +assert.throws(Test262Error, function() { + c.method(); +}); diff --git a/test/language/statements/class/dstr-gen-meth-dflt-obj-ptrn-prop-id-get-value-err.js b/test/language/statements/class/dstr-gen-meth-dflt-obj-ptrn-prop-id-get-value-err.js new file mode 100644 index 0000000000..b24624bb5f --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-dflt-obj-ptrn-prop-id-get-value-err.js @@ -0,0 +1,85 @@ +// 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-gen-meth-dflt.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 { + *method({ poisoned: x = ++initEvalCount } = poisonedProperty) {} +}; +var c = new C(); + +assert.throws(Test262Error, function() { + c.method(); +}); + +assert.sameValue(initEvalCount, 0); diff --git a/test/language/statements/class/dstr-gen-meth-dflt-obj-ptrn-prop-id-init-skipped.js b/test/language/statements/class/dstr-gen-meth-dflt-obj-ptrn-prop-id-init-skipped.js new file mode 100644 index 0000000000..e2aaa500dd --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-dflt-obj-ptrn-prop-id-init-skipped.js @@ -0,0 +1,101 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-skipped.case +// - src/dstr-binding/default/cls-decl-gen-meth-dflt.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + [...] +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var callCount = 0; +class C { + *method({ s: t = counter(), u: v = counter(), w: x = counter(), y: z = counter() } = { s: null, u: 0, w: false, y: '' }) { + assert.sameValue(t, null); + assert.sameValue(v, 0); + assert.sameValue(x, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + + assert.throws(ReferenceError, function() { + s; + }); + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-dflt-obj-ptrn-prop-id-init-throws.js b/test/language/statements/class/dstr-gen-meth-dflt-obj-ptrn-prop-id-init-throws.js new file mode 100644 index 0000000000..105c76a4d5 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-dflt-obj-ptrn-prop-id-init-throws.js @@ -0,0 +1,83 @@ +// 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-gen-meth-dflt.template +/*--- +description: Error thrown when evaluating the initializer (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 { + *method({ x: y = thrower() } = {}) {} +}; +var c = new C(); + +assert.throws(Test262Error, function() { + c.method(); +}); diff --git a/test/language/statements/class/dstr-gen-meth-dflt-obj-ptrn-prop-id-init-unresolvable.js b/test/language/statements/class/dstr-gen-meth-dflt-obj-ptrn-prop-id-init-unresolvable.js new file mode 100644 index 0000000000..abad384f72 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-dflt-obj-ptrn-prop-id-init-unresolvable.js @@ -0,0 +1,87 @@ +// 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-gen-meth-dflt.template +/*--- +description: Destructuring initializer is an unresolvable reference (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 { + *method({ x: y = unresolvableReference } = {}) {} +}; +var c = new C(); + +assert.throws(ReferenceError, function() { + c.method(); +}); diff --git a/test/language/statements/class/dstr-gen-meth-dflt-obj-ptrn-prop-id-init.js b/test/language/statements/class/dstr-gen-meth-dflt-obj-ptrn-prop-id-init.js new file mode 100644 index 0000000000..ebbcd496e8 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-dflt-obj-ptrn-prop-id-init.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init.case +// - src/dstr-binding/default/cls-decl-gen-meth-dflt.template +/*--- +description: Binding as specified via property name, identifier, and initializer (class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + *method({ x: y = 33 } = { }) { + assert.sameValue(y, 33); + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-dflt-obj-ptrn-prop-id-trailing-comma.js b/test/language/statements/class/dstr-gen-meth-dflt-obj-ptrn-prop-id-trailing-comma.js new file mode 100644 index 0000000000..02d1d9e588 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-dflt-obj-ptrn-prop-id-trailing-comma.js @@ -0,0 +1,83 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-trailing-comma.case +// - src/dstr-binding/default/cls-decl-gen-meth-dflt.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var callCount = 0; +class C { + *method({ x: y, } = { x: 23 }) { + assert.sameValue(y, 23); + + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-dflt-obj-ptrn-prop-id.js b/test/language/statements/class/dstr-gen-meth-dflt-obj-ptrn-prop-id.js new file mode 100644 index 0000000000..2999a988c5 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-dflt-obj-ptrn-prop-id.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id.case +// - src/dstr-binding/default/cls-decl-gen-meth-dflt.template +/*--- +description: Binding as specified via property name and identifier (class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + *method({ x: y } = { x: 23 }) { + assert.sameValue(y, 23); + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-dflt-obj-ptrn-prop-obj-init.js b/test/language/statements/class/dstr-gen-meth-dflt-obj-ptrn-prop-obj-init.js new file mode 100644 index 0000000000..8ee3d8341c --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-dflt-obj-ptrn-prop-obj-init.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-init.case +// - src/dstr-binding/default/cls-decl-gen-meth-dflt.template +/*--- +description: Object binding pattern with "nested" object binding pattern using initializer (class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +class C { + *method({ w: { x, y, z } = { x: 4, y: 5, z: 6 } } = { w: undefined }) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-dflt-obj-ptrn-prop-obj-value-null.js b/test/language/statements/class/dstr-gen-meth-dflt-obj-ptrn-prop-obj-value-null.js new file mode 100644 index 0000000000..acc6a814e3 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-dflt-obj-ptrn-prop-obj-value-null.js @@ -0,0 +1,78 @@ +// 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-gen-meth-dflt.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 { + *method({ w: { x, y, z } = { x: 4, y: 5, z: 6 } } = { w: null }) {} +}; +var c = new C(); + +assert.throws(TypeError, function() { + c.method(); +}); diff --git a/test/language/statements/class/dstr-gen-meth-dflt-obj-ptrn-prop-obj-value-undef.js b/test/language/statements/class/dstr-gen-meth-dflt-obj-ptrn-prop-obj-value-undef.js new file mode 100644 index 0000000000..472e7a211a --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-dflt-obj-ptrn-prop-obj-value-undef.js @@ -0,0 +1,78 @@ +// 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-gen-meth-dflt.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (class expression method (default parameter)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 { + *method({ w: { x, y, z } = undefined } = { }) {} +}; +var c = new C(); + +assert.throws(TypeError, function() { + c.method(); +}); diff --git a/test/language/statements/class/dstr-gen-meth-dflt-obj-ptrn-prop-obj.js b/test/language/statements/class/dstr-gen-meth-dflt-obj-ptrn-prop-obj.js new file mode 100644 index 0000000000..ad03ed484f --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-dflt-obj-ptrn-prop-obj.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj.case +// - src/dstr-binding/default/cls-decl-gen-meth-dflt.template +/*--- +description: Object binding pattern with "nested" object binding pattern not using initializer (class expression method (default parameters)) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +class C { + *method({ w: { x, y, z } = { x: 4, y: 5, z: 6 } } = { w: { x: undefined, z: 7 } }) { + assert.sameValue(x, undefined); + assert.sameValue(y, undefined); + assert.sameValue(z, 7); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } +}; + +new C().method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-static-dflt-ary-init-iter-close.js b/test/language/statements/class/dstr-gen-meth-static-dflt-ary-init-iter-close.js new file mode 100644 index 0000000000..e6f8e72dea --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-dflt-ary-init-iter-close.js @@ -0,0 +1,95 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-close.case +// - src/dstr-binding/default/cls-decl-gen-meth-static-dflt.template +/*--- +description: Iterator is closed when not exhausted by pattern evaluation (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [Symbol.iterator, destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + [...] + 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator, + result). + [...] + +---*/ +var doneCallCount = 0; +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return { value: null, done: false }; + }, + return: function() { + doneCallCount += 1; + return {}; + } + }; +}; + +var callCount = 0; +class C { + static *method([x] = iter) { + assert.sameValue(doneCallCount, 1); + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-static-dflt-ary-init-iter-get-err.js b/test/language/statements/class/dstr-gen-meth-static-dflt-ary-init-iter-get-err.js new file mode 100644 index 0000000000..d5417e4b3f --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-dflt-ary-init-iter-get-err.js @@ -0,0 +1,81 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-get-err.case +// - src/dstr-binding/error/cls-decl-gen-meth-static-dflt.template +/*--- +description: Abrupt completion returned by GetIterator (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [Symbol.iterator, destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 *method([x] = iter) {} +}; + +assert.throws(Test262Error, function() { + C.method(); +}); diff --git a/test/language/statements/class/dstr-gen-meth-static-dflt-ary-init-iter-no-close.js b/test/language/statements/class/dstr-gen-meth-static-dflt-ary-init-iter-no-close.js new file mode 100644 index 0000000000..16e1ca43a7 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-dflt-ary-init-iter-no-close.js @@ -0,0 +1,95 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-no-close.case +// - src/dstr-binding/default/cls-decl-gen-meth-static-dflt.template +/*--- +description: Iterator is not closed when exhausted by pattern evaluation (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [Symbol.iterator, destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + [...] + 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator, + result). + [...] + +---*/ +var doneCallCount = 0; +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return { value: null, done: true }; + }, + return: function() { + doneCallCount += 1; + return {}; + } + }; +}; + +var callCount = 0; +class C { + static *method([x] = iter) { + assert.sameValue(doneCallCount, 0); + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-static-dflt-ary-name-iter-val.js b/test/language/statements/class/dstr-gen-meth-static-dflt-ary-name-iter-val.js new file mode 100644 index 0000000000..99efc01cc5 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-dflt-ary-name-iter-val.js @@ -0,0 +1,94 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-name-iter-val.case +// - src/dstr-binding/default/cls-decl-gen-meth-static-dflt.template +/*--- +description: SingleNameBinding with normal value iteration (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set + iteratorRecord.[[done]] to true. + iii. ReturnIfAbrupt(v). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static *method([x, y, z] = [1, 2, 3]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 3); + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-ary-elem-init.js b/test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-ary-elem-init.js new file mode 100644 index 0000000000..ceb7a1f133 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-ary-elem-init.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elem-init.case +// - src/dstr-binding/default/cls-decl-gen-meth-static-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is used (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +class C { + static *method([[x, y, z] = [4, 5, 6]] = []) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-ary-elem-iter.js b/test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-ary-elem-iter.js new file mode 100644 index 0000000000..06e15c4688 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-ary-elem-iter.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elem-iter.case +// - src/dstr-binding/default/cls-decl-gen-meth-static-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +class C { + static *method([[x, y, z] = [4, 5, 6]] = [[7, 8, 9]]) { + assert.sameValue(x, 7); + assert.sameValue(y, 8); + assert.sameValue(z, 9); + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-ary-elision-init.js b/test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-ary-elision-init.js new file mode 100644 index 0000000000..54d83012c9 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-ary-elision-init.js @@ -0,0 +1,93 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elision-init.case +// - src/dstr-binding/default/cls-decl-gen-meth-static-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is used (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [generators, destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var callCount = 0; +class C { + static *method([[,] = g()] = []) { + assert.sameValue(first, 1); + assert.sameValue(second, 0); + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-ary-elision-iter.js b/test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-ary-elision-iter.js new file mode 100644 index 0000000000..33056cd443 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-ary-elision-iter.js @@ -0,0 +1,90 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elision-iter.case +// - src/dstr-binding/default/cls-decl-gen-meth-static-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [generators, destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var callCount = 0; +function* g() { + callCount += 1; +}; + +var callCount = 0; +class C { + static *method([[,] = g()] = [[]]) { + assert.sameValue(callCount, 0); + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-ary-empty-init.js b/test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-ary-empty-init.js new file mode 100644 index 0000000000..407aa1c06e --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-ary-empty-init.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-empty-init.case +// - src/dstr-binding/default/cls-decl-gen-meth-static-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is used (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var initCount = 0; +var iterCount = 0; +var iter = function*() { iterCount += 1; }(); + +var callCount = 0; +class C { + static *method([[] = function() { initCount += 1; return iter; }()] = []) { + assert.sameValue(initCount, 1); + assert.sameValue(iterCount, 0); + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-ary-empty-iter.js b/test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-ary-empty-iter.js new file mode 100644 index 0000000000..f644b0d648 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-ary-empty-iter.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-empty-iter.case +// - src/dstr-binding/default/cls-decl-gen-meth-static-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var initCount = 0; + +var callCount = 0; +class C { + static *method([[] = function() { initCount += 1; }()] = [[23]]) { + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-ary-rest-init.js b/test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-ary-rest-init.js new file mode 100644 index 0000000000..c2fbe5573e --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-ary-rest-init.js @@ -0,0 +1,90 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-rest-init.case +// - src/dstr-binding/default/cls-decl-gen-meth-static-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is used (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var values = [2, 1, 3]; + +var callCount = 0; +class C { + static *method([[...x] = values] = []) { + assert(Array.isArray(x)); + assert.sameValue(x[0], 2); + assert.sameValue(x[1], 1); + assert.sameValue(x[2], 3); + assert.sameValue(x.length, 3); + assert.notSameValue(x, values); + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-ary-rest-iter.js b/test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-ary-rest-iter.js new file mode 100644 index 0000000000..60f44a6adb --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-ary-rest-iter.js @@ -0,0 +1,93 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-rest-iter.case +// - src/dstr-binding/default/cls-decl-gen-meth-static-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var values = [2, 1, 3]; +var initCount = 0; + +var callCount = 0; +class C { + static *method([[...x] = function() { initCount += 1; }()] = [values]) { + assert(Array.isArray(x)); + assert.sameValue(x[0], 2); + assert.sameValue(x[1], 1); + assert.sameValue(x[2], 3); + assert.sameValue(x.length, 3); + assert.notSameValue(x, values); + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-ary-val-null.js b/test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-ary-val-null.js new file mode 100644 index 0000000000..feab2bd52a --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-ary-val-null.js @@ -0,0 +1,88 @@ +// 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-gen-meth-static-dflt.template +/*--- +description: Nested array destructuring with a null value (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 *method([[x]] = [null]) {} +}; + +assert.throws(TypeError, function() { + C.method(); +}); diff --git a/test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-id-init-exhausted.js b/test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-id-init-exhausted.js new file mode 100644 index 0000000000..b9d89f3feb --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-id-init-exhausted.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-exhausted.case +// - src/dstr-binding/default/cls-decl-gen-meth-static-dflt.template +/*--- +description: Destructuring initializer with an exhausted iterator (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static *method([x = 23] = []) { + assert.sameValue(x, 23); + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-arrow.js b/test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-arrow.js new file mode 100644 index 0000000000..af71786720 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-arrow.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-arrow.case +// - src/dstr-binding/default/cls-decl-gen-meth-static-dflt.template +/*--- +description: SingleNameBinding does assign name to arrow functions (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static *method([arrow = () => {}] = []) { + assert.sameValue(arrow.name, 'arrow'); + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-class.js b/test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-class.js new file mode 100644 index 0000000000..05d8fa2bf4 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-class.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-class.case +// - src/dstr-binding/default/cls-decl-gen-meth-static-dflt.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static *method([cls = class {}, xCls = class X {}] = []) { + assert.sameValue(cls.name, 'cls'); + assert.notSameValue(xCls.name, 'xCls'); + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-cover.js b/test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-cover.js new file mode 100644 index 0000000000..37efaf04a3 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-cover.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-cover.case +// - src/dstr-binding/default/cls-decl-gen-meth-static-dflt.template +/*--- +description: SingleNameBinding does assign name to "anonymous" functions "through" cover grammar (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static *method([cover = (function () {}), xCover = (0, function() {})] = []) { + assert.sameValue(cover.name, 'cover'); + assert.notSameValue(xCover.name, 'xCover'); + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-fn.js b/test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-fn.js new file mode 100644 index 0000000000..b54f0c961d --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-fn.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-fn.case +// - src/dstr-binding/default/cls-decl-gen-meth-static-dflt.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static *method([fn = function () {}, xFn = function x() {}] = []) { + assert.sameValue(fn.name, 'fn'); + assert.notSameValue(xFn.name, 'xFn'); + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-gen.js b/test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-gen.js new file mode 100644 index 0000000000..80835c85b4 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-gen.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-gen.case +// - src/dstr-binding/default/cls-decl-gen-meth-static-dflt.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static *method([gen = function* () {}, xGen = function* x() {}] = []) { + assert.sameValue(gen.name, 'gen'); + assert.notSameValue(xGen.name, 'xGen'); + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-id-init-hole.js b/test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-id-init-hole.js new file mode 100644 index 0000000000..32d4cabcb6 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-id-init-hole.js @@ -0,0 +1,81 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-hole.case +// - src/dstr-binding/default/cls-decl-gen-meth-static-dflt.template +/*--- +description: Destructuring initializer with a "hole" (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + SingleNameBinding : BindingIdentifier Initializeropt + [...] 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + [...] + 7. If environment is undefined, return PutValue(lhs, v). 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static *method([x = 23] = [,]) { + assert.sameValue(x, 23); + // another statement + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-id-init-skipped.js b/test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-id-init-skipped.js new file mode 100644 index 0000000000..8d141b7777 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-id-init-skipped.js @@ -0,0 +1,90 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-skipped.case +// - src/dstr-binding/default/cls-decl-gen-meth-static-dflt.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var callCount = 0; +class C { + static *method([w = counter(), x = counter(), y = counter(), z = counter()] = [null, 0, false, '']) { + assert.sameValue(w, null); + assert.sameValue(x, 0); + assert.sameValue(y, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-id-init-throws.js b/test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-id-init-throws.js new file mode 100644 index 0000000000..ff4f0b188f --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-id-init-throws.js @@ -0,0 +1,79 @@ +// 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-gen-meth-static-dflt.template +/*--- +description: Destructuring initializer returns an abrupt completion (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 *method([x = (function() { throw new Test262Error(); })()] = [undefined]) {} +}; + +assert.throws(Test262Error, function() { + C.method(); +}); diff --git a/test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-id-init-undef.js b/test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-id-init-undef.js new file mode 100644 index 0000000000..759006d0ad --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-id-init-undef.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-undef.case +// - src/dstr-binding/default/cls-decl-gen-meth-static-dflt.template +/*--- +description: Destructuring initializer with an undefined value (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static *method([x = 23] = [undefined]) { + assert.sameValue(x, 23); + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-id-init-unresolvable.js b/test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-id-init-unresolvable.js new file mode 100644 index 0000000000..5d1b958b80 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-id-init-unresolvable.js @@ -0,0 +1,86 @@ +// 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-gen-meth-static-dflt.template +/*--- +description: Destructuring initializer is an unresolvable reference (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 *method([ x = unresolvableReference ] = []) {} +}; + +assert.throws(ReferenceError, function() { + C.method(); +}); diff --git a/test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-id-iter-complete.js b/test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-id-iter-complete.js new file mode 100644 index 0000000000..fb97f6cd28 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-id-iter-complete.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-complete.case +// - src/dstr-binding/default/cls-decl-gen-meth-static-dflt.template +/*--- +description: SingleNameBinding when value iteration completes (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static *method([x] = []) { + assert.sameValue(x, undefined); + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-id-iter-done.js b/test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-id-iter-done.js new file mode 100644 index 0000000000..d8915ed63e --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-id-iter-done.js @@ -0,0 +1,83 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-done.case +// - src/dstr-binding/default/cls-decl-gen-meth-static-dflt.template +/*--- +description: SingleNameBinding when value iteration was completed previously (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static *method([_, x] = []) { + assert.sameValue(x, undefined); + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-id-iter-step-err.js b/test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-id-iter-step-err.js new file mode 100644 index 0000000000..6313d6eb5c --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-id-iter-step-err.js @@ -0,0 +1,87 @@ +// 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-gen-meth-static-dflt.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 *method([x] = g) {} +}; + +assert.throws(Test262Error, function() { + C.method(); +}); diff --git a/test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-id-iter-val-err.js b/test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-id-iter-val-err.js new file mode 100644 index 0000000000..4cfa6b8fee --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-id-iter-val-err.js @@ -0,0 +1,98 @@ +// 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-gen-meth-static-dflt.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 *method([x] = g) {} +}; + +assert.throws(Test262Error, function() { + C.method(); +}); diff --git a/test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-id-iter-val.js b/test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-id-iter-val.js new file mode 100644 index 0000000000..8034693be0 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-id-iter-val.js @@ -0,0 +1,94 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val.case +// - src/dstr-binding/default/cls-decl-gen-meth-static-dflt.template +/*--- +description: SingleNameBinding when value iteration was completed previously (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set + iteratorRecord.[[done]] to true. + iii. ReturnIfAbrupt(v). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static *method([x, y, z] = [1, 2, 3]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 3); + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-obj-id-init.js b/test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-obj-id-init.js new file mode 100644 index 0000000000..5752ac8265 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-obj-id-init.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-id-init.case +// - src/dstr-binding/default/cls-decl-gen-meth-static-dflt.template +/*--- +description: BindingElement with object binding pattern and initializer is used (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +class C { + static *method([{ x, y, z } = { x: 44, y: 55, z: 66 }] = []) { + assert.sameValue(x, 44); + assert.sameValue(y, 55); + assert.sameValue(z, 66); + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-obj-id.js b/test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-obj-id.js new file mode 100644 index 0000000000..b4292842ca --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-obj-id.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-id.case +// - src/dstr-binding/default/cls-decl-gen-meth-static-dflt.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +class C { + static *method([{ x, y, z } = { x: 44, y: 55, z: 66 }] = [{ x: 11, y: 22, z: 33 }]) { + assert.sameValue(x, 11); + assert.sameValue(y, 22); + assert.sameValue(z, 33); + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-obj-prop-id-init.js b/test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-obj-prop-id-init.js new file mode 100644 index 0000000000..5f22ddd1de --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-obj-prop-id-init.js @@ -0,0 +1,96 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-prop-id-init.case +// - src/dstr-binding/default/cls-decl-gen-meth-static-dflt.template +/*--- +description: BindingElement with object binding pattern and initializer is used (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +class C { + static *method([{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }] = []) { + assert.sameValue(v, 444); + assert.sameValue(x, 555); + assert.sameValue(z, 666); + + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-obj-prop-id.js b/test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-obj-prop-id.js new file mode 100644 index 0000000000..74a98c85d6 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-obj-prop-id.js @@ -0,0 +1,96 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-prop-id.case +// - src/dstr-binding/default/cls-decl-gen-meth-static-dflt.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +class C { + static *method([{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }] = [{ u: 777, w: 888, y: 999 }]) { + assert.sameValue(v, 777); + assert.sameValue(x, 888); + assert.sameValue(z, 999); + + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-obj-val-null.js b/test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-obj-val-null.js new file mode 100644 index 0000000000..fd78cea8e8 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-obj-val-null.js @@ -0,0 +1,88 @@ +// 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-gen-meth-static-dflt.template +/*--- +description: Nested object destructuring with a null value (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 *method([{ x }] = [null]) {} +}; + +assert.throws(TypeError, function() { + C.method(); +}); diff --git a/test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-obj-val-undef.js b/test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-obj-val-undef.js new file mode 100644 index 0000000000..3f3385b702 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-elem-obj-val-undef.js @@ -0,0 +1,88 @@ +// 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-gen-meth-static-dflt.template +/*--- +description: Nested object destructuring with a value of `undefined` (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 *method([{ x }] = []) {} +}; + +assert.throws(TypeError, function() { + C.method(); +}); diff --git a/test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-elision-exhausted.js b/test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-elision-exhausted.js new file mode 100644 index 0000000000..5e58e7a430 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-elision-exhausted.js @@ -0,0 +1,91 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-exhausted.case +// - src/dstr-binding/default/cls-decl-gen-meth-static-dflt.template +/*--- +description: Elision accepts exhausted iterator (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [generator, destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + [...] + 2. Return NormalCompletion(empty). + +---*/ +var iter = function*() {}(); +iter.next(); + +var callCount = 0; +class C { + static *method([,] = iter) { + + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-elision-step-err.js b/test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-elision-step-err.js new file mode 100644 index 0000000000..cfbc6d536d --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-elision-step-err.js @@ -0,0 +1,95 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-step-err.case +// - src/dstr-binding/error/cls-decl-gen-meth-static-dflt.template +/*--- +description: Elision advances iterator and forwards abrupt completions (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [generator, destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 *method([,] = iter) {} +}; + +assert.throws(Test262Error, function() { + C.method(); +}); + +iter.next(); +assert.sameValue(following, 0, 'Iterator was properly closed.'); diff --git a/test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-elision.js b/test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-elision.js new file mode 100644 index 0000000000..ae16773145 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-elision.js @@ -0,0 +1,100 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision.case +// - src/dstr-binding/default/cls-decl-gen-meth-static-dflt.template +/*--- +description: Elision advances iterator (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [generator, destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + 2. Return NormalCompletion(empty). + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var callCount = 0; +class C { + static *method([,] = g()) { + assert.sameValue(first, 1); + assert.sameValue(second, 0); + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-empty.js b/test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-empty.js new file mode 100644 index 0000000000..0d9e4d523e --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-empty.js @@ -0,0 +1,83 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-empty.case +// - src/dstr-binding/default/cls-decl-gen-meth-static-dflt.template +/*--- +description: No iteration occurs for an "empty" array binding pattern (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [generators, destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ ] + + 1. Return NormalCompletion(empty). + +---*/ +var iterations = 0; +var iter = function*() { + iterations += 1; +}(); + +var callCount = 0; +class C { + static *method([] = iter) { + assert.sameValue(iterations, 0); + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-rest-ary-elem.js b/test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-rest-ary-elem.js new file mode 100644 index 0000000000..511012222f --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-rest-ary-elem.js @@ -0,0 +1,107 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-elem.case +// - src/dstr-binding/default/cls-decl-gen-meth-static-dflt.template +/*--- +description: Rest element containing an array BindingElementList pattern (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set + iteratorRecord.[[done]] to true. + iii. ReturnIfAbrupt(v). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static *method([...[x, y, z]] = [3, 4, 5]) { + assert.sameValue(x, 3); + assert.sameValue(y, 4); + assert.sameValue(z, 5); + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-rest-ary-elision.js b/test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-rest-ary-elision.js new file mode 100644 index 0000000000..e9b443bc88 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-rest-ary-elision.js @@ -0,0 +1,113 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-elision.case +// - src/dstr-binding/default/cls-decl-gen-meth-static-dflt.template +/*--- +description: Rest element containing an elision (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [generators, destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + 2. Return NormalCompletion(empty). + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var callCount = 0; +class C { + static *method([...[,]] = g()) { + assert.sameValue(first, 1); + assert.sameValue(second, 1); + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-rest-ary-empty.js b/test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-rest-ary-empty.js new file mode 100644 index 0000000000..be9eedcf90 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-rest-ary-empty.js @@ -0,0 +1,96 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-empty.case +// - src/dstr-binding/default/cls-decl-gen-meth-static-dflt.template +/*--- +description: Rest element containing an "empty" array pattern (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [generators, destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ ] + + 1. Return NormalCompletion(empty). + +---*/ +var iterations = 0; +var iter = function*() { + iterations += 1; +}(); + +var callCount = 0; +class C { + static *method([...[]] = iter) { + assert.sameValue(iterations, 1); + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-rest-ary-rest.js b/test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-rest-ary-rest.js new file mode 100644 index 0000000000..bc515d1d50 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-rest-ary-rest.js @@ -0,0 +1,92 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-rest.case +// - src/dstr-binding/default/cls-decl-gen-meth-static-dflt.template +/*--- +description: Rest element containing a rest element (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ +var values = [1, 2, 3]; + +var callCount = 0; +class C { + static *method([...[...x]] = values) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 1); + assert.sameValue(x[1], 2); + assert.sameValue(x[2], 3); + assert.notSameValue(x, values); + + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-rest-id-elision-next-err.js b/test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-rest-id-elision-next-err.js new file mode 100644 index 0000000000..aba507c0ed --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-rest-id-elision-next-err.js @@ -0,0 +1,81 @@ +// 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-gen-meth-static-dflt.template +/*--- +description: Rest element following elision elements (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [generators, destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 *method([, ...x] = iter) {} +}; + +assert.throws(Test262Error, function() { + C.method(); +}); diff --git a/test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-rest-id-elision.js b/test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-rest-id-elision.js new file mode 100644 index 0000000000..e005f4e036 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-rest-id-elision.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision.case +// - src/dstr-binding/default/cls-decl-gen-meth-static-dflt.template +/*--- +description: Rest element following elision elements (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + ArrayBindingPattern : [ Elisionopt BindingRestElement ] + 1. If Elision is present, then + a. Let status be the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with + iteratorRecord as the argument. + b. ReturnIfAbrupt(status). + 2. Return the result of performing IteratorBindingInitialization for + BindingRestElement with iteratorRecord and environment as arguments. +---*/ +var values = [1, 2, 3, 4, 5]; + +var callCount = 0; +class C { + static *method([ , , ...x] = values) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 3); + assert.sameValue(x[1], 4); + assert.sameValue(x[2], 5); + assert.notSameValue(x, values); + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-rest-id-exhausted.js b/test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-rest-id-exhausted.js new file mode 100644 index 0000000000..1f1e458902 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-rest-id-exhausted.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-exhausted.case +// - src/dstr-binding/default/cls-decl-gen-meth-static-dflt.template +/*--- +description: RestElement applied to an exhausted iterator (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [Symbol.iterator, destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier, + environment). + 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat, + [...] + b. If iteratorRecord.[[done]] is true, then + i. If environment is undefined, return PutValue(lhs, A). + ii. Return InitializeReferencedBinding(lhs, A). + +---*/ + +var callCount = 0; +class C { + static *method([, , ...x] = [1, 2]) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 0); + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-rest-id-iter-step-err.js b/test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-rest-id-iter-step-err.js new file mode 100644 index 0000000000..b804c5453c --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-rest-id-iter-step-err.js @@ -0,0 +1,92 @@ +// 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-gen-meth-static-dflt.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [generators, destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 *method([...x] = iter) {} +}; + +assert.throws(Test262Error, function() { + C.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-gen-meth-static-dflt-ary-ptrn-rest-id-iter-val-err.js b/test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-rest-id-iter-val-err.js new file mode 100644 index 0000000000..fb73c8980f --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-rest-id-iter-val-err.js @@ -0,0 +1,94 @@ +// 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-gen-meth-static-dflt.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [Symbol.iterator, destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 *method([...x] = iter) {} +}; + +assert.throws(Test262Error, function() { + C.method(); +}); diff --git a/test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-rest-id.js b/test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-rest-id.js new file mode 100644 index 0000000000..7cbf15d5ca --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-rest-id.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id.case +// - src/dstr-binding/default/cls-decl-gen-meth-static-dflt.template +/*--- +description: Lone rest element (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + [...] 3. Let A be ArrayCreate(0). [...] 5. Repeat + [...] + f. Let status be CreateDataProperty(A, ToString (n), nextValue). + [...] +---*/ +var values = [1, 2, 3]; + +var callCount = 0; +class C { + static *method([...x] = values) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 1); + assert.sameValue(x[1], 2); + assert.sameValue(x[2], 3); + assert.notSameValue(x, values); + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-rest-init-ary.js b/test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-rest-init-ary.js new file mode 100644 index 0000000000..4c816cfa3c --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-rest-init-ary.js @@ -0,0 +1,79 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-ary.case +// - src/dstr-binding/default/cls-decl-gen-meth-static-dflt.template +/*--- +description: Reset element (nested array pattern) does not support initializer (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +flags: [generated] +negative: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +class C { + static *method([...[ x ] = []] = []) { + + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-rest-init-id.js b/test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-rest-init-id.js new file mode 100644 index 0000000000..2749d1d94c --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-rest-init-id.js @@ -0,0 +1,79 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-id.case +// - src/dstr-binding/default/cls-decl-gen-meth-static-dflt.template +/*--- +description: Reset element (identifier) does not support initializer (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +flags: [generated] +negative: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +class C { + static *method([...x = []] = []) { + + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-rest-init-obj.js b/test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-rest-init-obj.js new file mode 100644 index 0000000000..421af5e3a4 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-rest-init-obj.js @@ -0,0 +1,79 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-obj.case +// - src/dstr-binding/default/cls-decl-gen-meth-static-dflt.template +/*--- +description: Reset element (nested object pattern) does not support initializer (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +flags: [generated] +negative: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +class C { + static *method([...{ x } = []] = []) { + + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-rest-not-final-ary.js b/test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-rest-not-final-ary.js new file mode 100644 index 0000000000..e875636188 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-rest-not-final-ary.js @@ -0,0 +1,79 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-ary.case +// - src/dstr-binding/default/cls-decl-gen-meth-static-dflt.template +/*--- +description: Rest element (array binding pattern) may not be followed by any element (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +flags: [generated] +negative: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +class C { + static *method([...[x], y] = [1, 2, 3]) { + + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-rest-not-final-id.js b/test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-rest-not-final-id.js new file mode 100644 index 0000000000..56ab611158 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-rest-not-final-id.js @@ -0,0 +1,79 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-id.case +// - src/dstr-binding/default/cls-decl-gen-meth-static-dflt.template +/*--- +description: Rest element (identifier) may not be followed by any element (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +flags: [generated] +negative: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +class C { + static *method([...x, y] = [1, 2, 3]) { + + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-rest-not-final-obj.js b/test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-rest-not-final-obj.js new file mode 100644 index 0000000000..2d8cb1dcd7 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-rest-not-final-obj.js @@ -0,0 +1,79 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-obj.case +// - src/dstr-binding/default/cls-decl-gen-meth-static-dflt.template +/*--- +description: Rest element (object binding pattern) may not be followed by any element (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +flags: [generated] +negative: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +class C { + static *method([...{ x }, y] = [1, 2, 3]) { + + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-rest-obj-id.js b/test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-rest-obj-id.js new file mode 100644 index 0000000000..99a1a21241 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-rest-obj-id.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-obj-id.case +// - src/dstr-binding/default/cls-decl-gen-meth-static-dflt.template +/*--- +description: Rest element containing an object binding pattern (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ + +var callCount = 0; +class C { + static *method([...{ length }] = [1, 2, 3]) { + assert.sameValue(length, 3); + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-rest-obj-prop-id.js b/test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-rest-obj-prop-id.js new file mode 100644 index 0000000000..b1fba994a2 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-dflt-ary-ptrn-rest-obj-prop-id.js @@ -0,0 +1,93 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-obj-prop-id.case +// - src/dstr-binding/default/cls-decl-gen-meth-static-dflt.template +/*--- +description: Rest element containing an object binding pattern (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ + +var callCount = 0; +class C { + static *method([...{ 0: v, 1: w, 2: x, 3: y, length: z }] = [7, 8, 9]) { + assert.sameValue(v, 7); + assert.sameValue(w, 8); + assert.sameValue(x, 9); + assert.sameValue(y, undefined); + assert.sameValue(z, 3); + + assert.throws(ReferenceError, function() { + length; + }); + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-static-dflt-obj-init-null.js b/test/language/statements/class/dstr-gen-meth-static-dflt-obj-init-null.js new file mode 100644 index 0000000000..77017df4a3 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-dflt-obj-init-null.js @@ -0,0 +1,75 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-null.case +// - src/dstr-binding/error/cls-decl-gen-meth-static-dflt.template +/*--- +description: Value specifed for object binding pattern must be object coercible (null) (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + +class C { + static *method({} = null) {} +}; + +assert.throws(TypeError, function() { + C.method(); +}); diff --git a/test/language/statements/class/dstr-gen-meth-static-dflt-obj-init-undefined.js b/test/language/statements/class/dstr-gen-meth-static-dflt-obj-init-undefined.js new file mode 100644 index 0000000000..523b662f2d --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-dflt-obj-init-undefined.js @@ -0,0 +1,75 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-undefined.case +// - src/dstr-binding/error/cls-decl-gen-meth-static-dflt.template +/*--- +description: Value specifed for object binding pattern must be object coercible (undefined) (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + +class C { + static *method({} = undefined) {} +}; + +assert.throws(TypeError, function() { + C.method(); +}); diff --git a/test/language/statements/class/dstr-gen-meth-static-dflt-obj-ptrn-empty.js b/test/language/statements/class/dstr-gen-meth-static-dflt-obj-ptrn-empty.js new file mode 100644 index 0000000000..a2b9b986cb --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-dflt-obj-ptrn-empty.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-empty.case +// - src/dstr-binding/default/cls-decl-gen-meth-static-dflt.template +/*--- +description: No property access occurs for an "empty" object binding pattern (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ +var accessCount = 0; +var obj = Object.defineProperty({}, 'attr', { + get: function() { + accessCount += 1; + } +}); + +var callCount = 0; +class C { + static *method({} = obj) { + assert.sameValue(accessCount, 0); + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-static-dflt-obj-ptrn-id-get-value-err.js b/test/language/statements/class/dstr-gen-meth-static-dflt-obj-ptrn-id-get-value-err.js new file mode 100644 index 0000000000..963d6e8c5e --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-dflt-obj-ptrn-id-get-value-err.js @@ -0,0 +1,82 @@ +// 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-gen-meth-static-dflt.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 *method({ poisoned } = poisonedProperty) {} +}; + +assert.throws(Test262Error, function() { + C.method(); +}); diff --git a/test/language/statements/class/dstr-gen-meth-static-dflt-obj-ptrn-id-init-fn-name-arrow.js b/test/language/statements/class/dstr-gen-meth-static-dflt-obj-ptrn-id-init-fn-name-arrow.js new file mode 100644 index 0000000000..52120dac15 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-dflt-obj-ptrn-id-init-fn-name-arrow.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-arrow.case +// - src/dstr-binding/default/cls-decl-gen-meth-static-dflt.template +/*--- +description: SingleNameBinding assigns `name` to arrow functions (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +class C { + static *method({ arrow = () => {} } = {}) { + assert.sameValue(arrow.name, 'arrow'); + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-static-dflt-obj-ptrn-id-init-fn-name-class.js b/test/language/statements/class/dstr-gen-meth-static-dflt-obj-ptrn-id-init-fn-name-class.js new file mode 100644 index 0000000000..4c93913819 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-dflt-obj-ptrn-id-init-fn-name-class.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-class.case +// - src/dstr-binding/default/cls-decl-gen-meth-static-dflt.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +class C { + static *method({ cls = class {}, xCls = class X {} } = {}) { + assert.sameValue(cls.name, 'cls'); + assert.notSameValue(xCls.name, 'xCls'); + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-static-dflt-obj-ptrn-id-init-fn-name-cover.js b/test/language/statements/class/dstr-gen-meth-static-dflt-obj-ptrn-id-init-fn-name-cover.js new file mode 100644 index 0000000000..26e5ba6401 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-dflt-obj-ptrn-id-init-fn-name-cover.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-cover.case +// - src/dstr-binding/default/cls-decl-gen-meth-static-dflt.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" functions "through" cover grammar (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +class C { + static *method({ cover = (function () {}), xCover = (0, function() {}) } = {}) { + assert.sameValue(cover.name, 'cover'); + assert.notSameValue(xCover.name, 'xCover'); + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-static-dflt-obj-ptrn-id-init-fn-name-fn.js b/test/language/statements/class/dstr-gen-meth-static-dflt-obj-ptrn-id-init-fn-name-fn.js new file mode 100644 index 0000000000..0bb43fe393 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-dflt-obj-ptrn-id-init-fn-name-fn.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-fn.case +// - src/dstr-binding/default/cls-decl-gen-meth-static-dflt.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +class C { + static *method({ fn = function () {}, xFn = function x() {} } = {}) { + assert.sameValue(fn.name, 'fn'); + assert.notSameValue(xFn.name, 'xFn'); + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-static-dflt-obj-ptrn-id-init-fn-name-gen.js b/test/language/statements/class/dstr-gen-meth-static-dflt-obj-ptrn-id-init-fn-name-gen.js new file mode 100644 index 0000000000..ec7167e2d4 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-dflt-obj-ptrn-id-init-fn-name-gen.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-gen.case +// - src/dstr-binding/default/cls-decl-gen-meth-static-dflt.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +class C { + static *method({ gen = function* () {}, xGen = function* x() {} } = {}) { + assert.sameValue(gen.name, 'gen'); + assert.notSameValue(xGen.name, 'xGen'); + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-static-dflt-obj-ptrn-id-init-skipped.js b/test/language/statements/class/dstr-gen-meth-static-dflt-obj-ptrn-id-init-skipped.js new file mode 100644 index 0000000000..139fbd7fa7 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-dflt-obj-ptrn-id-init-skipped.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-skipped.case +// - src/dstr-binding/default/cls-decl-gen-meth-static-dflt.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + [...] +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var callCount = 0; +class C { + static *method({ w = counter(), x = counter(), y = counter(), z = counter() } = { w: null, x: 0, y: false, z: '' }) { + assert.sameValue(w, null); + assert.sameValue(x, 0); + assert.sameValue(y, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-static-dflt-obj-ptrn-id-init-throws.js b/test/language/statements/class/dstr-gen-meth-static-dflt-obj-ptrn-id-init-throws.js new file mode 100644 index 0000000000..66fd04c7a8 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-dflt-obj-ptrn-id-init-throws.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-throws.case +// - src/dstr-binding/error/cls-decl-gen-meth-static-dflt.template +/*--- +description: Error thrown when evaluating the initializer (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 *method({ x = thrower() } = {}) {} +}; + +assert.throws(Test262Error, function() { + C.method(); +}); diff --git a/test/language/statements/class/dstr-gen-meth-static-dflt-obj-ptrn-id-init-unresolvable.js b/test/language/statements/class/dstr-gen-meth-static-dflt-obj-ptrn-id-init-unresolvable.js new file mode 100644 index 0000000000..180b96a088 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-dflt-obj-ptrn-id-init-unresolvable.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-unresolvable.case +// - src/dstr-binding/error/cls-decl-gen-meth-static-dflt.template +/*--- +description: Destructuring initializer is an unresolvable reference (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 *method({ x = unresolvableReference } = {}) {} +}; + +assert.throws(ReferenceError, function() { + C.method(); +}); diff --git a/test/language/statements/class/dstr-gen-meth-static-dflt-obj-ptrn-id-trailing-comma.js b/test/language/statements/class/dstr-gen-meth-static-dflt-obj-ptrn-id-trailing-comma.js new file mode 100644 index 0000000000..9c7c64b985 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-dflt-obj-ptrn-id-trailing-comma.js @@ -0,0 +1,79 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-trailing-comma.case +// - src/dstr-binding/default/cls-decl-gen-meth-static-dflt.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var callCount = 0; +class C { + static *method({ x, } = { x: 23 }) { + assert.sameValue(x, 23); + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-static-dflt-obj-ptrn-list-err.js b/test/language/statements/class/dstr-gen-meth-static-dflt-obj-ptrn-list-err.js new file mode 100644 index 0000000000..1c54ef902a --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-dflt-obj-ptrn-list-err.js @@ -0,0 +1,83 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-list-err.case +// - src/dstr-binding/error/cls-decl-gen-meth-static-dflt.template +/*--- +description: Binding property list evaluation is interrupted by an abrupt completion (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 *method({ a, b = thrower(), c = ++initCount } = {}) {} +}; + +assert.throws(Test262Error, function() { + C.method(); +}); + +assert.sameValue(initCount, 0); diff --git a/test/language/statements/class/dstr-gen-meth-static-dflt-obj-ptrn-prop-ary-init.js b/test/language/statements/class/dstr-gen-meth-static-dflt-obj-ptrn-prop-ary-init.js new file mode 100644 index 0000000000..040248ac59 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-dflt-obj-ptrn-prop-ary-init.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-init.case +// - src/dstr-binding/default/cls-decl-gen-meth-static-dflt.template +/*--- +description: Object binding pattern with "nested" array binding pattern using initializer (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +class C { + static *method({ w: [x, y, z] = [4, 5, 6] } = {}) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-static-dflt-obj-ptrn-prop-ary-trailing-comma.js b/test/language/statements/class/dstr-gen-meth-static-dflt-obj-ptrn-prop-ary-trailing-comma.js new file mode 100644 index 0000000000..e6c43d7407 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-dflt-obj-ptrn-prop-ary-trailing-comma.js @@ -0,0 +1,79 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-trailing-comma.case +// - src/dstr-binding/default/cls-decl-gen-meth-static-dflt.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var callCount = 0; +class C { + static *method({ x: [y], } = { x: [45] }) { + assert.sameValue(y,45); + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-static-dflt-obj-ptrn-prop-ary-value-null.js b/test/language/statements/class/dstr-gen-meth-static-dflt-obj-ptrn-prop-ary-value-null.js new file mode 100644 index 0000000000..416c8f46c3 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-dflt-obj-ptrn-prop-ary-value-null.js @@ -0,0 +1,77 @@ +// 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-gen-meth-static-dflt.template +/*--- +description: Object binding pattern with "nested" array binding pattern taking the `null` value (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 *method({ w: [x, y, z] = [4, 5, 6] } = { w: null }) {} +}; + +assert.throws(TypeError, function() { + C.method(); +}); diff --git a/test/language/statements/class/dstr-gen-meth-static-dflt-obj-ptrn-prop-ary.js b/test/language/statements/class/dstr-gen-meth-static-dflt-obj-ptrn-prop-ary.js new file mode 100644 index 0000000000..f4cfaebfa6 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-dflt-obj-ptrn-prop-ary.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary.case +// - src/dstr-binding/default/cls-decl-gen-meth-static-dflt.template +/*--- +description: Object binding pattern with "nested" array binding pattern not using initializer (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +class C { + static *method({ w: [x, y, z] = [4, 5, 6] } = { w: [7, undefined, ] }) { + assert.sameValue(x, 7); + assert.sameValue(y, undefined); + assert.sameValue(z, undefined); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-static-dflt-obj-ptrn-prop-eval-err.js b/test/language/statements/class/dstr-gen-meth-static-dflt-obj-ptrn-prop-eval-err.js new file mode 100644 index 0000000000..f78ae52061 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-dflt-obj-ptrn-prop-eval-err.js @@ -0,0 +1,79 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-eval-err.case +// - src/dstr-binding/error/cls-decl-gen-meth-static-dflt.template +/*--- +description: Evaluation of property name returns an abrupt completion (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 *method({ [thrower()]: x } = {}) {} +}; + +assert.throws(Test262Error, function() { + C.method(); +}); diff --git a/test/language/statements/class/dstr-gen-meth-static-dflt-obj-ptrn-prop-id-get-value-err.js b/test/language/statements/class/dstr-gen-meth-static-dflt-obj-ptrn-prop-id-get-value-err.js new file mode 100644 index 0000000000..eb5269f73a --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-dflt-obj-ptrn-prop-id-get-value-err.js @@ -0,0 +1,84 @@ +// 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-gen-meth-static-dflt.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 *method({ poisoned: x = ++initEvalCount } = poisonedProperty) {} +}; + +assert.throws(Test262Error, function() { + C.method(); +}); + +assert.sameValue(initEvalCount, 0); diff --git a/test/language/statements/class/dstr-gen-meth-static-dflt-obj-ptrn-prop-id-init-skipped.js b/test/language/statements/class/dstr-gen-meth-static-dflt-obj-ptrn-prop-id-init-skipped.js new file mode 100644 index 0000000000..8f06565fc0 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-dflt-obj-ptrn-prop-id-init-skipped.js @@ -0,0 +1,101 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-skipped.case +// - src/dstr-binding/default/cls-decl-gen-meth-static-dflt.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + [...] +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var callCount = 0; +class C { + static *method({ s: t = counter(), u: v = counter(), w: x = counter(), y: z = counter() } = { s: null, u: 0, w: false, y: '' }) { + assert.sameValue(t, null); + assert.sameValue(v, 0); + assert.sameValue(x, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + + assert.throws(ReferenceError, function() { + s; + }); + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-static-dflt-obj-ptrn-prop-id-init-throws.js b/test/language/statements/class/dstr-gen-meth-static-dflt-obj-ptrn-prop-id-init-throws.js new file mode 100644 index 0000000000..386031fea7 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-dflt-obj-ptrn-prop-id-init-throws.js @@ -0,0 +1,82 @@ +// 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-gen-meth-static-dflt.template +/*--- +description: Error thrown when evaluating the initializer (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 *method({ x: y = thrower() } = {}) {} +}; + +assert.throws(Test262Error, function() { + C.method(); +}); diff --git a/test/language/statements/class/dstr-gen-meth-static-dflt-obj-ptrn-prop-id-init-unresolvable.js b/test/language/statements/class/dstr-gen-meth-static-dflt-obj-ptrn-prop-id-init-unresolvable.js new file mode 100644 index 0000000000..4f774207b2 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-dflt-obj-ptrn-prop-id-init-unresolvable.js @@ -0,0 +1,86 @@ +// 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-gen-meth-static-dflt.template +/*--- +description: Destructuring initializer is an unresolvable reference (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 *method({ x: y = unresolvableReference } = {}) {} +}; + +assert.throws(ReferenceError, function() { + C.method(); +}); diff --git a/test/language/statements/class/dstr-gen-meth-static-dflt-obj-ptrn-prop-id-init.js b/test/language/statements/class/dstr-gen-meth-static-dflt-obj-ptrn-prop-id-init.js new file mode 100644 index 0000000000..675f73d0c6 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-dflt-obj-ptrn-prop-id-init.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init.case +// - src/dstr-binding/default/cls-decl-gen-meth-static-dflt.template +/*--- +description: Binding as specified via property name, identifier, and initializer (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static *method({ x: y = 33 } = { }) { + assert.sameValue(y, 33); + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-static-dflt-obj-ptrn-prop-id-trailing-comma.js b/test/language/statements/class/dstr-gen-meth-static-dflt-obj-ptrn-prop-id-trailing-comma.js new file mode 100644 index 0000000000..9e98c160a6 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-dflt-obj-ptrn-prop-id-trailing-comma.js @@ -0,0 +1,83 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-trailing-comma.case +// - src/dstr-binding/default/cls-decl-gen-meth-static-dflt.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var callCount = 0; +class C { + static *method({ x: y, } = { x: 23 }) { + assert.sameValue(y, 23); + + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-static-dflt-obj-ptrn-prop-id.js b/test/language/statements/class/dstr-gen-meth-static-dflt-obj-ptrn-prop-id.js new file mode 100644 index 0000000000..0a48908564 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-dflt-obj-ptrn-prop-id.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id.case +// - src/dstr-binding/default/cls-decl-gen-meth-static-dflt.template +/*--- +description: Binding as specified via property name and identifier (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static *method({ x: y } = { x: 23 }) { + assert.sameValue(y, 23); + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-static-dflt-obj-ptrn-prop-obj-init.js b/test/language/statements/class/dstr-gen-meth-static-dflt-obj-ptrn-prop-obj-init.js new file mode 100644 index 0000000000..7fd6de3876 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-dflt-obj-ptrn-prop-obj-init.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-init.case +// - src/dstr-binding/default/cls-decl-gen-meth-static-dflt.template +/*--- +description: Object binding pattern with "nested" object binding pattern using initializer (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +class C { + static *method({ w: { x, y, z } = { x: 4, y: 5, z: 6 } } = { w: undefined }) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-gen-meth-static-dflt-obj-ptrn-prop-obj-value-null.js b/test/language/statements/class/dstr-gen-meth-static-dflt-obj-ptrn-prop-obj-value-null.js new file mode 100644 index 0000000000..91537b5f6a --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-dflt-obj-ptrn-prop-obj-value-null.js @@ -0,0 +1,77 @@ +// 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-gen-meth-static-dflt.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 *method({ w: { x, y, z } = { x: 4, y: 5, z: 6 } } = { w: null }) {} +}; + +assert.throws(TypeError, function() { + C.method(); +}); diff --git a/test/language/statements/class/dstr-gen-meth-static-dflt-obj-ptrn-prop-obj-value-undef.js b/test/language/statements/class/dstr-gen-meth-static-dflt-obj-ptrn-prop-obj-value-undef.js new file mode 100644 index 0000000000..fcd324e7ab --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-dflt-obj-ptrn-prop-obj-value-undef.js @@ -0,0 +1,77 @@ +// 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-gen-meth-static-dflt.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 *method({ w: { x, y, z } = undefined } = { }) {} +}; + +assert.throws(TypeError, function() { + C.method(); +}); diff --git a/test/language/statements/class/dstr-gen-meth-static-dflt-obj-ptrn-prop-obj.js b/test/language/statements/class/dstr-gen-meth-static-dflt-obj-ptrn-prop-obj.js new file mode 100644 index 0000000000..9272d80dfb --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-dflt-obj-ptrn-prop-obj.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj.case +// - src/dstr-binding/default/cls-decl-gen-meth-static-dflt.template +/*--- +description: Object binding pattern with "nested" object binding pattern not using initializer (static class expression generator method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +class C { + static *method({ w: { x, y, z } = { x: 4, y: 5, z: 6 } } = { w: { x: undefined, z: 7 } }) { + assert.sameValue(x, undefined); + assert.sameValue(y, undefined); + assert.sameValue(z, 7); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } +}; + +C.method().next(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-dflt-ary-init-iter-close.js b/test/language/statements/class/dstr-meth-dflt-ary-init-iter-close.js new file mode 100644 index 0000000000..f622f29f77 --- /dev/null +++ b/test/language/statements/class/dstr-meth-dflt-ary-init-iter-close.js @@ -0,0 +1,93 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-close.case +// - src/dstr-binding/default/cls-decl-meth-dflt.template +/*--- +description: Iterator is closed when not exhausted by pattern evaluation (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [Symbol.iterator, destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + [...] + 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator, + result). + [...] + +---*/ +var doneCallCount = 0; +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return { value: null, done: false }; + }, + return: function() { + doneCallCount += 1; + return {}; + } + }; +}; + +var callCount = 0; +class C { + method([x] = iter) { + assert.sameValue(doneCallCount, 1); + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-dflt-ary-init-iter-get-err.js b/test/language/statements/class/dstr-meth-dflt-ary-init-iter-get-err.js new file mode 100644 index 0000000000..7d0fc862d9 --- /dev/null +++ b/test/language/statements/class/dstr-meth-dflt-ary-init-iter-get-err.js @@ -0,0 +1,81 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-get-err.case +// - src/dstr-binding/error/cls-decl-meth-dflt.template +/*--- +description: Abrupt completion returned by GetIterator (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [Symbol.iterator, destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 { + method([x] = iter) {} +}; + +var c = new C(); + +assert.throws(Test262Error, function() { + c.method(); +}); diff --git a/test/language/statements/class/dstr-meth-dflt-ary-init-iter-no-close.js b/test/language/statements/class/dstr-meth-dflt-ary-init-iter-no-close.js new file mode 100644 index 0000000000..351b527e10 --- /dev/null +++ b/test/language/statements/class/dstr-meth-dflt-ary-init-iter-no-close.js @@ -0,0 +1,93 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-no-close.case +// - src/dstr-binding/default/cls-decl-meth-dflt.template +/*--- +description: Iterator is not closed when exhausted by pattern evaluation (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [Symbol.iterator, destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + [...] + 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator, + result). + [...] + +---*/ +var doneCallCount = 0; +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return { value: null, done: true }; + }, + return: function() { + doneCallCount += 1; + return {}; + } + }; +}; + +var callCount = 0; +class C { + method([x] = iter) { + assert.sameValue(doneCallCount, 0); + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-dflt-ary-name-iter-val.js b/test/language/statements/class/dstr-meth-dflt-ary-name-iter-val.js new file mode 100644 index 0000000000..d73b777f19 --- /dev/null +++ b/test/language/statements/class/dstr-meth-dflt-ary-name-iter-val.js @@ -0,0 +1,92 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-name-iter-val.case +// - src/dstr-binding/default/cls-decl-meth-dflt.template +/*--- +description: SingleNameBinding with normal value iteration (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set + iteratorRecord.[[done]] to true. + iii. ReturnIfAbrupt(v). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + method([x, y, z] = [1, 2, 3]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 3); + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-dflt-ary-ptrn-elem-ary-elem-init.js b/test/language/statements/class/dstr-meth-dflt-ary-ptrn-elem-ary-elem-init.js new file mode 100644 index 0000000000..2113b8fcdd --- /dev/null +++ b/test/language/statements/class/dstr-meth-dflt-ary-ptrn-elem-ary-elem-init.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elem-init.case +// - src/dstr-binding/default/cls-decl-meth-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is used (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +class C { + method([[x, y, z] = [4, 5, 6]] = []) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-dflt-ary-ptrn-elem-ary-elem-iter.js b/test/language/statements/class/dstr-meth-dflt-ary-ptrn-elem-ary-elem-iter.js new file mode 100644 index 0000000000..8b5bd3ceb8 --- /dev/null +++ b/test/language/statements/class/dstr-meth-dflt-ary-ptrn-elem-ary-elem-iter.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elem-iter.case +// - src/dstr-binding/default/cls-decl-meth-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +class C { + method([[x, y, z] = [4, 5, 6]] = [[7, 8, 9]]) { + assert.sameValue(x, 7); + assert.sameValue(y, 8); + assert.sameValue(z, 9); + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-dflt-ary-ptrn-elem-ary-elision-init.js b/test/language/statements/class/dstr-meth-dflt-ary-ptrn-elem-ary-elision-init.js new file mode 100644 index 0000000000..54e1565583 --- /dev/null +++ b/test/language/statements/class/dstr-meth-dflt-ary-ptrn-elem-ary-elision-init.js @@ -0,0 +1,91 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elision-init.case +// - src/dstr-binding/default/cls-decl-meth-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is used (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [generators, destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var callCount = 0; +class C { + method([[,] = g()] = []) { + assert.sameValue(first, 1); + assert.sameValue(second, 0); + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-dflt-ary-ptrn-elem-ary-elision-iter.js b/test/language/statements/class/dstr-meth-dflt-ary-ptrn-elem-ary-elision-iter.js new file mode 100644 index 0000000000..fdfa656d54 --- /dev/null +++ b/test/language/statements/class/dstr-meth-dflt-ary-ptrn-elem-ary-elision-iter.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elision-iter.case +// - src/dstr-binding/default/cls-decl-meth-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [generators, destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var callCount = 0; +function* g() { + callCount += 1; +}; + +var callCount = 0; +class C { + method([[,] = g()] = [[]]) { + assert.sameValue(callCount, 0); + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-dflt-ary-ptrn-elem-ary-empty-init.js b/test/language/statements/class/dstr-meth-dflt-ary-ptrn-elem-ary-empty-init.js new file mode 100644 index 0000000000..54c2e7e2c0 --- /dev/null +++ b/test/language/statements/class/dstr-meth-dflt-ary-ptrn-elem-ary-empty-init.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-empty-init.case +// - src/dstr-binding/default/cls-decl-meth-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is used (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var initCount = 0; +var iterCount = 0; +var iter = function*() { iterCount += 1; }(); + +var callCount = 0; +class C { + method([[] = function() { initCount += 1; return iter; }()] = []) { + assert.sameValue(initCount, 1); + assert.sameValue(iterCount, 0); + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-dflt-ary-ptrn-elem-ary-empty-iter.js b/test/language/statements/class/dstr-meth-dflt-ary-ptrn-elem-ary-empty-iter.js new file mode 100644 index 0000000000..1df936e3ef --- /dev/null +++ b/test/language/statements/class/dstr-meth-dflt-ary-ptrn-elem-ary-empty-iter.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-empty-iter.case +// - src/dstr-binding/default/cls-decl-meth-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var initCount = 0; + +var callCount = 0; +class C { + method([[] = function() { initCount += 1; }()] = [[23]]) { + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-dflt-ary-ptrn-elem-ary-rest-init.js b/test/language/statements/class/dstr-meth-dflt-ary-ptrn-elem-ary-rest-init.js new file mode 100644 index 0000000000..b116bf9d26 --- /dev/null +++ b/test/language/statements/class/dstr-meth-dflt-ary-ptrn-elem-ary-rest-init.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-rest-init.case +// - src/dstr-binding/default/cls-decl-meth-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is used (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var values = [2, 1, 3]; + +var callCount = 0; +class C { + method([[...x] = values] = []) { + assert(Array.isArray(x)); + assert.sameValue(x[0], 2); + assert.sameValue(x[1], 1); + assert.sameValue(x[2], 3); + assert.sameValue(x.length, 3); + assert.notSameValue(x, values); + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-dflt-ary-ptrn-elem-ary-rest-iter.js b/test/language/statements/class/dstr-meth-dflt-ary-ptrn-elem-ary-rest-iter.js new file mode 100644 index 0000000000..711bbd2b4d --- /dev/null +++ b/test/language/statements/class/dstr-meth-dflt-ary-ptrn-elem-ary-rest-iter.js @@ -0,0 +1,91 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-rest-iter.case +// - src/dstr-binding/default/cls-decl-meth-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var values = [2, 1, 3]; +var initCount = 0; + +var callCount = 0; +class C { + method([[...x] = function() { initCount += 1; }()] = [values]) { + assert(Array.isArray(x)); + assert.sameValue(x[0], 2); + assert.sameValue(x[1], 1); + assert.sameValue(x[2], 3); + assert.sameValue(x.length, 3); + assert.notSameValue(x, values); + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-dflt-ary-ptrn-elem-ary-val-null.js b/test/language/statements/class/dstr-meth-dflt-ary-ptrn-elem-ary-val-null.js new file mode 100644 index 0000000000..2c28fea71c --- /dev/null +++ b/test/language/statements/class/dstr-meth-dflt-ary-ptrn-elem-ary-val-null.js @@ -0,0 +1,88 @@ +// 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-meth-dflt.template +/*--- +description: Nested array destructuring with a null value (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 { + method([[x]] = [null]) {} +}; + +var c = new C(); + +assert.throws(TypeError, function() { + c.method(); +}); diff --git a/test/language/statements/class/dstr-meth-dflt-ary-ptrn-elem-id-init-exhausted.js b/test/language/statements/class/dstr-meth-dflt-ary-ptrn-elem-id-init-exhausted.js new file mode 100644 index 0000000000..17d992f20e --- /dev/null +++ b/test/language/statements/class/dstr-meth-dflt-ary-ptrn-elem-id-init-exhausted.js @@ -0,0 +1,83 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-exhausted.case +// - src/dstr-binding/default/cls-decl-meth-dflt.template +/*--- +description: Destructuring initializer with an exhausted iterator (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + method([x = 23] = []) { + assert.sameValue(x, 23); + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-dflt-ary-ptrn-elem-id-init-fn-name-arrow.js b/test/language/statements/class/dstr-meth-dflt-ary-ptrn-elem-id-init-fn-name-arrow.js new file mode 100644 index 0000000000..d18d57374c --- /dev/null +++ b/test/language/statements/class/dstr-meth-dflt-ary-ptrn-elem-id-init-fn-name-arrow.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-arrow.case +// - src/dstr-binding/default/cls-decl-meth-dflt.template +/*--- +description: SingleNameBinding does assign name to arrow functions (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + method([arrow = () => {}] = []) { + assert.sameValue(arrow.name, 'arrow'); + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-dflt-ary-ptrn-elem-id-init-fn-name-class.js b/test/language/statements/class/dstr-meth-dflt-ary-ptrn-elem-id-init-fn-name-class.js new file mode 100644 index 0000000000..4979f5020d --- /dev/null +++ b/test/language/statements/class/dstr-meth-dflt-ary-ptrn-elem-id-init-fn-name-class.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-class.case +// - src/dstr-binding/default/cls-decl-meth-dflt.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + method([cls = class {}, xCls = class X {}] = []) { + assert.sameValue(cls.name, 'cls'); + assert.notSameValue(xCls.name, 'xCls'); + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-dflt-ary-ptrn-elem-id-init-fn-name-cover.js b/test/language/statements/class/dstr-meth-dflt-ary-ptrn-elem-id-init-fn-name-cover.js new file mode 100644 index 0000000000..7f25f0f1cd --- /dev/null +++ b/test/language/statements/class/dstr-meth-dflt-ary-ptrn-elem-id-init-fn-name-cover.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-cover.case +// - src/dstr-binding/default/cls-decl-meth-dflt.template +/*--- +description: SingleNameBinding does assign name to "anonymous" functions "through" cover grammar (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + method([cover = (function () {}), xCover = (0, function() {})] = []) { + assert.sameValue(cover.name, 'cover'); + assert.notSameValue(xCover.name, 'xCover'); + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-dflt-ary-ptrn-elem-id-init-fn-name-fn.js b/test/language/statements/class/dstr-meth-dflt-ary-ptrn-elem-id-init-fn-name-fn.js new file mode 100644 index 0000000000..785f00d5a9 --- /dev/null +++ b/test/language/statements/class/dstr-meth-dflt-ary-ptrn-elem-id-init-fn-name-fn.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-fn.case +// - src/dstr-binding/default/cls-decl-meth-dflt.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + method([fn = function () {}, xFn = function x() {}] = []) { + assert.sameValue(fn.name, 'fn'); + assert.notSameValue(xFn.name, 'xFn'); + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-dflt-ary-ptrn-elem-id-init-fn-name-gen.js b/test/language/statements/class/dstr-meth-dflt-ary-ptrn-elem-id-init-fn-name-gen.js new file mode 100644 index 0000000000..24fa5286ea --- /dev/null +++ b/test/language/statements/class/dstr-meth-dflt-ary-ptrn-elem-id-init-fn-name-gen.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-gen.case +// - src/dstr-binding/default/cls-decl-meth-dflt.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + method([gen = function* () {}, xGen = function* x() {}] = []) { + assert.sameValue(gen.name, 'gen'); + assert.notSameValue(xGen.name, 'xGen'); + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-dflt-ary-ptrn-elem-id-init-hole.js b/test/language/statements/class/dstr-meth-dflt-ary-ptrn-elem-id-init-hole.js new file mode 100644 index 0000000000..871c869657 --- /dev/null +++ b/test/language/statements/class/dstr-meth-dflt-ary-ptrn-elem-id-init-hole.js @@ -0,0 +1,79 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-hole.case +// - src/dstr-binding/default/cls-decl-meth-dflt.template +/*--- +description: Destructuring initializer with a "hole" (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + SingleNameBinding : BindingIdentifier Initializeropt + [...] 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + [...] + 7. If environment is undefined, return PutValue(lhs, v). 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + method([x = 23] = [,]) { + assert.sameValue(x, 23); + // another statement + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-dflt-ary-ptrn-elem-id-init-skipped.js b/test/language/statements/class/dstr-meth-dflt-ary-ptrn-elem-id-init-skipped.js new file mode 100644 index 0000000000..8cc86b0bcc --- /dev/null +++ b/test/language/statements/class/dstr-meth-dflt-ary-ptrn-elem-id-init-skipped.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-skipped.case +// - src/dstr-binding/default/cls-decl-meth-dflt.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var callCount = 0; +class C { + method([w = counter(), x = counter(), y = counter(), z = counter()] = [null, 0, false, '']) { + assert.sameValue(w, null); + assert.sameValue(x, 0); + assert.sameValue(y, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-dflt-ary-ptrn-elem-id-init-throws.js b/test/language/statements/class/dstr-meth-dflt-ary-ptrn-elem-id-init-throws.js new file mode 100644 index 0000000000..870590414b --- /dev/null +++ b/test/language/statements/class/dstr-meth-dflt-ary-ptrn-elem-id-init-throws.js @@ -0,0 +1,79 @@ +// 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-meth-dflt.template +/*--- +description: Destructuring initializer returns an abrupt completion (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 { + method([x = (function() { throw new Test262Error(); })()] = [undefined]) {} +}; + +var c = new C(); + +assert.throws(Test262Error, function() { + c.method(); +}); diff --git a/test/language/statements/class/dstr-meth-dflt-ary-ptrn-elem-id-init-undef.js b/test/language/statements/class/dstr-meth-dflt-ary-ptrn-elem-id-init-undef.js new file mode 100644 index 0000000000..1762e2c3b4 --- /dev/null +++ b/test/language/statements/class/dstr-meth-dflt-ary-ptrn-elem-id-init-undef.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-undef.case +// - src/dstr-binding/default/cls-decl-meth-dflt.template +/*--- +description: Destructuring initializer with an undefined value (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + method([x = 23] = [undefined]) { + assert.sameValue(x, 23); + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-dflt-ary-ptrn-elem-id-init-unresolvable.js b/test/language/statements/class/dstr-meth-dflt-ary-ptrn-elem-id-init-unresolvable.js new file mode 100644 index 0000000000..366106c155 --- /dev/null +++ b/test/language/statements/class/dstr-meth-dflt-ary-ptrn-elem-id-init-unresolvable.js @@ -0,0 +1,86 @@ +// 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-meth-dflt.template +/*--- +description: Destructuring initializer is an unresolvable reference (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 { + method([ x = unresolvableReference ] = []) {} +}; + +var c = new C(); + +assert.throws(ReferenceError, function() { + c.method(); +}); diff --git a/test/language/statements/class/dstr-meth-dflt-ary-ptrn-elem-id-iter-complete.js b/test/language/statements/class/dstr-meth-dflt-ary-ptrn-elem-id-iter-complete.js new file mode 100644 index 0000000000..69f37ffcaa --- /dev/null +++ b/test/language/statements/class/dstr-meth-dflt-ary-ptrn-elem-id-iter-complete.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-complete.case +// - src/dstr-binding/default/cls-decl-meth-dflt.template +/*--- +description: SingleNameBinding when value iteration completes (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + method([x] = []) { + assert.sameValue(x, undefined); + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-dflt-ary-ptrn-elem-id-iter-done.js b/test/language/statements/class/dstr-meth-dflt-ary-ptrn-elem-id-iter-done.js new file mode 100644 index 0000000000..971963272d --- /dev/null +++ b/test/language/statements/class/dstr-meth-dflt-ary-ptrn-elem-id-iter-done.js @@ -0,0 +1,81 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-done.case +// - src/dstr-binding/default/cls-decl-meth-dflt.template +/*--- +description: SingleNameBinding when value iteration was completed previously (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + method([_, x] = []) { + assert.sameValue(x, undefined); + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-dflt-ary-ptrn-elem-id-iter-step-err.js b/test/language/statements/class/dstr-meth-dflt-ary-ptrn-elem-id-iter-step-err.js new file mode 100644 index 0000000000..d01da5241a --- /dev/null +++ b/test/language/statements/class/dstr-meth-dflt-ary-ptrn-elem-id-iter-step-err.js @@ -0,0 +1,87 @@ +// 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-meth-dflt.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 { + method([x] = g) {} +}; + +var c = new C(); + +assert.throws(Test262Error, function() { + c.method(); +}); diff --git a/test/language/statements/class/dstr-meth-dflt-ary-ptrn-elem-id-iter-val-err.js b/test/language/statements/class/dstr-meth-dflt-ary-ptrn-elem-id-iter-val-err.js new file mode 100644 index 0000000000..b422b175df --- /dev/null +++ b/test/language/statements/class/dstr-meth-dflt-ary-ptrn-elem-id-iter-val-err.js @@ -0,0 +1,98 @@ +// 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-meth-dflt.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 { + method([x] = g) {} +}; + +var c = new C(); + +assert.throws(Test262Error, function() { + c.method(); +}); diff --git a/test/language/statements/class/dstr-meth-dflt-ary-ptrn-elem-id-iter-val.js b/test/language/statements/class/dstr-meth-dflt-ary-ptrn-elem-id-iter-val.js new file mode 100644 index 0000000000..7769f2ac26 --- /dev/null +++ b/test/language/statements/class/dstr-meth-dflt-ary-ptrn-elem-id-iter-val.js @@ -0,0 +1,92 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val.case +// - src/dstr-binding/default/cls-decl-meth-dflt.template +/*--- +description: SingleNameBinding when value iteration was completed previously (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set + iteratorRecord.[[done]] to true. + iii. ReturnIfAbrupt(v). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + method([x, y, z] = [1, 2, 3]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 3); + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-dflt-ary-ptrn-elem-obj-id-init.js b/test/language/statements/class/dstr-meth-dflt-ary-ptrn-elem-obj-id-init.js new file mode 100644 index 0000000000..ed009e3423 --- /dev/null +++ b/test/language/statements/class/dstr-meth-dflt-ary-ptrn-elem-obj-id-init.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-id-init.case +// - src/dstr-binding/default/cls-decl-meth-dflt.template +/*--- +description: BindingElement with object binding pattern and initializer is used (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +class C { + method([{ x, y, z } = { x: 44, y: 55, z: 66 }] = []) { + assert.sameValue(x, 44); + assert.sameValue(y, 55); + assert.sameValue(z, 66); + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-dflt-ary-ptrn-elem-obj-id.js b/test/language/statements/class/dstr-meth-dflt-ary-ptrn-elem-obj-id.js new file mode 100644 index 0000000000..0e91ee5de5 --- /dev/null +++ b/test/language/statements/class/dstr-meth-dflt-ary-ptrn-elem-obj-id.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-id.case +// - src/dstr-binding/default/cls-decl-meth-dflt.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +class C { + method([{ x, y, z } = { x: 44, y: 55, z: 66 }] = [{ x: 11, y: 22, z: 33 }]) { + assert.sameValue(x, 11); + assert.sameValue(y, 22); + assert.sameValue(z, 33); + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-dflt-ary-ptrn-elem-obj-prop-id-init.js b/test/language/statements/class/dstr-meth-dflt-ary-ptrn-elem-obj-prop-id-init.js new file mode 100644 index 0000000000..fa6b594519 --- /dev/null +++ b/test/language/statements/class/dstr-meth-dflt-ary-ptrn-elem-obj-prop-id-init.js @@ -0,0 +1,94 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-prop-id-init.case +// - src/dstr-binding/default/cls-decl-meth-dflt.template +/*--- +description: BindingElement with object binding pattern and initializer is used (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +class C { + method([{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }] = []) { + assert.sameValue(v, 444); + assert.sameValue(x, 555); + assert.sameValue(z, 666); + + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-dflt-ary-ptrn-elem-obj-prop-id.js b/test/language/statements/class/dstr-meth-dflt-ary-ptrn-elem-obj-prop-id.js new file mode 100644 index 0000000000..07acb7ca38 --- /dev/null +++ b/test/language/statements/class/dstr-meth-dflt-ary-ptrn-elem-obj-prop-id.js @@ -0,0 +1,94 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-prop-id.case +// - src/dstr-binding/default/cls-decl-meth-dflt.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +class C { + method([{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }] = [{ u: 777, w: 888, y: 999 }]) { + assert.sameValue(v, 777); + assert.sameValue(x, 888); + assert.sameValue(z, 999); + + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-dflt-ary-ptrn-elem-obj-val-null.js b/test/language/statements/class/dstr-meth-dflt-ary-ptrn-elem-obj-val-null.js new file mode 100644 index 0000000000..31f338f736 --- /dev/null +++ b/test/language/statements/class/dstr-meth-dflt-ary-ptrn-elem-obj-val-null.js @@ -0,0 +1,88 @@ +// 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-meth-dflt.template +/*--- +description: Nested object destructuring with a null value (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 { + method([{ x }] = [null]) {} +}; + +var c = new C(); + +assert.throws(TypeError, function() { + c.method(); +}); diff --git a/test/language/statements/class/dstr-meth-dflt-ary-ptrn-elem-obj-val-undef.js b/test/language/statements/class/dstr-meth-dflt-ary-ptrn-elem-obj-val-undef.js new file mode 100644 index 0000000000..6e76a10db8 --- /dev/null +++ b/test/language/statements/class/dstr-meth-dflt-ary-ptrn-elem-obj-val-undef.js @@ -0,0 +1,88 @@ +// 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-meth-dflt.template +/*--- +description: Nested object destructuring with a value of `undefined` (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 { + method([{ x }] = []) {} +}; + +var c = new C(); + +assert.throws(TypeError, function() { + c.method(); +}); diff --git a/test/language/statements/class/dstr-meth-dflt-ary-ptrn-elision-exhausted.js b/test/language/statements/class/dstr-meth-dflt-ary-ptrn-elision-exhausted.js new file mode 100644 index 0000000000..e6ca887d66 --- /dev/null +++ b/test/language/statements/class/dstr-meth-dflt-ary-ptrn-elision-exhausted.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-exhausted.case +// - src/dstr-binding/default/cls-decl-meth-dflt.template +/*--- +description: Elision accepts exhausted iterator (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [generator, destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + [...] + 2. Return NormalCompletion(empty). + +---*/ +var iter = function*() {}(); +iter.next(); + +var callCount = 0; +class C { + method([,] = iter) { + + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-dflt-ary-ptrn-elision-step-err.js b/test/language/statements/class/dstr-meth-dflt-ary-ptrn-elision-step-err.js new file mode 100644 index 0000000000..be34b4068e --- /dev/null +++ b/test/language/statements/class/dstr-meth-dflt-ary-ptrn-elision-step-err.js @@ -0,0 +1,95 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-step-err.case +// - src/dstr-binding/error/cls-decl-meth-dflt.template +/*--- +description: Elision advances iterator and forwards abrupt completions (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [generator, destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 { + method([,] = iter) {} +}; + +var c = new C(); + +assert.throws(Test262Error, function() { + c.method(); +}); + +iter.next(); +assert.sameValue(following, 0, 'Iterator was properly closed.'); diff --git a/test/language/statements/class/dstr-meth-dflt-ary-ptrn-elision.js b/test/language/statements/class/dstr-meth-dflt-ary-ptrn-elision.js new file mode 100644 index 0000000000..25cebd605f --- /dev/null +++ b/test/language/statements/class/dstr-meth-dflt-ary-ptrn-elision.js @@ -0,0 +1,98 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision.case +// - src/dstr-binding/default/cls-decl-meth-dflt.template +/*--- +description: Elision advances iterator (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [generator, destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + 2. Return NormalCompletion(empty). + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var callCount = 0; +class C { + method([,] = g()) { + assert.sameValue(first, 1); + assert.sameValue(second, 0); + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-dflt-ary-ptrn-empty.js b/test/language/statements/class/dstr-meth-dflt-ary-ptrn-empty.js new file mode 100644 index 0000000000..8b421d4106 --- /dev/null +++ b/test/language/statements/class/dstr-meth-dflt-ary-ptrn-empty.js @@ -0,0 +1,81 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-empty.case +// - src/dstr-binding/default/cls-decl-meth-dflt.template +/*--- +description: No iteration occurs for an "empty" array binding pattern (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [generators, destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ ] + + 1. Return NormalCompletion(empty). + +---*/ +var iterations = 0; +var iter = function*() { + iterations += 1; +}(); + +var callCount = 0; +class C { + method([] = iter) { + assert.sameValue(iterations, 0); + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-dflt-ary-ptrn-rest-ary-elem.js b/test/language/statements/class/dstr-meth-dflt-ary-ptrn-rest-ary-elem.js new file mode 100644 index 0000000000..8b0ef02793 --- /dev/null +++ b/test/language/statements/class/dstr-meth-dflt-ary-ptrn-rest-ary-elem.js @@ -0,0 +1,105 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-elem.case +// - src/dstr-binding/default/cls-decl-meth-dflt.template +/*--- +description: Rest element containing an array BindingElementList pattern (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set + iteratorRecord.[[done]] to true. + iii. ReturnIfAbrupt(v). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + method([...[x, y, z]] = [3, 4, 5]) { + assert.sameValue(x, 3); + assert.sameValue(y, 4); + assert.sameValue(z, 5); + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-dflt-ary-ptrn-rest-ary-elision.js b/test/language/statements/class/dstr-meth-dflt-ary-ptrn-rest-ary-elision.js new file mode 100644 index 0000000000..eecdce1c91 --- /dev/null +++ b/test/language/statements/class/dstr-meth-dflt-ary-ptrn-rest-ary-elision.js @@ -0,0 +1,111 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-elision.case +// - src/dstr-binding/default/cls-decl-meth-dflt.template +/*--- +description: Rest element containing an elision (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [generators, destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + 2. Return NormalCompletion(empty). + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var callCount = 0; +class C { + method([...[,]] = g()) { + assert.sameValue(first, 1); + assert.sameValue(second, 1); + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-dflt-ary-ptrn-rest-ary-empty.js b/test/language/statements/class/dstr-meth-dflt-ary-ptrn-rest-ary-empty.js new file mode 100644 index 0000000000..47a0ff81bd --- /dev/null +++ b/test/language/statements/class/dstr-meth-dflt-ary-ptrn-rest-ary-empty.js @@ -0,0 +1,94 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-empty.case +// - src/dstr-binding/default/cls-decl-meth-dflt.template +/*--- +description: Rest element containing an "empty" array pattern (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [generators, destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ ] + + 1. Return NormalCompletion(empty). + +---*/ +var iterations = 0; +var iter = function*() { + iterations += 1; +}(); + +var callCount = 0; +class C { + method([...[]] = iter) { + assert.sameValue(iterations, 1); + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-dflt-ary-ptrn-rest-ary-rest.js b/test/language/statements/class/dstr-meth-dflt-ary-ptrn-rest-ary-rest.js new file mode 100644 index 0000000000..07ed9d6322 --- /dev/null +++ b/test/language/statements/class/dstr-meth-dflt-ary-ptrn-rest-ary-rest.js @@ -0,0 +1,90 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-rest.case +// - src/dstr-binding/default/cls-decl-meth-dflt.template +/*--- +description: Rest element containing a rest element (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ +var values = [1, 2, 3]; + +var callCount = 0; +class C { + method([...[...x]] = values) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 1); + assert.sameValue(x[1], 2); + assert.sameValue(x[2], 3); + assert.notSameValue(x, values); + + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-dflt-ary-ptrn-rest-id-elision-next-err.js b/test/language/statements/class/dstr-meth-dflt-ary-ptrn-rest-id-elision-next-err.js new file mode 100644 index 0000000000..87216e1f3a --- /dev/null +++ b/test/language/statements/class/dstr-meth-dflt-ary-ptrn-rest-id-elision-next-err.js @@ -0,0 +1,81 @@ +// 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-meth-dflt.template +/*--- +description: Rest element following elision elements (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [generators, destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 { + method([, ...x] = iter) {} +}; + +var c = new C(); + +assert.throws(Test262Error, function() { + c.method(); +}); diff --git a/test/language/statements/class/dstr-meth-dflt-ary-ptrn-rest-id-elision.js b/test/language/statements/class/dstr-meth-dflt-ary-ptrn-rest-id-elision.js new file mode 100644 index 0000000000..eef090b43a --- /dev/null +++ b/test/language/statements/class/dstr-meth-dflt-ary-ptrn-rest-id-elision.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision.case +// - src/dstr-binding/default/cls-decl-meth-dflt.template +/*--- +description: Rest element following elision elements (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + ArrayBindingPattern : [ Elisionopt BindingRestElement ] + 1. If Elision is present, then + a. Let status be the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with + iteratorRecord as the argument. + b. ReturnIfAbrupt(status). + 2. Return the result of performing IteratorBindingInitialization for + BindingRestElement with iteratorRecord and environment as arguments. +---*/ +var values = [1, 2, 3, 4, 5]; + +var callCount = 0; +class C { + method([ , , ...x] = values) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 3); + assert.sameValue(x[1], 4); + assert.sameValue(x[2], 5); + assert.notSameValue(x, values); + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-dflt-ary-ptrn-rest-id-exhausted.js b/test/language/statements/class/dstr-meth-dflt-ary-ptrn-rest-id-exhausted.js new file mode 100644 index 0000000000..969655eccb --- /dev/null +++ b/test/language/statements/class/dstr-meth-dflt-ary-ptrn-rest-id-exhausted.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-exhausted.case +// - src/dstr-binding/default/cls-decl-meth-dflt.template +/*--- +description: RestElement applied to an exhausted iterator (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [Symbol.iterator, destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier, + environment). + 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat, + [...] + b. If iteratorRecord.[[done]] is true, then + i. If environment is undefined, return PutValue(lhs, A). + ii. Return InitializeReferencedBinding(lhs, A). + +---*/ + +var callCount = 0; +class C { + method([, , ...x] = [1, 2]) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 0); + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-dflt-ary-ptrn-rest-id-iter-step-err.js b/test/language/statements/class/dstr-meth-dflt-ary-ptrn-rest-id-iter-step-err.js new file mode 100644 index 0000000000..5d1dda5733 --- /dev/null +++ b/test/language/statements/class/dstr-meth-dflt-ary-ptrn-rest-id-iter-step-err.js @@ -0,0 +1,92 @@ +// 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-meth-dflt.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [generators, destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 { + method([...x] = iter) {} +}; + +var c = new C(); + +assert.throws(Test262Error, function() { + c.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-meth-dflt-ary-ptrn-rest-id-iter-val-err.js b/test/language/statements/class/dstr-meth-dflt-ary-ptrn-rest-id-iter-val-err.js new file mode 100644 index 0000000000..c7d484a7b6 --- /dev/null +++ b/test/language/statements/class/dstr-meth-dflt-ary-ptrn-rest-id-iter-val-err.js @@ -0,0 +1,94 @@ +// 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-meth-dflt.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [Symbol.iterator, destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 { + method([...x] = iter) {} +}; + +var c = new C(); + +assert.throws(Test262Error, function() { + c.method(); +}); diff --git a/test/language/statements/class/dstr-meth-dflt-ary-ptrn-rest-id.js b/test/language/statements/class/dstr-meth-dflt-ary-ptrn-rest-id.js new file mode 100644 index 0000000000..f1320a791d --- /dev/null +++ b/test/language/statements/class/dstr-meth-dflt-ary-ptrn-rest-id.js @@ -0,0 +1,83 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id.case +// - src/dstr-binding/default/cls-decl-meth-dflt.template +/*--- +description: Lone rest element (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + [...] 3. Let A be ArrayCreate(0). [...] 5. Repeat + [...] + f. Let status be CreateDataProperty(A, ToString (n), nextValue). + [...] +---*/ +var values = [1, 2, 3]; + +var callCount = 0; +class C { + method([...x] = values) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 1); + assert.sameValue(x[1], 2); + assert.sameValue(x[2], 3); + assert.notSameValue(x, values); + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-dflt-ary-ptrn-rest-init-ary.js b/test/language/statements/class/dstr-meth-dflt-ary-ptrn-rest-init-ary.js new file mode 100644 index 0000000000..51e9b03354 --- /dev/null +++ b/test/language/statements/class/dstr-meth-dflt-ary-ptrn-rest-init-ary.js @@ -0,0 +1,77 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-ary.case +// - src/dstr-binding/default/cls-decl-meth-dflt.template +/*--- +description: Reset element (nested array pattern) does not support initializer (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +flags: [generated] +negative: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +class C { + method([...[ x ] = []] = []) { + + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-dflt-ary-ptrn-rest-init-id.js b/test/language/statements/class/dstr-meth-dflt-ary-ptrn-rest-init-id.js new file mode 100644 index 0000000000..182992ad8b --- /dev/null +++ b/test/language/statements/class/dstr-meth-dflt-ary-ptrn-rest-init-id.js @@ -0,0 +1,77 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-id.case +// - src/dstr-binding/default/cls-decl-meth-dflt.template +/*--- +description: Reset element (identifier) does not support initializer (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +flags: [generated] +negative: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +class C { + method([...x = []] = []) { + + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-dflt-ary-ptrn-rest-init-obj.js b/test/language/statements/class/dstr-meth-dflt-ary-ptrn-rest-init-obj.js new file mode 100644 index 0000000000..8bc377226f --- /dev/null +++ b/test/language/statements/class/dstr-meth-dflt-ary-ptrn-rest-init-obj.js @@ -0,0 +1,77 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-obj.case +// - src/dstr-binding/default/cls-decl-meth-dflt.template +/*--- +description: Reset element (nested object pattern) does not support initializer (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +flags: [generated] +negative: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +class C { + method([...{ x } = []] = []) { + + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-dflt-ary-ptrn-rest-not-final-ary.js b/test/language/statements/class/dstr-meth-dflt-ary-ptrn-rest-not-final-ary.js new file mode 100644 index 0000000000..85ade6f323 --- /dev/null +++ b/test/language/statements/class/dstr-meth-dflt-ary-ptrn-rest-not-final-ary.js @@ -0,0 +1,77 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-ary.case +// - src/dstr-binding/default/cls-decl-meth-dflt.template +/*--- +description: Rest element (array binding pattern) may not be followed by any element (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +flags: [generated] +negative: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +class C { + method([...[x], y] = [1, 2, 3]) { + + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-dflt-ary-ptrn-rest-not-final-id.js b/test/language/statements/class/dstr-meth-dflt-ary-ptrn-rest-not-final-id.js new file mode 100644 index 0000000000..778a535e03 --- /dev/null +++ b/test/language/statements/class/dstr-meth-dflt-ary-ptrn-rest-not-final-id.js @@ -0,0 +1,77 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-id.case +// - src/dstr-binding/default/cls-decl-meth-dflt.template +/*--- +description: Rest element (identifier) may not be followed by any element (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +flags: [generated] +negative: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +class C { + method([...x, y] = [1, 2, 3]) { + + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-dflt-ary-ptrn-rest-not-final-obj.js b/test/language/statements/class/dstr-meth-dflt-ary-ptrn-rest-not-final-obj.js new file mode 100644 index 0000000000..eb8046ef02 --- /dev/null +++ b/test/language/statements/class/dstr-meth-dflt-ary-ptrn-rest-not-final-obj.js @@ -0,0 +1,77 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-obj.case +// - src/dstr-binding/default/cls-decl-meth-dflt.template +/*--- +description: Rest element (object binding pattern) may not be followed by any element (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +flags: [generated] +negative: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +class C { + method([...{ x }, y] = [1, 2, 3]) { + + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-dflt-ary-ptrn-rest-obj-id.js b/test/language/statements/class/dstr-meth-dflt-ary-ptrn-rest-obj-id.js new file mode 100644 index 0000000000..b5172d9098 --- /dev/null +++ b/test/language/statements/class/dstr-meth-dflt-ary-ptrn-rest-obj-id.js @@ -0,0 +1,83 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-obj-id.case +// - src/dstr-binding/default/cls-decl-meth-dflt.template +/*--- +description: Rest element containing an object binding pattern (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ + +var callCount = 0; +class C { + method([...{ length }] = [1, 2, 3]) { + assert.sameValue(length, 3); + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-dflt-ary-ptrn-rest-obj-prop-id.js b/test/language/statements/class/dstr-meth-dflt-ary-ptrn-rest-obj-prop-id.js new file mode 100644 index 0000000000..447c10d94d --- /dev/null +++ b/test/language/statements/class/dstr-meth-dflt-ary-ptrn-rest-obj-prop-id.js @@ -0,0 +1,91 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-obj-prop-id.case +// - src/dstr-binding/default/cls-decl-meth-dflt.template +/*--- +description: Rest element containing an object binding pattern (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ + +var callCount = 0; +class C { + method([...{ 0: v, 1: w, 2: x, 3: y, length: z }] = [7, 8, 9]) { + assert.sameValue(v, 7); + assert.sameValue(w, 8); + assert.sameValue(x, 9); + assert.sameValue(y, undefined); + assert.sameValue(z, 3); + + assert.throws(ReferenceError, function() { + length; + }); + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-dflt-obj-init-null.js b/test/language/statements/class/dstr-meth-dflt-obj-init-null.js new file mode 100644 index 0000000000..010bb00ac9 --- /dev/null +++ b/test/language/statements/class/dstr-meth-dflt-obj-init-null.js @@ -0,0 +1,75 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-null.case +// - src/dstr-binding/error/cls-decl-meth-dflt.template +/*--- +description: Value specifed for object binding pattern must be object coercible (null) (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + +class C { + method({} = null) {} +}; + +var c = new C(); + +assert.throws(TypeError, function() { + c.method(); +}); diff --git a/test/language/statements/class/dstr-meth-dflt-obj-init-undefined.js b/test/language/statements/class/dstr-meth-dflt-obj-init-undefined.js new file mode 100644 index 0000000000..46e57a9cea --- /dev/null +++ b/test/language/statements/class/dstr-meth-dflt-obj-init-undefined.js @@ -0,0 +1,75 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-undefined.case +// - src/dstr-binding/error/cls-decl-meth-dflt.template +/*--- +description: Value specifed for object binding pattern must be object coercible (undefined) (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + +class C { + method({} = undefined) {} +}; + +var c = new C(); + +assert.throws(TypeError, function() { + c.method(); +}); diff --git a/test/language/statements/class/dstr-meth-dflt-obj-ptrn-empty.js b/test/language/statements/class/dstr-meth-dflt-obj-ptrn-empty.js new file mode 100644 index 0000000000..0225dd2fd1 --- /dev/null +++ b/test/language/statements/class/dstr-meth-dflt-obj-ptrn-empty.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-empty.case +// - src/dstr-binding/default/cls-decl-meth-dflt.template +/*--- +description: No property access occurs for an "empty" object binding pattern (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ +var accessCount = 0; +var obj = Object.defineProperty({}, 'attr', { + get: function() { + accessCount += 1; + } +}); + +var callCount = 0; +class C { + method({} = obj) { + assert.sameValue(accessCount, 0); + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-dflt-obj-ptrn-id-get-value-err.js b/test/language/statements/class/dstr-meth-dflt-obj-ptrn-id-get-value-err.js new file mode 100644 index 0000000000..8dcda8d874 --- /dev/null +++ b/test/language/statements/class/dstr-meth-dflt-obj-ptrn-id-get-value-err.js @@ -0,0 +1,82 @@ +// 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-meth-dflt.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 { + method({ poisoned } = poisonedProperty) {} +}; + +var c = new C(); + +assert.throws(Test262Error, function() { + c.method(); +}); diff --git a/test/language/statements/class/dstr-meth-dflt-obj-ptrn-id-init-fn-name-arrow.js b/test/language/statements/class/dstr-meth-dflt-obj-ptrn-id-init-fn-name-arrow.js new file mode 100644 index 0000000000..8bbf3187a0 --- /dev/null +++ b/test/language/statements/class/dstr-meth-dflt-obj-ptrn-id-init-fn-name-arrow.js @@ -0,0 +1,83 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-arrow.case +// - src/dstr-binding/default/cls-decl-meth-dflt.template +/*--- +description: SingleNameBinding assigns `name` to arrow functions (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +class C { + method({ arrow = () => {} } = {}) { + assert.sameValue(arrow.name, 'arrow'); + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-dflt-obj-ptrn-id-init-fn-name-class.js b/test/language/statements/class/dstr-meth-dflt-obj-ptrn-id-init-fn-name-class.js new file mode 100644 index 0000000000..a2b56f5abe --- /dev/null +++ b/test/language/statements/class/dstr-meth-dflt-obj-ptrn-id-init-fn-name-class.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-class.case +// - src/dstr-binding/default/cls-decl-meth-dflt.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +class C { + method({ cls = class {}, xCls = class X {} } = {}) { + assert.sameValue(cls.name, 'cls'); + assert.notSameValue(xCls.name, 'xCls'); + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-dflt-obj-ptrn-id-init-fn-name-cover.js b/test/language/statements/class/dstr-meth-dflt-obj-ptrn-id-init-fn-name-cover.js new file mode 100644 index 0000000000..8345bf3481 --- /dev/null +++ b/test/language/statements/class/dstr-meth-dflt-obj-ptrn-id-init-fn-name-cover.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-cover.case +// - src/dstr-binding/default/cls-decl-meth-dflt.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" functions "through" cover grammar (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +class C { + method({ cover = (function () {}), xCover = (0, function() {}) } = {}) { + assert.sameValue(cover.name, 'cover'); + assert.notSameValue(xCover.name, 'xCover'); + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-dflt-obj-ptrn-id-init-fn-name-fn.js b/test/language/statements/class/dstr-meth-dflt-obj-ptrn-id-init-fn-name-fn.js new file mode 100644 index 0000000000..9dc51483cd --- /dev/null +++ b/test/language/statements/class/dstr-meth-dflt-obj-ptrn-id-init-fn-name-fn.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-fn.case +// - src/dstr-binding/default/cls-decl-meth-dflt.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +class C { + method({ fn = function () {}, xFn = function x() {} } = {}) { + assert.sameValue(fn.name, 'fn'); + assert.notSameValue(xFn.name, 'xFn'); + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-dflt-obj-ptrn-id-init-fn-name-gen.js b/test/language/statements/class/dstr-meth-dflt-obj-ptrn-id-init-fn-name-gen.js new file mode 100644 index 0000000000..b3cd4c3172 --- /dev/null +++ b/test/language/statements/class/dstr-meth-dflt-obj-ptrn-id-init-fn-name-gen.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-gen.case +// - src/dstr-binding/default/cls-decl-meth-dflt.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +class C { + method({ gen = function* () {}, xGen = function* x() {} } = {}) { + assert.sameValue(gen.name, 'gen'); + assert.notSameValue(xGen.name, 'xGen'); + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-dflt-obj-ptrn-id-init-skipped.js b/test/language/statements/class/dstr-meth-dflt-obj-ptrn-id-init-skipped.js new file mode 100644 index 0000000000..7c5f8a1453 --- /dev/null +++ b/test/language/statements/class/dstr-meth-dflt-obj-ptrn-id-init-skipped.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-skipped.case +// - src/dstr-binding/default/cls-decl-meth-dflt.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + [...] +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var callCount = 0; +class C { + method({ w = counter(), x = counter(), y = counter(), z = counter() } = { w: null, x: 0, y: false, z: '' }) { + assert.sameValue(w, null); + assert.sameValue(x, 0); + assert.sameValue(y, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-dflt-obj-ptrn-id-init-throws.js b/test/language/statements/class/dstr-meth-dflt-obj-ptrn-id-init-throws.js new file mode 100644 index 0000000000..ede61ab581 --- /dev/null +++ b/test/language/statements/class/dstr-meth-dflt-obj-ptrn-id-init-throws.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-throws.case +// - src/dstr-binding/error/cls-decl-meth-dflt.template +/*--- +description: Error thrown when evaluating the initializer (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 { + method({ x = thrower() } = {}) {} +}; + +var c = new C(); + +assert.throws(Test262Error, function() { + c.method(); +}); diff --git a/test/language/statements/class/dstr-meth-dflt-obj-ptrn-id-init-unresolvable.js b/test/language/statements/class/dstr-meth-dflt-obj-ptrn-id-init-unresolvable.js new file mode 100644 index 0000000000..f685d6925d --- /dev/null +++ b/test/language/statements/class/dstr-meth-dflt-obj-ptrn-id-init-unresolvable.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-unresolvable.case +// - src/dstr-binding/error/cls-decl-meth-dflt.template +/*--- +description: Destructuring initializer is an unresolvable reference (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 { + method({ x = unresolvableReference } = {}) {} +}; + +var c = new C(); + +assert.throws(ReferenceError, function() { + c.method(); +}); diff --git a/test/language/statements/class/dstr-meth-dflt-obj-ptrn-id-trailing-comma.js b/test/language/statements/class/dstr-meth-dflt-obj-ptrn-id-trailing-comma.js new file mode 100644 index 0000000000..91d6e40522 --- /dev/null +++ b/test/language/statements/class/dstr-meth-dflt-obj-ptrn-id-trailing-comma.js @@ -0,0 +1,77 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-trailing-comma.case +// - src/dstr-binding/default/cls-decl-meth-dflt.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var callCount = 0; +class C { + method({ x, } = { x: 23 }) { + assert.sameValue(x, 23); + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-dflt-obj-ptrn-list-err.js b/test/language/statements/class/dstr-meth-dflt-obj-ptrn-list-err.js new file mode 100644 index 0000000000..9ee791529c --- /dev/null +++ b/test/language/statements/class/dstr-meth-dflt-obj-ptrn-list-err.js @@ -0,0 +1,83 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-list-err.case +// - src/dstr-binding/error/cls-decl-meth-dflt.template +/*--- +description: Binding property list evaluation is interrupted by an abrupt completion (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 { + method({ a, b = thrower(), c = ++initCount } = {}) {} +}; + +var c = new C(); + +assert.throws(Test262Error, function() { + c.method(); +}); + +assert.sameValue(initCount, 0); diff --git a/test/language/statements/class/dstr-meth-dflt-obj-ptrn-prop-ary-init.js b/test/language/statements/class/dstr-meth-dflt-obj-ptrn-prop-ary-init.js new file mode 100644 index 0000000000..65aa2ea5d9 --- /dev/null +++ b/test/language/statements/class/dstr-meth-dflt-obj-ptrn-prop-ary-init.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-init.case +// - src/dstr-binding/default/cls-decl-meth-dflt.template +/*--- +description: Object binding pattern with "nested" array binding pattern using initializer (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +class C { + method({ w: [x, y, z] = [4, 5, 6] } = {}) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-dflt-obj-ptrn-prop-ary-trailing-comma.js b/test/language/statements/class/dstr-meth-dflt-obj-ptrn-prop-ary-trailing-comma.js new file mode 100644 index 0000000000..bf7b97f870 --- /dev/null +++ b/test/language/statements/class/dstr-meth-dflt-obj-ptrn-prop-ary-trailing-comma.js @@ -0,0 +1,77 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-trailing-comma.case +// - src/dstr-binding/default/cls-decl-meth-dflt.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var callCount = 0; +class C { + method({ x: [y], } = { x: [45] }) { + assert.sameValue(y,45); + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-dflt-obj-ptrn-prop-ary-value-null.js b/test/language/statements/class/dstr-meth-dflt-obj-ptrn-prop-ary-value-null.js new file mode 100644 index 0000000000..cbe4f3c967 --- /dev/null +++ b/test/language/statements/class/dstr-meth-dflt-obj-ptrn-prop-ary-value-null.js @@ -0,0 +1,77 @@ +// 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-meth-dflt.template +/*--- +description: Object binding pattern with "nested" array binding pattern taking the `null` value (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 { + method({ w: [x, y, z] = [4, 5, 6] } = { w: null }) {} +}; + +var c = new C(); + +assert.throws(TypeError, function() { + c.method(); +}); diff --git a/test/language/statements/class/dstr-meth-dflt-obj-ptrn-prop-ary.js b/test/language/statements/class/dstr-meth-dflt-obj-ptrn-prop-ary.js new file mode 100644 index 0000000000..ad8c844723 --- /dev/null +++ b/test/language/statements/class/dstr-meth-dflt-obj-ptrn-prop-ary.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary.case +// - src/dstr-binding/default/cls-decl-meth-dflt.template +/*--- +description: Object binding pattern with "nested" array binding pattern not using initializer (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +class C { + method({ w: [x, y, z] = [4, 5, 6] } = { w: [7, undefined, ] }) { + assert.sameValue(x, 7); + assert.sameValue(y, undefined); + assert.sameValue(z, undefined); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-dflt-obj-ptrn-prop-eval-err.js b/test/language/statements/class/dstr-meth-dflt-obj-ptrn-prop-eval-err.js new file mode 100644 index 0000000000..f56697919c --- /dev/null +++ b/test/language/statements/class/dstr-meth-dflt-obj-ptrn-prop-eval-err.js @@ -0,0 +1,79 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-eval-err.case +// - src/dstr-binding/error/cls-decl-meth-dflt.template +/*--- +description: Evaluation of property name returns an abrupt completion (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 { + method({ [thrower()]: x } = {}) {} +}; + +var c = new C(); + +assert.throws(Test262Error, function() { + c.method(); +}); diff --git a/test/language/statements/class/dstr-meth-dflt-obj-ptrn-prop-id-get-value-err.js b/test/language/statements/class/dstr-meth-dflt-obj-ptrn-prop-id-get-value-err.js new file mode 100644 index 0000000000..524ac7ba85 --- /dev/null +++ b/test/language/statements/class/dstr-meth-dflt-obj-ptrn-prop-id-get-value-err.js @@ -0,0 +1,84 @@ +// 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-meth-dflt.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 { + method({ poisoned: x = ++initEvalCount } = poisonedProperty) {} +}; + +var c = new C(); + +assert.throws(Test262Error, function() { + c.method(); +}); + +assert.sameValue(initEvalCount, 0); diff --git a/test/language/statements/class/dstr-meth-dflt-obj-ptrn-prop-id-init-skipped.js b/test/language/statements/class/dstr-meth-dflt-obj-ptrn-prop-id-init-skipped.js new file mode 100644 index 0000000000..9855fc3a8f --- /dev/null +++ b/test/language/statements/class/dstr-meth-dflt-obj-ptrn-prop-id-init-skipped.js @@ -0,0 +1,99 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-skipped.case +// - src/dstr-binding/default/cls-decl-meth-dflt.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + [...] +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var callCount = 0; +class C { + method({ s: t = counter(), u: v = counter(), w: x = counter(), y: z = counter() } = { s: null, u: 0, w: false, y: '' }) { + assert.sameValue(t, null); + assert.sameValue(v, 0); + assert.sameValue(x, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + + assert.throws(ReferenceError, function() { + s; + }); + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-dflt-obj-ptrn-prop-id-init-throws.js b/test/language/statements/class/dstr-meth-dflt-obj-ptrn-prop-id-init-throws.js new file mode 100644 index 0000000000..1d9e6a9dcb --- /dev/null +++ b/test/language/statements/class/dstr-meth-dflt-obj-ptrn-prop-id-init-throws.js @@ -0,0 +1,82 @@ +// 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-meth-dflt.template +/*--- +description: Error thrown when evaluating the initializer (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 { + method({ x: y = thrower() } = {}) {} +}; + +var c = new C(); + +assert.throws(Test262Error, function() { + c.method(); +}); diff --git a/test/language/statements/class/dstr-meth-dflt-obj-ptrn-prop-id-init-unresolvable.js b/test/language/statements/class/dstr-meth-dflt-obj-ptrn-prop-id-init-unresolvable.js new file mode 100644 index 0000000000..72b320dfa9 --- /dev/null +++ b/test/language/statements/class/dstr-meth-dflt-obj-ptrn-prop-id-init-unresolvable.js @@ -0,0 +1,86 @@ +// 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-meth-dflt.template +/*--- +description: Destructuring initializer is an unresolvable reference (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 { + method({ x: y = unresolvableReference } = {}) {} +}; + +var c = new C(); + +assert.throws(ReferenceError, function() { + c.method(); +}); diff --git a/test/language/statements/class/dstr-meth-dflt-obj-ptrn-prop-id-init.js b/test/language/statements/class/dstr-meth-dflt-obj-ptrn-prop-id-init.js new file mode 100644 index 0000000000..89d5c3e662 --- /dev/null +++ b/test/language/statements/class/dstr-meth-dflt-obj-ptrn-prop-id-init.js @@ -0,0 +1,80 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init.case +// - src/dstr-binding/default/cls-decl-meth-dflt.template +/*--- +description: Binding as specified via property name, identifier, and initializer (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + method({ x: y = 33 } = { }) { + assert.sameValue(y, 33); + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-dflt-obj-ptrn-prop-id-trailing-comma.js b/test/language/statements/class/dstr-meth-dflt-obj-ptrn-prop-id-trailing-comma.js new file mode 100644 index 0000000000..f4b1133d11 --- /dev/null +++ b/test/language/statements/class/dstr-meth-dflt-obj-ptrn-prop-id-trailing-comma.js @@ -0,0 +1,81 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-trailing-comma.case +// - src/dstr-binding/default/cls-decl-meth-dflt.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var callCount = 0; +class C { + method({ x: y, } = { x: 23 }) { + assert.sameValue(y, 23); + + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-dflt-obj-ptrn-prop-id.js b/test/language/statements/class/dstr-meth-dflt-obj-ptrn-prop-id.js new file mode 100644 index 0000000000..06bd46d480 --- /dev/null +++ b/test/language/statements/class/dstr-meth-dflt-obj-ptrn-prop-id.js @@ -0,0 +1,80 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id.case +// - src/dstr-binding/default/cls-decl-meth-dflt.template +/*--- +description: Binding as specified via property name and identifier (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + method({ x: y } = { x: 23 }) { + assert.sameValue(y, 23); + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-dflt-obj-ptrn-prop-obj-init.js b/test/language/statements/class/dstr-meth-dflt-obj-ptrn-prop-obj-init.js new file mode 100644 index 0000000000..7a0878443e --- /dev/null +++ b/test/language/statements/class/dstr-meth-dflt-obj-ptrn-prop-obj-init.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-init.case +// - src/dstr-binding/default/cls-decl-meth-dflt.template +/*--- +description: Object binding pattern with "nested" object binding pattern using initializer (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +class C { + method({ w: { x, y, z } = { x: 4, y: 5, z: 6 } } = { w: undefined }) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-dflt-obj-ptrn-prop-obj-value-null.js b/test/language/statements/class/dstr-meth-dflt-obj-ptrn-prop-obj-value-null.js new file mode 100644 index 0000000000..24a7a1e876 --- /dev/null +++ b/test/language/statements/class/dstr-meth-dflt-obj-ptrn-prop-obj-value-null.js @@ -0,0 +1,77 @@ +// 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-meth-dflt.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 { + method({ w: { x, y, z } = { x: 4, y: 5, z: 6 } } = { w: null }) {} +}; + +var c = new C(); + +assert.throws(TypeError, function() { + c.method(); +}); diff --git a/test/language/statements/class/dstr-meth-dflt-obj-ptrn-prop-obj-value-undef.js b/test/language/statements/class/dstr-meth-dflt-obj-ptrn-prop-obj-value-undef.js new file mode 100644 index 0000000000..92d4cf3f9f --- /dev/null +++ b/test/language/statements/class/dstr-meth-dflt-obj-ptrn-prop-obj-value-undef.js @@ -0,0 +1,77 @@ +// 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-meth-dflt.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 { + method({ w: { x, y, z } = undefined } = { }) {} +}; + +var c = new C(); + +assert.throws(TypeError, function() { + c.method(); +}); diff --git a/test/language/statements/class/dstr-meth-dflt-obj-ptrn-prop-obj.js b/test/language/statements/class/dstr-meth-dflt-obj-ptrn-prop-obj.js new file mode 100644 index 0000000000..a51a6f2fd0 --- /dev/null +++ b/test/language/statements/class/dstr-meth-dflt-obj-ptrn-prop-obj.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj.case +// - src/dstr-binding/default/cls-decl-meth-dflt.template +/*--- +description: Object binding pattern with "nested" object binding pattern not using initializer (class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +class C { + method({ w: { x, y, z } = { x: 4, y: 5, z: 6 } } = { w: { x: undefined, z: 7 } }) { + assert.sameValue(x, undefined); + assert.sameValue(y, undefined); + assert.sameValue(z, 7); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } +}; + +new C().method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-static-dflt-ary-init-iter-close.js b/test/language/statements/class/dstr-meth-static-dflt-ary-init-iter-close.js new file mode 100644 index 0000000000..73dd499b86 --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-dflt-ary-init-iter-close.js @@ -0,0 +1,93 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-close.case +// - src/dstr-binding/default/cls-decl-meth-static-dflt.template +/*--- +description: Iterator is closed when not exhausted by pattern evaluation (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [Symbol.iterator, destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + [...] + 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator, + result). + [...] + +---*/ +var doneCallCount = 0; +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return { value: null, done: false }; + }, + return: function() { + doneCallCount += 1; + return {}; + } + }; +}; + +var callCount = 0; +class C { + static method([x] = iter) { + assert.sameValue(doneCallCount, 1); + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-static-dflt-ary-init-iter-get-err.js b/test/language/statements/class/dstr-meth-static-dflt-ary-init-iter-get-err.js new file mode 100644 index 0000000000..466bc738be --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-dflt-ary-init-iter-get-err.js @@ -0,0 +1,79 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-get-err.case +// - src/dstr-binding/error/cls-decl-meth-static-dflt.template +/*--- +description: Abrupt completion returned by GetIterator (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [Symbol.iterator, destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 method([x] = iter) {} +}; + +assert.throws(Test262Error, function() { + C.method(); +}); diff --git a/test/language/statements/class/dstr-meth-static-dflt-ary-init-iter-no-close.js b/test/language/statements/class/dstr-meth-static-dflt-ary-init-iter-no-close.js new file mode 100644 index 0000000000..13bf83b0d8 --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-dflt-ary-init-iter-no-close.js @@ -0,0 +1,93 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-no-close.case +// - src/dstr-binding/default/cls-decl-meth-static-dflt.template +/*--- +description: Iterator is not closed when exhausted by pattern evaluation (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [Symbol.iterator, destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + [...] + 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator, + result). + [...] + +---*/ +var doneCallCount = 0; +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return { value: null, done: true }; + }, + return: function() { + doneCallCount += 1; + return {}; + } + }; +}; + +var callCount = 0; +class C { + static method([x] = iter) { + assert.sameValue(doneCallCount, 0); + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-static-dflt-ary-name-iter-val.js b/test/language/statements/class/dstr-meth-static-dflt-ary-name-iter-val.js new file mode 100644 index 0000000000..f6e0d82e7b --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-dflt-ary-name-iter-val.js @@ -0,0 +1,92 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-name-iter-val.case +// - src/dstr-binding/default/cls-decl-meth-static-dflt.template +/*--- +description: SingleNameBinding with normal value iteration (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set + iteratorRecord.[[done]] to true. + iii. ReturnIfAbrupt(v). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static method([x, y, z] = [1, 2, 3]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 3); + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-elem-ary-elem-init.js b/test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-elem-ary-elem-init.js new file mode 100644 index 0000000000..27b67f0a8d --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-elem-ary-elem-init.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elem-init.case +// - src/dstr-binding/default/cls-decl-meth-static-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is used (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +class C { + static method([[x, y, z] = [4, 5, 6]] = []) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-elem-ary-elem-iter.js b/test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-elem-ary-elem-iter.js new file mode 100644 index 0000000000..2a25dabf14 --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-elem-ary-elem-iter.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elem-iter.case +// - src/dstr-binding/default/cls-decl-meth-static-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +class C { + static method([[x, y, z] = [4, 5, 6]] = [[7, 8, 9]]) { + assert.sameValue(x, 7); + assert.sameValue(y, 8); + assert.sameValue(z, 9); + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-elem-ary-elision-init.js b/test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-elem-ary-elision-init.js new file mode 100644 index 0000000000..24896dd63f --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-elem-ary-elision-init.js @@ -0,0 +1,91 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elision-init.case +// - src/dstr-binding/default/cls-decl-meth-static-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is used (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [generators, destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var callCount = 0; +class C { + static method([[,] = g()] = []) { + assert.sameValue(first, 1); + assert.sameValue(second, 0); + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-elem-ary-elision-iter.js b/test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-elem-ary-elision-iter.js new file mode 100644 index 0000000000..2e5bef1035 --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-elem-ary-elision-iter.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elision-iter.case +// - src/dstr-binding/default/cls-decl-meth-static-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [generators, destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var callCount = 0; +function* g() { + callCount += 1; +}; + +var callCount = 0; +class C { + static method([[,] = g()] = [[]]) { + assert.sameValue(callCount, 0); + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-elem-ary-empty-init.js b/test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-elem-ary-empty-init.js new file mode 100644 index 0000000000..0d9c8e47dd --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-elem-ary-empty-init.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-empty-init.case +// - src/dstr-binding/default/cls-decl-meth-static-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is used (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var initCount = 0; +var iterCount = 0; +var iter = function*() { iterCount += 1; }(); + +var callCount = 0; +class C { + static method([[] = function() { initCount += 1; return iter; }()] = []) { + assert.sameValue(initCount, 1); + assert.sameValue(iterCount, 0); + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-elem-ary-empty-iter.js b/test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-elem-ary-empty-iter.js new file mode 100644 index 0000000000..562ee56690 --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-elem-ary-empty-iter.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-empty-iter.case +// - src/dstr-binding/default/cls-decl-meth-static-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var initCount = 0; + +var callCount = 0; +class C { + static method([[] = function() { initCount += 1; }()] = [[23]]) { + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-elem-ary-rest-init.js b/test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-elem-ary-rest-init.js new file mode 100644 index 0000000000..de51d5527e --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-elem-ary-rest-init.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-rest-init.case +// - src/dstr-binding/default/cls-decl-meth-static-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is used (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var values = [2, 1, 3]; + +var callCount = 0; +class C { + static method([[...x] = values] = []) { + assert(Array.isArray(x)); + assert.sameValue(x[0], 2); + assert.sameValue(x[1], 1); + assert.sameValue(x[2], 3); + assert.sameValue(x.length, 3); + assert.notSameValue(x, values); + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-elem-ary-rest-iter.js b/test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-elem-ary-rest-iter.js new file mode 100644 index 0000000000..f061737cf0 --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-elem-ary-rest-iter.js @@ -0,0 +1,91 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-rest-iter.case +// - src/dstr-binding/default/cls-decl-meth-static-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var values = [2, 1, 3]; +var initCount = 0; + +var callCount = 0; +class C { + static method([[...x] = function() { initCount += 1; }()] = [values]) { + assert(Array.isArray(x)); + assert.sameValue(x[0], 2); + assert.sameValue(x[1], 1); + assert.sameValue(x[2], 3); + assert.sameValue(x.length, 3); + assert.notSameValue(x, values); + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-elem-ary-val-null.js b/test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-elem-ary-val-null.js new file mode 100644 index 0000000000..304f5b444b --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-elem-ary-val-null.js @@ -0,0 +1,86 @@ +// 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-meth-static-dflt.template +/*--- +description: Nested array destructuring with a null value (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 method([[x]] = [null]) {} +}; + +assert.throws(TypeError, function() { + C.method(); +}); diff --git a/test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-elem-id-init-exhausted.js b/test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-elem-id-init-exhausted.js new file mode 100644 index 0000000000..4981f9743d --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-elem-id-init-exhausted.js @@ -0,0 +1,83 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-exhausted.case +// - src/dstr-binding/default/cls-decl-meth-static-dflt.template +/*--- +description: Destructuring initializer with an exhausted iterator (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static method([x = 23] = []) { + assert.sameValue(x, 23); + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-arrow.js b/test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-arrow.js new file mode 100644 index 0000000000..dab5ffd8f0 --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-arrow.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-arrow.case +// - src/dstr-binding/default/cls-decl-meth-static-dflt.template +/*--- +description: SingleNameBinding does assign name to arrow functions (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static method([arrow = () => {}] = []) { + assert.sameValue(arrow.name, 'arrow'); + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-class.js b/test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-class.js new file mode 100644 index 0000000000..922e3042fe --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-class.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-class.case +// - src/dstr-binding/default/cls-decl-meth-static-dflt.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static method([cls = class {}, xCls = class X {}] = []) { + assert.sameValue(cls.name, 'cls'); + assert.notSameValue(xCls.name, 'xCls'); + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-cover.js b/test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-cover.js new file mode 100644 index 0000000000..c8d7120e74 --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-cover.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-cover.case +// - src/dstr-binding/default/cls-decl-meth-static-dflt.template +/*--- +description: SingleNameBinding does assign name to "anonymous" functions "through" cover grammar (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static method([cover = (function () {}), xCover = (0, function() {})] = []) { + assert.sameValue(cover.name, 'cover'); + assert.notSameValue(xCover.name, 'xCover'); + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-fn.js b/test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-fn.js new file mode 100644 index 0000000000..e7f32f1208 --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-fn.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-fn.case +// - src/dstr-binding/default/cls-decl-meth-static-dflt.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static method([fn = function () {}, xFn = function x() {}] = []) { + assert.sameValue(fn.name, 'fn'); + assert.notSameValue(xFn.name, 'xFn'); + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-gen.js b/test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-gen.js new file mode 100644 index 0000000000..0b19c53702 --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-elem-id-init-fn-name-gen.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-gen.case +// - src/dstr-binding/default/cls-decl-meth-static-dflt.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static method([gen = function* () {}, xGen = function* x() {}] = []) { + assert.sameValue(gen.name, 'gen'); + assert.notSameValue(xGen.name, 'xGen'); + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-elem-id-init-hole.js b/test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-elem-id-init-hole.js new file mode 100644 index 0000000000..8e6c2e9673 --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-elem-id-init-hole.js @@ -0,0 +1,79 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-hole.case +// - src/dstr-binding/default/cls-decl-meth-static-dflt.template +/*--- +description: Destructuring initializer with a "hole" (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + SingleNameBinding : BindingIdentifier Initializeropt + [...] 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + [...] + 7. If environment is undefined, return PutValue(lhs, v). 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static method([x = 23] = [,]) { + assert.sameValue(x, 23); + // another statement + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-elem-id-init-skipped.js b/test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-elem-id-init-skipped.js new file mode 100644 index 0000000000..6c319ee354 --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-elem-id-init-skipped.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-skipped.case +// - src/dstr-binding/default/cls-decl-meth-static-dflt.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var callCount = 0; +class C { + static method([w = counter(), x = counter(), y = counter(), z = counter()] = [null, 0, false, '']) { + assert.sameValue(w, null); + assert.sameValue(x, 0); + assert.sameValue(y, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-elem-id-init-throws.js b/test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-elem-id-init-throws.js new file mode 100644 index 0000000000..8102ea7210 --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-elem-id-init-throws.js @@ -0,0 +1,77 @@ +// 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-meth-static-dflt.template +/*--- +description: Destructuring initializer returns an abrupt completion (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 method([x = (function() { throw new Test262Error(); })()] = [undefined]) {} +}; + +assert.throws(Test262Error, function() { + C.method(); +}); diff --git a/test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-elem-id-init-undef.js b/test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-elem-id-init-undef.js new file mode 100644 index 0000000000..61cbf1370d --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-elem-id-init-undef.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-undef.case +// - src/dstr-binding/default/cls-decl-meth-static-dflt.template +/*--- +description: Destructuring initializer with an undefined value (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static method([x = 23] = [undefined]) { + assert.sameValue(x, 23); + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-elem-id-init-unresolvable.js b/test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-elem-id-init-unresolvable.js new file mode 100644 index 0000000000..934a41dfa0 --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-elem-id-init-unresolvable.js @@ -0,0 +1,84 @@ +// 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-meth-static-dflt.template +/*--- +description: Destructuring initializer is an unresolvable reference (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 method([ x = unresolvableReference ] = []) {} +}; + +assert.throws(ReferenceError, function() { + C.method(); +}); diff --git a/test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-elem-id-iter-complete.js b/test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-elem-id-iter-complete.js new file mode 100644 index 0000000000..fc739b6657 --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-elem-id-iter-complete.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-complete.case +// - src/dstr-binding/default/cls-decl-meth-static-dflt.template +/*--- +description: SingleNameBinding when value iteration completes (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static method([x] = []) { + assert.sameValue(x, undefined); + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-elem-id-iter-done.js b/test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-elem-id-iter-done.js new file mode 100644 index 0000000000..9ec53e2ae7 --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-elem-id-iter-done.js @@ -0,0 +1,81 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-done.case +// - src/dstr-binding/default/cls-decl-meth-static-dflt.template +/*--- +description: SingleNameBinding when value iteration was completed previously (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static method([_, x] = []) { + assert.sameValue(x, undefined); + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-elem-id-iter-step-err.js b/test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-elem-id-iter-step-err.js new file mode 100644 index 0000000000..1b577f92c7 --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-elem-id-iter-step-err.js @@ -0,0 +1,85 @@ +// 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-meth-static-dflt.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 method([x] = g) {} +}; + +assert.throws(Test262Error, function() { + C.method(); +}); diff --git a/test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-elem-id-iter-val-err.js b/test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-elem-id-iter-val-err.js new file mode 100644 index 0000000000..6bc92b07e6 --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-elem-id-iter-val-err.js @@ -0,0 +1,96 @@ +// 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-meth-static-dflt.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 method([x] = g) {} +}; + +assert.throws(Test262Error, function() { + C.method(); +}); diff --git a/test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-elem-id-iter-val.js b/test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-elem-id-iter-val.js new file mode 100644 index 0000000000..776c19b7eb --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-elem-id-iter-val.js @@ -0,0 +1,92 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val.case +// - src/dstr-binding/default/cls-decl-meth-static-dflt.template +/*--- +description: SingleNameBinding when value iteration was completed previously (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set + iteratorRecord.[[done]] to true. + iii. ReturnIfAbrupt(v). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static method([x, y, z] = [1, 2, 3]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 3); + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-elem-obj-id-init.js b/test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-elem-obj-id-init.js new file mode 100644 index 0000000000..a4ddbacd42 --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-elem-obj-id-init.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-id-init.case +// - src/dstr-binding/default/cls-decl-meth-static-dflt.template +/*--- +description: BindingElement with object binding pattern and initializer is used (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +class C { + static method([{ x, y, z } = { x: 44, y: 55, z: 66 }] = []) { + assert.sameValue(x, 44); + assert.sameValue(y, 55); + assert.sameValue(z, 66); + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-elem-obj-id.js b/test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-elem-obj-id.js new file mode 100644 index 0000000000..72c062c11b --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-elem-obj-id.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-id.case +// - src/dstr-binding/default/cls-decl-meth-static-dflt.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +class C { + static method([{ x, y, z } = { x: 44, y: 55, z: 66 }] = [{ x: 11, y: 22, z: 33 }]) { + assert.sameValue(x, 11); + assert.sameValue(y, 22); + assert.sameValue(z, 33); + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-elem-obj-prop-id-init.js b/test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-elem-obj-prop-id-init.js new file mode 100644 index 0000000000..66878c7af3 --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-elem-obj-prop-id-init.js @@ -0,0 +1,94 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-prop-id-init.case +// - src/dstr-binding/default/cls-decl-meth-static-dflt.template +/*--- +description: BindingElement with object binding pattern and initializer is used (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +class C { + static method([{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }] = []) { + assert.sameValue(v, 444); + assert.sameValue(x, 555); + assert.sameValue(z, 666); + + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-elem-obj-prop-id.js b/test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-elem-obj-prop-id.js new file mode 100644 index 0000000000..7cf14cff82 --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-elem-obj-prop-id.js @@ -0,0 +1,94 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-prop-id.case +// - src/dstr-binding/default/cls-decl-meth-static-dflt.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +class C { + static method([{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }] = [{ u: 777, w: 888, y: 999 }]) { + assert.sameValue(v, 777); + assert.sameValue(x, 888); + assert.sameValue(z, 999); + + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-elem-obj-val-null.js b/test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-elem-obj-val-null.js new file mode 100644 index 0000000000..4041160ca1 --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-elem-obj-val-null.js @@ -0,0 +1,86 @@ +// 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-meth-static-dflt.template +/*--- +description: Nested object destructuring with a null value (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 method([{ x }] = [null]) {} +}; + +assert.throws(TypeError, function() { + C.method(); +}); diff --git a/test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-elem-obj-val-undef.js b/test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-elem-obj-val-undef.js new file mode 100644 index 0000000000..5f8cbdfc96 --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-elem-obj-val-undef.js @@ -0,0 +1,86 @@ +// 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-meth-static-dflt.template +/*--- +description: Nested object destructuring with a value of `undefined` (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 method([{ x }] = []) {} +}; + +assert.throws(TypeError, function() { + C.method(); +}); diff --git a/test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-elision-exhausted.js b/test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-elision-exhausted.js new file mode 100644 index 0000000000..e011176909 --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-elision-exhausted.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-exhausted.case +// - src/dstr-binding/default/cls-decl-meth-static-dflt.template +/*--- +description: Elision accepts exhausted iterator (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [generator, destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + [...] + 2. Return NormalCompletion(empty). + +---*/ +var iter = function*() {}(); +iter.next(); + +var callCount = 0; +class C { + static method([,] = iter) { + + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-elision-step-err.js b/test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-elision-step-err.js new file mode 100644 index 0000000000..e4b4b56762 --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-elision-step-err.js @@ -0,0 +1,93 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-step-err.case +// - src/dstr-binding/error/cls-decl-meth-static-dflt.template +/*--- +description: Elision advances iterator and forwards abrupt completions (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [generator, destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 method([,] = iter) {} +}; + +assert.throws(Test262Error, function() { + C.method(); +}); + +iter.next(); +assert.sameValue(following, 0, 'Iterator was properly closed.'); diff --git a/test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-elision.js b/test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-elision.js new file mode 100644 index 0000000000..d090623ce8 --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-elision.js @@ -0,0 +1,98 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision.case +// - src/dstr-binding/default/cls-decl-meth-static-dflt.template +/*--- +description: Elision advances iterator (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [generator, destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + 2. Return NormalCompletion(empty). + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var callCount = 0; +class C { + static method([,] = g()) { + assert.sameValue(first, 1); + assert.sameValue(second, 0); + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-empty.js b/test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-empty.js new file mode 100644 index 0000000000..d361f69b1c --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-empty.js @@ -0,0 +1,81 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-empty.case +// - src/dstr-binding/default/cls-decl-meth-static-dflt.template +/*--- +description: No iteration occurs for an "empty" array binding pattern (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [generators, destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ ] + + 1. Return NormalCompletion(empty). + +---*/ +var iterations = 0; +var iter = function*() { + iterations += 1; +}(); + +var callCount = 0; +class C { + static method([] = iter) { + assert.sameValue(iterations, 0); + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-rest-ary-elem.js b/test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-rest-ary-elem.js new file mode 100644 index 0000000000..13d59b5093 --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-rest-ary-elem.js @@ -0,0 +1,105 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-elem.case +// - src/dstr-binding/default/cls-decl-meth-static-dflt.template +/*--- +description: Rest element containing an array BindingElementList pattern (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set + iteratorRecord.[[done]] to true. + iii. ReturnIfAbrupt(v). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static method([...[x, y, z]] = [3, 4, 5]) { + assert.sameValue(x, 3); + assert.sameValue(y, 4); + assert.sameValue(z, 5); + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-rest-ary-elision.js b/test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-rest-ary-elision.js new file mode 100644 index 0000000000..14c7eac34d --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-rest-ary-elision.js @@ -0,0 +1,111 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-elision.case +// - src/dstr-binding/default/cls-decl-meth-static-dflt.template +/*--- +description: Rest element containing an elision (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [generators, destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + 2. Return NormalCompletion(empty). + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var callCount = 0; +class C { + static method([...[,]] = g()) { + assert.sameValue(first, 1); + assert.sameValue(second, 1); + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-rest-ary-empty.js b/test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-rest-ary-empty.js new file mode 100644 index 0000000000..91f24a4508 --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-rest-ary-empty.js @@ -0,0 +1,94 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-empty.case +// - src/dstr-binding/default/cls-decl-meth-static-dflt.template +/*--- +description: Rest element containing an "empty" array pattern (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [generators, destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ ] + + 1. Return NormalCompletion(empty). + +---*/ +var iterations = 0; +var iter = function*() { + iterations += 1; +}(); + +var callCount = 0; +class C { + static method([...[]] = iter) { + assert.sameValue(iterations, 1); + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-rest-ary-rest.js b/test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-rest-ary-rest.js new file mode 100644 index 0000000000..41b355b0b4 --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-rest-ary-rest.js @@ -0,0 +1,90 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-rest.case +// - src/dstr-binding/default/cls-decl-meth-static-dflt.template +/*--- +description: Rest element containing a rest element (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ +var values = [1, 2, 3]; + +var callCount = 0; +class C { + static method([...[...x]] = values) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 1); + assert.sameValue(x[1], 2); + assert.sameValue(x[2], 3); + assert.notSameValue(x, values); + + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-rest-id-elision-next-err.js b/test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-rest-id-elision-next-err.js new file mode 100644 index 0000000000..fbda4c0f1f --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-rest-id-elision-next-err.js @@ -0,0 +1,79 @@ +// 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-meth-static-dflt.template +/*--- +description: Rest element following elision elements (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [generators, destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 method([, ...x] = iter) {} +}; + +assert.throws(Test262Error, function() { + C.method(); +}); diff --git a/test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-rest-id-elision.js b/test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-rest-id-elision.js new file mode 100644 index 0000000000..710b261aa9 --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-rest-id-elision.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision.case +// - src/dstr-binding/default/cls-decl-meth-static-dflt.template +/*--- +description: Rest element following elision elements (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + ArrayBindingPattern : [ Elisionopt BindingRestElement ] + 1. If Elision is present, then + a. Let status be the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with + iteratorRecord as the argument. + b. ReturnIfAbrupt(status). + 2. Return the result of performing IteratorBindingInitialization for + BindingRestElement with iteratorRecord and environment as arguments. +---*/ +var values = [1, 2, 3, 4, 5]; + +var callCount = 0; +class C { + static method([ , , ...x] = values) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 3); + assert.sameValue(x[1], 4); + assert.sameValue(x[2], 5); + assert.notSameValue(x, values); + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-rest-id-exhausted.js b/test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-rest-id-exhausted.js new file mode 100644 index 0000000000..7c3fd3e4d0 --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-rest-id-exhausted.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-exhausted.case +// - src/dstr-binding/default/cls-decl-meth-static-dflt.template +/*--- +description: RestElement applied to an exhausted iterator (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [Symbol.iterator, destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier, + environment). + 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat, + [...] + b. If iteratorRecord.[[done]] is true, then + i. If environment is undefined, return PutValue(lhs, A). + ii. Return InitializeReferencedBinding(lhs, A). + +---*/ + +var callCount = 0; +class C { + static method([, , ...x] = [1, 2]) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 0); + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-rest-id-iter-step-err.js b/test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-rest-id-iter-step-err.js new file mode 100644 index 0000000000..c69040be38 --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-rest-id-iter-step-err.js @@ -0,0 +1,90 @@ +// 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-meth-static-dflt.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [generators, destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 method([...x] = iter) {} +}; + +assert.throws(Test262Error, function() { + C.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-meth-static-dflt-ary-ptrn-rest-id-iter-val-err.js b/test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-rest-id-iter-val-err.js new file mode 100644 index 0000000000..2284a6448d --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-rest-id-iter-val-err.js @@ -0,0 +1,92 @@ +// 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-meth-static-dflt.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [Symbol.iterator, destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 method([...x] = iter) {} +}; + +assert.throws(Test262Error, function() { + C.method(); +}); diff --git a/test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-rest-id.js b/test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-rest-id.js new file mode 100644 index 0000000000..6d78576dab --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-rest-id.js @@ -0,0 +1,83 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id.case +// - src/dstr-binding/default/cls-decl-meth-static-dflt.template +/*--- +description: Lone rest element (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + [...] 3. Let A be ArrayCreate(0). [...] 5. Repeat + [...] + f. Let status be CreateDataProperty(A, ToString (n), nextValue). + [...] +---*/ +var values = [1, 2, 3]; + +var callCount = 0; +class C { + static method([...x] = values) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 1); + assert.sameValue(x[1], 2); + assert.sameValue(x[2], 3); + assert.notSameValue(x, values); + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-rest-init-ary.js b/test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-rest-init-ary.js new file mode 100644 index 0000000000..263f3b84b8 --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-rest-init-ary.js @@ -0,0 +1,77 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-ary.case +// - src/dstr-binding/default/cls-decl-meth-static-dflt.template +/*--- +description: Reset element (nested array pattern) does not support initializer (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +flags: [generated] +negative: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +class C { + static method([...[ x ] = []] = []) { + + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-rest-init-id.js b/test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-rest-init-id.js new file mode 100644 index 0000000000..a61c9a964d --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-rest-init-id.js @@ -0,0 +1,77 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-id.case +// - src/dstr-binding/default/cls-decl-meth-static-dflt.template +/*--- +description: Reset element (identifier) does not support initializer (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +flags: [generated] +negative: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +class C { + static method([...x = []] = []) { + + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-rest-init-obj.js b/test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-rest-init-obj.js new file mode 100644 index 0000000000..d5aa4120b6 --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-rest-init-obj.js @@ -0,0 +1,77 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-obj.case +// - src/dstr-binding/default/cls-decl-meth-static-dflt.template +/*--- +description: Reset element (nested object pattern) does not support initializer (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +flags: [generated] +negative: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +class C { + static method([...{ x } = []] = []) { + + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-rest-not-final-ary.js b/test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-rest-not-final-ary.js new file mode 100644 index 0000000000..1632b535f9 --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-rest-not-final-ary.js @@ -0,0 +1,77 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-ary.case +// - src/dstr-binding/default/cls-decl-meth-static-dflt.template +/*--- +description: Rest element (array binding pattern) may not be followed by any element (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +flags: [generated] +negative: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +class C { + static method([...[x], y] = [1, 2, 3]) { + + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-rest-not-final-id.js b/test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-rest-not-final-id.js new file mode 100644 index 0000000000..c8095b1607 --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-rest-not-final-id.js @@ -0,0 +1,77 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-id.case +// - src/dstr-binding/default/cls-decl-meth-static-dflt.template +/*--- +description: Rest element (identifier) may not be followed by any element (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +flags: [generated] +negative: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +class C { + static method([...x, y] = [1, 2, 3]) { + + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-rest-not-final-obj.js b/test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-rest-not-final-obj.js new file mode 100644 index 0000000000..b7394c8048 --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-rest-not-final-obj.js @@ -0,0 +1,77 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-obj.case +// - src/dstr-binding/default/cls-decl-meth-static-dflt.template +/*--- +description: Rest element (object binding pattern) may not be followed by any element (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +flags: [generated] +negative: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +class C { + static method([...{ x }, y] = [1, 2, 3]) { + + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-rest-obj-id.js b/test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-rest-obj-id.js new file mode 100644 index 0000000000..fef1563144 --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-rest-obj-id.js @@ -0,0 +1,83 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-obj-id.case +// - src/dstr-binding/default/cls-decl-meth-static-dflt.template +/*--- +description: Rest element containing an object binding pattern (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ + +var callCount = 0; +class C { + static method([...{ length }] = [1, 2, 3]) { + assert.sameValue(length, 3); + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-rest-obj-prop-id.js b/test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-rest-obj-prop-id.js new file mode 100644 index 0000000000..d8f0410c05 --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-dflt-ary-ptrn-rest-obj-prop-id.js @@ -0,0 +1,91 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-obj-prop-id.case +// - src/dstr-binding/default/cls-decl-meth-static-dflt.template +/*--- +description: Rest element containing an object binding pattern (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ + +var callCount = 0; +class C { + static method([...{ 0: v, 1: w, 2: x, 3: y, length: z }] = [7, 8, 9]) { + assert.sameValue(v, 7); + assert.sameValue(w, 8); + assert.sameValue(x, 9); + assert.sameValue(y, undefined); + assert.sameValue(z, 3); + + assert.throws(ReferenceError, function() { + length; + }); + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-static-dflt-obj-init-null.js b/test/language/statements/class/dstr-meth-static-dflt-obj-init-null.js new file mode 100644 index 0000000000..041aba454d --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-dflt-obj-init-null.js @@ -0,0 +1,73 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-null.case +// - src/dstr-binding/error/cls-decl-meth-static-dflt.template +/*--- +description: Value specifed for object binding pattern must be object coercible (null) (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + +class C { + static method({} = null) {} +}; + +assert.throws(TypeError, function() { + C.method(); +}); diff --git a/test/language/statements/class/dstr-meth-static-dflt-obj-init-undefined.js b/test/language/statements/class/dstr-meth-static-dflt-obj-init-undefined.js new file mode 100644 index 0000000000..ae08aa1b31 --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-dflt-obj-init-undefined.js @@ -0,0 +1,73 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-undefined.case +// - src/dstr-binding/error/cls-decl-meth-static-dflt.template +/*--- +description: Value specifed for object binding pattern must be object coercible (undefined) (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + +class C { + static method({} = undefined) {} +}; + +assert.throws(TypeError, function() { + C.method(); +}); diff --git a/test/language/statements/class/dstr-meth-static-dflt-obj-ptrn-empty.js b/test/language/statements/class/dstr-meth-static-dflt-obj-ptrn-empty.js new file mode 100644 index 0000000000..d15e6ea031 --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-dflt-obj-ptrn-empty.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-empty.case +// - src/dstr-binding/default/cls-decl-meth-static-dflt.template +/*--- +description: No property access occurs for an "empty" object binding pattern (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ +var accessCount = 0; +var obj = Object.defineProperty({}, 'attr', { + get: function() { + accessCount += 1; + } +}); + +var callCount = 0; +class C { + static method({} = obj) { + assert.sameValue(accessCount, 0); + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-static-dflt-obj-ptrn-id-get-value-err.js b/test/language/statements/class/dstr-meth-static-dflt-obj-ptrn-id-get-value-err.js new file mode 100644 index 0000000000..85ab81e46f --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-dflt-obj-ptrn-id-get-value-err.js @@ -0,0 +1,80 @@ +// 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-meth-static-dflt.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 method({ poisoned } = poisonedProperty) {} +}; + +assert.throws(Test262Error, function() { + C.method(); +}); diff --git a/test/language/statements/class/dstr-meth-static-dflt-obj-ptrn-id-init-fn-name-arrow.js b/test/language/statements/class/dstr-meth-static-dflt-obj-ptrn-id-init-fn-name-arrow.js new file mode 100644 index 0000000000..3fff254c93 --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-dflt-obj-ptrn-id-init-fn-name-arrow.js @@ -0,0 +1,83 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-arrow.case +// - src/dstr-binding/default/cls-decl-meth-static-dflt.template +/*--- +description: SingleNameBinding assigns `name` to arrow functions (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +class C { + static method({ arrow = () => {} } = {}) { + assert.sameValue(arrow.name, 'arrow'); + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-static-dflt-obj-ptrn-id-init-fn-name-class.js b/test/language/statements/class/dstr-meth-static-dflt-obj-ptrn-id-init-fn-name-class.js new file mode 100644 index 0000000000..4a7a08b579 --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-dflt-obj-ptrn-id-init-fn-name-class.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-class.case +// - src/dstr-binding/default/cls-decl-meth-static-dflt.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +class C { + static method({ cls = class {}, xCls = class X {} } = {}) { + assert.sameValue(cls.name, 'cls'); + assert.notSameValue(xCls.name, 'xCls'); + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-static-dflt-obj-ptrn-id-init-fn-name-cover.js b/test/language/statements/class/dstr-meth-static-dflt-obj-ptrn-id-init-fn-name-cover.js new file mode 100644 index 0000000000..5306f5f3be --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-dflt-obj-ptrn-id-init-fn-name-cover.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-cover.case +// - src/dstr-binding/default/cls-decl-meth-static-dflt.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" functions "through" cover grammar (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +class C { + static method({ cover = (function () {}), xCover = (0, function() {}) } = {}) { + assert.sameValue(cover.name, 'cover'); + assert.notSameValue(xCover.name, 'xCover'); + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-static-dflt-obj-ptrn-id-init-fn-name-fn.js b/test/language/statements/class/dstr-meth-static-dflt-obj-ptrn-id-init-fn-name-fn.js new file mode 100644 index 0000000000..87aef5a67b --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-dflt-obj-ptrn-id-init-fn-name-fn.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-fn.case +// - src/dstr-binding/default/cls-decl-meth-static-dflt.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +class C { + static method({ fn = function () {}, xFn = function x() {} } = {}) { + assert.sameValue(fn.name, 'fn'); + assert.notSameValue(xFn.name, 'xFn'); + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-static-dflt-obj-ptrn-id-init-fn-name-gen.js b/test/language/statements/class/dstr-meth-static-dflt-obj-ptrn-id-init-fn-name-gen.js new file mode 100644 index 0000000000..1c8d131152 --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-dflt-obj-ptrn-id-init-fn-name-gen.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-gen.case +// - src/dstr-binding/default/cls-decl-meth-static-dflt.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +class C { + static method({ gen = function* () {}, xGen = function* x() {} } = {}) { + assert.sameValue(gen.name, 'gen'); + assert.notSameValue(xGen.name, 'xGen'); + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-static-dflt-obj-ptrn-id-init-skipped.js b/test/language/statements/class/dstr-meth-static-dflt-obj-ptrn-id-init-skipped.js new file mode 100644 index 0000000000..8c5fed7d15 --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-dflt-obj-ptrn-id-init-skipped.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-skipped.case +// - src/dstr-binding/default/cls-decl-meth-static-dflt.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + [...] +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var callCount = 0; +class C { + static method({ w = counter(), x = counter(), y = counter(), z = counter() } = { w: null, x: 0, y: false, z: '' }) { + assert.sameValue(w, null); + assert.sameValue(x, 0); + assert.sameValue(y, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-static-dflt-obj-ptrn-id-init-throws.js b/test/language/statements/class/dstr-meth-static-dflt-obj-ptrn-id-init-throws.js new file mode 100644 index 0000000000..5e21a5e861 --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-dflt-obj-ptrn-id-init-throws.js @@ -0,0 +1,80 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-throws.case +// - src/dstr-binding/error/cls-decl-meth-static-dflt.template +/*--- +description: Error thrown when evaluating the initializer (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 method({ x = thrower() } = {}) {} +}; + +assert.throws(Test262Error, function() { + C.method(); +}); diff --git a/test/language/statements/class/dstr-meth-static-dflt-obj-ptrn-id-init-unresolvable.js b/test/language/statements/class/dstr-meth-static-dflt-obj-ptrn-id-init-unresolvable.js new file mode 100644 index 0000000000..6a41823b39 --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-dflt-obj-ptrn-id-init-unresolvable.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-unresolvable.case +// - src/dstr-binding/error/cls-decl-meth-static-dflt.template +/*--- +description: Destructuring initializer is an unresolvable reference (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 method({ x = unresolvableReference } = {}) {} +}; + +assert.throws(ReferenceError, function() { + C.method(); +}); diff --git a/test/language/statements/class/dstr-meth-static-dflt-obj-ptrn-id-trailing-comma.js b/test/language/statements/class/dstr-meth-static-dflt-obj-ptrn-id-trailing-comma.js new file mode 100644 index 0000000000..a74daebfb9 --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-dflt-obj-ptrn-id-trailing-comma.js @@ -0,0 +1,77 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-trailing-comma.case +// - src/dstr-binding/default/cls-decl-meth-static-dflt.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var callCount = 0; +class C { + static method({ x, } = { x: 23 }) { + assert.sameValue(x, 23); + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-static-dflt-obj-ptrn-list-err.js b/test/language/statements/class/dstr-meth-static-dflt-obj-ptrn-list-err.js new file mode 100644 index 0000000000..618d6e3b92 --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-dflt-obj-ptrn-list-err.js @@ -0,0 +1,81 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-list-err.case +// - src/dstr-binding/error/cls-decl-meth-static-dflt.template +/*--- +description: Binding property list evaluation is interrupted by an abrupt completion (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 method({ a, b = thrower(), c = ++initCount } = {}) {} +}; + +assert.throws(Test262Error, function() { + C.method(); +}); + +assert.sameValue(initCount, 0); diff --git a/test/language/statements/class/dstr-meth-static-dflt-obj-ptrn-prop-ary-init.js b/test/language/statements/class/dstr-meth-static-dflt-obj-ptrn-prop-ary-init.js new file mode 100644 index 0000000000..5c5c17f394 --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-dflt-obj-ptrn-prop-ary-init.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-init.case +// - src/dstr-binding/default/cls-decl-meth-static-dflt.template +/*--- +description: Object binding pattern with "nested" array binding pattern using initializer (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +class C { + static method({ w: [x, y, z] = [4, 5, 6] } = {}) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-static-dflt-obj-ptrn-prop-ary-trailing-comma.js b/test/language/statements/class/dstr-meth-static-dflt-obj-ptrn-prop-ary-trailing-comma.js new file mode 100644 index 0000000000..9bd2ce8723 --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-dflt-obj-ptrn-prop-ary-trailing-comma.js @@ -0,0 +1,77 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-trailing-comma.case +// - src/dstr-binding/default/cls-decl-meth-static-dflt.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var callCount = 0; +class C { + static method({ x: [y], } = { x: [45] }) { + assert.sameValue(y,45); + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-static-dflt-obj-ptrn-prop-ary-value-null.js b/test/language/statements/class/dstr-meth-static-dflt-obj-ptrn-prop-ary-value-null.js new file mode 100644 index 0000000000..1ad1c33712 --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-dflt-obj-ptrn-prop-ary-value-null.js @@ -0,0 +1,75 @@ +// 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-meth-static-dflt.template +/*--- +description: Object binding pattern with "nested" array binding pattern taking the `null` value (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 method({ w: [x, y, z] = [4, 5, 6] } = { w: null }) {} +}; + +assert.throws(TypeError, function() { + C.method(); +}); diff --git a/test/language/statements/class/dstr-meth-static-dflt-obj-ptrn-prop-ary.js b/test/language/statements/class/dstr-meth-static-dflt-obj-ptrn-prop-ary.js new file mode 100644 index 0000000000..891f6ad1a5 --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-dflt-obj-ptrn-prop-ary.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary.case +// - src/dstr-binding/default/cls-decl-meth-static-dflt.template +/*--- +description: Object binding pattern with "nested" array binding pattern not using initializer (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +class C { + static method({ w: [x, y, z] = [4, 5, 6] } = { w: [7, undefined, ] }) { + assert.sameValue(x, 7); + assert.sameValue(y, undefined); + assert.sameValue(z, undefined); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-static-dflt-obj-ptrn-prop-eval-err.js b/test/language/statements/class/dstr-meth-static-dflt-obj-ptrn-prop-eval-err.js new file mode 100644 index 0000000000..67ac32e8dd --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-dflt-obj-ptrn-prop-eval-err.js @@ -0,0 +1,77 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-eval-err.case +// - src/dstr-binding/error/cls-decl-meth-static-dflt.template +/*--- +description: Evaluation of property name returns an abrupt completion (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 method({ [thrower()]: x } = {}) {} +}; + +assert.throws(Test262Error, function() { + C.method(); +}); diff --git a/test/language/statements/class/dstr-meth-static-dflt-obj-ptrn-prop-id-get-value-err.js b/test/language/statements/class/dstr-meth-static-dflt-obj-ptrn-prop-id-get-value-err.js new file mode 100644 index 0000000000..e1d0b4a18b --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-dflt-obj-ptrn-prop-id-get-value-err.js @@ -0,0 +1,82 @@ +// 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-meth-static-dflt.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 method({ poisoned: x = ++initEvalCount } = poisonedProperty) {} +}; + +assert.throws(Test262Error, function() { + C.method(); +}); + +assert.sameValue(initEvalCount, 0); diff --git a/test/language/statements/class/dstr-meth-static-dflt-obj-ptrn-prop-id-init-skipped.js b/test/language/statements/class/dstr-meth-static-dflt-obj-ptrn-prop-id-init-skipped.js new file mode 100644 index 0000000000..16a8e460fa --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-dflt-obj-ptrn-prop-id-init-skipped.js @@ -0,0 +1,99 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-skipped.case +// - src/dstr-binding/default/cls-decl-meth-static-dflt.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + [...] +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var callCount = 0; +class C { + static method({ s: t = counter(), u: v = counter(), w: x = counter(), y: z = counter() } = { s: null, u: 0, w: false, y: '' }) { + assert.sameValue(t, null); + assert.sameValue(v, 0); + assert.sameValue(x, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + + assert.throws(ReferenceError, function() { + s; + }); + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-static-dflt-obj-ptrn-prop-id-init-throws.js b/test/language/statements/class/dstr-meth-static-dflt-obj-ptrn-prop-id-init-throws.js new file mode 100644 index 0000000000..77a296fd95 --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-dflt-obj-ptrn-prop-id-init-throws.js @@ -0,0 +1,80 @@ +// 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-meth-static-dflt.template +/*--- +description: Error thrown when evaluating the initializer (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 method({ x: y = thrower() } = {}) {} +}; + +assert.throws(Test262Error, function() { + C.method(); +}); diff --git a/test/language/statements/class/dstr-meth-static-dflt-obj-ptrn-prop-id-init-unresolvable.js b/test/language/statements/class/dstr-meth-static-dflt-obj-ptrn-prop-id-init-unresolvable.js new file mode 100644 index 0000000000..4e32a61ddb --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-dflt-obj-ptrn-prop-id-init-unresolvable.js @@ -0,0 +1,84 @@ +// 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-meth-static-dflt.template +/*--- +description: Destructuring initializer is an unresolvable reference (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 method({ x: y = unresolvableReference } = {}) {} +}; + +assert.throws(ReferenceError, function() { + C.method(); +}); diff --git a/test/language/statements/class/dstr-meth-static-dflt-obj-ptrn-prop-id-init.js b/test/language/statements/class/dstr-meth-static-dflt-obj-ptrn-prop-id-init.js new file mode 100644 index 0000000000..8e4acbea92 --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-dflt-obj-ptrn-prop-id-init.js @@ -0,0 +1,80 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init.case +// - src/dstr-binding/default/cls-decl-meth-static-dflt.template +/*--- +description: Binding as specified via property name, identifier, and initializer (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static method({ x: y = 33 } = { }) { + assert.sameValue(y, 33); + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-static-dflt-obj-ptrn-prop-id-trailing-comma.js b/test/language/statements/class/dstr-meth-static-dflt-obj-ptrn-prop-id-trailing-comma.js new file mode 100644 index 0000000000..183eab3b35 --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-dflt-obj-ptrn-prop-id-trailing-comma.js @@ -0,0 +1,81 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-trailing-comma.case +// - src/dstr-binding/default/cls-decl-meth-static-dflt.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var callCount = 0; +class C { + static method({ x: y, } = { x: 23 }) { + assert.sameValue(y, 23); + + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-static-dflt-obj-ptrn-prop-id.js b/test/language/statements/class/dstr-meth-static-dflt-obj-ptrn-prop-id.js new file mode 100644 index 0000000000..08c170130a --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-dflt-obj-ptrn-prop-id.js @@ -0,0 +1,80 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id.case +// - src/dstr-binding/default/cls-decl-meth-static-dflt.template +/*--- +description: Binding as specified via property name and identifier (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +class C { + static method({ x: y } = { x: 23 }) { + assert.sameValue(y, 23); + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-static-dflt-obj-ptrn-prop-obj-init.js b/test/language/statements/class/dstr-meth-static-dflt-obj-ptrn-prop-obj-init.js new file mode 100644 index 0000000000..ad9399c870 --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-dflt-obj-ptrn-prop-obj-init.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-init.case +// - src/dstr-binding/default/cls-decl-meth-static-dflt.template +/*--- +description: Object binding pattern with "nested" object binding pattern using initializer (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +class C { + static method({ w: { x, y, z } = { x: 4, y: 5, z: 6 } } = { w: undefined }) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/dstr-meth-static-dflt-obj-ptrn-prop-obj-value-null.js b/test/language/statements/class/dstr-meth-static-dflt-obj-ptrn-prop-obj-value-null.js new file mode 100644 index 0000000000..70af3fad03 --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-dflt-obj-ptrn-prop-obj-value-null.js @@ -0,0 +1,75 @@ +// 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-meth-static-dflt.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 method({ w: { x, y, z } = { x: 4, y: 5, z: 6 } } = { w: null }) {} +}; + +assert.throws(TypeError, function() { + C.method(); +}); diff --git a/test/language/statements/class/dstr-meth-static-dflt-obj-ptrn-prop-obj-value-undef.js b/test/language/statements/class/dstr-meth-static-dflt-obj-ptrn-prop-obj-value-undef.js new file mode 100644 index 0000000000..cd6d87dd78 --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-dflt-obj-ptrn-prop-obj-value-undef.js @@ -0,0 +1,75 @@ +// 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-meth-static-dflt.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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 method({ w: { x, y, z } = undefined } = { }) {} +}; + +assert.throws(TypeError, function() { + C.method(); +}); diff --git a/test/language/statements/class/dstr-meth-static-dflt-obj-ptrn-prop-obj.js b/test/language/statements/class/dstr-meth-static-dflt-obj-ptrn-prop-obj.js new file mode 100644 index 0000000000..3051e14f4b --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-dflt-obj-ptrn-prop-obj.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj.case +// - src/dstr-binding/default/cls-decl-meth-static-dflt.template +/*--- +description: Object binding pattern with "nested" object binding pattern not using initializer (static class expression method (default parameter)) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [destructuring-binding, default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +class C { + static method({ w: { x, y, z } = { x: 4, y: 5, z: 6 } } = { w: { x: undefined, z: 7 } }) { + assert.sameValue(x, undefined); + assert.sameValue(y, undefined); + assert.sameValue(z, 7); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; + } +}; + +C.method(); +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/function/dstr-dflt-ary-init-iter-close.js b/test/language/statements/function/dstr-dflt-ary-init-iter-close.js new file mode 100644 index 0000000000..6dcd43be36 --- /dev/null +++ b/test/language/statements/function/dstr-dflt-ary-init-iter-close.js @@ -0,0 +1,72 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-close.case +// - src/dstr-binding/default/func-decl-dflt.template +/*--- +description: Iterator is closed when not exhausted by pattern evaluation (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.1.19 +features: [Symbol.iterator, destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + [...] + 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator, + result). + [...] + +---*/ +var doneCallCount = 0; +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return { value: null, done: false }; + }, + return: function() { + doneCallCount += 1; + return {}; + } + }; +}; + +var callCount = 0; +function f([x] = iter) { + assert.sameValue(doneCallCount, 1); + callCount = callCount + 1; +}; +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/statements/function/dstr-dflt-ary-init-iter-get-err.js b/test/language/statements/function/dstr-dflt-ary-init-iter-get-err.js new file mode 100644 index 0000000000..cb46c7abc5 --- /dev/null +++ b/test/language/statements/function/dstr-dflt-ary-init-iter-get-err.js @@ -0,0 +1,59 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-get-err.case +// - src/dstr-binding/error/func-decl-dflt.template +/*--- +description: Abrupt completion returned by GetIterator (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.1.19 +features: [Symbol.iterator, destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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(); +}; + +function f([x] = iter) {} + +assert.throws(Test262Error, function() { + f(); +}); diff --git a/test/language/statements/function/dstr-dflt-ary-init-iter-no-close.js b/test/language/statements/function/dstr-dflt-ary-init-iter-no-close.js new file mode 100644 index 0000000000..5ce2199795 --- /dev/null +++ b/test/language/statements/function/dstr-dflt-ary-init-iter-no-close.js @@ -0,0 +1,72 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-no-close.case +// - src/dstr-binding/default/func-decl-dflt.template +/*--- +description: Iterator is not closed when exhausted by pattern evaluation (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.1.19 +features: [Symbol.iterator, destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + [...] + 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator, + result). + [...] + +---*/ +var doneCallCount = 0; +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return { value: null, done: true }; + }, + return: function() { + doneCallCount += 1; + return {}; + } + }; +}; + +var callCount = 0; +function f([x] = iter) { + assert.sameValue(doneCallCount, 0); + callCount = callCount + 1; +}; +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/statements/function/dstr-dflt-ary-name-iter-val.js b/test/language/statements/function/dstr-dflt-ary-name-iter-val.js new file mode 100644 index 0000000000..55ffdbc86f --- /dev/null +++ b/test/language/statements/function/dstr-dflt-ary-name-iter-val.js @@ -0,0 +1,71 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-name-iter-val.case +// - src/dstr-binding/default/func-decl-dflt.template +/*--- +description: SingleNameBinding with normal value iteration (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.1.19 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set + iteratorRecord.[[done]] to true. + iii. ReturnIfAbrupt(v). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +function f([x, y, z] = [1, 2, 3]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 3); + callCount = callCount + 1; +}; +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/statements/function/dstr-dflt-ary-ptrn-elem-ary-elem-init.js b/test/language/statements/function/dstr-dflt-ary-ptrn-elem-ary-elem-init.js new file mode 100644 index 0000000000..fb11fbbf05 --- /dev/null +++ b/test/language/statements/function/dstr-dflt-ary-ptrn-elem-ary-elem-init.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elem-init.case +// - src/dstr-binding/default/func-decl-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is used (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.1.19 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +function f([[x, y, z] = [4, 5, 6]] = []) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + callCount = callCount + 1; +}; +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/statements/function/dstr-dflt-ary-ptrn-elem-ary-elem-iter.js b/test/language/statements/function/dstr-dflt-ary-ptrn-elem-ary-elem-iter.js new file mode 100644 index 0000000000..30b9b0aef6 --- /dev/null +++ b/test/language/statements/function/dstr-dflt-ary-ptrn-elem-ary-elem-iter.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elem-iter.case +// - src/dstr-binding/default/func-decl-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.1.19 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +function f([[x, y, z] = [4, 5, 6]] = [[7, 8, 9]]) { + assert.sameValue(x, 7); + assert.sameValue(y, 8); + assert.sameValue(z, 9); + callCount = callCount + 1; +}; +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/statements/function/dstr-dflt-ary-ptrn-elem-ary-elision-init.js b/test/language/statements/function/dstr-dflt-ary-ptrn-elem-ary-elision-init.js new file mode 100644 index 0000000000..a85dd0e042 --- /dev/null +++ b/test/language/statements/function/dstr-dflt-ary-ptrn-elem-ary-elision-init.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elision-init.case +// - src/dstr-binding/default/func-decl-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is used (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.1.19 +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var callCount = 0; +function f([[,] = g()] = []) { + assert.sameValue(first, 1); + assert.sameValue(second, 0); + callCount = callCount + 1; +}; +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/statements/function/dstr-dflt-ary-ptrn-elem-ary-elision-iter.js b/test/language/statements/function/dstr-dflt-ary-ptrn-elem-ary-elision-iter.js new file mode 100644 index 0000000000..2efc077cd1 --- /dev/null +++ b/test/language/statements/function/dstr-dflt-ary-ptrn-elem-ary-elision-iter.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elision-iter.case +// - src/dstr-binding/default/func-decl-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.1.19 +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var callCount = 0; +function* g() { + callCount += 1; +}; + +var callCount = 0; +function f([[,] = g()] = [[]]) { + assert.sameValue(callCount, 0); + callCount = callCount + 1; +}; +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/statements/function/dstr-dflt-ary-ptrn-elem-ary-empty-init.js b/test/language/statements/function/dstr-dflt-ary-ptrn-elem-ary-empty-init.js new file mode 100644 index 0000000000..81ae466e1a --- /dev/null +++ b/test/language/statements/function/dstr-dflt-ary-ptrn-elem-ary-empty-init.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-empty-init.case +// - src/dstr-binding/default/func-decl-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is used (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.1.19 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var initCount = 0; +var iterCount = 0; +var iter = function*() { iterCount += 1; }(); + +var callCount = 0; +function f([[] = function() { initCount += 1; return iter; }()] = []) { + assert.sameValue(initCount, 1); + assert.sameValue(iterCount, 0); + callCount = callCount + 1; +}; +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/statements/function/dstr-dflt-ary-ptrn-elem-ary-empty-iter.js b/test/language/statements/function/dstr-dflt-ary-ptrn-elem-ary-empty-iter.js new file mode 100644 index 0000000000..37f7f2f89b --- /dev/null +++ b/test/language/statements/function/dstr-dflt-ary-ptrn-elem-ary-empty-iter.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-empty-iter.case +// - src/dstr-binding/default/func-decl-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.1.19 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var initCount = 0; + +var callCount = 0; +function f([[] = function() { initCount += 1; }()] = [[23]]) { + assert.sameValue(initCount, 0); + callCount = callCount + 1; +}; +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/statements/function/dstr-dflt-ary-ptrn-elem-ary-rest-init.js b/test/language/statements/function/dstr-dflt-ary-ptrn-elem-ary-rest-init.js new file mode 100644 index 0000000000..8d854e5c94 --- /dev/null +++ b/test/language/statements/function/dstr-dflt-ary-ptrn-elem-ary-rest-init.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-rest-init.case +// - src/dstr-binding/default/func-decl-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is used (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.1.19 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var values = [2, 1, 3]; + +var callCount = 0; +function f([[...x] = values] = []) { + assert(Array.isArray(x)); + assert.sameValue(x[0], 2); + assert.sameValue(x[1], 1); + assert.sameValue(x[2], 3); + assert.sameValue(x.length, 3); + assert.notSameValue(x, values); + callCount = callCount + 1; +}; +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/statements/function/dstr-dflt-ary-ptrn-elem-ary-rest-iter.js b/test/language/statements/function/dstr-dflt-ary-ptrn-elem-ary-rest-iter.js new file mode 100644 index 0000000000..50044b4989 --- /dev/null +++ b/test/language/statements/function/dstr-dflt-ary-ptrn-elem-ary-rest-iter.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-rest-iter.case +// - src/dstr-binding/default/func-decl-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.1.19 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var values = [2, 1, 3]; +var initCount = 0; + +var callCount = 0; +function f([[...x] = function() { initCount += 1; }()] = [values]) { + assert(Array.isArray(x)); + assert.sameValue(x[0], 2); + assert.sameValue(x[1], 1); + assert.sameValue(x[2], 3); + assert.sameValue(x.length, 3); + assert.notSameValue(x, values); + assert.sameValue(initCount, 0); + callCount = callCount + 1; +}; +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/statements/function/dstr-dflt-ary-ptrn-elem-ary-val-null.js b/test/language/statements/function/dstr-dflt-ary-ptrn-elem-ary-val-null.js new file mode 100644 index 0000000000..1bb6c789ba --- /dev/null +++ b/test/language/statements/function/dstr-dflt-ary-ptrn-elem-ary-val-null.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-val-null.case +// - src/dstr-binding/error/func-decl-dflt.template +/*--- +description: Nested array destructuring with a null value (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.1.19 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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). +---*/ + +function f([[x]] = [null]) {} + +assert.throws(TypeError, function() { + f(); +}); diff --git a/test/language/statements/function/dstr-dflt-ary-ptrn-elem-id-init-exhausted.js b/test/language/statements/function/dstr-dflt-ary-ptrn-elem-id-init-exhausted.js new file mode 100644 index 0000000000..5c0817e4a1 --- /dev/null +++ b/test/language/statements/function/dstr-dflt-ary-ptrn-elem-id-init-exhausted.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-exhausted.case +// - src/dstr-binding/default/func-decl-dflt.template +/*--- +description: Destructuring initializer with an exhausted iterator (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.1.19 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +function f([x = 23] = []) { + assert.sameValue(x, 23); + callCount = callCount + 1; +}; +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/statements/function/dstr-dflt-ary-ptrn-elem-id-init-fn-name-arrow.js b/test/language/statements/function/dstr-dflt-ary-ptrn-elem-id-init-fn-name-arrow.js new file mode 100644 index 0000000000..2d4a22bcc3 --- /dev/null +++ b/test/language/statements/function/dstr-dflt-ary-ptrn-elem-id-init-fn-name-arrow.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-arrow.case +// - src/dstr-binding/default/func-decl-dflt.template +/*--- +description: SingleNameBinding does assign name to arrow functions (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.1.19 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +function f([arrow = () => {}] = []) { + assert.sameValue(arrow.name, 'arrow'); + callCount = callCount + 1; +}; +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/statements/function/dstr-dflt-ary-ptrn-elem-id-init-fn-name-class.js b/test/language/statements/function/dstr-dflt-ary-ptrn-elem-id-init-fn-name-class.js new file mode 100644 index 0000000000..477e554042 --- /dev/null +++ b/test/language/statements/function/dstr-dflt-ary-ptrn-elem-id-init-fn-name-class.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-class.case +// - src/dstr-binding/default/func-decl-dflt.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.1.19 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +function f([cls = class {}, xCls = class X {}] = []) { + assert.sameValue(cls.name, 'cls'); + assert.notSameValue(xCls.name, 'xCls'); + callCount = callCount + 1; +}; +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/statements/function/dstr-dflt-ary-ptrn-elem-id-init-fn-name-cover.js b/test/language/statements/function/dstr-dflt-ary-ptrn-elem-id-init-fn-name-cover.js new file mode 100644 index 0000000000..78226fc1f0 --- /dev/null +++ b/test/language/statements/function/dstr-dflt-ary-ptrn-elem-id-init-fn-name-cover.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-cover.case +// - src/dstr-binding/default/func-decl-dflt.template +/*--- +description: SingleNameBinding does assign name to "anonymous" functions "through" cover grammar (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.1.19 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +function f([cover = (function () {}), xCover = (0, function() {})] = []) { + assert.sameValue(cover.name, 'cover'); + assert.notSameValue(xCover.name, 'xCover'); + callCount = callCount + 1; +}; +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/statements/function/dstr-dflt-ary-ptrn-elem-id-init-fn-name-fn.js b/test/language/statements/function/dstr-dflt-ary-ptrn-elem-id-init-fn-name-fn.js new file mode 100644 index 0000000000..47f2d01fa9 --- /dev/null +++ b/test/language/statements/function/dstr-dflt-ary-ptrn-elem-id-init-fn-name-fn.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-fn.case +// - src/dstr-binding/default/func-decl-dflt.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.1.19 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +function f([fn = function () {}, xFn = function x() {}] = []) { + assert.sameValue(fn.name, 'fn'); + assert.notSameValue(xFn.name, 'xFn'); + callCount = callCount + 1; +}; +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/statements/function/dstr-dflt-ary-ptrn-elem-id-init-fn-name-gen.js b/test/language/statements/function/dstr-dflt-ary-ptrn-elem-id-init-fn-name-gen.js new file mode 100644 index 0000000000..ba3ab7b2a5 --- /dev/null +++ b/test/language/statements/function/dstr-dflt-ary-ptrn-elem-id-init-fn-name-gen.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-gen.case +// - src/dstr-binding/default/func-decl-dflt.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.1.19 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +function f([gen = function* () {}, xGen = function* x() {}] = []) { + assert.sameValue(gen.name, 'gen'); + assert.notSameValue(xGen.name, 'xGen'); + callCount = callCount + 1; +}; +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/statements/function/dstr-dflt-ary-ptrn-elem-id-init-hole.js b/test/language/statements/function/dstr-dflt-ary-ptrn-elem-id-init-hole.js new file mode 100644 index 0000000000..ace40abc4e --- /dev/null +++ b/test/language/statements/function/dstr-dflt-ary-ptrn-elem-id-init-hole.js @@ -0,0 +1,58 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-hole.case +// - src/dstr-binding/default/func-decl-dflt.template +/*--- +description: Destructuring initializer with a "hole" (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.1.19 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + SingleNameBinding : BindingIdentifier Initializeropt + [...] 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + [...] + 7. If environment is undefined, return PutValue(lhs, v). 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +function f([x = 23] = [,]) { + assert.sameValue(x, 23); + // another statement + callCount = callCount + 1; +}; +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/statements/function/dstr-dflt-ary-ptrn-elem-id-init-skipped.js b/test/language/statements/function/dstr-dflt-ary-ptrn-elem-id-init-skipped.js new file mode 100644 index 0000000000..0dbdeb0f28 --- /dev/null +++ b/test/language/statements/function/dstr-dflt-ary-ptrn-elem-id-init-skipped.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-skipped.case +// - src/dstr-binding/default/func-decl-dflt.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.1.19 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var callCount = 0; +function f([w = counter(), x = counter(), y = counter(), z = counter()] = [null, 0, false, '']) { + assert.sameValue(w, null); + assert.sameValue(x, 0); + assert.sameValue(y, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + callCount = callCount + 1; +}; +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/statements/function/dstr-dflt-ary-ptrn-elem-id-init-throws.js b/test/language/statements/function/dstr-dflt-ary-ptrn-elem-id-init-throws.js new file mode 100644 index 0000000000..b9ef8da228 --- /dev/null +++ b/test/language/statements/function/dstr-dflt-ary-ptrn-elem-id-init-throws.js @@ -0,0 +1,57 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-throws.case +// - src/dstr-binding/error/func-decl-dflt.template +/*--- +description: Destructuring initializer returns an abrupt completion (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.1.19 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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). +---*/ + +function f([x = (function() { throw new Test262Error(); })()] = [undefined]) {} + +assert.throws(Test262Error, function() { + f(); +}); diff --git a/test/language/statements/function/dstr-dflt-ary-ptrn-elem-id-init-undef.js b/test/language/statements/function/dstr-dflt-ary-ptrn-elem-id-init-undef.js new file mode 100644 index 0000000000..d9b1a3c840 --- /dev/null +++ b/test/language/statements/function/dstr-dflt-ary-ptrn-elem-id-init-undef.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-undef.case +// - src/dstr-binding/default/func-decl-dflt.template +/*--- +description: Destructuring initializer with an undefined value (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.1.19 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +function f([x = 23] = [undefined]) { + assert.sameValue(x, 23); + callCount = callCount + 1; +}; +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/statements/function/dstr-dflt-ary-ptrn-elem-id-init-unresolvable.js b/test/language/statements/function/dstr-dflt-ary-ptrn-elem-id-init-unresolvable.js new file mode 100644 index 0000000000..9a9361afd3 --- /dev/null +++ b/test/language/statements/function/dstr-dflt-ary-ptrn-elem-id-init-unresolvable.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-unresolvable.case +// - src/dstr-binding/error/func-decl-dflt.template +/*--- +description: Destructuring initializer is an unresolvable reference (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.1.19 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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. +---*/ + +function f([ x = unresolvableReference ] = []) {} + +assert.throws(ReferenceError, function() { + f(); +}); diff --git a/test/language/statements/function/dstr-dflt-ary-ptrn-elem-id-iter-complete.js b/test/language/statements/function/dstr-dflt-ary-ptrn-elem-id-iter-complete.js new file mode 100644 index 0000000000..1dfa727bb7 --- /dev/null +++ b/test/language/statements/function/dstr-dflt-ary-ptrn-elem-id-iter-complete.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-complete.case +// - src/dstr-binding/default/func-decl-dflt.template +/*--- +description: SingleNameBinding when value iteration completes (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.1.19 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +function f([x] = []) { + assert.sameValue(x, undefined); + callCount = callCount + 1; +}; +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/statements/function/dstr-dflt-ary-ptrn-elem-id-iter-done.js b/test/language/statements/function/dstr-dflt-ary-ptrn-elem-id-iter-done.js new file mode 100644 index 0000000000..6a5711406e --- /dev/null +++ b/test/language/statements/function/dstr-dflt-ary-ptrn-elem-id-iter-done.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-done.case +// - src/dstr-binding/default/func-decl-dflt.template +/*--- +description: SingleNameBinding when value iteration was completed previously (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.1.19 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +function f([_, x] = []) { + assert.sameValue(x, undefined); + callCount = callCount + 1; +}; +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/statements/function/dstr-dflt-ary-ptrn-elem-id-iter-step-err.js b/test/language/statements/function/dstr-dflt-ary-ptrn-elem-id-iter-step-err.js new file mode 100644 index 0000000000..690a2fa252 --- /dev/null +++ b/test/language/statements/function/dstr-dflt-ary-ptrn-elem-id-iter-step-err.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-step-err.case +// - src/dstr-binding/error/func-decl-dflt.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.1.19 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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(); + } + }; +}; + +function f([x] = g) {} + +assert.throws(Test262Error, function() { + f(); +}); diff --git a/test/language/statements/function/dstr-dflt-ary-ptrn-elem-id-iter-val-err.js b/test/language/statements/function/dstr-dflt-ary-ptrn-elem-id-iter-val-err.js new file mode 100644 index 0000000000..960598c1f0 --- /dev/null +++ b/test/language/statements/function/dstr-dflt-ary-ptrn-elem-id-iter-val-err.js @@ -0,0 +1,76 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val-err.case +// - src/dstr-binding/error/func-decl-dflt.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.1.19 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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; + } + }; +}; + +function f([x] = g) {} + +assert.throws(Test262Error, function() { + f(); +}); diff --git a/test/language/statements/function/dstr-dflt-ary-ptrn-elem-id-iter-val.js b/test/language/statements/function/dstr-dflt-ary-ptrn-elem-id-iter-val.js new file mode 100644 index 0000000000..66b0f4cb9e --- /dev/null +++ b/test/language/statements/function/dstr-dflt-ary-ptrn-elem-id-iter-val.js @@ -0,0 +1,71 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val.case +// - src/dstr-binding/default/func-decl-dflt.template +/*--- +description: SingleNameBinding when value iteration was completed previously (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.1.19 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set + iteratorRecord.[[done]] to true. + iii. ReturnIfAbrupt(v). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +function f([x, y, z] = [1, 2, 3]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 3); + callCount = callCount + 1; +}; +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/statements/function/dstr-dflt-ary-ptrn-elem-obj-id-init.js b/test/language/statements/function/dstr-dflt-ary-ptrn-elem-obj-id-init.js new file mode 100644 index 0000000000..c93a3452eb --- /dev/null +++ b/test/language/statements/function/dstr-dflt-ary-ptrn-elem-obj-id-init.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-id-init.case +// - src/dstr-binding/default/func-decl-dflt.template +/*--- +description: BindingElement with object binding pattern and initializer is used (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.1.19 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +function f([{ x, y, z } = { x: 44, y: 55, z: 66 }] = []) { + assert.sameValue(x, 44); + assert.sameValue(y, 55); + assert.sameValue(z, 66); + callCount = callCount + 1; +}; +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/statements/function/dstr-dflt-ary-ptrn-elem-obj-id.js b/test/language/statements/function/dstr-dflt-ary-ptrn-elem-obj-id.js new file mode 100644 index 0000000000..b090600c0b --- /dev/null +++ b/test/language/statements/function/dstr-dflt-ary-ptrn-elem-obj-id.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-id.case +// - src/dstr-binding/default/func-decl-dflt.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.1.19 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +function f([{ x, y, z } = { x: 44, y: 55, z: 66 }] = [{ x: 11, y: 22, z: 33 }]) { + assert.sameValue(x, 11); + assert.sameValue(y, 22); + assert.sameValue(z, 33); + callCount = callCount + 1; +}; +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/statements/function/dstr-dflt-ary-ptrn-elem-obj-prop-id-init.js b/test/language/statements/function/dstr-dflt-ary-ptrn-elem-obj-prop-id-init.js new file mode 100644 index 0000000000..5cd253bfdd --- /dev/null +++ b/test/language/statements/function/dstr-dflt-ary-ptrn-elem-obj-prop-id-init.js @@ -0,0 +1,73 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-prop-id-init.case +// - src/dstr-binding/default/func-decl-dflt.template +/*--- +description: BindingElement with object binding pattern and initializer is used (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.1.19 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +function f([{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }] = []) { + assert.sameValue(v, 444); + assert.sameValue(x, 555); + assert.sameValue(z, 666); + + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; +}; +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/statements/function/dstr-dflt-ary-ptrn-elem-obj-prop-id.js b/test/language/statements/function/dstr-dflt-ary-ptrn-elem-obj-prop-id.js new file mode 100644 index 0000000000..7cef2b8a06 --- /dev/null +++ b/test/language/statements/function/dstr-dflt-ary-ptrn-elem-obj-prop-id.js @@ -0,0 +1,73 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-prop-id.case +// - src/dstr-binding/default/func-decl-dflt.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.1.19 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +function f([{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }] = [{ u: 777, w: 888, y: 999 }]) { + assert.sameValue(v, 777); + assert.sameValue(x, 888); + assert.sameValue(z, 999); + + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; +}; +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/statements/function/dstr-dflt-ary-ptrn-elem-obj-val-null.js b/test/language/statements/function/dstr-dflt-ary-ptrn-elem-obj-val-null.js new file mode 100644 index 0000000000..7f1fb1e106 --- /dev/null +++ b/test/language/statements/function/dstr-dflt-ary-ptrn-elem-obj-val-null.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-null.case +// - src/dstr-binding/error/func-decl-dflt.template +/*--- +description: Nested object destructuring with a null value (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.1.19 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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). +---*/ + +function f([{ x }] = [null]) {} + +assert.throws(TypeError, function() { + f(); +}); diff --git a/test/language/statements/function/dstr-dflt-ary-ptrn-elem-obj-val-undef.js b/test/language/statements/function/dstr-dflt-ary-ptrn-elem-obj-val-undef.js new file mode 100644 index 0000000000..a6847a6ff4 --- /dev/null +++ b/test/language/statements/function/dstr-dflt-ary-ptrn-elem-obj-val-undef.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-undef.case +// - src/dstr-binding/error/func-decl-dflt.template +/*--- +description: Nested object destructuring with a value of `undefined` (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.1.19 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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). +---*/ + +function f([{ x }] = []) {} + +assert.throws(TypeError, function() { + f(); +}); diff --git a/test/language/statements/function/dstr-dflt-ary-ptrn-elision-exhausted.js b/test/language/statements/function/dstr-dflt-ary-ptrn-elision-exhausted.js new file mode 100644 index 0000000000..47d1b06c7e --- /dev/null +++ b/test/language/statements/function/dstr-dflt-ary-ptrn-elision-exhausted.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-exhausted.case +// - src/dstr-binding/default/func-decl-dflt.template +/*--- +description: Elision accepts exhausted iterator (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.1.19 +features: [generator, destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + [...] + 2. Return NormalCompletion(empty). + +---*/ +var iter = function*() {}(); +iter.next(); + +var callCount = 0; +function f([,] = iter) { + + callCount = callCount + 1; +}; +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/statements/function/dstr-dflt-ary-ptrn-elision-step-err.js b/test/language/statements/function/dstr-dflt-ary-ptrn-elision-step-err.js new file mode 100644 index 0000000000..423b3d16fa --- /dev/null +++ b/test/language/statements/function/dstr-dflt-ary-ptrn-elision-step-err.js @@ -0,0 +1,73 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-step-err.case +// - src/dstr-binding/error/func-decl-dflt.template +/*--- +description: Elision advances iterator and forwards abrupt completions (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.1.19 +features: [generator, destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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; +}(); + +function f([,] = iter) {} + +assert.throws(Test262Error, function() { + f(); +}); + +iter.next(); +assert.sameValue(following, 0, 'Iterator was properly closed.'); diff --git a/test/language/statements/function/dstr-dflt-ary-ptrn-elision.js b/test/language/statements/function/dstr-dflt-ary-ptrn-elision.js new file mode 100644 index 0000000000..3844f7dd89 --- /dev/null +++ b/test/language/statements/function/dstr-dflt-ary-ptrn-elision.js @@ -0,0 +1,77 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision.case +// - src/dstr-binding/default/func-decl-dflt.template +/*--- +description: Elision advances iterator (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.1.19 +features: [generator, destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + 2. Return NormalCompletion(empty). + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var callCount = 0; +function f([,] = g()) { + assert.sameValue(first, 1); + assert.sameValue(second, 0); + callCount = callCount + 1; +}; +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/statements/function/dstr-dflt-ary-ptrn-empty.js b/test/language/statements/function/dstr-dflt-ary-ptrn-empty.js new file mode 100644 index 0000000000..87ba2c4103 --- /dev/null +++ b/test/language/statements/function/dstr-dflt-ary-ptrn-empty.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-empty.case +// - src/dstr-binding/default/func-decl-dflt.template +/*--- +description: No iteration occurs for an "empty" array binding pattern (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.1.19 +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ ] + + 1. Return NormalCompletion(empty). + +---*/ +var iterations = 0; +var iter = function*() { + iterations += 1; +}(); + +var callCount = 0; +function f([] = iter) { + assert.sameValue(iterations, 0); + callCount = callCount + 1; +}; +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/statements/function/dstr-dflt-ary-ptrn-rest-ary-elem.js b/test/language/statements/function/dstr-dflt-ary-ptrn-rest-ary-elem.js new file mode 100644 index 0000000000..2903d5efa4 --- /dev/null +++ b/test/language/statements/function/dstr-dflt-ary-ptrn-rest-ary-elem.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-elem.case +// - src/dstr-binding/default/func-decl-dflt.template +/*--- +description: Rest element containing an array BindingElementList pattern (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.1.19 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set + iteratorRecord.[[done]] to true. + iii. ReturnIfAbrupt(v). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +function f([...[x, y, z]] = [3, 4, 5]) { + assert.sameValue(x, 3); + assert.sameValue(y, 4); + assert.sameValue(z, 5); + callCount = callCount + 1; +}; +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/statements/function/dstr-dflt-ary-ptrn-rest-ary-elision.js b/test/language/statements/function/dstr-dflt-ary-ptrn-rest-ary-elision.js new file mode 100644 index 0000000000..c2dc9d6a2b --- /dev/null +++ b/test/language/statements/function/dstr-dflt-ary-ptrn-rest-ary-elision.js @@ -0,0 +1,90 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-elision.case +// - src/dstr-binding/default/func-decl-dflt.template +/*--- +description: Rest element containing an elision (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.1.19 +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + 2. Return NormalCompletion(empty). + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var callCount = 0; +function f([...[,]] = g()) { + assert.sameValue(first, 1); + assert.sameValue(second, 1); + callCount = callCount + 1; +}; +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/statements/function/dstr-dflt-ary-ptrn-rest-ary-empty.js b/test/language/statements/function/dstr-dflt-ary-ptrn-rest-ary-empty.js new file mode 100644 index 0000000000..03bcd7af2a --- /dev/null +++ b/test/language/statements/function/dstr-dflt-ary-ptrn-rest-ary-empty.js @@ -0,0 +1,73 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-empty.case +// - src/dstr-binding/default/func-decl-dflt.template +/*--- +description: Rest element containing an "empty" array pattern (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.1.19 +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ ] + + 1. Return NormalCompletion(empty). + +---*/ +var iterations = 0; +var iter = function*() { + iterations += 1; +}(); + +var callCount = 0; +function f([...[]] = iter) { + assert.sameValue(iterations, 1); + callCount = callCount + 1; +}; +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/statements/function/dstr-dflt-ary-ptrn-rest-ary-rest.js b/test/language/statements/function/dstr-dflt-ary-ptrn-rest-ary-rest.js new file mode 100644 index 0000000000..7ce2a0d4af --- /dev/null +++ b/test/language/statements/function/dstr-dflt-ary-ptrn-rest-ary-rest.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-rest.case +// - src/dstr-binding/default/func-decl-dflt.template +/*--- +description: Rest element containing a rest element (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.1.19 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ +var values = [1, 2, 3]; + +var callCount = 0; +function f([...[...x]] = values) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 1); + assert.sameValue(x[1], 2); + assert.sameValue(x[2], 3); + assert.notSameValue(x, values); + + callCount = callCount + 1; +}; +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/statements/function/dstr-dflt-ary-ptrn-rest-id-elision-next-err.js b/test/language/statements/function/dstr-dflt-ary-ptrn-rest-id-elision-next-err.js new file mode 100644 index 0000000000..9d86883469 --- /dev/null +++ b/test/language/statements/function/dstr-dflt-ary-ptrn-rest-id-elision-next-err.js @@ -0,0 +1,59 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision-next-err.case +// - src/dstr-binding/error/func-decl-dflt.template +/*--- +description: Rest element following elision elements (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.1.19 +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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(); })(); + +function f([, ...x] = iter) {} + +assert.throws(Test262Error, function() { + f(); +}); diff --git a/test/language/statements/function/dstr-dflt-ary-ptrn-rest-id-elision.js b/test/language/statements/function/dstr-dflt-ary-ptrn-rest-id-elision.js new file mode 100644 index 0000000000..4afe09d859 --- /dev/null +++ b/test/language/statements/function/dstr-dflt-ary-ptrn-rest-id-elision.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision.case +// - src/dstr-binding/default/func-decl-dflt.template +/*--- +description: Rest element following elision elements (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.1.19 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + ArrayBindingPattern : [ Elisionopt BindingRestElement ] + 1. If Elision is present, then + a. Let status be the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with + iteratorRecord as the argument. + b. ReturnIfAbrupt(status). + 2. Return the result of performing IteratorBindingInitialization for + BindingRestElement with iteratorRecord and environment as arguments. +---*/ +var values = [1, 2, 3, 4, 5]; + +var callCount = 0; +function f([ , , ...x] = values) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 3); + assert.sameValue(x[1], 4); + assert.sameValue(x[2], 5); + assert.notSameValue(x, values); + callCount = callCount + 1; +}; +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/statements/function/dstr-dflt-ary-ptrn-rest-id-exhausted.js b/test/language/statements/function/dstr-dflt-ary-ptrn-rest-id-exhausted.js new file mode 100644 index 0000000000..cd05ebdc67 --- /dev/null +++ b/test/language/statements/function/dstr-dflt-ary-ptrn-rest-id-exhausted.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-exhausted.case +// - src/dstr-binding/default/func-decl-dflt.template +/*--- +description: RestElement applied to an exhausted iterator (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.1.19 +features: [Symbol.iterator, destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier, + environment). + 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat, + [...] + b. If iteratorRecord.[[done]] is true, then + i. If environment is undefined, return PutValue(lhs, A). + ii. Return InitializeReferencedBinding(lhs, A). + +---*/ + +var callCount = 0; +function f([, , ...x] = [1, 2]) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 0); + callCount = callCount + 1; +}; +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/statements/function/dstr-dflt-ary-ptrn-rest-id-iter-step-err.js b/test/language/statements/function/dstr-dflt-ary-ptrn-rest-id-iter-step-err.js new file mode 100644 index 0000000000..2a9445800a --- /dev/null +++ b/test/language/statements/function/dstr-dflt-ary-ptrn-rest-id-iter-step-err.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-step-err.case +// - src/dstr-binding/error/func-decl-dflt.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.1.19 +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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; +}(); + +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/function/dstr-dflt-ary-ptrn-rest-id-iter-val-err.js b/test/language/statements/function/dstr-dflt-ary-ptrn-rest-id-iter-val-err.js new file mode 100644 index 0000000000..fe9088155c --- /dev/null +++ b/test/language/statements/function/dstr-dflt-ary-ptrn-rest-id-iter-val-err.js @@ -0,0 +1,72 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-val-err.case +// - src/dstr-binding/error/func-decl-dflt.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.1.19 +features: [Symbol.iterator, destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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; + } + }; +}; + +function f([...x] = iter) {} + +assert.throws(Test262Error, function() { + f(); +}); diff --git a/test/language/statements/function/dstr-dflt-ary-ptrn-rest-id.js b/test/language/statements/function/dstr-dflt-ary-ptrn-rest-id.js new file mode 100644 index 0000000000..b080eb6689 --- /dev/null +++ b/test/language/statements/function/dstr-dflt-ary-ptrn-rest-id.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id.case +// - src/dstr-binding/default/func-decl-dflt.template +/*--- +description: Lone rest element (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.1.19 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + [...] 3. Let A be ArrayCreate(0). [...] 5. Repeat + [...] + f. Let status be CreateDataProperty(A, ToString (n), nextValue). + [...] +---*/ +var values = [1, 2, 3]; + +var callCount = 0; +function f([...x] = values) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 1); + assert.sameValue(x[1], 2); + assert.sameValue(x[2], 3); + assert.notSameValue(x, values); + callCount = callCount + 1; +}; +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/statements/function/dstr-dflt-ary-ptrn-rest-init-ary.js b/test/language/statements/function/dstr-dflt-ary-ptrn-rest-init-ary.js new file mode 100644 index 0000000000..bccd34bba8 --- /dev/null +++ b/test/language/statements/function/dstr-dflt-ary-ptrn-rest-init-ary.js @@ -0,0 +1,56 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-ary.case +// - src/dstr-binding/default/func-decl-dflt.template +/*--- +description: Reset element (nested array pattern) does not support initializer (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.1.19 +features: [destructuring-binding, default-parameters] +flags: [generated] +negative: SyntaxError +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +function f([...[ x ] = []] = []) { + + callCount = callCount + 1; +}; +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/statements/function/dstr-dflt-ary-ptrn-rest-init-id.js b/test/language/statements/function/dstr-dflt-ary-ptrn-rest-init-id.js new file mode 100644 index 0000000000..804f98bfea --- /dev/null +++ b/test/language/statements/function/dstr-dflt-ary-ptrn-rest-init-id.js @@ -0,0 +1,56 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-id.case +// - src/dstr-binding/default/func-decl-dflt.template +/*--- +description: Reset element (identifier) does not support initializer (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.1.19 +features: [destructuring-binding, default-parameters] +flags: [generated] +negative: SyntaxError +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +function f([...x = []] = []) { + + callCount = callCount + 1; +}; +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/statements/function/dstr-dflt-ary-ptrn-rest-init-obj.js b/test/language/statements/function/dstr-dflt-ary-ptrn-rest-init-obj.js new file mode 100644 index 0000000000..39a080d8dd --- /dev/null +++ b/test/language/statements/function/dstr-dflt-ary-ptrn-rest-init-obj.js @@ -0,0 +1,56 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-obj.case +// - src/dstr-binding/default/func-decl-dflt.template +/*--- +description: Reset element (nested object pattern) does not support initializer (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.1.19 +features: [destructuring-binding, default-parameters] +flags: [generated] +negative: SyntaxError +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +function f([...{ x } = []] = []) { + + callCount = callCount + 1; +}; +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/statements/function/dstr-dflt-ary-ptrn-rest-not-final-ary.js b/test/language/statements/function/dstr-dflt-ary-ptrn-rest-not-final-ary.js new file mode 100644 index 0000000000..f23820db95 --- /dev/null +++ b/test/language/statements/function/dstr-dflt-ary-ptrn-rest-not-final-ary.js @@ -0,0 +1,56 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-ary.case +// - src/dstr-binding/default/func-decl-dflt.template +/*--- +description: Rest element (array binding pattern) may not be followed by any element (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.1.19 +features: [destructuring-binding, default-parameters] +flags: [generated] +negative: SyntaxError +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +function f([...[x], y] = [1, 2, 3]) { + + callCount = callCount + 1; +}; +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/statements/function/dstr-dflt-ary-ptrn-rest-not-final-id.js b/test/language/statements/function/dstr-dflt-ary-ptrn-rest-not-final-id.js new file mode 100644 index 0000000000..a3bd7a3b30 --- /dev/null +++ b/test/language/statements/function/dstr-dflt-ary-ptrn-rest-not-final-id.js @@ -0,0 +1,56 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-id.case +// - src/dstr-binding/default/func-decl-dflt.template +/*--- +description: Rest element (identifier) may not be followed by any element (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.1.19 +features: [destructuring-binding, default-parameters] +flags: [generated] +negative: SyntaxError +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +function f([...x, y] = [1, 2, 3]) { + + callCount = callCount + 1; +}; +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/statements/function/dstr-dflt-ary-ptrn-rest-not-final-obj.js b/test/language/statements/function/dstr-dflt-ary-ptrn-rest-not-final-obj.js new file mode 100644 index 0000000000..b0bffcfb89 --- /dev/null +++ b/test/language/statements/function/dstr-dflt-ary-ptrn-rest-not-final-obj.js @@ -0,0 +1,56 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-obj.case +// - src/dstr-binding/default/func-decl-dflt.template +/*--- +description: Rest element (object binding pattern) may not be followed by any element (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.1.19 +features: [destructuring-binding, default-parameters] +flags: [generated] +negative: SyntaxError +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +function f([...{ x }, y] = [1, 2, 3]) { + + callCount = callCount + 1; +}; +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/statements/function/dstr-dflt-ary-ptrn-rest-obj-id.js b/test/language/statements/function/dstr-dflt-ary-ptrn-rest-obj-id.js new file mode 100644 index 0000000000..75f4774135 --- /dev/null +++ b/test/language/statements/function/dstr-dflt-ary-ptrn-rest-obj-id.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-obj-id.case +// - src/dstr-binding/default/func-decl-dflt.template +/*--- +description: Rest element containing an object binding pattern (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.1.19 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ + +var callCount = 0; +function f([...{ length }] = [1, 2, 3]) { + assert.sameValue(length, 3); + callCount = callCount + 1; +}; +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/statements/function/dstr-dflt-ary-ptrn-rest-obj-prop-id.js b/test/language/statements/function/dstr-dflt-ary-ptrn-rest-obj-prop-id.js new file mode 100644 index 0000000000..e10f62a5cb --- /dev/null +++ b/test/language/statements/function/dstr-dflt-ary-ptrn-rest-obj-prop-id.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-obj-prop-id.case +// - src/dstr-binding/default/func-decl-dflt.template +/*--- +description: Rest element containing an object binding pattern (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.1.19 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ + +var callCount = 0; +function f([...{ 0: v, 1: w, 2: x, 3: y, length: z }] = [7, 8, 9]) { + assert.sameValue(v, 7); + assert.sameValue(w, 8); + assert.sameValue(x, 9); + assert.sameValue(y, undefined); + assert.sameValue(z, 3); + + assert.throws(ReferenceError, function() { + length; + }); + callCount = callCount + 1; +}; +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/statements/function/dstr-dflt-obj-init-null.js b/test/language/statements/function/dstr-dflt-obj-init-null.js new file mode 100644 index 0000000000..1bd9c032cb --- /dev/null +++ b/test/language/statements/function/dstr-dflt-obj-init-null.js @@ -0,0 +1,53 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-null.case +// - src/dstr-binding/error/func-decl-dflt.template +/*--- +description: Value specifed for object binding pattern must be object coercible (null) (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.1.19 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + +function f({} = null) {} + +assert.throws(TypeError, function() { + f(); +}); diff --git a/test/language/statements/function/dstr-dflt-obj-init-undefined.js b/test/language/statements/function/dstr-dflt-obj-init-undefined.js new file mode 100644 index 0000000000..aeb4510c47 --- /dev/null +++ b/test/language/statements/function/dstr-dflt-obj-init-undefined.js @@ -0,0 +1,53 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-undefined.case +// - src/dstr-binding/error/func-decl-dflt.template +/*--- +description: Value specifed for object binding pattern must be object coercible (undefined) (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.1.19 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + +function f({} = undefined) {} + +assert.throws(TypeError, function() { + f(); +}); diff --git a/test/language/statements/function/dstr-dflt-obj-ptrn-empty.js b/test/language/statements/function/dstr-dflt-obj-ptrn-empty.js new file mode 100644 index 0000000000..d7dce50fd2 --- /dev/null +++ b/test/language/statements/function/dstr-dflt-obj-ptrn-empty.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-empty.case +// - src/dstr-binding/default/func-decl-dflt.template +/*--- +description: No property access occurs for an "empty" object binding pattern (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.1.19 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ +var accessCount = 0; +var obj = Object.defineProperty({}, 'attr', { + get: function() { + accessCount += 1; + } +}); + +var callCount = 0; +function f({} = obj) { + assert.sameValue(accessCount, 0); + callCount = callCount + 1; +}; +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/statements/function/dstr-dflt-obj-ptrn-id-get-value-err.js b/test/language/statements/function/dstr-dflt-obj-ptrn-id-get-value-err.js new file mode 100644 index 0000000000..4fcba776f5 --- /dev/null +++ b/test/language/statements/function/dstr-dflt-obj-ptrn-id-get-value-err.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-get-value-err.case +// - src/dstr-binding/error/func-decl-dflt.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.1.19 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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(); + } +}); + +function f({ poisoned } = poisonedProperty) {} + +assert.throws(Test262Error, function() { + f(); +}); diff --git a/test/language/statements/function/dstr-dflt-obj-ptrn-id-init-fn-name-arrow.js b/test/language/statements/function/dstr-dflt-obj-ptrn-id-init-fn-name-arrow.js new file mode 100644 index 0000000000..440975b842 --- /dev/null +++ b/test/language/statements/function/dstr-dflt-obj-ptrn-id-init-fn-name-arrow.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-arrow.case +// - src/dstr-binding/default/func-decl-dflt.template +/*--- +description: SingleNameBinding assigns `name` to arrow functions (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.1.19 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +function f({ arrow = () => {} } = {}) { + assert.sameValue(arrow.name, 'arrow'); + callCount = callCount + 1; +}; +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/statements/function/dstr-dflt-obj-ptrn-id-init-fn-name-class.js b/test/language/statements/function/dstr-dflt-obj-ptrn-id-init-fn-name-class.js new file mode 100644 index 0000000000..f9eb8e325f --- /dev/null +++ b/test/language/statements/function/dstr-dflt-obj-ptrn-id-init-fn-name-class.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-class.case +// - src/dstr-binding/default/func-decl-dflt.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.1.19 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +function f({ cls = class {}, xCls = class X {} } = {}) { + assert.sameValue(cls.name, 'cls'); + assert.notSameValue(xCls.name, 'xCls'); + callCount = callCount + 1; +}; +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/statements/function/dstr-dflt-obj-ptrn-id-init-fn-name-cover.js b/test/language/statements/function/dstr-dflt-obj-ptrn-id-init-fn-name-cover.js new file mode 100644 index 0000000000..67c39b7db8 --- /dev/null +++ b/test/language/statements/function/dstr-dflt-obj-ptrn-id-init-fn-name-cover.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-cover.case +// - src/dstr-binding/default/func-decl-dflt.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" functions "through" cover grammar (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.1.19 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +function f({ cover = (function () {}), xCover = (0, function() {}) } = {}) { + assert.sameValue(cover.name, 'cover'); + assert.notSameValue(xCover.name, 'xCover'); + callCount = callCount + 1; +}; +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/statements/function/dstr-dflt-obj-ptrn-id-init-fn-name-fn.js b/test/language/statements/function/dstr-dflt-obj-ptrn-id-init-fn-name-fn.js new file mode 100644 index 0000000000..8882557c0e --- /dev/null +++ b/test/language/statements/function/dstr-dflt-obj-ptrn-id-init-fn-name-fn.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-fn.case +// - src/dstr-binding/default/func-decl-dflt.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.1.19 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +function f({ fn = function () {}, xFn = function x() {} } = {}) { + assert.sameValue(fn.name, 'fn'); + assert.notSameValue(xFn.name, 'xFn'); + callCount = callCount + 1; +}; +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/statements/function/dstr-dflt-obj-ptrn-id-init-fn-name-gen.js b/test/language/statements/function/dstr-dflt-obj-ptrn-id-init-fn-name-gen.js new file mode 100644 index 0000000000..cf12cc58a2 --- /dev/null +++ b/test/language/statements/function/dstr-dflt-obj-ptrn-id-init-fn-name-gen.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-gen.case +// - src/dstr-binding/default/func-decl-dflt.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.1.19 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +function f({ gen = function* () {}, xGen = function* x() {} } = {}) { + assert.sameValue(gen.name, 'gen'); + assert.notSameValue(xGen.name, 'xGen'); + callCount = callCount + 1; +}; +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/statements/function/dstr-dflt-obj-ptrn-id-init-skipped.js b/test/language/statements/function/dstr-dflt-obj-ptrn-id-init-skipped.js new file mode 100644 index 0000000000..95a339154f --- /dev/null +++ b/test/language/statements/function/dstr-dflt-obj-ptrn-id-init-skipped.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-skipped.case +// - src/dstr-binding/default/func-decl-dflt.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.1.19 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + [...] +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var callCount = 0; +function f({ w = counter(), x = counter(), y = counter(), z = counter() } = { w: null, x: 0, y: false, z: '' }) { + assert.sameValue(w, null); + assert.sameValue(x, 0); + assert.sameValue(y, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + callCount = callCount + 1; +}; +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/statements/function/dstr-dflt-obj-ptrn-id-init-throws.js b/test/language/statements/function/dstr-dflt-obj-ptrn-id-init-throws.js new file mode 100644 index 0000000000..82f393491d --- /dev/null +++ b/test/language/statements/function/dstr-dflt-obj-ptrn-id-init-throws.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-throws.case +// - src/dstr-binding/error/func-decl-dflt.template +/*--- +description: Error thrown when evaluating the initializer (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.1.19 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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(); +} + +function f({ x = thrower() } = {}) {} + +assert.throws(Test262Error, function() { + f(); +}); diff --git a/test/language/statements/function/dstr-dflt-obj-ptrn-id-init-unresolvable.js b/test/language/statements/function/dstr-dflt-obj-ptrn-id-init-unresolvable.js new file mode 100644 index 0000000000..1d2a127a38 --- /dev/null +++ b/test/language/statements/function/dstr-dflt-obj-ptrn-id-init-unresolvable.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-unresolvable.case +// - src/dstr-binding/error/func-decl-dflt.template +/*--- +description: Destructuring initializer is an unresolvable reference (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.1.19 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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. +---*/ + +function f({ x = unresolvableReference } = {}) {} + +assert.throws(ReferenceError, function() { + f(); +}); diff --git a/test/language/statements/function/dstr-dflt-obj-ptrn-id-trailing-comma.js b/test/language/statements/function/dstr-dflt-obj-ptrn-id-trailing-comma.js new file mode 100644 index 0000000000..64f938578c --- /dev/null +++ b/test/language/statements/function/dstr-dflt-obj-ptrn-id-trailing-comma.js @@ -0,0 +1,56 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-trailing-comma.case +// - src/dstr-binding/default/func-decl-dflt.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.1.19 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var callCount = 0; +function f({ x, } = { x: 23 }) { + assert.sameValue(x, 23); + callCount = callCount + 1; +}; +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/statements/function/dstr-dflt-obj-ptrn-list-err.js b/test/language/statements/function/dstr-dflt-obj-ptrn-list-err.js new file mode 100644 index 0000000000..2705a11561 --- /dev/null +++ b/test/language/statements/function/dstr-dflt-obj-ptrn-list-err.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-list-err.case +// - src/dstr-binding/error/func-decl-dflt.template +/*--- +description: Binding property list evaluation is interrupted by an abrupt completion (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.1.19 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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(); +} + +function f({ a, b = thrower(), c = ++initCount } = {}) {} + +assert.throws(Test262Error, function() { + f(); +}); + +assert.sameValue(initCount, 0); diff --git a/test/language/statements/function/dstr-dflt-obj-ptrn-prop-ary-init.js b/test/language/statements/function/dstr-dflt-obj-ptrn-prop-ary-init.js new file mode 100644 index 0000000000..620fb163b1 --- /dev/null +++ b/test/language/statements/function/dstr-dflt-obj-ptrn-prop-ary-init.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-init.case +// - src/dstr-binding/default/func-decl-dflt.template +/*--- +description: Object binding pattern with "nested" array binding pattern using initializer (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.1.19 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +function f({ w: [x, y, z] = [4, 5, 6] } = {}) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; +}; +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/statements/function/dstr-dflt-obj-ptrn-prop-ary-trailing-comma.js b/test/language/statements/function/dstr-dflt-obj-ptrn-prop-ary-trailing-comma.js new file mode 100644 index 0000000000..638d893adf --- /dev/null +++ b/test/language/statements/function/dstr-dflt-obj-ptrn-prop-ary-trailing-comma.js @@ -0,0 +1,56 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-trailing-comma.case +// - src/dstr-binding/default/func-decl-dflt.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.1.19 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var callCount = 0; +function f({ x: [y], } = { x: [45] }) { + assert.sameValue(y,45); + callCount = callCount + 1; +}; +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/statements/function/dstr-dflt-obj-ptrn-prop-ary-value-null.js b/test/language/statements/function/dstr-dflt-obj-ptrn-prop-ary-value-null.js new file mode 100644 index 0000000000..39c810641e --- /dev/null +++ b/test/language/statements/function/dstr-dflt-obj-ptrn-prop-ary-value-null.js @@ -0,0 +1,55 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-value-null.case +// - src/dstr-binding/error/func-decl-dflt.template +/*--- +description: Object binding pattern with "nested" array binding pattern taking the `null` value (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.1.19 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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. +---*/ + +function f({ w: [x, y, z] = [4, 5, 6] } = { w: null }) {} + +assert.throws(TypeError, function() { + f(); +}); diff --git a/test/language/statements/function/dstr-dflt-obj-ptrn-prop-ary.js b/test/language/statements/function/dstr-dflt-obj-ptrn-prop-ary.js new file mode 100644 index 0000000000..616e757ad3 --- /dev/null +++ b/test/language/statements/function/dstr-dflt-obj-ptrn-prop-ary.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary.case +// - src/dstr-binding/default/func-decl-dflt.template +/*--- +description: Object binding pattern with "nested" array binding pattern not using initializer (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.1.19 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +function f({ w: [x, y, z] = [4, 5, 6] } = { w: [7, undefined, ] }) { + assert.sameValue(x, 7); + assert.sameValue(y, undefined); + assert.sameValue(z, undefined); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; +}; +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/statements/function/dstr-dflt-obj-ptrn-prop-eval-err.js b/test/language/statements/function/dstr-dflt-obj-ptrn-prop-eval-err.js new file mode 100644 index 0000000000..9bbdd4df19 --- /dev/null +++ b/test/language/statements/function/dstr-dflt-obj-ptrn-prop-eval-err.js @@ -0,0 +1,57 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-eval-err.case +// - src/dstr-binding/error/func-decl-dflt.template +/*--- +description: Evaluation of property name returns an abrupt completion (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.1.19 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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(); +} + +function f({ [thrower()]: x } = {}) {} + +assert.throws(Test262Error, function() { + f(); +}); diff --git a/test/language/statements/function/dstr-dflt-obj-ptrn-prop-id-get-value-err.js b/test/language/statements/function/dstr-dflt-obj-ptrn-prop-id-get-value-err.js new file mode 100644 index 0000000000..566e29e297 --- /dev/null +++ b/test/language/statements/function/dstr-dflt-obj-ptrn-prop-id-get-value-err.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-get-value-err.case +// - src/dstr-binding/error/func-decl-dflt.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.1.19 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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(); + } +}); + +function f({ poisoned: x = ++initEvalCount } = poisonedProperty) {} + +assert.throws(Test262Error, function() { + f(); +}); + +assert.sameValue(initEvalCount, 0); diff --git a/test/language/statements/function/dstr-dflt-obj-ptrn-prop-id-init-skipped.js b/test/language/statements/function/dstr-dflt-obj-ptrn-prop-id-init-skipped.js new file mode 100644 index 0000000000..050d2e3dfa --- /dev/null +++ b/test/language/statements/function/dstr-dflt-obj-ptrn-prop-id-init-skipped.js @@ -0,0 +1,78 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-skipped.case +// - src/dstr-binding/default/func-decl-dflt.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.1.19 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + [...] +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var callCount = 0; +function f({ s: t = counter(), u: v = counter(), w: x = counter(), y: z = counter() } = { s: null, u: 0, w: false, y: '' }) { + assert.sameValue(t, null); + assert.sameValue(v, 0); + assert.sameValue(x, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + + assert.throws(ReferenceError, function() { + s; + }); + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; +}; +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/statements/function/dstr-dflt-obj-ptrn-prop-id-init-throws.js b/test/language/statements/function/dstr-dflt-obj-ptrn-prop-id-init-throws.js new file mode 100644 index 0000000000..24d20c1efc --- /dev/null +++ b/test/language/statements/function/dstr-dflt-obj-ptrn-prop-id-init-throws.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-throws.case +// - src/dstr-binding/error/func-decl-dflt.template +/*--- +description: Error thrown when evaluating the initializer (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.1.19 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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(); +} + +function f({ x: y = thrower() } = {}) {} + +assert.throws(Test262Error, function() { + f(); +}); diff --git a/test/language/statements/function/dstr-dflt-obj-ptrn-prop-id-init-unresolvable.js b/test/language/statements/function/dstr-dflt-obj-ptrn-prop-id-init-unresolvable.js new file mode 100644 index 0000000000..65feafa0dc --- /dev/null +++ b/test/language/statements/function/dstr-dflt-obj-ptrn-prop-id-init-unresolvable.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-unresolvable.case +// - src/dstr-binding/error/func-decl-dflt.template +/*--- +description: Destructuring initializer is an unresolvable reference (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.1.19 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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. +---*/ + +function f({ x: y = unresolvableReference } = {}) {} + +assert.throws(ReferenceError, function() { + f(); +}); diff --git a/test/language/statements/function/dstr-dflt-obj-ptrn-prop-id-init.js b/test/language/statements/function/dstr-dflt-obj-ptrn-prop-id-init.js new file mode 100644 index 0000000000..fa07c0c0d1 --- /dev/null +++ b/test/language/statements/function/dstr-dflt-obj-ptrn-prop-id-init.js @@ -0,0 +1,59 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init.case +// - src/dstr-binding/default/func-decl-dflt.template +/*--- +description: Binding as specified via property name, identifier, and initializer (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.1.19 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +function f({ x: y = 33 } = { }) { + assert.sameValue(y, 33); + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; +}; +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/statements/function/dstr-dflt-obj-ptrn-prop-id-trailing-comma.js b/test/language/statements/function/dstr-dflt-obj-ptrn-prop-id-trailing-comma.js new file mode 100644 index 0000000000..a8da076bd4 --- /dev/null +++ b/test/language/statements/function/dstr-dflt-obj-ptrn-prop-id-trailing-comma.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-trailing-comma.case +// - src/dstr-binding/default/func-decl-dflt.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.1.19 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var callCount = 0; +function f({ x: y, } = { x: 23 }) { + assert.sameValue(y, 23); + + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; +}; +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/statements/function/dstr-dflt-obj-ptrn-prop-id.js b/test/language/statements/function/dstr-dflt-obj-ptrn-prop-id.js new file mode 100644 index 0000000000..14f2b8b60d --- /dev/null +++ b/test/language/statements/function/dstr-dflt-obj-ptrn-prop-id.js @@ -0,0 +1,59 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id.case +// - src/dstr-binding/default/func-decl-dflt.template +/*--- +description: Binding as specified via property name and identifier (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.1.19 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +function f({ x: y } = { x: 23 }) { + assert.sameValue(y, 23); + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; +}; +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/statements/function/dstr-dflt-obj-ptrn-prop-obj-init.js b/test/language/statements/function/dstr-dflt-obj-ptrn-prop-obj-init.js new file mode 100644 index 0000000000..537fe4db81 --- /dev/null +++ b/test/language/statements/function/dstr-dflt-obj-ptrn-prop-obj-init.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-init.case +// - src/dstr-binding/default/func-decl-dflt.template +/*--- +description: Object binding pattern with "nested" object binding pattern using initializer (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.1.19 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +function f({ w: { x, y, z } = { x: 4, y: 5, z: 6 } } = { w: undefined }) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; +}; +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/statements/function/dstr-dflt-obj-ptrn-prop-obj-value-null.js b/test/language/statements/function/dstr-dflt-obj-ptrn-prop-obj-value-null.js new file mode 100644 index 0000000000..918d9027d1 --- /dev/null +++ b/test/language/statements/function/dstr-dflt-obj-ptrn-prop-obj-value-null.js @@ -0,0 +1,55 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-null.case +// - src/dstr-binding/error/func-decl-dflt.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.1.19 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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. +---*/ + +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/function/dstr-dflt-obj-ptrn-prop-obj-value-undef.js b/test/language/statements/function/dstr-dflt-obj-ptrn-prop-obj-value-undef.js new file mode 100644 index 0000000000..7256753f9f --- /dev/null +++ b/test/language/statements/function/dstr-dflt-obj-ptrn-prop-obj-value-undef.js @@ -0,0 +1,55 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-undef.case +// - src/dstr-binding/error/func-decl-dflt.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.1.19 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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. +---*/ + +function f({ w: { x, y, z } = undefined } = { }) {} + +assert.throws(TypeError, function() { + f(); +}); diff --git a/test/language/statements/function/dstr-dflt-obj-ptrn-prop-obj.js b/test/language/statements/function/dstr-dflt-obj-ptrn-prop-obj.js new file mode 100644 index 0000000000..e94711519b --- /dev/null +++ b/test/language/statements/function/dstr-dflt-obj-ptrn-prop-obj.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj.case +// - src/dstr-binding/default/func-decl-dflt.template +/*--- +description: Object binding pattern with "nested" object binding pattern not using initializer (function declaration (default parameter)) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.1.19 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +function f({ w: { x, y, z } = { x: 4, y: 5, z: 6 } } = { w: { x: undefined, z: 7 } }) { + assert.sameValue(x, undefined); + assert.sameValue(y, undefined); + assert.sameValue(z, 7); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; +}; +f(); +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/statements/generators/dstr-dflt-ary-init-iter-close.js b/test/language/statements/generators/dstr-dflt-ary-init-iter-close.js new file mode 100644 index 0000000000..b7159d14f7 --- /dev/null +++ b/test/language/statements/generators/dstr-dflt-ary-init-iter-close.js @@ -0,0 +1,71 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-close.case +// - src/dstr-binding/default/gen-func-decl-dflt.template +/*--- +description: Iterator is closed when not exhausted by pattern evaluation (generator function declaration (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.4.12 +features: [Symbol.iterator, destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorDeclaration : function * ( FormalParameters ) { GeneratorBody } + + [...] + 2. Let F be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + [...] + 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator, + result). + [...] + +---*/ +var doneCallCount = 0; +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return { value: null, done: false }; + }, + return: function() { + doneCallCount += 1; + return {}; + } + }; +}; + +var callCount = 0; +function* f([x] = iter) { + assert.sameValue(doneCallCount, 1); + callCount = callCount + 1; +}; +f().next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/statements/generators/dstr-dflt-ary-init-iter-get-err.js b/test/language/statements/generators/dstr-dflt-ary-init-iter-get-err.js new file mode 100644 index 0000000000..be0a0929fe --- /dev/null +++ b/test/language/statements/generators/dstr-dflt-ary-init-iter-get-err.js @@ -0,0 +1,58 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-get-err.case +// - src/dstr-binding/error/gen-func-decl-dflt.template +/*--- +description: Abrupt completion returned by GetIterator (generator function declaration (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.4.12 +features: [Symbol.iterator, destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorDeclaration : function * ( FormalParameters ) { GeneratorBody } + + [...] + 2. Let F be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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(); +}; + +function* f([x] = iter) {} + +assert.throws(Test262Error, function() { + f(); +}); diff --git a/test/language/statements/generators/dstr-dflt-ary-init-iter-no-close.js b/test/language/statements/generators/dstr-dflt-ary-init-iter-no-close.js new file mode 100644 index 0000000000..b08a9f0841 --- /dev/null +++ b/test/language/statements/generators/dstr-dflt-ary-init-iter-no-close.js @@ -0,0 +1,71 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-init-iter-no-close.case +// - src/dstr-binding/default/gen-func-decl-dflt.template +/*--- +description: Iterator is not closed when exhausted by pattern evaluation (generator function declaration (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.4.12 +features: [Symbol.iterator, destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorDeclaration : function * ( FormalParameters ) { GeneratorBody } + + [...] + 2. Let F be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.5 Runtime Semantics: BindingInitialization + + BindingPattern : ArrayBindingPattern + + [...] + 4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator, + result). + [...] + +---*/ +var doneCallCount = 0; +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + return { value: null, done: true }; + }, + return: function() { + doneCallCount += 1; + return {}; + } + }; +}; + +var callCount = 0; +function* f([x] = iter) { + assert.sameValue(doneCallCount, 0); + callCount = callCount + 1; +}; +f().next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/statements/generators/dstr-dflt-ary-name-iter-val.js b/test/language/statements/generators/dstr-dflt-ary-name-iter-val.js new file mode 100644 index 0000000000..01cc9dfb4d --- /dev/null +++ b/test/language/statements/generators/dstr-dflt-ary-name-iter-val.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-name-iter-val.case +// - src/dstr-binding/default/gen-func-decl-dflt.template +/*--- +description: SingleNameBinding with normal value iteration (generator function declaration (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.4.12 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorDeclaration : function * ( FormalParameters ) { GeneratorBody } + + [...] + 2. Let F be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set + iteratorRecord.[[done]] to true. + iii. ReturnIfAbrupt(v). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +function* f([x, y, z] = [1, 2, 3]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 3); + callCount = callCount + 1; +}; +f().next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/statements/generators/dstr-dflt-ary-ptrn-elem-ary-elem-init.js b/test/language/statements/generators/dstr-dflt-ary-ptrn-elem-ary-elem-init.js new file mode 100644 index 0000000000..86d79f337b --- /dev/null +++ b/test/language/statements/generators/dstr-dflt-ary-ptrn-elem-ary-elem-init.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elem-init.case +// - src/dstr-binding/default/gen-func-decl-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is used (generator function declaration (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.4.12 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorDeclaration : function * ( FormalParameters ) { GeneratorBody } + + [...] + 2. Let F be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +function* f([[x, y, z] = [4, 5, 6]] = []) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + callCount = callCount + 1; +}; +f().next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/statements/generators/dstr-dflt-ary-ptrn-elem-ary-elem-iter.js b/test/language/statements/generators/dstr-dflt-ary-ptrn-elem-ary-elem-iter.js new file mode 100644 index 0000000000..4df9e01554 --- /dev/null +++ b/test/language/statements/generators/dstr-dflt-ary-ptrn-elem-ary-elem-iter.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elem-iter.case +// - src/dstr-binding/default/gen-func-decl-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (generator function declaration (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.4.12 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorDeclaration : function * ( FormalParameters ) { GeneratorBody } + + [...] + 2. Let F be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +function* f([[x, y, z] = [4, 5, 6]] = [[7, 8, 9]]) { + assert.sameValue(x, 7); + assert.sameValue(y, 8); + assert.sameValue(z, 9); + callCount = callCount + 1; +}; +f().next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/statements/generators/dstr-dflt-ary-ptrn-elem-ary-elision-init.js b/test/language/statements/generators/dstr-dflt-ary-ptrn-elem-ary-elision-init.js new file mode 100644 index 0000000000..5a711c3b10 --- /dev/null +++ b/test/language/statements/generators/dstr-dflt-ary-ptrn-elem-ary-elision-init.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elision-init.case +// - src/dstr-binding/default/gen-func-decl-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is used (generator function declaration (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.4.12 +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorDeclaration : function * ( FormalParameters ) { GeneratorBody } + + [...] + 2. Let F be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var callCount = 0; +function* f([[,] = g()] = []) { + assert.sameValue(first, 1); + assert.sameValue(second, 0); + callCount = callCount + 1; +}; +f().next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/statements/generators/dstr-dflt-ary-ptrn-elem-ary-elision-iter.js b/test/language/statements/generators/dstr-dflt-ary-ptrn-elem-ary-elision-iter.js new file mode 100644 index 0000000000..a37124d6bf --- /dev/null +++ b/test/language/statements/generators/dstr-dflt-ary-ptrn-elem-ary-elision-iter.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-elision-iter.case +// - src/dstr-binding/default/gen-func-decl-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (generator function declaration (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.4.12 +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorDeclaration : function * ( FormalParameters ) { GeneratorBody } + + [...] + 2. Let F be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. + +---*/ +var callCount = 0; +function* g() { + callCount += 1; +}; + +var callCount = 0; +function* f([[,] = g()] = [[]]) { + assert.sameValue(callCount, 0); + callCount = callCount + 1; +}; +f().next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/statements/generators/dstr-dflt-ary-ptrn-elem-ary-empty-init.js b/test/language/statements/generators/dstr-dflt-ary-ptrn-elem-ary-empty-init.js new file mode 100644 index 0000000000..d535b67c4b --- /dev/null +++ b/test/language/statements/generators/dstr-dflt-ary-ptrn-elem-ary-empty-init.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-empty-init.case +// - src/dstr-binding/default/gen-func-decl-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is used (generator function declaration (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.4.12 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorDeclaration : function * ( FormalParameters ) { GeneratorBody } + + [...] + 2. Let F be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var initCount = 0; +var iterCount = 0; +var iter = function*() { iterCount += 1; }(); + +var callCount = 0; +function* f([[] = function() { initCount += 1; return iter; }()] = []) { + assert.sameValue(initCount, 1); + assert.sameValue(iterCount, 0); + callCount = callCount + 1; +}; +f().next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/statements/generators/dstr-dflt-ary-ptrn-elem-ary-empty-iter.js b/test/language/statements/generators/dstr-dflt-ary-ptrn-elem-ary-empty-iter.js new file mode 100644 index 0000000000..db6ad2f12a --- /dev/null +++ b/test/language/statements/generators/dstr-dflt-ary-ptrn-elem-ary-empty-iter.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-empty-iter.case +// - src/dstr-binding/default/gen-func-decl-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (generator function declaration (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.4.12 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorDeclaration : function * ( FormalParameters ) { GeneratorBody } + + [...] + 2. Let F be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var initCount = 0; + +var callCount = 0; +function* f([[] = function() { initCount += 1; }()] = [[23]]) { + assert.sameValue(initCount, 0); + callCount = callCount + 1; +}; +f().next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/statements/generators/dstr-dflt-ary-ptrn-elem-ary-rest-init.js b/test/language/statements/generators/dstr-dflt-ary-ptrn-elem-ary-rest-init.js new file mode 100644 index 0000000000..1cbba70f3c --- /dev/null +++ b/test/language/statements/generators/dstr-dflt-ary-ptrn-elem-ary-rest-init.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-rest-init.case +// - src/dstr-binding/default/gen-func-decl-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is used (generator function declaration (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.4.12 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorDeclaration : function * ( FormalParameters ) { GeneratorBody } + + [...] + 2. Let F be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var values = [2, 1, 3]; + +var callCount = 0; +function* f([[...x] = values] = []) { + assert(Array.isArray(x)); + assert.sameValue(x[0], 2); + assert.sameValue(x[1], 1); + assert.sameValue(x[2], 3); + assert.sameValue(x.length, 3); + assert.notSameValue(x, values); + callCount = callCount + 1; +}; +f().next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/statements/generators/dstr-dflt-ary-ptrn-elem-ary-rest-iter.js b/test/language/statements/generators/dstr-dflt-ary-ptrn-elem-ary-rest-iter.js new file mode 100644 index 0000000000..08f81debb1 --- /dev/null +++ b/test/language/statements/generators/dstr-dflt-ary-ptrn-elem-ary-rest-iter.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-rest-iter.case +// - src/dstr-binding/default/gen-func-decl-dflt.template +/*--- +description: BindingElement with array binding pattern and initializer is not used (generator function declaration (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.4.12 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorDeclaration : function * ( FormalParameters ) { GeneratorBody } + + [...] + 2. Let F be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + [...] + e. Else, + i. Let v be IteratorValue(next). + [...] + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ +var values = [2, 1, 3]; +var initCount = 0; + +var callCount = 0; +function* f([[...x] = function() { initCount += 1; }()] = [values]) { + assert(Array.isArray(x)); + assert.sameValue(x[0], 2); + assert.sameValue(x[1], 1); + assert.sameValue(x[2], 3); + assert.sameValue(x.length, 3); + assert.notSameValue(x, values); + assert.sameValue(initCount, 0); + callCount = callCount + 1; +}; +f().next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/statements/generators/dstr-dflt-ary-ptrn-elem-ary-val-null.js b/test/language/statements/generators/dstr-dflt-ary-ptrn-elem-ary-val-null.js new file mode 100644 index 0000000000..67ea3a8278 --- /dev/null +++ b/test/language/statements/generators/dstr-dflt-ary-ptrn-elem-ary-val-null.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-ary-val-null.case +// - src/dstr-binding/error/gen-func-decl-dflt.template +/*--- +description: Nested array destructuring with a null value (generator function declaration (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.4.12 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorDeclaration : function * ( FormalParameters ) { GeneratorBody } + + [...] + 2. Let F be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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). +---*/ + +function* f([[x]] = [null]) {} + +assert.throws(TypeError, function() { + f(); +}); diff --git a/test/language/statements/generators/dstr-dflt-ary-ptrn-elem-id-init-exhausted.js b/test/language/statements/generators/dstr-dflt-ary-ptrn-elem-id-init-exhausted.js new file mode 100644 index 0000000000..193c144826 --- /dev/null +++ b/test/language/statements/generators/dstr-dflt-ary-ptrn-elem-id-init-exhausted.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-exhausted.case +// - src/dstr-binding/default/gen-func-decl-dflt.template +/*--- +description: Destructuring initializer with an exhausted iterator (generator function declaration (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.4.12 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorDeclaration : function * ( FormalParameters ) { GeneratorBody } + + [...] + 2. Let F be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +function* f([x = 23] = []) { + assert.sameValue(x, 23); + callCount = callCount + 1; +}; +f().next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/statements/generators/dstr-dflt-ary-ptrn-elem-id-init-fn-name-arrow.js b/test/language/statements/generators/dstr-dflt-ary-ptrn-elem-id-init-fn-name-arrow.js new file mode 100644 index 0000000000..854c4457fb --- /dev/null +++ b/test/language/statements/generators/dstr-dflt-ary-ptrn-elem-id-init-fn-name-arrow.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-arrow.case +// - src/dstr-binding/default/gen-func-decl-dflt.template +/*--- +description: SingleNameBinding does assign name to arrow functions (generator function declaration (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.4.12 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorDeclaration : function * ( FormalParameters ) { GeneratorBody } + + [...] + 2. Let F be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +function* f([arrow = () => {}] = []) { + assert.sameValue(arrow.name, 'arrow'); + callCount = callCount + 1; +}; +f().next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/statements/generators/dstr-dflt-ary-ptrn-elem-id-init-fn-name-class.js b/test/language/statements/generators/dstr-dflt-ary-ptrn-elem-id-init-fn-name-class.js new file mode 100644 index 0000000000..4724ef3f25 --- /dev/null +++ b/test/language/statements/generators/dstr-dflt-ary-ptrn-elem-id-init-fn-name-class.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-class.case +// - src/dstr-binding/default/gen-func-decl-dflt.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (generator function declaration (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.4.12 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorDeclaration : function * ( FormalParameters ) { GeneratorBody } + + [...] + 2. Let F be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +function* f([cls = class {}, xCls = class X {}] = []) { + assert.sameValue(cls.name, 'cls'); + assert.notSameValue(xCls.name, 'xCls'); + callCount = callCount + 1; +}; +f().next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/statements/generators/dstr-dflt-ary-ptrn-elem-id-init-fn-name-cover.js b/test/language/statements/generators/dstr-dflt-ary-ptrn-elem-id-init-fn-name-cover.js new file mode 100644 index 0000000000..37ac885369 --- /dev/null +++ b/test/language/statements/generators/dstr-dflt-ary-ptrn-elem-id-init-fn-name-cover.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-cover.case +// - src/dstr-binding/default/gen-func-decl-dflt.template +/*--- +description: SingleNameBinding does assign name to "anonymous" functions "through" cover grammar (generator function declaration (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.4.12 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorDeclaration : function * ( FormalParameters ) { GeneratorBody } + + [...] + 2. Let F be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +function* f([cover = (function () {}), xCover = (0, function() {})] = []) { + assert.sameValue(cover.name, 'cover'); + assert.notSameValue(xCover.name, 'xCover'); + callCount = callCount + 1; +}; +f().next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/statements/generators/dstr-dflt-ary-ptrn-elem-id-init-fn-name-fn.js b/test/language/statements/generators/dstr-dflt-ary-ptrn-elem-id-init-fn-name-fn.js new file mode 100644 index 0000000000..e2f20084a9 --- /dev/null +++ b/test/language/statements/generators/dstr-dflt-ary-ptrn-elem-id-init-fn-name-fn.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-fn.case +// - src/dstr-binding/default/gen-func-decl-dflt.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (generator function declaration (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.4.12 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorDeclaration : function * ( FormalParameters ) { GeneratorBody } + + [...] + 2. Let F be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +function* f([fn = function () {}, xFn = function x() {}] = []) { + assert.sameValue(fn.name, 'fn'); + assert.notSameValue(xFn.name, 'xFn'); + callCount = callCount + 1; +}; +f().next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/statements/generators/dstr-dflt-ary-ptrn-elem-id-init-fn-name-gen.js b/test/language/statements/generators/dstr-dflt-ary-ptrn-elem-id-init-fn-name-gen.js new file mode 100644 index 0000000000..de951966fc --- /dev/null +++ b/test/language/statements/generators/dstr-dflt-ary-ptrn-elem-id-init-fn-name-gen.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-fn-name-gen.case +// - src/dstr-binding/default/gen-func-decl-dflt.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (generator function declaration (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.4.12 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorDeclaration : function * ( FormalParameters ) { GeneratorBody } + + [...] + 2. Let F be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +function* f([gen = function* () {}, xGen = function* x() {}] = []) { + assert.sameValue(gen.name, 'gen'); + assert.notSameValue(xGen.name, 'xGen'); + callCount = callCount + 1; +}; +f().next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/statements/generators/dstr-dflt-ary-ptrn-elem-id-init-hole.js b/test/language/statements/generators/dstr-dflt-ary-ptrn-elem-id-init-hole.js new file mode 100644 index 0000000000..ef05a5478b --- /dev/null +++ b/test/language/statements/generators/dstr-dflt-ary-ptrn-elem-id-init-hole.js @@ -0,0 +1,57 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-hole.case +// - src/dstr-binding/default/gen-func-decl-dflt.template +/*--- +description: Destructuring initializer with a "hole" (generator function declaration (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.4.12 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorDeclaration : function * ( FormalParameters ) { GeneratorBody } + + [...] + 2. Let F be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + SingleNameBinding : BindingIdentifier Initializeropt + [...] 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + [...] + 7. If environment is undefined, return PutValue(lhs, v). 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +function* f([x = 23] = [,]) { + assert.sameValue(x, 23); + // another statement + callCount = callCount + 1; +}; +f().next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/statements/generators/dstr-dflt-ary-ptrn-elem-id-init-skipped.js b/test/language/statements/generators/dstr-dflt-ary-ptrn-elem-id-init-skipped.js new file mode 100644 index 0000000000..067f1dbe10 --- /dev/null +++ b/test/language/statements/generators/dstr-dflt-ary-ptrn-elem-id-init-skipped.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-skipped.case +// - src/dstr-binding/default/gen-func-decl-dflt.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (generator function declaration (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.4.12 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorDeclaration : function * ( FormalParameters ) { GeneratorBody } + + [...] + 2. Let F be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var callCount = 0; +function* f([w = counter(), x = counter(), y = counter(), z = counter()] = [null, 0, false, '']) { + assert.sameValue(w, null); + assert.sameValue(x, 0); + assert.sameValue(y, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + callCount = callCount + 1; +}; +f().next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/statements/generators/dstr-dflt-ary-ptrn-elem-id-init-throws.js b/test/language/statements/generators/dstr-dflt-ary-ptrn-elem-id-init-throws.js new file mode 100644 index 0000000000..e5bdb2bf5c --- /dev/null +++ b/test/language/statements/generators/dstr-dflt-ary-ptrn-elem-id-init-throws.js @@ -0,0 +1,56 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-throws.case +// - src/dstr-binding/error/gen-func-decl-dflt.template +/*--- +description: Destructuring initializer returns an abrupt completion (generator function declaration (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.4.12 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorDeclaration : function * ( FormalParameters ) { GeneratorBody } + + [...] + 2. Let F be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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). +---*/ + +function* f([x = (function() { throw new Test262Error(); })()] = [undefined]) {} + +assert.throws(Test262Error, function() { + f(); +}); diff --git a/test/language/statements/generators/dstr-dflt-ary-ptrn-elem-id-init-undef.js b/test/language/statements/generators/dstr-dflt-ary-ptrn-elem-id-init-undef.js new file mode 100644 index 0000000000..12cc3cd63c --- /dev/null +++ b/test/language/statements/generators/dstr-dflt-ary-ptrn-elem-id-init-undef.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-undef.case +// - src/dstr-binding/default/gen-func-decl-dflt.template +/*--- +description: Destructuring initializer with an undefined value (generator function declaration (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.4.12 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorDeclaration : function * ( FormalParameters ) { GeneratorBody } + + [...] + 2. Let F be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + [...] + 7. If environment is undefined, return PutValue(lhs, v). + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +function* f([x = 23] = [undefined]) { + assert.sameValue(x, 23); + callCount = callCount + 1; +}; +f().next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/statements/generators/dstr-dflt-ary-ptrn-elem-id-init-unresolvable.js b/test/language/statements/generators/dstr-dflt-ary-ptrn-elem-id-init-unresolvable.js new file mode 100644 index 0000000000..3860cbd0c0 --- /dev/null +++ b/test/language/statements/generators/dstr-dflt-ary-ptrn-elem-id-init-unresolvable.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-init-unresolvable.case +// - src/dstr-binding/error/gen-func-decl-dflt.template +/*--- +description: Destructuring initializer is an unresolvable reference (generator function declaration (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.4.12 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorDeclaration : function * ( FormalParameters ) { GeneratorBody } + + [...] + 2. Let F be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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. +---*/ + +function* f([ x = unresolvableReference ] = []) {} + +assert.throws(ReferenceError, function() { + f(); +}); diff --git a/test/language/statements/generators/dstr-dflt-ary-ptrn-elem-id-iter-complete.js b/test/language/statements/generators/dstr-dflt-ary-ptrn-elem-id-iter-complete.js new file mode 100644 index 0000000000..801b828215 --- /dev/null +++ b/test/language/statements/generators/dstr-dflt-ary-ptrn-elem-id-iter-complete.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-complete.case +// - src/dstr-binding/default/gen-func-decl-dflt.template +/*--- +description: SingleNameBinding when value iteration completes (generator function declaration (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.4.12 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorDeclaration : function * ( FormalParameters ) { GeneratorBody } + + [...] + 2. Let F be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +function* f([x] = []) { + assert.sameValue(x, undefined); + callCount = callCount + 1; +}; +f().next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/statements/generators/dstr-dflt-ary-ptrn-elem-id-iter-done.js b/test/language/statements/generators/dstr-dflt-ary-ptrn-elem-id-iter-done.js new file mode 100644 index 0000000000..433f52ee60 --- /dev/null +++ b/test/language/statements/generators/dstr-dflt-ary-ptrn-elem-id-iter-done.js @@ -0,0 +1,59 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-done.case +// - src/dstr-binding/default/gen-func-decl-dflt.template +/*--- +description: SingleNameBinding when value iteration was completed previously (generator function declaration (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.4.12 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorDeclaration : function * ( FormalParameters ) { GeneratorBody } + + [...] + 2. Let F be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + [...] + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +function* f([_, x] = []) { + assert.sameValue(x, undefined); + callCount = callCount + 1; +}; +f().next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/statements/generators/dstr-dflt-ary-ptrn-elem-id-iter-step-err.js b/test/language/statements/generators/dstr-dflt-ary-ptrn-elem-id-iter-step-err.js new file mode 100644 index 0000000000..08c70c21c3 --- /dev/null +++ b/test/language/statements/generators/dstr-dflt-ary-ptrn-elem-id-iter-step-err.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-step-err.case +// - src/dstr-binding/error/gen-func-decl-dflt.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (generator function declaration (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.4.12 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorDeclaration : function * ( FormalParameters ) { GeneratorBody } + + [...] + 2. Let F be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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(); + } + }; +}; + +function* f([x] = g) {} + +assert.throws(Test262Error, function() { + f(); +}); diff --git a/test/language/statements/generators/dstr-dflt-ary-ptrn-elem-id-iter-val-err.js b/test/language/statements/generators/dstr-dflt-ary-ptrn-elem-id-iter-val-err.js new file mode 100644 index 0000000000..e223c03b4d --- /dev/null +++ b/test/language/statements/generators/dstr-dflt-ary-ptrn-elem-id-iter-val-err.js @@ -0,0 +1,75 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val-err.case +// - src/dstr-binding/error/gen-func-decl-dflt.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (generator function declaration (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.4.12 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorDeclaration : function * ( FormalParameters ) { GeneratorBody } + + [...] + 2. Let F be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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; + } + }; +}; + +function* f([x] = g) {} + +assert.throws(Test262Error, function() { + f(); +}); diff --git a/test/language/statements/generators/dstr-dflt-ary-ptrn-elem-id-iter-val.js b/test/language/statements/generators/dstr-dflt-ary-ptrn-elem-id-iter-val.js new file mode 100644 index 0000000000..22cc5f2077 --- /dev/null +++ b/test/language/statements/generators/dstr-dflt-ary-ptrn-elem-id-iter-val.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-id-iter-val.case +// - src/dstr-binding/default/gen-func-decl-dflt.template +/*--- +description: SingleNameBinding when value iteration was completed previously (generator function declaration (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.4.12 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorDeclaration : function * ( FormalParameters ) { GeneratorBody } + + [...] + 2. Let F be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set + iteratorRecord.[[done]] to true. + iii. ReturnIfAbrupt(v). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +function* f([x, y, z] = [1, 2, 3]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 3); + callCount = callCount + 1; +}; +f().next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/statements/generators/dstr-dflt-ary-ptrn-elem-obj-id-init.js b/test/language/statements/generators/dstr-dflt-ary-ptrn-elem-obj-id-init.js new file mode 100644 index 0000000000..39067b4ab9 --- /dev/null +++ b/test/language/statements/generators/dstr-dflt-ary-ptrn-elem-obj-id-init.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-id-init.case +// - src/dstr-binding/default/gen-func-decl-dflt.template +/*--- +description: BindingElement with object binding pattern and initializer is used (generator function declaration (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.4.12 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorDeclaration : function * ( FormalParameters ) { GeneratorBody } + + [...] + 2. Let F be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +function* f([{ x, y, z } = { x: 44, y: 55, z: 66 }] = []) { + assert.sameValue(x, 44); + assert.sameValue(y, 55); + assert.sameValue(z, 66); + callCount = callCount + 1; +}; +f().next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/statements/generators/dstr-dflt-ary-ptrn-elem-obj-id.js b/test/language/statements/generators/dstr-dflt-ary-ptrn-elem-obj-id.js new file mode 100644 index 0000000000..191f6635ea --- /dev/null +++ b/test/language/statements/generators/dstr-dflt-ary-ptrn-elem-obj-id.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-id.case +// - src/dstr-binding/default/gen-func-decl-dflt.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (generator function declaration (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.4.12 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorDeclaration : function * ( FormalParameters ) { GeneratorBody } + + [...] + 2. Let F be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +function* f([{ x, y, z } = { x: 44, y: 55, z: 66 }] = [{ x: 11, y: 22, z: 33 }]) { + assert.sameValue(x, 11); + assert.sameValue(y, 22); + assert.sameValue(z, 33); + callCount = callCount + 1; +}; +f().next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/statements/generators/dstr-dflt-ary-ptrn-elem-obj-prop-id-init.js b/test/language/statements/generators/dstr-dflt-ary-ptrn-elem-obj-prop-id-init.js new file mode 100644 index 0000000000..1ece4c26d1 --- /dev/null +++ b/test/language/statements/generators/dstr-dflt-ary-ptrn-elem-obj-prop-id-init.js @@ -0,0 +1,72 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-prop-id-init.case +// - src/dstr-binding/default/gen-func-decl-dflt.template +/*--- +description: BindingElement with object binding pattern and initializer is used (generator function declaration (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.4.12 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorDeclaration : function * ( FormalParameters ) { GeneratorBody } + + [...] + 2. Let F be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +function* f([{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }] = []) { + assert.sameValue(v, 444); + assert.sameValue(x, 555); + assert.sameValue(z, 666); + + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; +}; +f().next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/statements/generators/dstr-dflt-ary-ptrn-elem-obj-prop-id.js b/test/language/statements/generators/dstr-dflt-ary-ptrn-elem-obj-prop-id.js new file mode 100644 index 0000000000..5c50e495f8 --- /dev/null +++ b/test/language/statements/generators/dstr-dflt-ary-ptrn-elem-obj-prop-id.js @@ -0,0 +1,72 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-prop-id.case +// - src/dstr-binding/default/gen-func-decl-dflt.template +/*--- +description: BindingElement with object binding pattern and initializer is not used (generator function declaration (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.4.12 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorDeclaration : function * ( FormalParameters ) { GeneratorBody } + + [...] + 2. Let F be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingElement : BindingPatternInitializer opt + + [...] + 2. If iteratorRecord.[[done]] is true, let v be undefined. + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be ? GetValue(defaultValue). + 4. Return the result of performing BindingInitialization of BindingPattern + with v and environment as the arguments. +---*/ + +var callCount = 0; +function* f([{ u: v, w: x, y: z } = { u: 444, w: 555, y: 666 }] = [{ u: 777, w: 888, y: 999 }]) { + assert.sameValue(v, 777); + assert.sameValue(x, 888); + assert.sameValue(z, 999); + + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; +}; +f().next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/statements/generators/dstr-dflt-ary-ptrn-elem-obj-val-null.js b/test/language/statements/generators/dstr-dflt-ary-ptrn-elem-obj-val-null.js new file mode 100644 index 0000000000..596d0aab10 --- /dev/null +++ b/test/language/statements/generators/dstr-dflt-ary-ptrn-elem-obj-val-null.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-null.case +// - src/dstr-binding/error/gen-func-decl-dflt.template +/*--- +description: Nested object destructuring with a null value (generator function declaration (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.4.12 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorDeclaration : function * ( FormalParameters ) { GeneratorBody } + + [...] + 2. Let F be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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). +---*/ + +function* f([{ x }] = [null]) {} + +assert.throws(TypeError, function() { + f(); +}); diff --git a/test/language/statements/generators/dstr-dflt-ary-ptrn-elem-obj-val-undef.js b/test/language/statements/generators/dstr-dflt-ary-ptrn-elem-obj-val-undef.js new file mode 100644 index 0000000000..0731bc027e --- /dev/null +++ b/test/language/statements/generators/dstr-dflt-ary-ptrn-elem-obj-val-undef.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elem-obj-val-undef.case +// - src/dstr-binding/error/gen-func-decl-dflt.template +/*--- +description: Nested object destructuring with a value of `undefined` (generator function declaration (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.4.12 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorDeclaration : function * ( FormalParameters ) { GeneratorBody } + + [...] + 2. Let F be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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). +---*/ + +function* f([{ x }] = []) {} + +assert.throws(TypeError, function() { + f(); +}); diff --git a/test/language/statements/generators/dstr-dflt-ary-ptrn-elision-exhausted.js b/test/language/statements/generators/dstr-dflt-ary-ptrn-elision-exhausted.js new file mode 100644 index 0000000000..8cfb101211 --- /dev/null +++ b/test/language/statements/generators/dstr-dflt-ary-ptrn-elision-exhausted.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-exhausted.case +// - src/dstr-binding/default/gen-func-decl-dflt.template +/*--- +description: Elision accepts exhausted iterator (generator function declaration (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.4.12 +features: [generator, destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorDeclaration : function * ( FormalParameters ) { GeneratorBody } + + [...] + 2. Let F be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + [...] + 2. Return NormalCompletion(empty). + +---*/ +var iter = function*() {}(); +iter.next(); + +var callCount = 0; +function* f([,] = iter) { + + callCount = callCount + 1; +}; +f().next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/statements/generators/dstr-dflt-ary-ptrn-elision-step-err.js b/test/language/statements/generators/dstr-dflt-ary-ptrn-elision-step-err.js new file mode 100644 index 0000000000..c9713a1e3e --- /dev/null +++ b/test/language/statements/generators/dstr-dflt-ary-ptrn-elision-step-err.js @@ -0,0 +1,72 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision-step-err.case +// - src/dstr-binding/error/gen-func-decl-dflt.template +/*--- +description: Elision advances iterator and forwards abrupt completions (generator function declaration (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.4.12 +features: [generator, destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorDeclaration : function * ( FormalParameters ) { GeneratorBody } + + [...] + 2. Let F be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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; +}(); + +function* f([,] = iter) {} + +assert.throws(Test262Error, function() { + f(); +}); + +iter.next(); +assert.sameValue(following, 0, 'Iterator was properly closed.'); diff --git a/test/language/statements/generators/dstr-dflt-ary-ptrn-elision.js b/test/language/statements/generators/dstr-dflt-ary-ptrn-elision.js new file mode 100644 index 0000000000..f9e7235810 --- /dev/null +++ b/test/language/statements/generators/dstr-dflt-ary-ptrn-elision.js @@ -0,0 +1,76 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-elision.case +// - src/dstr-binding/default/gen-func-decl-dflt.template +/*--- +description: Elision advances iterator (generator function declaration (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.4.12 +features: [generator, destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorDeclaration : function * ( FormalParameters ) { GeneratorBody } + + [...] + 2. Let F be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + 2. Return NormalCompletion(empty). + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var callCount = 0; +function* f([,] = g()) { + assert.sameValue(first, 1); + assert.sameValue(second, 0); + callCount = callCount + 1; +}; +f().next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/statements/generators/dstr-dflt-ary-ptrn-empty.js b/test/language/statements/generators/dstr-dflt-ary-ptrn-empty.js new file mode 100644 index 0000000000..6f0a518888 --- /dev/null +++ b/test/language/statements/generators/dstr-dflt-ary-ptrn-empty.js @@ -0,0 +1,59 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-empty.case +// - src/dstr-binding/default/gen-func-decl-dflt.template +/*--- +description: No iteration occurs for an "empty" array binding pattern (generator function declaration (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.4.12 +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorDeclaration : function * ( FormalParameters ) { GeneratorBody } + + [...] + 2. Let F be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ ] + + 1. Return NormalCompletion(empty). + +---*/ +var iterations = 0; +var iter = function*() { + iterations += 1; +}(); + +var callCount = 0; +function* f([] = iter) { + assert.sameValue(iterations, 0); + callCount = callCount + 1; +}; +f().next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/statements/generators/dstr-dflt-ary-ptrn-rest-ary-elem.js b/test/language/statements/generators/dstr-dflt-ary-ptrn-rest-ary-elem.js new file mode 100644 index 0000000000..eef37179bb --- /dev/null +++ b/test/language/statements/generators/dstr-dflt-ary-ptrn-rest-ary-elem.js @@ -0,0 +1,83 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-elem.case +// - src/dstr-binding/default/gen-func-decl-dflt.template +/*--- +description: Rest element containing an array BindingElementList pattern (generator function declaration (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.4.12 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorDeclaration : function * ( FormalParameters ) { GeneratorBody } + + [...] + 2. Let F be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 4. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + e. Else, + [...] + i. Let v be IteratorValue(next). + ii. If v is an abrupt completion, set + iteratorRecord.[[done]] to true. + iii. ReturnIfAbrupt(v). + 5. If iteratorRecord.[[done]] is true, let v be undefined. + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +function* f([...[x, y, z]] = [3, 4, 5]) { + assert.sameValue(x, 3); + assert.sameValue(y, 4); + assert.sameValue(z, 5); + callCount = callCount + 1; +}; +f().next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/statements/generators/dstr-dflt-ary-ptrn-rest-ary-elision.js b/test/language/statements/generators/dstr-dflt-ary-ptrn-rest-ary-elision.js new file mode 100644 index 0000000000..33ba155823 --- /dev/null +++ b/test/language/statements/generators/dstr-dflt-ary-ptrn-rest-ary-elision.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-elision.case +// - src/dstr-binding/default/gen-func-decl-dflt.template +/*--- +description: Rest element containing an elision (generator function declaration (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.4.12 +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorDeclaration : function * ( FormalParameters ) { GeneratorBody } + + [...] + 2. Let F be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ Elision ] + + 1. Return the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord + as the argument. + + 12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation + + Elision : , + + 1. If iteratorRecord.[[done]] is false, then + a. Let next be IteratorStep(iteratorRecord.[[iterator]]). + b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. + c. ReturnIfAbrupt(next). + d. If next is false, set iteratorRecord.[[done]] to true. + 2. Return NormalCompletion(empty). + +---*/ +var first = 0; +var second = 0; +function* g() { + first += 1; + yield; + second += 1; +}; + +var callCount = 0; +function* f([...[,]] = g()) { + assert.sameValue(first, 1); + assert.sameValue(second, 1); + callCount = callCount + 1; +}; +f().next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/statements/generators/dstr-dflt-ary-ptrn-rest-ary-empty.js b/test/language/statements/generators/dstr-dflt-ary-ptrn-rest-ary-empty.js new file mode 100644 index 0000000000..21e7af104a --- /dev/null +++ b/test/language/statements/generators/dstr-dflt-ary-ptrn-rest-ary-empty.js @@ -0,0 +1,72 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-empty.case +// - src/dstr-binding/default/gen-func-decl-dflt.template +/*--- +description: Rest element containing an "empty" array pattern (generator function declaration (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.4.12 +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorDeclaration : function * ( FormalParameters ) { GeneratorBody } + + [...] + 2. Let F be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + ArrayBindingPattern : [ ] + + 1. Return NormalCompletion(empty). + +---*/ +var iterations = 0; +var iter = function*() { + iterations += 1; +}(); + +var callCount = 0; +function* f([...[]] = iter) { + assert.sameValue(iterations, 1); + callCount = callCount + 1; +}; +f().next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/statements/generators/dstr-dflt-ary-ptrn-rest-ary-rest.js b/test/language/statements/generators/dstr-dflt-ary-ptrn-rest-ary-rest.js new file mode 100644 index 0000000000..c3f1e58bc2 --- /dev/null +++ b/test/language/statements/generators/dstr-dflt-ary-ptrn-rest-ary-rest.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-ary-rest.case +// - src/dstr-binding/default/gen-func-decl-dflt.template +/*--- +description: Rest element containing a rest element (generator function declaration (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.4.12 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorDeclaration : function * ( FormalParameters ) { GeneratorBody } + + [...] + 2. Let F be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ +var values = [1, 2, 3]; + +var callCount = 0; +function* f([...[...x]] = values) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 1); + assert.sameValue(x[1], 2); + assert.sameValue(x[2], 3); + assert.notSameValue(x, values); + + callCount = callCount + 1; +}; +f().next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/statements/generators/dstr-dflt-ary-ptrn-rest-id-elision-next-err.js b/test/language/statements/generators/dstr-dflt-ary-ptrn-rest-id-elision-next-err.js new file mode 100644 index 0000000000..e83d023e74 --- /dev/null +++ b/test/language/statements/generators/dstr-dflt-ary-ptrn-rest-id-elision-next-err.js @@ -0,0 +1,58 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision-next-err.case +// - src/dstr-binding/error/gen-func-decl-dflt.template +/*--- +description: Rest element following elision elements (generator function declaration (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.4.12 +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorDeclaration : function * ( FormalParameters ) { GeneratorBody } + + [...] + 2. Let F be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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(); })(); + +function* f([, ...x] = iter) {} + +assert.throws(Test262Error, function() { + f(); +}); diff --git a/test/language/statements/generators/dstr-dflt-ary-ptrn-rest-id-elision.js b/test/language/statements/generators/dstr-dflt-ary-ptrn-rest-id-elision.js new file mode 100644 index 0000000000..ad05e3cfd1 --- /dev/null +++ b/test/language/statements/generators/dstr-dflt-ary-ptrn-rest-id-elision.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-elision.case +// - src/dstr-binding/default/gen-func-decl-dflt.template +/*--- +description: Rest element following elision elements (generator function declaration (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.4.12 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorDeclaration : function * ( FormalParameters ) { GeneratorBody } + + [...] + 2. Let F be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + ArrayBindingPattern : [ Elisionopt BindingRestElement ] + 1. If Elision is present, then + a. Let status be the result of performing + IteratorDestructuringAssignmentEvaluation of Elision with + iteratorRecord as the argument. + b. ReturnIfAbrupt(status). + 2. Return the result of performing IteratorBindingInitialization for + BindingRestElement with iteratorRecord and environment as arguments. +---*/ +var values = [1, 2, 3, 4, 5]; + +var callCount = 0; +function* f([ , , ...x] = values) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 3); + assert.sameValue(x[1], 4); + assert.sameValue(x[2], 5); + assert.notSameValue(x, values); + callCount = callCount + 1; +}; +f().next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/statements/generators/dstr-dflt-ary-ptrn-rest-id-exhausted.js b/test/language/statements/generators/dstr-dflt-ary-ptrn-rest-id-exhausted.js new file mode 100644 index 0000000000..add35a813b --- /dev/null +++ b/test/language/statements/generators/dstr-dflt-ary-ptrn-rest-id-exhausted.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-exhausted.case +// - src/dstr-binding/default/gen-func-decl-dflt.template +/*--- +description: RestElement applied to an exhausted iterator (generator function declaration (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.4.12 +features: [Symbol.iterator, destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorDeclaration : function * ( FormalParameters ) { GeneratorBody } + + [...] + 2. Let F be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + 1. Let lhs be ResolveBinding(StringValue of BindingIdentifier, + environment). + 2. ReturnIfAbrupt(lhs). 3. Let A be ArrayCreate(0). 4. Let n=0. 5. Repeat, + [...] + b. If iteratorRecord.[[done]] is true, then + i. If environment is undefined, return PutValue(lhs, A). + ii. Return InitializeReferencedBinding(lhs, A). + +---*/ + +var callCount = 0; +function* f([, , ...x] = [1, 2]) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 0); + callCount = callCount + 1; +}; +f().next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/statements/generators/dstr-dflt-ary-ptrn-rest-id-iter-step-err.js b/test/language/statements/generators/dstr-dflt-ary-ptrn-rest-id-iter-step-err.js new file mode 100644 index 0000000000..71415f728d --- /dev/null +++ b/test/language/statements/generators/dstr-dflt-ary-ptrn-rest-id-iter-step-err.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-step-err.case +// - src/dstr-binding/error/gen-func-decl-dflt.template +/*--- +description: Error forwarding when IteratorStep returns an abrupt completion (generator function declaration (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.4.12 +features: [generators, destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorDeclaration : function * ( FormalParameters ) { GeneratorBody } + + [...] + 2. Let F be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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; +}(); + +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/generators/dstr-dflt-ary-ptrn-rest-id-iter-val-err.js b/test/language/statements/generators/dstr-dflt-ary-ptrn-rest-id-iter-val-err.js new file mode 100644 index 0000000000..6adac85057 --- /dev/null +++ b/test/language/statements/generators/dstr-dflt-ary-ptrn-rest-id-iter-val-err.js @@ -0,0 +1,71 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id-iter-val-err.case +// - src/dstr-binding/error/gen-func-decl-dflt.template +/*--- +description: Error forwarding when IteratorValue returns an abrupt completion (generator function declaration (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.4.12 +features: [Symbol.iterator, destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorDeclaration : function * ( FormalParameters ) { GeneratorBody } + + [...] + 2. Let F be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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; + } + }; +}; + +function* f([...x] = iter) {} + +assert.throws(Test262Error, function() { + f(); +}); diff --git a/test/language/statements/generators/dstr-dflt-ary-ptrn-rest-id.js b/test/language/statements/generators/dstr-dflt-ary-ptrn-rest-id.js new file mode 100644 index 0000000000..3663784da3 --- /dev/null +++ b/test/language/statements/generators/dstr-dflt-ary-ptrn-rest-id.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-id.case +// - src/dstr-binding/default/gen-func-decl-dflt.template +/*--- +description: Lone rest element (generator function declaration (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.4.12 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorDeclaration : function * ( FormalParameters ) { GeneratorBody } + + [...] + 2. Let F be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + BindingRestElement : ... BindingIdentifier + [...] 3. Let A be ArrayCreate(0). [...] 5. Repeat + [...] + f. Let status be CreateDataProperty(A, ToString (n), nextValue). + [...] +---*/ +var values = [1, 2, 3]; + +var callCount = 0; +function* f([...x] = values) { + assert(Array.isArray(x)); + assert.sameValue(x.length, 3); + assert.sameValue(x[0], 1); + assert.sameValue(x[1], 2); + assert.sameValue(x[2], 3); + assert.notSameValue(x, values); + callCount = callCount + 1; +}; +f().next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/statements/generators/dstr-dflt-ary-ptrn-rest-init-ary.js b/test/language/statements/generators/dstr-dflt-ary-ptrn-rest-init-ary.js new file mode 100644 index 0000000000..2482ebae3e --- /dev/null +++ b/test/language/statements/generators/dstr-dflt-ary-ptrn-rest-init-ary.js @@ -0,0 +1,55 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-ary.case +// - src/dstr-binding/default/gen-func-decl-dflt.template +/*--- +description: Reset element (nested array pattern) does not support initializer (generator function declaration (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.4.12 +features: [destructuring-binding, default-parameters] +flags: [generated] +negative: SyntaxError +info: | + GeneratorDeclaration : function * ( FormalParameters ) { GeneratorBody } + + [...] + 2. Let F be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +function* f([...[ x ] = []] = []) { + + callCount = callCount + 1; +}; +f().next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/statements/generators/dstr-dflt-ary-ptrn-rest-init-id.js b/test/language/statements/generators/dstr-dflt-ary-ptrn-rest-init-id.js new file mode 100644 index 0000000000..8f5757f7ab --- /dev/null +++ b/test/language/statements/generators/dstr-dflt-ary-ptrn-rest-init-id.js @@ -0,0 +1,55 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-id.case +// - src/dstr-binding/default/gen-func-decl-dflt.template +/*--- +description: Reset element (identifier) does not support initializer (generator function declaration (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.4.12 +features: [destructuring-binding, default-parameters] +flags: [generated] +negative: SyntaxError +info: | + GeneratorDeclaration : function * ( FormalParameters ) { GeneratorBody } + + [...] + 2. Let F be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +function* f([...x = []] = []) { + + callCount = callCount + 1; +}; +f().next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/statements/generators/dstr-dflt-ary-ptrn-rest-init-obj.js b/test/language/statements/generators/dstr-dflt-ary-ptrn-rest-init-obj.js new file mode 100644 index 0000000000..3a7ae56563 --- /dev/null +++ b/test/language/statements/generators/dstr-dflt-ary-ptrn-rest-init-obj.js @@ -0,0 +1,55 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-init-obj.case +// - src/dstr-binding/default/gen-func-decl-dflt.template +/*--- +description: Reset element (nested object pattern) does not support initializer (generator function declaration (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.4.12 +features: [destructuring-binding, default-parameters] +flags: [generated] +negative: SyntaxError +info: | + GeneratorDeclaration : function * ( FormalParameters ) { GeneratorBody } + + [...] + 2. Let F be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +function* f([...{ x } = []] = []) { + + callCount = callCount + 1; +}; +f().next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/statements/generators/dstr-dflt-ary-ptrn-rest-not-final-ary.js b/test/language/statements/generators/dstr-dflt-ary-ptrn-rest-not-final-ary.js new file mode 100644 index 0000000000..db823e4941 --- /dev/null +++ b/test/language/statements/generators/dstr-dflt-ary-ptrn-rest-not-final-ary.js @@ -0,0 +1,55 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-ary.case +// - src/dstr-binding/default/gen-func-decl-dflt.template +/*--- +description: Rest element (array binding pattern) may not be followed by any element (generator function declaration (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.4.12 +features: [destructuring-binding, default-parameters] +flags: [generated] +negative: SyntaxError +info: | + GeneratorDeclaration : function * ( FormalParameters ) { GeneratorBody } + + [...] + 2. Let F be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +function* f([...[x], y] = [1, 2, 3]) { + + callCount = callCount + 1; +}; +f().next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/statements/generators/dstr-dflt-ary-ptrn-rest-not-final-id.js b/test/language/statements/generators/dstr-dflt-ary-ptrn-rest-not-final-id.js new file mode 100644 index 0000000000..19178f05f9 --- /dev/null +++ b/test/language/statements/generators/dstr-dflt-ary-ptrn-rest-not-final-id.js @@ -0,0 +1,55 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-id.case +// - src/dstr-binding/default/gen-func-decl-dflt.template +/*--- +description: Rest element (identifier) may not be followed by any element (generator function declaration (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.4.12 +features: [destructuring-binding, default-parameters] +flags: [generated] +negative: SyntaxError +info: | + GeneratorDeclaration : function * ( FormalParameters ) { GeneratorBody } + + [...] + 2. Let F be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +function* f([...x, y] = [1, 2, 3]) { + + callCount = callCount + 1; +}; +f().next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/statements/generators/dstr-dflt-ary-ptrn-rest-not-final-obj.js b/test/language/statements/generators/dstr-dflt-ary-ptrn-rest-not-final-obj.js new file mode 100644 index 0000000000..0b871fc2e6 --- /dev/null +++ b/test/language/statements/generators/dstr-dflt-ary-ptrn-rest-not-final-obj.js @@ -0,0 +1,55 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-not-final-obj.case +// - src/dstr-binding/default/gen-func-decl-dflt.template +/*--- +description: Rest element (object binding pattern) may not be followed by any element (generator function declaration (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.4.12 +features: [destructuring-binding, default-parameters] +flags: [generated] +negative: SyntaxError +info: | + GeneratorDeclaration : function * ( FormalParameters ) { GeneratorBody } + + [...] + 2. Let F be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + ArrayBindingPattern[Yield] : + [ Elisionopt BindingRestElement[?Yield]opt ] + [ BindingElementList[?Yield] ] + [ BindingElementList[?Yield] , Elisionopt BindingRestElement[?Yield]opt ] +---*/ + +var callCount = 0; +function* f([...{ x }, y] = [1, 2, 3]) { + + callCount = callCount + 1; +}; +f().next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/statements/generators/dstr-dflt-ary-ptrn-rest-obj-id.js b/test/language/statements/generators/dstr-dflt-ary-ptrn-rest-obj-id.js new file mode 100644 index 0000000000..cdf51b5aff --- /dev/null +++ b/test/language/statements/generators/dstr-dflt-ary-ptrn-rest-obj-id.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-obj-id.case +// - src/dstr-binding/default/gen-func-decl-dflt.template +/*--- +description: Rest element containing an object binding pattern (generator function declaration (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.4.12 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorDeclaration : function * ( FormalParameters ) { GeneratorBody } + + [...] + 2. Let F be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ + +var callCount = 0; +function* f([...{ length }] = [1, 2, 3]) { + assert.sameValue(length, 3); + callCount = callCount + 1; +}; +f().next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/statements/generators/dstr-dflt-ary-ptrn-rest-obj-prop-id.js b/test/language/statements/generators/dstr-dflt-ary-ptrn-rest-obj-prop-id.js new file mode 100644 index 0000000000..b2b54f17f5 --- /dev/null +++ b/test/language/statements/generators/dstr-dflt-ary-ptrn-rest-obj-prop-id.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-ptrn-rest-obj-prop-id.case +// - src/dstr-binding/default/gen-func-decl-dflt.template +/*--- +description: Rest element containing an object binding pattern (generator function declaration (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.4.12 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorDeclaration : function * ( FormalParameters ) { GeneratorBody } + + [...] + 2. Let F be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.6 Runtime Semantics: IteratorBindingInitialization + + BindingRestElement : ... BindingPattern + + 1. Let A be ArrayCreate(0). + [...] + 3. Repeat + [...] + b. If iteratorRecord.[[done]] is true, then + i. Return the result of performing BindingInitialization of + BindingPattern with A and environment as the arguments. + [...] +---*/ + +var callCount = 0; +function* f([...{ 0: v, 1: w, 2: x, 3: y, length: z }] = [7, 8, 9]) { + assert.sameValue(v, 7); + assert.sameValue(w, 8); + assert.sameValue(x, 9); + assert.sameValue(y, undefined); + assert.sameValue(z, 3); + + assert.throws(ReferenceError, function() { + length; + }); + callCount = callCount + 1; +}; +f().next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/statements/generators/dstr-dflt-obj-init-null.js b/test/language/statements/generators/dstr-dflt-obj-init-null.js new file mode 100644 index 0000000000..f412768ba4 --- /dev/null +++ b/test/language/statements/generators/dstr-dflt-obj-init-null.js @@ -0,0 +1,52 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-null.case +// - src/dstr-binding/error/gen-func-decl-dflt.template +/*--- +description: Value specifed for object binding pattern must be object coercible (null) (generator function declaration (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.4.12 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorDeclaration : function * ( FormalParameters ) { GeneratorBody } + + [...] + 2. Let F be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + +function* f({} = null) {} + +assert.throws(TypeError, function() { + f(); +}); diff --git a/test/language/statements/generators/dstr-dflt-obj-init-undefined.js b/test/language/statements/generators/dstr-dflt-obj-init-undefined.js new file mode 100644 index 0000000000..f6468ebeb6 --- /dev/null +++ b/test/language/statements/generators/dstr-dflt-obj-init-undefined.js @@ -0,0 +1,52 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-init-undefined.case +// - src/dstr-binding/error/gen-func-decl-dflt.template +/*--- +description: Value specifed for object binding pattern must be object coercible (undefined) (generator function declaration (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.4.12 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorDeclaration : function * ( FormalParameters ) { GeneratorBody } + + [...] + 2. Let F be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ + +function* f({} = undefined) {} + +assert.throws(TypeError, function() { + f(); +}); diff --git a/test/language/statements/generators/dstr-dflt-obj-ptrn-empty.js b/test/language/statements/generators/dstr-dflt-obj-ptrn-empty.js new file mode 100644 index 0000000000..253010fdeb --- /dev/null +++ b/test/language/statements/generators/dstr-dflt-obj-ptrn-empty.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-empty.case +// - src/dstr-binding/default/gen-func-decl-dflt.template +/*--- +description: No property access occurs for an "empty" object binding pattern (generator function declaration (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.4.12 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorDeclaration : function * ( FormalParameters ) { GeneratorBody } + + [...] + 2. Let F be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + Runtime Semantics: BindingInitialization + + ObjectBindingPattern : { } + + 1. Return NormalCompletion(empty). +---*/ +var accessCount = 0; +var obj = Object.defineProperty({}, 'attr', { + get: function() { + accessCount += 1; + } +}); + +var callCount = 0; +function* f({} = obj) { + assert.sameValue(accessCount, 0); + callCount = callCount + 1; +}; +f().next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/statements/generators/dstr-dflt-obj-ptrn-id-get-value-err.js b/test/language/statements/generators/dstr-dflt-obj-ptrn-id-get-value-err.js new file mode 100644 index 0000000000..0d0e5ba2e9 --- /dev/null +++ b/test/language/statements/generators/dstr-dflt-obj-ptrn-id-get-value-err.js @@ -0,0 +1,59 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-get-value-err.case +// - src/dstr-binding/error/gen-func-decl-dflt.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (generator function declaration (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.4.12 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorDeclaration : function * ( FormalParameters ) { GeneratorBody } + + [...] + 2. Let F be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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(); + } +}); + +function* f({ poisoned } = poisonedProperty) {} + +assert.throws(Test262Error, function() { + f(); +}); diff --git a/test/language/statements/generators/dstr-dflt-obj-ptrn-id-init-fn-name-arrow.js b/test/language/statements/generators/dstr-dflt-obj-ptrn-id-init-fn-name-arrow.js new file mode 100644 index 0000000000..fcfb26a19f --- /dev/null +++ b/test/language/statements/generators/dstr-dflt-obj-ptrn-id-init-fn-name-arrow.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-arrow.case +// - src/dstr-binding/default/gen-func-decl-dflt.template +/*--- +description: SingleNameBinding assigns `name` to arrow functions (generator function declaration (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.4.12 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorDeclaration : function * ( FormalParameters ) { GeneratorBody } + + [...] + 2. Let F be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +function* f({ arrow = () => {} } = {}) { + assert.sameValue(arrow.name, 'arrow'); + callCount = callCount + 1; +}; +f().next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/statements/generators/dstr-dflt-obj-ptrn-id-init-fn-name-class.js b/test/language/statements/generators/dstr-dflt-obj-ptrn-id-init-fn-name-class.js new file mode 100644 index 0000000000..c2bbc7e66a --- /dev/null +++ b/test/language/statements/generators/dstr-dflt-obj-ptrn-id-init-fn-name-class.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-class.case +// - src/dstr-binding/default/gen-func-decl-dflt.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" classes (generator function declaration (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.4.12 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorDeclaration : function * ( FormalParameters ) { GeneratorBody } + + [...] + 2. Let F be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +function* f({ cls = class {}, xCls = class X {} } = {}) { + assert.sameValue(cls.name, 'cls'); + assert.notSameValue(xCls.name, 'xCls'); + callCount = callCount + 1; +}; +f().next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/statements/generators/dstr-dflt-obj-ptrn-id-init-fn-name-cover.js b/test/language/statements/generators/dstr-dflt-obj-ptrn-id-init-fn-name-cover.js new file mode 100644 index 0000000000..5543d43b2c --- /dev/null +++ b/test/language/statements/generators/dstr-dflt-obj-ptrn-id-init-fn-name-cover.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-cover.case +// - src/dstr-binding/default/gen-func-decl-dflt.template +/*--- +description: SingleNameBinding assigns `name` to "anonymous" functions "through" cover grammar (generator function declaration (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.4.12 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorDeclaration : function * ( FormalParameters ) { GeneratorBody } + + [...] + 2. Let F be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +function* f({ cover = (function () {}), xCover = (0, function() {}) } = {}) { + assert.sameValue(cover.name, 'cover'); + assert.notSameValue(xCover.name, 'xCover'); + callCount = callCount + 1; +}; +f().next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/statements/generators/dstr-dflt-obj-ptrn-id-init-fn-name-fn.js b/test/language/statements/generators/dstr-dflt-obj-ptrn-id-init-fn-name-fn.js new file mode 100644 index 0000000000..324a5c2276 --- /dev/null +++ b/test/language/statements/generators/dstr-dflt-obj-ptrn-id-init-fn-name-fn.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-fn.case +// - src/dstr-binding/default/gen-func-decl-dflt.template +/*--- +description: SingleNameBinding assigns name to "anonymous" functions (generator function declaration (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.4.12 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorDeclaration : function * ( FormalParameters ) { GeneratorBody } + + [...] + 2. Let F be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +function* f({ fn = function () {}, xFn = function x() {} } = {}) { + assert.sameValue(fn.name, 'fn'); + assert.notSameValue(xFn.name, 'xFn'); + callCount = callCount + 1; +}; +f().next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/statements/generators/dstr-dflt-obj-ptrn-id-init-fn-name-gen.js b/test/language/statements/generators/dstr-dflt-obj-ptrn-id-init-fn-name-gen.js new file mode 100644 index 0000000000..6d994dd2da --- /dev/null +++ b/test/language/statements/generators/dstr-dflt-obj-ptrn-id-init-fn-name-gen.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-fn-name-gen.case +// - src/dstr-binding/default/gen-func-decl-dflt.template +/*--- +description: SingleNameBinding assigns name to "anonymous" generator functions (generator function declaration (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.4.12 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorDeclaration : function * ( FormalParameters ) { GeneratorBody } + + [...] + 2. Let F be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + d. If IsAnonymousFunctionDefinition(Initializer) is true, then + i. Let hasNameProperty be HasOwnProperty(v, "name"). + ii. ReturnIfAbrupt(hasNameProperty). + iii. If hasNameProperty is false, perform SetFunctionName(v, + bindingId). +---*/ + +var callCount = 0; +function* f({ gen = function* () {}, xGen = function* x() {} } = {}) { + assert.sameValue(gen.name, 'gen'); + assert.notSameValue(xGen.name, 'xGen'); + callCount = callCount + 1; +}; +f().next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/statements/generators/dstr-dflt-obj-ptrn-id-init-skipped.js b/test/language/statements/generators/dstr-dflt-obj-ptrn-id-init-skipped.js new file mode 100644 index 0000000000..4096a4b59f --- /dev/null +++ b/test/language/statements/generators/dstr-dflt-obj-ptrn-id-init-skipped.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-skipped.case +// - src/dstr-binding/default/gen-func-decl-dflt.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (generator function declaration (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.4.12 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorDeclaration : function * ( FormalParameters ) { GeneratorBody } + + [...] + 2. Let F be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 6. If Initializer is present and v is undefined, then + [...] + [...] +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var callCount = 0; +function* f({ w = counter(), x = counter(), y = counter(), z = counter() } = { w: null, x: 0, y: false, z: '' }) { + assert.sameValue(w, null); + assert.sameValue(x, 0); + assert.sameValue(y, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + callCount = callCount + 1; +}; +f().next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/statements/generators/dstr-dflt-obj-ptrn-id-init-throws.js b/test/language/statements/generators/dstr-dflt-obj-ptrn-id-init-throws.js new file mode 100644 index 0000000000..d06548d200 --- /dev/null +++ b/test/language/statements/generators/dstr-dflt-obj-ptrn-id-init-throws.js @@ -0,0 +1,59 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-throws.case +// - src/dstr-binding/error/gen-func-decl-dflt.template +/*--- +description: Error thrown when evaluating the initializer (generator function declaration (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.4.12 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorDeclaration : function * ( FormalParameters ) { GeneratorBody } + + [...] + 2. Let F be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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(); +} + +function* f({ x = thrower() } = {}) {} + +assert.throws(Test262Error, function() { + f(); +}); diff --git a/test/language/statements/generators/dstr-dflt-obj-ptrn-id-init-unresolvable.js b/test/language/statements/generators/dstr-dflt-obj-ptrn-id-init-unresolvable.js new file mode 100644 index 0000000000..dddb47c93f --- /dev/null +++ b/test/language/statements/generators/dstr-dflt-obj-ptrn-id-init-unresolvable.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-init-unresolvable.case +// - src/dstr-binding/error/gen-func-decl-dflt.template +/*--- +description: Destructuring initializer is an unresolvable reference (generator function declaration (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.4.12 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorDeclaration : function * ( FormalParameters ) { GeneratorBody } + + [...] + 2. Let F be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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. +---*/ + +function* f({ x = unresolvableReference } = {}) {} + +assert.throws(ReferenceError, function() { + f(); +}); diff --git a/test/language/statements/generators/dstr-dflt-obj-ptrn-id-trailing-comma.js b/test/language/statements/generators/dstr-dflt-obj-ptrn-id-trailing-comma.js new file mode 100644 index 0000000000..7d4a83c1c6 --- /dev/null +++ b/test/language/statements/generators/dstr-dflt-obj-ptrn-id-trailing-comma.js @@ -0,0 +1,55 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-id-trailing-comma.case +// - src/dstr-binding/default/gen-func-decl-dflt.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (generator function declaration (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.4.12 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorDeclaration : function * ( FormalParameters ) { GeneratorBody } + + [...] + 2. Let F be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var callCount = 0; +function* f({ x, } = { x: 23 }) { + assert.sameValue(x, 23); + callCount = callCount + 1; +}; +f().next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/statements/generators/dstr-dflt-obj-ptrn-list-err.js b/test/language/statements/generators/dstr-dflt-obj-ptrn-list-err.js new file mode 100644 index 0000000000..0981d78f75 --- /dev/null +++ b/test/language/statements/generators/dstr-dflt-obj-ptrn-list-err.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-list-err.case +// - src/dstr-binding/error/gen-func-decl-dflt.template +/*--- +description: Binding property list evaluation is interrupted by an abrupt completion (generator function declaration (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.4.12 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorDeclaration : function * ( FormalParameters ) { GeneratorBody } + + [...] + 2. Let F be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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(); +} + +function* f({ a, b = thrower(), c = ++initCount } = {}) {} + +assert.throws(Test262Error, function() { + f(); +}); + +assert.sameValue(initCount, 0); diff --git a/test/language/statements/generators/dstr-dflt-obj-ptrn-prop-ary-init.js b/test/language/statements/generators/dstr-dflt-obj-ptrn-prop-ary-init.js new file mode 100644 index 0000000000..0674cd5ed2 --- /dev/null +++ b/test/language/statements/generators/dstr-dflt-obj-ptrn-prop-ary-init.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-init.case +// - src/dstr-binding/default/gen-func-decl-dflt.template +/*--- +description: Object binding pattern with "nested" array binding pattern using initializer (generator function declaration (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.4.12 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorDeclaration : function * ( FormalParameters ) { GeneratorBody } + + [...] + 2. Let F be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +function* f({ w: [x, y, z] = [4, 5, 6] } = {}) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; +}; +f().next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/statements/generators/dstr-dflt-obj-ptrn-prop-ary-trailing-comma.js b/test/language/statements/generators/dstr-dflt-obj-ptrn-prop-ary-trailing-comma.js new file mode 100644 index 0000000000..db8885f2cf --- /dev/null +++ b/test/language/statements/generators/dstr-dflt-obj-ptrn-prop-ary-trailing-comma.js @@ -0,0 +1,55 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-trailing-comma.case +// - src/dstr-binding/default/gen-func-decl-dflt.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (generator function declaration (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.4.12 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorDeclaration : function * ( FormalParameters ) { GeneratorBody } + + [...] + 2. Let F be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var callCount = 0; +function* f({ x: [y], } = { x: [45] }) { + assert.sameValue(y,45); + callCount = callCount + 1; +}; +f().next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/statements/generators/dstr-dflt-obj-ptrn-prop-ary-value-null.js b/test/language/statements/generators/dstr-dflt-obj-ptrn-prop-ary-value-null.js new file mode 100644 index 0000000000..a767e22aae --- /dev/null +++ b/test/language/statements/generators/dstr-dflt-obj-ptrn-prop-ary-value-null.js @@ -0,0 +1,54 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary-value-null.case +// - src/dstr-binding/error/gen-func-decl-dflt.template +/*--- +description: Object binding pattern with "nested" array binding pattern taking the `null` value (generator function declaration (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.4.12 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorDeclaration : function * ( FormalParameters ) { GeneratorBody } + + [...] + 2. Let F be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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. +---*/ + +function* f({ w: [x, y, z] = [4, 5, 6] } = { w: null }) {} + +assert.throws(TypeError, function() { + f(); +}); diff --git a/test/language/statements/generators/dstr-dflt-obj-ptrn-prop-ary.js b/test/language/statements/generators/dstr-dflt-obj-ptrn-prop-ary.js new file mode 100644 index 0000000000..41971dd081 --- /dev/null +++ b/test/language/statements/generators/dstr-dflt-obj-ptrn-prop-ary.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-ary.case +// - src/dstr-binding/default/gen-func-decl-dflt.template +/*--- +description: Object binding pattern with "nested" array binding pattern not using initializer (generator function declaration (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.4.12 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorDeclaration : function * ( FormalParameters ) { GeneratorBody } + + [...] + 2. Let F be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +function* f({ w: [x, y, z] = [4, 5, 6] } = { w: [7, undefined, ] }) { + assert.sameValue(x, 7); + assert.sameValue(y, undefined); + assert.sameValue(z, undefined); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; +}; +f().next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/statements/generators/dstr-dflt-obj-ptrn-prop-eval-err.js b/test/language/statements/generators/dstr-dflt-obj-ptrn-prop-eval-err.js new file mode 100644 index 0000000000..4d9e8f4a2d --- /dev/null +++ b/test/language/statements/generators/dstr-dflt-obj-ptrn-prop-eval-err.js @@ -0,0 +1,56 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-eval-err.case +// - src/dstr-binding/error/gen-func-decl-dflt.template +/*--- +description: Evaluation of property name returns an abrupt completion (generator function declaration (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.4.12 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorDeclaration : function * ( FormalParameters ) { GeneratorBody } + + [...] + 2. Let F be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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(); +} + +function* f({ [thrower()]: x } = {}) {} + +assert.throws(Test262Error, function() { + f(); +}); diff --git a/test/language/statements/generators/dstr-dflt-obj-ptrn-prop-id-get-value-err.js b/test/language/statements/generators/dstr-dflt-obj-ptrn-prop-id-get-value-err.js new file mode 100644 index 0000000000..62b3f35e01 --- /dev/null +++ b/test/language/statements/generators/dstr-dflt-obj-ptrn-prop-id-get-value-err.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-get-value-err.case +// - src/dstr-binding/error/gen-func-decl-dflt.template +/*--- +description: Error thrown when accessing the corresponding property of the value object (generator function declaration (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.4.12 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorDeclaration : function * ( FormalParameters ) { GeneratorBody } + + [...] + 2. Let F be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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(); + } +}); + +function* f({ poisoned: x = ++initEvalCount } = poisonedProperty) {} + +assert.throws(Test262Error, function() { + f(); +}); + +assert.sameValue(initEvalCount, 0); diff --git a/test/language/statements/generators/dstr-dflt-obj-ptrn-prop-id-init-skipped.js b/test/language/statements/generators/dstr-dflt-obj-ptrn-prop-id-init-skipped.js new file mode 100644 index 0000000000..a468e20520 --- /dev/null +++ b/test/language/statements/generators/dstr-dflt-obj-ptrn-prop-id-init-skipped.js @@ -0,0 +1,77 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-skipped.case +// - src/dstr-binding/default/gen-func-decl-dflt.template +/*--- +description: Destructuring initializer is not evaluated when value is not `undefined` (generator function declaration (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.4.12 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorDeclaration : function * ( FormalParameters ) { GeneratorBody } + + [...] + 2. Let F be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + BindingElement : BindingPattern Initializeropt + + [...] + 3. If Initializer is present and v is undefined, then + [...] +---*/ +var initCount = 0; +function counter() { + initCount += 1; +} + +var callCount = 0; +function* f({ s: t = counter(), u: v = counter(), w: x = counter(), y: z = counter() } = { s: null, u: 0, w: false, y: '' }) { + assert.sameValue(t, null); + assert.sameValue(v, 0); + assert.sameValue(x, false); + assert.sameValue(z, ''); + assert.sameValue(initCount, 0); + + assert.throws(ReferenceError, function() { + s; + }); + assert.throws(ReferenceError, function() { + u; + }); + assert.throws(ReferenceError, function() { + w; + }); + assert.throws(ReferenceError, function() { + y; + }); + callCount = callCount + 1; +}; +f().next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/statements/generators/dstr-dflt-obj-ptrn-prop-id-init-throws.js b/test/language/statements/generators/dstr-dflt-obj-ptrn-prop-id-init-throws.js new file mode 100644 index 0000000000..263fb6f1d4 --- /dev/null +++ b/test/language/statements/generators/dstr-dflt-obj-ptrn-prop-id-init-throws.js @@ -0,0 +1,59 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-throws.case +// - src/dstr-binding/error/gen-func-decl-dflt.template +/*--- +description: Error thrown when evaluating the initializer (generator function declaration (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.4.12 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorDeclaration : function * ( FormalParameters ) { GeneratorBody } + + [...] + 2. Let F be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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(); +} + +function* f({ x: y = thrower() } = {}) {} + +assert.throws(Test262Error, function() { + f(); +}); diff --git a/test/language/statements/generators/dstr-dflt-obj-ptrn-prop-id-init-unresolvable.js b/test/language/statements/generators/dstr-dflt-obj-ptrn-prop-id-init-unresolvable.js new file mode 100644 index 0000000000..45ba2c738d --- /dev/null +++ b/test/language/statements/generators/dstr-dflt-obj-ptrn-prop-id-init-unresolvable.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init-unresolvable.case +// - src/dstr-binding/error/gen-func-decl-dflt.template +/*--- +description: Destructuring initializer is an unresolvable reference (generator function declaration (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.4.12 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorDeclaration : function * ( FormalParameters ) { GeneratorBody } + + [...] + 2. Let F be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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. +---*/ + +function* f({ x: y = unresolvableReference } = {}) {} + +assert.throws(ReferenceError, function() { + f(); +}); diff --git a/test/language/statements/generators/dstr-dflt-obj-ptrn-prop-id-init.js b/test/language/statements/generators/dstr-dflt-obj-ptrn-prop-id-init.js new file mode 100644 index 0000000000..ff051f9789 --- /dev/null +++ b/test/language/statements/generators/dstr-dflt-obj-ptrn-prop-id-init.js @@ -0,0 +1,58 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-init.case +// - src/dstr-binding/default/gen-func-decl-dflt.template +/*--- +description: Binding as specified via property name, identifier, and initializer (generator function declaration (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.4.12 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorDeclaration : function * ( FormalParameters ) { GeneratorBody } + + [...] + 2. Let F be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +function* f({ x: y = 33 } = { }) { + assert.sameValue(y, 33); + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; +}; +f().next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/statements/generators/dstr-dflt-obj-ptrn-prop-id-trailing-comma.js b/test/language/statements/generators/dstr-dflt-obj-ptrn-prop-id-trailing-comma.js new file mode 100644 index 0000000000..3884b210f8 --- /dev/null +++ b/test/language/statements/generators/dstr-dflt-obj-ptrn-prop-id-trailing-comma.js @@ -0,0 +1,59 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id-trailing-comma.case +// - src/dstr-binding/default/gen-func-decl-dflt.template +/*--- +description: Trailing comma is allowed following BindingPropertyList (generator function declaration (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.4.12 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorDeclaration : function * ( FormalParameters ) { GeneratorBody } + + [...] + 2. Let F be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3 Destructuring Binding Patterns + + ObjectBindingPattern[Yield] : + { } + { BindingPropertyList[?Yield] } + { BindingPropertyList[?Yield] , } +---*/ + +var callCount = 0; +function* f({ x: y, } = { x: 23 }) { + assert.sameValue(y, 23); + + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; +}; +f().next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/statements/generators/dstr-dflt-obj-ptrn-prop-id.js b/test/language/statements/generators/dstr-dflt-obj-ptrn-prop-id.js new file mode 100644 index 0000000000..91d177e31d --- /dev/null +++ b/test/language/statements/generators/dstr-dflt-obj-ptrn-prop-id.js @@ -0,0 +1,58 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-id.case +// - src/dstr-binding/default/gen-func-decl-dflt.template +/*--- +description: Binding as specified via property name and identifier (generator function declaration (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.4.12 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorDeclaration : function * ( FormalParameters ) { GeneratorBody } + + [...] + 2. Let F be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + SingleNameBinding : BindingIdentifier Initializeropt + + [...] + 8. Return InitializeReferencedBinding(lhs, v). +---*/ + +var callCount = 0; +function* f({ x: y } = { x: 23 }) { + assert.sameValue(y, 23); + assert.throws(ReferenceError, function() { + x; + }); + callCount = callCount + 1; +}; +f().next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/statements/generators/dstr-dflt-obj-ptrn-prop-obj-init.js b/test/language/statements/generators/dstr-dflt-obj-ptrn-prop-obj-init.js new file mode 100644 index 0000000000..a98ab8ea25 --- /dev/null +++ b/test/language/statements/generators/dstr-dflt-obj-ptrn-prop-obj-init.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-init.case +// - src/dstr-binding/default/gen-func-decl-dflt.template +/*--- +description: Object binding pattern with "nested" object binding pattern using initializer (generator function declaration (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.4.12 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorDeclaration : function * ( FormalParameters ) { GeneratorBody } + + [...] + 2. Let F be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + a. Let defaultValue be the result of evaluating Initializer. + b. Let v be GetValue(defaultValue). + c. ReturnIfAbrupt(v). + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +function* f({ w: { x, y, z } = { x: 4, y: 5, z: 6 } } = { w: undefined }) { + assert.sameValue(x, 4); + assert.sameValue(y, 5); + assert.sameValue(z, 6); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; +}; +f().next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/statements/generators/dstr-dflt-obj-ptrn-prop-obj-value-null.js b/test/language/statements/generators/dstr-dflt-obj-ptrn-prop-obj-value-null.js new file mode 100644 index 0000000000..07270d3221 --- /dev/null +++ b/test/language/statements/generators/dstr-dflt-obj-ptrn-prop-obj-value-null.js @@ -0,0 +1,54 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-null.case +// - src/dstr-binding/error/gen-func-decl-dflt.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (generator function declaration (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.4.12 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorDeclaration : function * ( FormalParameters ) { GeneratorBody } + + [...] + 2. Let F be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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. +---*/ + +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/generators/dstr-dflt-obj-ptrn-prop-obj-value-undef.js b/test/language/statements/generators/dstr-dflt-obj-ptrn-prop-obj-value-undef.js new file mode 100644 index 0000000000..29d8c6980a --- /dev/null +++ b/test/language/statements/generators/dstr-dflt-obj-ptrn-prop-obj-value-undef.js @@ -0,0 +1,54 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj-value-undef.case +// - src/dstr-binding/error/gen-func-decl-dflt.template +/*--- +description: Object binding pattern with "nested" object binding pattern taking the `null` value (generator function declaration (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.4.12 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorDeclaration : function * ( FormalParameters ) { GeneratorBody } + + [...] + 2. Let F be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 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. +---*/ + +function* f({ w: { x, y, z } = undefined } = { }) {} + +assert.throws(TypeError, function() { + f(); +}); diff --git a/test/language/statements/generators/dstr-dflt-obj-ptrn-prop-obj.js b/test/language/statements/generators/dstr-dflt-obj-ptrn-prop-obj.js new file mode 100644 index 0000000000..965520888f --- /dev/null +++ b/test/language/statements/generators/dstr-dflt-obj-ptrn-prop-obj.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/obj-ptrn-prop-obj.case +// - src/dstr-binding/default/gen-func-decl-dflt.template +/*--- +description: Object binding pattern with "nested" object binding pattern not using initializer (generator function declaration (default parameter)) +esid: sec-generator-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.4.12 +features: [destructuring-binding, default-parameters] +flags: [generated] +info: | + GeneratorDeclaration : function * ( FormalParameters ) { GeneratorBody } + + [...] + 2. Let F be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 13.3.3.7 Runtime Semantics: KeyedBindingInitialization + + [...] + 3. If Initializer is present and v is undefined, then + [...] + 4. Return the result of performing BindingInitialization for BindingPattern + passing v and environment as arguments. +---*/ + +var callCount = 0; +function* f({ w: { x, y, z } = { x: 4, y: 5, z: 6 } } = { w: { x: undefined, z: 7 } }) { + assert.sameValue(x, undefined); + assert.sameValue(y, undefined); + assert.sameValue(z, 7); + + assert.throws(ReferenceError, function() { + w; + }); + callCount = callCount + 1; +}; +f().next(); +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); -- GitLab From 71f9559f11a5f602cc22884ed1ddd48b826ba76c Mon Sep 17 00:00:00 2001 From: Mike Pennisi <mike@mikepennisi.com> Date: Thu, 2 Jun 2016 14:30:48 -0400 Subject: [PATCH 3/8] Add tests for default parameters --- src/dflt-params/abrupt.case | 21 ++++++ src/dflt-params/arg-val-not-undefined.case | 47 ++++++++++++ src/dflt-params/arg-val-undefined.case | 29 +++++++ .../default/arrow-function.template | 48 ++++++++++++ .../default/cls-decl-gen-meth-static.template | 72 ++++++++++++++++++ .../default/cls-decl-gen-meth.template | 72 ++++++++++++++++++ .../default/cls-decl-meth-static.template | 70 +++++++++++++++++ .../default/cls-decl-meth.template | 70 +++++++++++++++++ .../default/cls-expr-gen-meth-static.template | 74 ++++++++++++++++++ .../default/cls-expr-gen-meth.template | 74 ++++++++++++++++++ .../default/cls-expr-meth-static.template | 71 ++++++++++++++++++ .../default/cls-expr-meth.template | 71 ++++++++++++++++++ src/dflt-params/default/func-decl.template | 50 +++++++++++++ src/dflt-params/default/func-expr.template | 50 +++++++++++++ .../default/gen-func-decl.template | 49 ++++++++++++ .../default/gen-func-expr.template | 50 +++++++++++++ src/dflt-params/default/gen-meth.template | 56 ++++++++++++++ src/dflt-params/default/meth.template | 53 +++++++++++++ src/dflt-params/duplicates.case | 25 +++++++ src/dflt-params/error/arrow-function.template | 50 +++++++++++++ .../error/cls-decl-gen-meth-static.template | 74 ++++++++++++++++++ .../error/cls-decl-gen-meth.template | 73 ++++++++++++++++++ .../error/cls-decl-meth-static.template | 71 ++++++++++++++++++ src/dflt-params/error/cls-decl-meth.template | 71 ++++++++++++++++++ .../error/cls-expr-gen-meth-static.template | 75 +++++++++++++++++++ .../error/cls-expr-gen-meth.template | 75 +++++++++++++++++++ .../error/cls-expr-meth-static.template | 72 ++++++++++++++++++ src/dflt-params/error/cls-expr-meth.template | 72 ++++++++++++++++++ src/dflt-params/error/func-decl.template | 50 +++++++++++++ src/dflt-params/error/func-expr.template | 51 +++++++++++++ src/dflt-params/error/gen-func-decl.template | 51 +++++++++++++ src/dflt-params/error/gen-func-expr.template | 51 +++++++++++++ src/dflt-params/error/gen-meth.template | 57 ++++++++++++++ src/dflt-params/error/meth.template | 54 +++++++++++++ src/dflt-params/ref-later.case | 23 ++++++ src/dflt-params/ref-prior.case | 27 +++++++ src/dflt-params/ref-self.case | 23 ++++++ src/dflt-params/rest.case | 27 +++++++ .../syntax/arrow-function.template | 42 +++++++++++ .../syntax/cls-decl-gen-meth-static.template | 66 ++++++++++++++++ .../syntax/cls-decl-gen-meth.template | 66 ++++++++++++++++ .../syntax/cls-decl-meth-static.template | 64 ++++++++++++++++ src/dflt-params/syntax/cls-decl-meth.template | 64 ++++++++++++++++ .../syntax/cls-expr-gen-meth-static.template | 68 +++++++++++++++++ .../syntax/cls-expr-gen-meth.template | 68 +++++++++++++++++ .../syntax/cls-expr-meth-static.template | 65 ++++++++++++++++ src/dflt-params/syntax/cls-expr-meth.template | 65 ++++++++++++++++ src/dflt-params/syntax/func-decl.template | 44 +++++++++++ src/dflt-params/syntax/func-expr.template | 43 +++++++++++ src/dflt-params/syntax/gen-func-decl.template | 43 +++++++++++ src/dflt-params/syntax/gen-func-expr.template | 43 +++++++++++ src/dflt-params/syntax/gen-meth.template | 50 +++++++++++++ src/dflt-params/syntax/meth.template | 47 ++++++++++++ 53 files changed, 2937 insertions(+) create mode 100644 src/dflt-params/abrupt.case create mode 100644 src/dflt-params/arg-val-not-undefined.case create mode 100644 src/dflt-params/arg-val-undefined.case create mode 100644 src/dflt-params/default/arrow-function.template create mode 100644 src/dflt-params/default/cls-decl-gen-meth-static.template create mode 100644 src/dflt-params/default/cls-decl-gen-meth.template create mode 100644 src/dflt-params/default/cls-decl-meth-static.template create mode 100644 src/dflt-params/default/cls-decl-meth.template create mode 100644 src/dflt-params/default/cls-expr-gen-meth-static.template create mode 100644 src/dflt-params/default/cls-expr-gen-meth.template create mode 100644 src/dflt-params/default/cls-expr-meth-static.template create mode 100644 src/dflt-params/default/cls-expr-meth.template create mode 100644 src/dflt-params/default/func-decl.template create mode 100644 src/dflt-params/default/func-expr.template create mode 100644 src/dflt-params/default/gen-func-decl.template create mode 100644 src/dflt-params/default/gen-func-expr.template create mode 100644 src/dflt-params/default/gen-meth.template create mode 100644 src/dflt-params/default/meth.template create mode 100644 src/dflt-params/duplicates.case create mode 100644 src/dflt-params/error/arrow-function.template create mode 100644 src/dflt-params/error/cls-decl-gen-meth-static.template create mode 100644 src/dflt-params/error/cls-decl-gen-meth.template create mode 100644 src/dflt-params/error/cls-decl-meth-static.template create mode 100644 src/dflt-params/error/cls-decl-meth.template create mode 100644 src/dflt-params/error/cls-expr-gen-meth-static.template create mode 100644 src/dflt-params/error/cls-expr-gen-meth.template create mode 100644 src/dflt-params/error/cls-expr-meth-static.template create mode 100644 src/dflt-params/error/cls-expr-meth.template create mode 100644 src/dflt-params/error/func-decl.template create mode 100644 src/dflt-params/error/func-expr.template create mode 100644 src/dflt-params/error/gen-func-decl.template create mode 100644 src/dflt-params/error/gen-func-expr.template create mode 100644 src/dflt-params/error/gen-meth.template create mode 100644 src/dflt-params/error/meth.template create mode 100644 src/dflt-params/ref-later.case create mode 100644 src/dflt-params/ref-prior.case create mode 100644 src/dflt-params/ref-self.case create mode 100644 src/dflt-params/rest.case create mode 100644 src/dflt-params/syntax/arrow-function.template create mode 100644 src/dflt-params/syntax/cls-decl-gen-meth-static.template create mode 100644 src/dflt-params/syntax/cls-decl-gen-meth.template create mode 100644 src/dflt-params/syntax/cls-decl-meth-static.template create mode 100644 src/dflt-params/syntax/cls-decl-meth.template create mode 100644 src/dflt-params/syntax/cls-expr-gen-meth-static.template create mode 100644 src/dflt-params/syntax/cls-expr-gen-meth.template create mode 100644 src/dflt-params/syntax/cls-expr-meth-static.template create mode 100644 src/dflt-params/syntax/cls-expr-meth.template create mode 100644 src/dflt-params/syntax/func-decl.template create mode 100644 src/dflt-params/syntax/func-expr.template create mode 100644 src/dflt-params/syntax/gen-func-decl.template create mode 100644 src/dflt-params/syntax/gen-func-expr.template create mode 100644 src/dflt-params/syntax/gen-meth.template create mode 100644 src/dflt-params/syntax/meth.template diff --git a/src/dflt-params/abrupt.case b/src/dflt-params/abrupt.case new file mode 100644 index 0000000000..7c52350567 --- /dev/null +++ b/src/dflt-params/abrupt.case @@ -0,0 +1,21 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: Abrupt completion returned by evaluation of initializer +template: error +info: | + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + 1. Let status be the result of performing IteratorBindingInitialization for + FormalsList using iteratorRecord and environment as the arguments. + 2. ReturnIfAbrupt(status). + 3. Return the result of performing IteratorBindingInitialization for + FormalParameter using iteratorRecord and environment as the arguments. +---*/ + +//- params +_ = (function() { throw new Test262Error(); }()) +//- error +Test262Error diff --git a/src/dflt-params/arg-val-not-undefined.case b/src/dflt-params/arg-val-not-undefined.case new file mode 100644 index 0000000000..20082b1ae9 --- /dev/null +++ b/src/dflt-params/arg-val-not-undefined.case @@ -0,0 +1,47 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: Use of intializer when argument value is not `undefined` +template: default +info: | + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + [...] + 23. Let iteratorRecord be Record {[[Iterator]]: + CreateListIterator(argumentsList), [[Done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + a. Perform ? IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +//- setup +var obj = {}; +var falseCount = 0; +var stringCount = 0; +var nanCount = 0; +var zeroCount = 0; +var nullCount = 0; +var objCount = 0; +//- params +aFalse = falseCount +=1, aString = stringCount += 1, aNaN = nanCount += 1, a0 = zeroCount += 1, aNull = nullCount += 1, aObj = objCount +=1 +//- args +false, '', NaN, 0, null, obj +//- body +assert.sameValue(aFalse, false); +assert.sameValue(aString, ''); +assert.sameValue(aNaN, NaN); +assert.sameValue(a0, 0); +assert.sameValue(aNull, null); +assert.sameValue(aObj, obj); +//- teardown +assert.sameValue(falseCount, 0, 'initializer not evaluated: false'); +assert.sameValue(stringCount, 0, 'initializer not evaluated: string'); +assert.sameValue(nanCount, 0, 'initializer not evaluated: NaN'); +assert.sameValue(zeroCount, 0, 'initializer not evaluated: 0'); +assert.sameValue(nullCount, 0, 'initializer not evaluated: null'); +assert.sameValue(objCount, 0, 'initializer not evaluated: object'); diff --git a/src/dflt-params/arg-val-undefined.case b/src/dflt-params/arg-val-undefined.case new file mode 100644 index 0000000000..3d4797b26e --- /dev/null +++ b/src/dflt-params/arg-val-undefined.case @@ -0,0 +1,29 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: Use of intializer when argument value is `undefined` +template: default +info: | + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + [...] + 23. Let iteratorRecord be Record {[[Iterator]]: + CreateListIterator(argumentsList), [[Done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + a. Perform ? IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +//- params +fromLiteral = 23, fromExpr = 45, fromHole = 99 +//- args +undefined, void 0 +//- body +assert.sameValue(fromLiteral, 23); +assert.sameValue(fromExpr, 45); +assert.sameValue(fromHole, 99); diff --git a/src/dflt-params/default/arrow-function.template b/src/dflt-params/default/arrow-function.template new file mode 100644 index 0000000000..d6b94de60a --- /dev/null +++ b/src/dflt-params/default/arrow-function.template @@ -0,0 +1,48 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/expressions/arrow-function/params-dflt- +name: arrow function expression +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +es6id: 14.2.16 +features: [default-parameters] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +var callCount = 0; +var f; +f = (/*{ params }*/) => { + /*{ body }*/ + callCount = callCount + 1; +}; + +f(/*{ args }*/); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); diff --git a/src/dflt-params/default/cls-decl-gen-meth-static.template b/src/dflt-params/default/cls-decl-gen-meth-static.template new file mode 100644 index 0000000000..a617fc6d6f --- /dev/null +++ b/src/dflt-params/default/cls-decl-gen-meth-static.template @@ -0,0 +1,72 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/statements/class/params-dflt-gen-meth-static- +name: static class expression generator method +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +var callCount = 0; +class C { + static *method(/*{ params }*/) { + /*{ body }*/ + callCount = callCount + 1; + } +} + +C.method(/*{ args }*/).next(); + +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/src/dflt-params/default/cls-decl-gen-meth.template b/src/dflt-params/default/cls-decl-gen-meth.template new file mode 100644 index 0000000000..ba80c6ecd2 --- /dev/null +++ b/src/dflt-params/default/cls-decl-gen-meth.template @@ -0,0 +1,72 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/statements/class/params-dflt-gen-meth- +name: class expression method +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +var callCount = 0; +class C { + *method(/*{ params }*/) { + /*{ body }*/ + callCount = callCount + 1; + } +} + +C.prototype.method(/*{ args }*/).next(); + +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/src/dflt-params/default/cls-decl-meth-static.template b/src/dflt-params/default/cls-decl-meth-static.template new file mode 100644 index 0000000000..637db4ac8d --- /dev/null +++ b/src/dflt-params/default/cls-decl-meth-static.template @@ -0,0 +1,70 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/statements/class/params-dflt-meth-static- +name: static class expression method +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +var callCount = 0; +class C { + static method(/*{ params }*/) { + /*{ body }*/ + callCount = callCount + 1; + } +} + +C.method(/*{ args }*/); + +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/src/dflt-params/default/cls-decl-meth.template b/src/dflt-params/default/cls-decl-meth.template new file mode 100644 index 0000000000..9c5eabaa95 --- /dev/null +++ b/src/dflt-params/default/cls-decl-meth.template @@ -0,0 +1,70 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/statements/class/params-dflt-meth- +name: class expression method +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +var callCount = 0; +class C { + method(/*{ params }*/) { + /*{ body }*/ + callCount = callCount + 1; + } +} + +C.prototype.method(/*{ args }*/); + +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/src/dflt-params/default/cls-expr-gen-meth-static.template b/src/dflt-params/default/cls-expr-gen-meth-static.template new file mode 100644 index 0000000000..1964116f89 --- /dev/null +++ b/src/dflt-params/default/cls-expr-gen-meth-static.template @@ -0,0 +1,74 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/expressions/class/params-dflt-gen-meth-static- +name: static class expression generator method +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +var callCount = 0; +var C = class { + static *method(/*{ params }*/) { + /*{ body }*/ + callCount = callCount + 1; + } +}; + +C.method(/*{ args }*/).next(); + +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/src/dflt-params/default/cls-expr-gen-meth.template b/src/dflt-params/default/cls-expr-gen-meth.template new file mode 100644 index 0000000000..a02781a19d --- /dev/null +++ b/src/dflt-params/default/cls-expr-gen-meth.template @@ -0,0 +1,74 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/expressions/class/params-dflt-gen-meth- +name: class expression method +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [default-parameters] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +var callCount = 0; +var C = class { + *method(/*{ params }*/) { + /*{ body }*/ + callCount = callCount + 1; + } +}; + +C.prototype.method(/*{ args }*/).next(); + +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/src/dflt-params/default/cls-expr-meth-static.template b/src/dflt-params/default/cls-expr-meth-static.template new file mode 100644 index 0000000000..1906dc9d1f --- /dev/null +++ b/src/dflt-params/default/cls-expr-meth-static.template @@ -0,0 +1,71 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/expressions/class/params-dflt-meth-static- +name: static class expression method +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +var callCount = 0; +var C = class { + static method(/*{ params }*/) { + /*{ body }*/ + callCount = callCount + 1; + } +}; + +C.method(/*{ args }*/); + +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/src/dflt-params/default/cls-expr-meth.template b/src/dflt-params/default/cls-expr-meth.template new file mode 100644 index 0000000000..0220880d47 --- /dev/null +++ b/src/dflt-params/default/cls-expr-meth.template @@ -0,0 +1,71 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/expressions/class/params-dflt-meth- +name: class expression method +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [default-parameters] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +var callCount = 0; +var C = class { + method(/*{ params }*/) { + /*{ body }*/ + callCount = callCount + 1; + } +}; + +C.prototype.method(/*{ args }*/); + +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/src/dflt-params/default/func-decl.template b/src/dflt-params/default/func-decl.template new file mode 100644 index 0000000000..d6cdb614b6 --- /dev/null +++ b/src/dflt-params/default/func-decl.template @@ -0,0 +1,50 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/statements/function/params-dflt- +name: function declaration +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.1.19 +features: [default-parameters] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +var callCount = 0; +function f(/*{ params }*/) { + /*{ body }*/ + callCount = callCount + 1; +} + +f(/*{ args }*/); + +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/src/dflt-params/default/func-expr.template b/src/dflt-params/default/func-expr.template new file mode 100644 index 0000000000..75cbfecf45 --- /dev/null +++ b/src/dflt-params/default/func-expr.template @@ -0,0 +1,50 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/expressions/function/params-dflt- +name: function expression +esid: sec-function-definitions-runtime-semantics-evaluation +es6id: 14.1.20 +features: [default-parameters] +info: | + FunctionExpression : function ( FormalParameters ) { FunctionBody } + + [...] + 3. Let closure be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +var callCount = 0; +var f; +f = function(/*{ params }*/) { + /*{ body }*/ + callCount = callCount + 1; +}; + +f(/*{ args }*/); + +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/src/dflt-params/default/gen-func-decl.template b/src/dflt-params/default/gen-func-decl.template new file mode 100644 index 0000000000..c3d38a3761 --- /dev/null +++ b/src/dflt-params/default/gen-func-decl.template @@ -0,0 +1,49 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/statements/generators/params-dflt- +name: generator function declaration +esid: sec-generator-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.4.12 +features: [default-parameters] +info: | + GeneratorDeclaration : function * ( FormalParameters ) { GeneratorBody } + + [...] + 2. Let F be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +var callCount = 0; +function* f(/*{ params }*/) { + /*{ body }*/ + callCount = callCount + 1; +} + +f(/*{ args }*/).next(); + +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/src/dflt-params/default/gen-func-expr.template b/src/dflt-params/default/gen-func-expr.template new file mode 100644 index 0000000000..c95d116be6 --- /dev/null +++ b/src/dflt-params/default/gen-func-expr.template @@ -0,0 +1,50 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/expressions/generators/params-dflt- +name: generator function expression +esid: sec-generator-function-definitions-runtime-semantics-evaluation +es6id: 14.4.14 +features: [default-parameters] +info: | + GeneratorExpression : function * ( FormalParameters ) { GeneratorBody } + + [...] + 3. Let closure be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +var callCount = 0; +var f; +f = function*(/*{ params }*/) { + /*{ body }*/ + callCount = callCount + 1; +}; + +f(/*{ args }*/).next(); + +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/src/dflt-params/default/gen-meth.template b/src/dflt-params/default/gen-meth.template new file mode 100644 index 0000000000..a302e61601 --- /dev/null +++ b/src/dflt-params/default/gen-meth.template @@ -0,0 +1,56 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/expressions/object/method-definition/params-dflt-gen-meth- +name: generator method +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +es6id: 14.4.13 +features: [default-parameters] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +var callCount = 0; +var obj = { + *method(/*{ params }*/) { + /*{ body }*/ + callCount = callCount + 1; + } +}; + +obj.method(/*{ args }*/).next(); + +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); diff --git a/src/dflt-params/default/meth.template b/src/dflt-params/default/meth.template new file mode 100644 index 0000000000..48f25bdfd0 --- /dev/null +++ b/src/dflt-params/default/meth.template @@ -0,0 +1,53 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/expressions/object/method-definition/params-dflt-meth- +name: method +esid: sec-runtime-semantics-definemethod +es6id: 14.3.8 +features: [default-parameters] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +var callCount = 0; +var obj = { + method(/*{ params }*/) { + /*{ body }*/ + callCount = callCount + 1; + } +}; + +obj.method(/*{ args }*/); + +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/src/dflt-params/duplicates.case b/src/dflt-params/duplicates.case new file mode 100644 index 0000000000..e2a6e424d0 --- /dev/null +++ b/src/dflt-params/duplicates.case @@ -0,0 +1,25 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: > + It is a Syntax Error if BoundNames of FormalParameters contains any duplicate + elements. +template: syntax +negative: SyntaxError +info: | + 14.1.2 Static Semantics: Early Errors + + StrictFormalParameters : FormalParameters + + - It is a Syntax Error if BoundNames of FormalParameters contains any + duplicate elements. + + FormalParameters : FormalParameterList + + - It is a Syntax Error if IsSimpleParameterList of FormalParameterList is + false and BoundNames of FormalParameterList contains any duplicate + elements. +---*/ + +//- params +x = 0, x diff --git a/src/dflt-params/error/arrow-function.template b/src/dflt-params/error/arrow-function.template new file mode 100644 index 0000000000..80e76e09b3 --- /dev/null +++ b/src/dflt-params/error/arrow-function.template @@ -0,0 +1,50 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/expressions/arrow-function/params-dflt- +name: arrow function expression +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +es6id: 14.2.16 +features: [default-parameters] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +var callCount = 0; +var f; +f = (/*{ params }*/) => { + /*{ body }*/ + callCount = callCount + 1; +}; + +assert.throws(/*{ error }*/, function() { + f(/*{ args }*/); +}); +assert.sameValue(callCount, 0, 'arrow function body not evaluated'); diff --git a/src/dflt-params/error/cls-decl-gen-meth-static.template b/src/dflt-params/error/cls-decl-gen-meth-static.template new file mode 100644 index 0000000000..91132c062e --- /dev/null +++ b/src/dflt-params/error/cls-decl-gen-meth-static.template @@ -0,0 +1,74 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/statements/class/params-dflt-gen-meth-static- +name: static class expression generator method +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +var callCount = 0; +class C { + static *method(/*{ params }*/) { + /*{ body }*/ + callCount = callCount + 1; + } +} + +assert.throws(/*{ error }*/, function() { + C.method(/*{ args }*/); +}); + +assert.sameValue(callCount, 0, 'method body not evaluated'); diff --git a/src/dflt-params/error/cls-decl-gen-meth.template b/src/dflt-params/error/cls-decl-gen-meth.template new file mode 100644 index 0000000000..a27716832b --- /dev/null +++ b/src/dflt-params/error/cls-decl-gen-meth.template @@ -0,0 +1,73 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/statements/class/params-dflt-gen-meth- +name: class expression method +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +var callCount = 0; +class C { + *method(/*{ params }*/) { + /*{ body }*/ + callCount = callCount + 1; + } +} + +assert.throws(/*{ error }*/, function() { + C.prototype.method(/*{ args }*/); +}); +assert.sameValue(callCount, 0, 'method body not evaluated'); diff --git a/src/dflt-params/error/cls-decl-meth-static.template b/src/dflt-params/error/cls-decl-meth-static.template new file mode 100644 index 0000000000..204380ef36 --- /dev/null +++ b/src/dflt-params/error/cls-decl-meth-static.template @@ -0,0 +1,71 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/statements/class/params-dflt-meth-static- +name: static class expression method +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +var callCount = 0; +class C { + static method(/*{ params }*/) { + /*{ body }*/ + callCount = callCount + 1; + } +} + +assert.throws(/*{ error }*/, function() { + C.method(/*{ args }*/); +}); +assert.sameValue(callCount, 0, 'method body not evaluated'); diff --git a/src/dflt-params/error/cls-decl-meth.template b/src/dflt-params/error/cls-decl-meth.template new file mode 100644 index 0000000000..3242269590 --- /dev/null +++ b/src/dflt-params/error/cls-decl-meth.template @@ -0,0 +1,71 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/statements/class/params-dflt-meth- +name: class expression method +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +var callCount = 0; +class C { + method(/*{ params }*/) { + /*{ body }*/ + callCount = callCount + 1; + } +} + +assert.throws(/*{ error }*/, function() { + C.prototype.method(/*{ args }*/); +}); +assert.sameValue(callCount, 0, 'method body not evaluated'); diff --git a/src/dflt-params/error/cls-expr-gen-meth-static.template b/src/dflt-params/error/cls-expr-gen-meth-static.template new file mode 100644 index 0000000000..9c43e710f6 --- /dev/null +++ b/src/dflt-params/error/cls-expr-gen-meth-static.template @@ -0,0 +1,75 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/expressions/class/params-dflt-gen-meth-static- +name: static class expression generator method +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +var callCount = 0; +var C = class { + static *method(/*{ params }*/) { + /*{ body }*/ + callCount = callCount + 1; + } +}; + +assert.throws(/*{ error }*/, function() { + C.method(/*{ args }*/); +}); +assert.sameValue(callCount, 0, 'method body not evaluated'); diff --git a/src/dflt-params/error/cls-expr-gen-meth.template b/src/dflt-params/error/cls-expr-gen-meth.template new file mode 100644 index 0000000000..f1603cf651 --- /dev/null +++ b/src/dflt-params/error/cls-expr-gen-meth.template @@ -0,0 +1,75 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/expressions/class/params-dflt-gen-meth- +name: class expression method +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [default-parameters] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +var callCount = 0; +var C = class { + *method(/*{ params }*/) { + /*{ body }*/ + callCount = callCount + 1; + } +}; + +assert.throws(/*{ error }*/, function() { + C.prototype.method(/*{ args }*/); +}); +assert.sameValue(callCount, 0, 'method body not evaluated'); diff --git a/src/dflt-params/error/cls-expr-meth-static.template b/src/dflt-params/error/cls-expr-meth-static.template new file mode 100644 index 0000000000..05bed0933b --- /dev/null +++ b/src/dflt-params/error/cls-expr-meth-static.template @@ -0,0 +1,72 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/expressions/class/params-dflt-meth-static- +name: static class expression method +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +var callCount = 0; +var C = class { + static method(/*{ params }*/) { + /*{ body }*/ + callCount = callCount + 1; + } +}; + +assert.throws(/*{ error }*/, function() { + C.method(/*{ args }*/); +}); +assert.sameValue(callCount, 0, 'method body not evaluated'); diff --git a/src/dflt-params/error/cls-expr-meth.template b/src/dflt-params/error/cls-expr-meth.template new file mode 100644 index 0000000000..b89ff9944f --- /dev/null +++ b/src/dflt-params/error/cls-expr-meth.template @@ -0,0 +1,72 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/expressions/class/params-dflt-meth- +name: class expression method +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [default-parameters] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +var callCount = 0; +var C = class { + method(/*{ params }*/) { + /*{ body }*/ + callCount = callCount + 1; + } +}; + +assert.throws(/*{ error }*/, function() { + C.prototype.method(/*{ args }*/); +}); +assert.sameValue(callCount, 0, 'method body not evaluated'); diff --git a/src/dflt-params/error/func-decl.template b/src/dflt-params/error/func-decl.template new file mode 100644 index 0000000000..81e5da3712 --- /dev/null +++ b/src/dflt-params/error/func-decl.template @@ -0,0 +1,50 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/statements/function/params-dflt- +name: function declaration +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.1.19 +features: [default-parameters] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +var callCount = 0; +function f(/*{ params }*/) { + /*{ body }*/ + callCount = callCount + 1; +} +assert.throws(/*{ error }*/, function() { + f(/*{ args }*/); +}); +assert.sameValue(callCount, 0, 'function body not evaluated'); diff --git a/src/dflt-params/error/func-expr.template b/src/dflt-params/error/func-expr.template new file mode 100644 index 0000000000..2d38723ca1 --- /dev/null +++ b/src/dflt-params/error/func-expr.template @@ -0,0 +1,51 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/expressions/function/params-dflt- +name: function expression +esid: sec-function-definitions-runtime-semantics-evaluation +es6id: 14.1.20 +features: [default-parameters] +info: | + FunctionExpression : function ( FormalParameters ) { FunctionBody } + + [...] + 3. Let closure be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +var callCount = 0; +var f; +f = function(/*{ params }*/) { + /*{ body }*/ + callCount = callCount + 1; +}; + +assert.throws(/*{ error }*/, function() { + f(/*{ args }*/); +}); +assert.sameValue(callCount, 0, 'function body not evaluated'); diff --git a/src/dflt-params/error/gen-func-decl.template b/src/dflt-params/error/gen-func-decl.template new file mode 100644 index 0000000000..74d7e3e33b --- /dev/null +++ b/src/dflt-params/error/gen-func-decl.template @@ -0,0 +1,51 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/statements/generators/params-dflt- +name: generator function declaration +esid: sec-generator-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.4.12 +features: [default-parameters] +info: | + GeneratorDeclaration : function * ( FormalParameters ) { GeneratorBody } + + [...] + 2. Let F be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +var callCount = 0; +function* f(/*{ params }*/) { + /*{ body }*/ + callCount = callCount + 1; +} + +assert.throws(/*{ error }*/, function() { + f(/*{ args }*/); +}); + +assert.sameValue(callCount, 0, 'generator function body not evaluated'); diff --git a/src/dflt-params/error/gen-func-expr.template b/src/dflt-params/error/gen-func-expr.template new file mode 100644 index 0000000000..950d3e132b --- /dev/null +++ b/src/dflt-params/error/gen-func-expr.template @@ -0,0 +1,51 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/expressions/generators/params-dflt- +name: generator function expression +esid: sec-generator-function-definitions-runtime-semantics-evaluation +es6id: 14.4.14 +features: [default-parameters] +info: | + GeneratorExpression : function * ( FormalParameters ) { GeneratorBody } + + [...] + 3. Let closure be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +var callCount = 0; +var f; +f = function*(/*{ params }*/) { + /*{ body }*/ + callCount = callCount + 1; +}; + +assert.throws(/*{ error }*/, function() { + f(/*{ args }*/); +}); +assert.sameValue(callCount, 0, 'generator function body not evaluated'); diff --git a/src/dflt-params/error/gen-meth.template b/src/dflt-params/error/gen-meth.template new file mode 100644 index 0000000000..3862e08507 --- /dev/null +++ b/src/dflt-params/error/gen-meth.template @@ -0,0 +1,57 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/expressions/object/method-definition/params-dflt-gen-meth- +name: generator method +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +es6id: 14.4.13 +features: [default-parameters] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +var callCount = 0; +var obj = { + *method(/*{ params }*/) { + /*{ body }*/ + callCount = callCount + 1; + } +}; + +assert.throws(/*{ error }*/, function() { + obj.method(/*{ args }*/); +}); +assert.sameValue(callCount, 0, 'generator method body not evaluated'); diff --git a/src/dflt-params/error/meth.template b/src/dflt-params/error/meth.template new file mode 100644 index 0000000000..3683dbbedf --- /dev/null +++ b/src/dflt-params/error/meth.template @@ -0,0 +1,54 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/expressions/object/method-definition/params-dflt-meth- +name: method +esid: sec-runtime-semantics-definemethod +es6id: 14.3.8 +features: [default-parameters] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +var callCount = 0; +var obj = { + method(/*{ params }*/) { + /*{ body }*/ + callCount = callCount + 1; + } +}; + +assert.throws(/*{ error }*/, function() { + obj.method(/*{ args }*/); +}); +assert.sameValue(callCount, 0, 'method body not evaluated'); diff --git a/src/dflt-params/ref-later.case b/src/dflt-params/ref-later.case new file mode 100644 index 0000000000..3087a10f32 --- /dev/null +++ b/src/dflt-params/ref-later.case @@ -0,0 +1,23 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: Referencing a parameter that occurs later in the ParameterList +template: error +info: | + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + 1. Let status be the result of performing IteratorBindingInitialization for + FormalsList using iteratorRecord and environment as the arguments. + 2. ReturnIfAbrupt(status). + 3. Return the result of performing IteratorBindingInitialization for + FormalParameter using iteratorRecord and environment as the arguments. +---*/ + +//- setup +var x = 0; +//- params +x = y, y +//- error +ReferenceError diff --git a/src/dflt-params/ref-prior.case b/src/dflt-params/ref-prior.case new file mode 100644 index 0000000000..5e28248bb0 --- /dev/null +++ b/src/dflt-params/ref-prior.case @@ -0,0 +1,27 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: Referencing a parameter that occurs earlier in the ParameterList +template: default +info: | + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + 1. Let status be the result of performing IteratorBindingInitialization for + FormalsList using iteratorRecord and environment as the arguments. + 2. ReturnIfAbrupt(status). + 3. Return the result of performing IteratorBindingInitialization for + FormalParameter using iteratorRecord and environment as the arguments. +---*/ + +//- setup +var x = 0; +//- params +x, y = x, z = y +//- args +3 +//- body +assert.sameValue(x, 3, 'first argument value'); +assert.sameValue(y, 3, 'second argument value'); +assert.sameValue(z, 3, 'third argument value'); diff --git a/src/dflt-params/ref-self.case b/src/dflt-params/ref-self.case new file mode 100644 index 0000000000..41b92f46e5 --- /dev/null +++ b/src/dflt-params/ref-self.case @@ -0,0 +1,23 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: Referencing a parameter from within its own initializer +template: error +info: | + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + 1. Let status be the result of performing IteratorBindingInitialization for + FormalsList using iteratorRecord and environment as the arguments. + 2. ReturnIfAbrupt(status). + 3. Return the result of performing IteratorBindingInitialization for + FormalParameter using iteratorRecord and environment as the arguments. +---*/ + +//- setup +var x = 0; +//- params +x = x +//- error +ReferenceError diff --git a/src/dflt-params/rest.case b/src/dflt-params/rest.case new file mode 100644 index 0000000000..e8b7f03e35 --- /dev/null +++ b/src/dflt-params/rest.case @@ -0,0 +1,27 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: RestParameter does not support an initializer +template: syntax +info: | + 14.1 Function Definitions + + Syntax + + FunctionRestParameter[Yield] : + + BindingRestElement[?Yield] + + 13.3.3 Destructuring Binding Patterns + + Syntax + + BindingRestElement[Yield] : + + ...BindingIdentifier[?Yield] + ...BindingPattern[?Yield] +negative: SyntaxError +---*/ + +//- params +...x = [] diff --git a/src/dflt-params/syntax/arrow-function.template b/src/dflt-params/syntax/arrow-function.template new file mode 100644 index 0000000000..46f6eabab0 --- /dev/null +++ b/src/dflt-params/syntax/arrow-function.template @@ -0,0 +1,42 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/expressions/arrow-function/params-dflt- +name: arrow function expression +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +es6id: 14.2.16 +features: [default-parameters] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +0, (/*{ params }*/) => { + /*{ body }*/ +}; diff --git a/src/dflt-params/syntax/cls-decl-gen-meth-static.template b/src/dflt-params/syntax/cls-decl-gen-meth-static.template new file mode 100644 index 0000000000..50414c1ada --- /dev/null +++ b/src/dflt-params/syntax/cls-decl-gen-meth-static.template @@ -0,0 +1,66 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/statements/class/params-dflt-gen-meth-static- +name: static class expression generator method +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +class C { + static *method(/*{ params }*/) { + /*{ body }*/ + } +} diff --git a/src/dflt-params/syntax/cls-decl-gen-meth.template b/src/dflt-params/syntax/cls-decl-gen-meth.template new file mode 100644 index 0000000000..fe6c086403 --- /dev/null +++ b/src/dflt-params/syntax/cls-decl-gen-meth.template @@ -0,0 +1,66 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/statements/class/params-dflt-gen-meth- +name: class expression method +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +class C { + *method(/*{ params }*/) { + /*{ body }*/ + } +} diff --git a/src/dflt-params/syntax/cls-decl-meth-static.template b/src/dflt-params/syntax/cls-decl-meth-static.template new file mode 100644 index 0000000000..b3c8b8709d --- /dev/null +++ b/src/dflt-params/syntax/cls-decl-meth-static.template @@ -0,0 +1,64 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/statements/class/params-dflt-meth-static- +name: static class expression method +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +class C { + static method(/*{ params }*/) { + /*{ body }*/ + } +} diff --git a/src/dflt-params/syntax/cls-decl-meth.template b/src/dflt-params/syntax/cls-decl-meth.template new file mode 100644 index 0000000000..f6cdd67e5d --- /dev/null +++ b/src/dflt-params/syntax/cls-decl-meth.template @@ -0,0 +1,64 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/statements/class/params-dflt-meth- +name: class expression method +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +class C { + method(/*{ params }*/) { + /*{ body }*/ + } +} diff --git a/src/dflt-params/syntax/cls-expr-gen-meth-static.template b/src/dflt-params/syntax/cls-expr-gen-meth-static.template new file mode 100644 index 0000000000..dad8668991 --- /dev/null +++ b/src/dflt-params/syntax/cls-expr-gen-meth-static.template @@ -0,0 +1,68 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/expressions/class/params-dflt-gen-meth-static- +name: static class expression generator method +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +0, class { + static *method(/*{ params }*/) { + /*{ body }*/ + } +}; diff --git a/src/dflt-params/syntax/cls-expr-gen-meth.template b/src/dflt-params/syntax/cls-expr-gen-meth.template new file mode 100644 index 0000000000..6557296226 --- /dev/null +++ b/src/dflt-params/syntax/cls-expr-gen-meth.template @@ -0,0 +1,68 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/expressions/class/params-dflt-gen-meth- +name: class expression method +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [default-parameters] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +0, class { + *method(/*{ params }*/) { + /*{ body }*/ + } +}; diff --git a/src/dflt-params/syntax/cls-expr-meth-static.template b/src/dflt-params/syntax/cls-expr-meth-static.template new file mode 100644 index 0000000000..f90fa8dccb --- /dev/null +++ b/src/dflt-params/syntax/cls-expr-meth-static.template @@ -0,0 +1,65 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/expressions/class/params-dflt-meth-static- +name: static class expression method +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +0, class { + static method(/*{ params }*/) { + /*{ body }*/ + } +}; diff --git a/src/dflt-params/syntax/cls-expr-meth.template b/src/dflt-params/syntax/cls-expr-meth.template new file mode 100644 index 0000000000..88f862d083 --- /dev/null +++ b/src/dflt-params/syntax/cls-expr-meth.template @@ -0,0 +1,65 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/expressions/class/params-dflt-meth- +name: class expression method +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [default-parameters] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +0, class { + method(/*{ params }*/) { + /*{ body }*/ + } +}; diff --git a/src/dflt-params/syntax/func-decl.template b/src/dflt-params/syntax/func-decl.template new file mode 100644 index 0000000000..601a9826b2 --- /dev/null +++ b/src/dflt-params/syntax/func-decl.template @@ -0,0 +1,44 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/statements/function/params-dflt- +name: function declaration +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.1.19 +features: [default-parameters] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +function f(/*{ params }*/) { + /*{ body }*/ +} diff --git a/src/dflt-params/syntax/func-expr.template b/src/dflt-params/syntax/func-expr.template new file mode 100644 index 0000000000..8407f2df2a --- /dev/null +++ b/src/dflt-params/syntax/func-expr.template @@ -0,0 +1,43 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/expressions/function/params-dflt- +name: function expression +esid: sec-function-definitions-runtime-semantics-evaluation +es6id: 14.1.20 +features: [default-parameters] +info: | + FunctionExpression : function ( FormalParameters ) { FunctionBody } + + [...] + 3. Let closure be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +0, function(/*{ params }*/) { + /*{ body }*/ +}; diff --git a/src/dflt-params/syntax/gen-func-decl.template b/src/dflt-params/syntax/gen-func-decl.template new file mode 100644 index 0000000000..79b7683c96 --- /dev/null +++ b/src/dflt-params/syntax/gen-func-decl.template @@ -0,0 +1,43 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/statements/generators/params-dflt- +name: generator function declaration +esid: sec-generator-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.4.12 +features: [default-parameters] +info: | + GeneratorDeclaration : function * ( FormalParameters ) { GeneratorBody } + + [...] + 2. Let F be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +function* f(/*{ params }*/) { + /*{ body }*/ +} diff --git a/src/dflt-params/syntax/gen-func-expr.template b/src/dflt-params/syntax/gen-func-expr.template new file mode 100644 index 0000000000..0ef6dbe35a --- /dev/null +++ b/src/dflt-params/syntax/gen-func-expr.template @@ -0,0 +1,43 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/expressions/generators/params-dflt- +name: generator function expression +esid: sec-generator-function-definitions-runtime-semantics-evaluation +es6id: 14.4.14 +features: [default-parameters] +info: | + GeneratorExpression : function * ( FormalParameters ) { GeneratorBody } + + [...] + 3. Let closure be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +0, function*(/*{ params }*/) { + /*{ body }*/ +}; diff --git a/src/dflt-params/syntax/gen-meth.template b/src/dflt-params/syntax/gen-meth.template new file mode 100644 index 0000000000..f9125cff59 --- /dev/null +++ b/src/dflt-params/syntax/gen-meth.template @@ -0,0 +1,50 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/expressions/object/method-definition/params-dflt-gen-meth- +name: generator method +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +es6id: 14.4.13 +features: [default-parameters] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +0, { + *method(/*{ params }*/) { + /*{ body }*/ + } +}; diff --git a/src/dflt-params/syntax/meth.template b/src/dflt-params/syntax/meth.template new file mode 100644 index 0000000000..b9f3c83109 --- /dev/null +++ b/src/dflt-params/syntax/meth.template @@ -0,0 +1,47 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/expressions/object/method-definition/params-dflt-meth- +name: method +esid: sec-runtime-semantics-definemethod +es6id: 14.3.8 +features: [default-parameters] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +0, { + method(/*{ params }*/) { + /*{ body }*/ + } +}; -- GitLab From e5f1740411b7a32bf7dedf769d80cef000b41fb5 Mon Sep 17 00:00:00 2001 From: Mike Pennisi <mike@mikepennisi.com> Date: Thu, 2 Jun 2016 14:49:52 -0400 Subject: [PATCH 4/8] Generate tests --- .../arrow-function/params-dflt-abrupt.js | 61 ++++++++++ .../params-dflt-arg-val-not-undefined.js | 82 +++++++++++++ .../params-dflt-arg-val-undefined.js | 65 +++++++++++ .../arrow-function/params-dflt-duplicates.js | 57 +++++++++ .../arrow-function/params-dflt-ref-later.js | 62 ++++++++++ .../arrow-function/params-dflt-ref-prior.js | 62 ++++++++++ .../arrow-function/params-dflt-ref-self.js | 62 ++++++++++ .../arrow-function/params-dflt-rest.js | 62 ++++++++++ .../class/params-dflt-gen-meth-abrupt.js | 86 ++++++++++++++ ...ams-dflt-gen-meth-arg-val-not-undefined.js | 108 ++++++++++++++++++ .../params-dflt-gen-meth-arg-val-undefined.js | 91 +++++++++++++++ .../class/params-dflt-gen-meth-duplicates.js | 83 ++++++++++++++ .../class/params-dflt-gen-meth-ref-later.js | 87 ++++++++++++++ .../class/params-dflt-gen-meth-ref-prior.js | 88 ++++++++++++++ .../class/params-dflt-gen-meth-ref-self.js | 87 ++++++++++++++ .../class/params-dflt-gen-meth-rest.js | 88 ++++++++++++++ .../params-dflt-gen-meth-static-abrupt.js | 86 ++++++++++++++ ...t-gen-meth-static-arg-val-not-undefined.js | 108 ++++++++++++++++++ ...-dflt-gen-meth-static-arg-val-undefined.js | 91 +++++++++++++++ .../params-dflt-gen-meth-static-duplicates.js | 83 ++++++++++++++ .../params-dflt-gen-meth-static-ref-later.js | 87 ++++++++++++++ .../params-dflt-gen-meth-static-ref-prior.js | 88 ++++++++++++++ .../params-dflt-gen-meth-static-ref-self.js | 87 ++++++++++++++ .../class/params-dflt-gen-meth-static-rest.js | 88 ++++++++++++++ .../class/params-dflt-meth-abrupt.js | 83 ++++++++++++++ .../params-dflt-meth-arg-val-not-undefined.js | 105 +++++++++++++++++ .../params-dflt-meth-arg-val-undefined.js | 88 ++++++++++++++ .../class/params-dflt-meth-duplicates.js | 80 +++++++++++++ .../class/params-dflt-meth-ref-later.js | 84 ++++++++++++++ .../class/params-dflt-meth-ref-prior.js | 85 ++++++++++++++ .../class/params-dflt-meth-ref-self.js | 84 ++++++++++++++ .../class/params-dflt-meth-rest.js | 85 ++++++++++++++ .../class/params-dflt-meth-static-abrupt.js | 83 ++++++++++++++ ...-dflt-meth-static-arg-val-not-undefined.js | 105 +++++++++++++++++ ...rams-dflt-meth-static-arg-val-undefined.js | 88 ++++++++++++++ .../params-dflt-meth-static-duplicates.js | 80 +++++++++++++ .../params-dflt-meth-static-ref-later.js | 84 ++++++++++++++ .../params-dflt-meth-static-ref-prior.js | 85 ++++++++++++++ .../class/params-dflt-meth-static-ref-self.js | 84 ++++++++++++++ .../class/params-dflt-meth-static-rest.js | 85 ++++++++++++++ .../function/params-dflt-abrupt.js | 62 ++++++++++ .../params-dflt-arg-val-not-undefined.js | 84 ++++++++++++++ .../function/params-dflt-arg-val-undefined.js | 67 +++++++++++ .../function/params-dflt-duplicates.js | 58 ++++++++++ .../function/params-dflt-ref-later.js | 63 ++++++++++ .../function/params-dflt-ref-prior.js | 64 +++++++++++ .../function/params-dflt-ref-self.js | 63 ++++++++++ .../expressions/function/params-dflt-rest.js | 63 ++++++++++ .../generators/params-dflt-abrupt.js | 62 ++++++++++ .../params-dflt-arg-val-not-undefined.js | 84 ++++++++++++++ .../params-dflt-arg-val-undefined.js | 67 +++++++++++ .../generators/params-dflt-duplicates.js | 58 ++++++++++ .../generators/params-dflt-ref-later.js | 63 ++++++++++ .../generators/params-dflt-ref-prior.js | 64 +++++++++++ .../generators/params-dflt-ref-self.js | 63 ++++++++++ .../generators/params-dflt-rest.js | 63 ++++++++++ .../params-dflt-gen-meth-abrupt.js | 68 +++++++++++ ...ams-dflt-gen-meth-arg-val-not-undefined.js | 90 +++++++++++++++ .../params-dflt-gen-meth-arg-val-undefined.js | 73 ++++++++++++ .../params-dflt-gen-meth-duplicates.js | 65 +++++++++++ .../params-dflt-gen-meth-ref-later.js | 69 +++++++++++ .../params-dflt-gen-meth-ref-prior.js | 70 ++++++++++++ .../params-dflt-gen-meth-ref-self.js | 69 +++++++++++ .../params-dflt-gen-meth-rest.js | 70 ++++++++++++ .../params-dflt-meth-abrupt.js | 65 +++++++++++ .../params-dflt-meth-arg-val-not-undefined.js | 87 ++++++++++++++ .../params-dflt-meth-arg-val-undefined.js | 70 ++++++++++++ .../params-dflt-meth-duplicates.js | 62 ++++++++++ .../params-dflt-meth-ref-later.js | 66 +++++++++++ .../params-dflt-meth-ref-prior.js | 67 +++++++++++ .../params-dflt-meth-ref-self.js | 66 +++++++++++ .../params-dflt-meth-rest.js | 67 +++++++++++ .../class/params-dflt-gen-meth-abrupt.js | 84 ++++++++++++++ ...ams-dflt-gen-meth-arg-val-not-undefined.js | 106 +++++++++++++++++ .../params-dflt-gen-meth-arg-val-undefined.js | 89 +++++++++++++++ .../class/params-dflt-gen-meth-duplicates.js | 81 +++++++++++++ .../class/params-dflt-gen-meth-ref-later.js | 85 ++++++++++++++ .../class/params-dflt-gen-meth-ref-prior.js | 86 ++++++++++++++ .../class/params-dflt-gen-meth-ref-self.js | 85 ++++++++++++++ .../class/params-dflt-gen-meth-rest.js | 86 ++++++++++++++ .../params-dflt-gen-meth-static-abrupt.js | 85 ++++++++++++++ ...t-gen-meth-static-arg-val-not-undefined.js | 106 +++++++++++++++++ ...-dflt-gen-meth-static-arg-val-undefined.js | 89 +++++++++++++++ .../params-dflt-gen-meth-static-duplicates.js | 81 +++++++++++++ .../params-dflt-gen-meth-static-ref-later.js | 86 ++++++++++++++ .../params-dflt-gen-meth-static-ref-prior.js | 86 ++++++++++++++ .../params-dflt-gen-meth-static-ref-self.js | 86 ++++++++++++++ .../class/params-dflt-gen-meth-static-rest.js | 86 ++++++++++++++ .../class/params-dflt-meth-abrupt.js | 82 +++++++++++++ .../params-dflt-meth-arg-val-not-undefined.js | 104 +++++++++++++++++ .../params-dflt-meth-arg-val-undefined.js | 87 ++++++++++++++ .../class/params-dflt-meth-duplicates.js | 79 +++++++++++++ .../class/params-dflt-meth-ref-later.js | 83 ++++++++++++++ .../class/params-dflt-meth-ref-prior.js | 84 ++++++++++++++ .../class/params-dflt-meth-ref-self.js | 83 ++++++++++++++ .../statements/class/params-dflt-meth-rest.js | 84 ++++++++++++++ .../class/params-dflt-meth-static-abrupt.js | 82 +++++++++++++ ...-dflt-meth-static-arg-val-not-undefined.js | 104 +++++++++++++++++ ...rams-dflt-meth-static-arg-val-undefined.js | 87 ++++++++++++++ .../params-dflt-meth-static-duplicates.js | 79 +++++++++++++ .../params-dflt-meth-static-ref-later.js | 83 ++++++++++++++ .../params-dflt-meth-static-ref-prior.js | 84 ++++++++++++++ .../class/params-dflt-meth-static-ref-self.js | 83 ++++++++++++++ .../class/params-dflt-meth-static-rest.js | 84 ++++++++++++++ .../statements/function/params-dflt-abrupt.js | 61 ++++++++++ .../params-dflt-arg-val-not-undefined.js | 84 ++++++++++++++ .../function/params-dflt-arg-val-undefined.js | 67 +++++++++++ .../function/params-dflt-duplicates.js | 59 ++++++++++ .../function/params-dflt-ref-later.js | 62 ++++++++++ .../function/params-dflt-ref-prior.js | 64 +++++++++++ .../function/params-dflt-ref-self.js | 62 ++++++++++ .../statements/function/params-dflt-rest.js | 64 +++++++++++ .../generators/params-dflt-abrupt.js | 62 ++++++++++ .../params-dflt-arg-val-not-undefined.js | 83 ++++++++++++++ .../params-dflt-arg-val-undefined.js | 66 +++++++++++ .../generators/params-dflt-duplicates.js | 58 ++++++++++ .../generators/params-dflt-ref-later.js | 63 ++++++++++ .../generators/params-dflt-ref-prior.js | 63 ++++++++++ .../generators/params-dflt-ref-self.js | 63 ++++++++++ .../statements/generators/params-dflt-rest.js | 63 ++++++++++ 120 files changed, 9332 insertions(+) create mode 100644 test/language/expressions/arrow-function/params-dflt-abrupt.js create mode 100644 test/language/expressions/arrow-function/params-dflt-arg-val-not-undefined.js create mode 100644 test/language/expressions/arrow-function/params-dflt-arg-val-undefined.js create mode 100644 test/language/expressions/arrow-function/params-dflt-duplicates.js create mode 100644 test/language/expressions/arrow-function/params-dflt-ref-later.js create mode 100644 test/language/expressions/arrow-function/params-dflt-ref-prior.js create mode 100644 test/language/expressions/arrow-function/params-dflt-ref-self.js create mode 100644 test/language/expressions/arrow-function/params-dflt-rest.js create mode 100644 test/language/expressions/class/params-dflt-gen-meth-abrupt.js create mode 100644 test/language/expressions/class/params-dflt-gen-meth-arg-val-not-undefined.js create mode 100644 test/language/expressions/class/params-dflt-gen-meth-arg-val-undefined.js create mode 100644 test/language/expressions/class/params-dflt-gen-meth-duplicates.js create mode 100644 test/language/expressions/class/params-dflt-gen-meth-ref-later.js create mode 100644 test/language/expressions/class/params-dflt-gen-meth-ref-prior.js create mode 100644 test/language/expressions/class/params-dflt-gen-meth-ref-self.js create mode 100644 test/language/expressions/class/params-dflt-gen-meth-rest.js create mode 100644 test/language/expressions/class/params-dflt-gen-meth-static-abrupt.js create mode 100644 test/language/expressions/class/params-dflt-gen-meth-static-arg-val-not-undefined.js create mode 100644 test/language/expressions/class/params-dflt-gen-meth-static-arg-val-undefined.js create mode 100644 test/language/expressions/class/params-dflt-gen-meth-static-duplicates.js create mode 100644 test/language/expressions/class/params-dflt-gen-meth-static-ref-later.js create mode 100644 test/language/expressions/class/params-dflt-gen-meth-static-ref-prior.js create mode 100644 test/language/expressions/class/params-dflt-gen-meth-static-ref-self.js create mode 100644 test/language/expressions/class/params-dflt-gen-meth-static-rest.js create mode 100644 test/language/expressions/class/params-dflt-meth-abrupt.js create mode 100644 test/language/expressions/class/params-dflt-meth-arg-val-not-undefined.js create mode 100644 test/language/expressions/class/params-dflt-meth-arg-val-undefined.js create mode 100644 test/language/expressions/class/params-dflt-meth-duplicates.js create mode 100644 test/language/expressions/class/params-dflt-meth-ref-later.js create mode 100644 test/language/expressions/class/params-dflt-meth-ref-prior.js create mode 100644 test/language/expressions/class/params-dflt-meth-ref-self.js create mode 100644 test/language/expressions/class/params-dflt-meth-rest.js create mode 100644 test/language/expressions/class/params-dflt-meth-static-abrupt.js create mode 100644 test/language/expressions/class/params-dflt-meth-static-arg-val-not-undefined.js create mode 100644 test/language/expressions/class/params-dflt-meth-static-arg-val-undefined.js create mode 100644 test/language/expressions/class/params-dflt-meth-static-duplicates.js create mode 100644 test/language/expressions/class/params-dflt-meth-static-ref-later.js create mode 100644 test/language/expressions/class/params-dflt-meth-static-ref-prior.js create mode 100644 test/language/expressions/class/params-dflt-meth-static-ref-self.js create mode 100644 test/language/expressions/class/params-dflt-meth-static-rest.js create mode 100644 test/language/expressions/function/params-dflt-abrupt.js create mode 100644 test/language/expressions/function/params-dflt-arg-val-not-undefined.js create mode 100644 test/language/expressions/function/params-dflt-arg-val-undefined.js create mode 100644 test/language/expressions/function/params-dflt-duplicates.js create mode 100644 test/language/expressions/function/params-dflt-ref-later.js create mode 100644 test/language/expressions/function/params-dflt-ref-prior.js create mode 100644 test/language/expressions/function/params-dflt-ref-self.js create mode 100644 test/language/expressions/function/params-dflt-rest.js create mode 100644 test/language/expressions/generators/params-dflt-abrupt.js create mode 100644 test/language/expressions/generators/params-dflt-arg-val-not-undefined.js create mode 100644 test/language/expressions/generators/params-dflt-arg-val-undefined.js create mode 100644 test/language/expressions/generators/params-dflt-duplicates.js create mode 100644 test/language/expressions/generators/params-dflt-ref-later.js create mode 100644 test/language/expressions/generators/params-dflt-ref-prior.js create mode 100644 test/language/expressions/generators/params-dflt-ref-self.js create mode 100644 test/language/expressions/generators/params-dflt-rest.js create mode 100644 test/language/expressions/object/method-definition/params-dflt-gen-meth-abrupt.js create mode 100644 test/language/expressions/object/method-definition/params-dflt-gen-meth-arg-val-not-undefined.js create mode 100644 test/language/expressions/object/method-definition/params-dflt-gen-meth-arg-val-undefined.js create mode 100644 test/language/expressions/object/method-definition/params-dflt-gen-meth-duplicates.js create mode 100644 test/language/expressions/object/method-definition/params-dflt-gen-meth-ref-later.js create mode 100644 test/language/expressions/object/method-definition/params-dflt-gen-meth-ref-prior.js create mode 100644 test/language/expressions/object/method-definition/params-dflt-gen-meth-ref-self.js create mode 100644 test/language/expressions/object/method-definition/params-dflt-gen-meth-rest.js create mode 100644 test/language/expressions/object/method-definition/params-dflt-meth-abrupt.js create mode 100644 test/language/expressions/object/method-definition/params-dflt-meth-arg-val-not-undefined.js create mode 100644 test/language/expressions/object/method-definition/params-dflt-meth-arg-val-undefined.js create mode 100644 test/language/expressions/object/method-definition/params-dflt-meth-duplicates.js create mode 100644 test/language/expressions/object/method-definition/params-dflt-meth-ref-later.js create mode 100644 test/language/expressions/object/method-definition/params-dflt-meth-ref-prior.js create mode 100644 test/language/expressions/object/method-definition/params-dflt-meth-ref-self.js create mode 100644 test/language/expressions/object/method-definition/params-dflt-meth-rest.js create mode 100644 test/language/statements/class/params-dflt-gen-meth-abrupt.js create mode 100644 test/language/statements/class/params-dflt-gen-meth-arg-val-not-undefined.js create mode 100644 test/language/statements/class/params-dflt-gen-meth-arg-val-undefined.js create mode 100644 test/language/statements/class/params-dflt-gen-meth-duplicates.js create mode 100644 test/language/statements/class/params-dflt-gen-meth-ref-later.js create mode 100644 test/language/statements/class/params-dflt-gen-meth-ref-prior.js create mode 100644 test/language/statements/class/params-dflt-gen-meth-ref-self.js create mode 100644 test/language/statements/class/params-dflt-gen-meth-rest.js create mode 100644 test/language/statements/class/params-dflt-gen-meth-static-abrupt.js create mode 100644 test/language/statements/class/params-dflt-gen-meth-static-arg-val-not-undefined.js create mode 100644 test/language/statements/class/params-dflt-gen-meth-static-arg-val-undefined.js create mode 100644 test/language/statements/class/params-dflt-gen-meth-static-duplicates.js create mode 100644 test/language/statements/class/params-dflt-gen-meth-static-ref-later.js create mode 100644 test/language/statements/class/params-dflt-gen-meth-static-ref-prior.js create mode 100644 test/language/statements/class/params-dflt-gen-meth-static-ref-self.js create mode 100644 test/language/statements/class/params-dflt-gen-meth-static-rest.js create mode 100644 test/language/statements/class/params-dflt-meth-abrupt.js create mode 100644 test/language/statements/class/params-dflt-meth-arg-val-not-undefined.js create mode 100644 test/language/statements/class/params-dflt-meth-arg-val-undefined.js create mode 100644 test/language/statements/class/params-dflt-meth-duplicates.js create mode 100644 test/language/statements/class/params-dflt-meth-ref-later.js create mode 100644 test/language/statements/class/params-dflt-meth-ref-prior.js create mode 100644 test/language/statements/class/params-dflt-meth-ref-self.js create mode 100644 test/language/statements/class/params-dflt-meth-rest.js create mode 100644 test/language/statements/class/params-dflt-meth-static-abrupt.js create mode 100644 test/language/statements/class/params-dflt-meth-static-arg-val-not-undefined.js create mode 100644 test/language/statements/class/params-dflt-meth-static-arg-val-undefined.js create mode 100644 test/language/statements/class/params-dflt-meth-static-duplicates.js create mode 100644 test/language/statements/class/params-dflt-meth-static-ref-later.js create mode 100644 test/language/statements/class/params-dflt-meth-static-ref-prior.js create mode 100644 test/language/statements/class/params-dflt-meth-static-ref-self.js create mode 100644 test/language/statements/class/params-dflt-meth-static-rest.js create mode 100644 test/language/statements/function/params-dflt-abrupt.js create mode 100644 test/language/statements/function/params-dflt-arg-val-not-undefined.js create mode 100644 test/language/statements/function/params-dflt-arg-val-undefined.js create mode 100644 test/language/statements/function/params-dflt-duplicates.js create mode 100644 test/language/statements/function/params-dflt-ref-later.js create mode 100644 test/language/statements/function/params-dflt-ref-prior.js create mode 100644 test/language/statements/function/params-dflt-ref-self.js create mode 100644 test/language/statements/function/params-dflt-rest.js create mode 100644 test/language/statements/generators/params-dflt-abrupt.js create mode 100644 test/language/statements/generators/params-dflt-arg-val-not-undefined.js create mode 100644 test/language/statements/generators/params-dflt-arg-val-undefined.js create mode 100644 test/language/statements/generators/params-dflt-duplicates.js create mode 100644 test/language/statements/generators/params-dflt-ref-later.js create mode 100644 test/language/statements/generators/params-dflt-ref-prior.js create mode 100644 test/language/statements/generators/params-dflt-ref-self.js create mode 100644 test/language/statements/generators/params-dflt-rest.js diff --git a/test/language/expressions/arrow-function/params-dflt-abrupt.js b/test/language/expressions/arrow-function/params-dflt-abrupt.js new file mode 100644 index 0000000000..04b7c2f954 --- /dev/null +++ b/test/language/expressions/arrow-function/params-dflt-abrupt.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dflt-params/abrupt.case +// - src/dflt-params/error/arrow-function.template +/*--- +description: Abrupt completion returned by evaluation of initializer (arrow function expression) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +es6id: 14.2.16 +features: [default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + 1. Let status be the result of performing IteratorBindingInitialization for + FormalsList using iteratorRecord and environment as the arguments. + 2. ReturnIfAbrupt(status). + 3. Return the result of performing IteratorBindingInitialization for + FormalParameter using iteratorRecord and environment as the arguments. +---*/ + +var callCount = 0; +var f; +f = (_ = (function() { throw new Test262Error(); }())) => { + + callCount = callCount + 1; +}; + +assert.throws(Test262Error, function() { + f(); +}); +assert.sameValue(callCount, 0, 'arrow function body not evaluated'); diff --git a/test/language/expressions/arrow-function/params-dflt-arg-val-not-undefined.js b/test/language/expressions/arrow-function/params-dflt-arg-val-not-undefined.js new file mode 100644 index 0000000000..317600ccec --- /dev/null +++ b/test/language/expressions/arrow-function/params-dflt-arg-val-not-undefined.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/dflt-params/arg-val-not-undefined.case +// - src/dflt-params/default/arrow-function.template +/*--- +description: Use of intializer when argument value is not `undefined` (arrow function expression) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +es6id: 14.2.16 +features: [default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + [...] + 23. Let iteratorRecord be Record {[[Iterator]]: + CreateListIterator(argumentsList), [[Done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + a. Perform ? IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var obj = {}; +var falseCount = 0; +var stringCount = 0; +var nanCount = 0; +var zeroCount = 0; +var nullCount = 0; +var objCount = 0; + +var callCount = 0; +var f; +f = (aFalse = falseCount +=1, aString = stringCount += 1, aNaN = nanCount += 1, a0 = zeroCount += 1, aNull = nullCount += 1, aObj = objCount +=1) => { + assert.sameValue(aFalse, false); + assert.sameValue(aString, ''); + assert.sameValue(aNaN, NaN); + assert.sameValue(a0, 0); + assert.sameValue(aNull, null); + assert.sameValue(aObj, obj); + callCount = callCount + 1; +}; + +f(false, '', NaN, 0, null, obj); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); + +assert.sameValue(falseCount, 0, 'initializer not evaluated: false'); +assert.sameValue(stringCount, 0, 'initializer not evaluated: string'); +assert.sameValue(nanCount, 0, 'initializer not evaluated: NaN'); +assert.sameValue(zeroCount, 0, 'initializer not evaluated: 0'); +assert.sameValue(nullCount, 0, 'initializer not evaluated: null'); +assert.sameValue(objCount, 0, 'initializer not evaluated: object'); diff --git a/test/language/expressions/arrow-function/params-dflt-arg-val-undefined.js b/test/language/expressions/arrow-function/params-dflt-arg-val-undefined.js new file mode 100644 index 0000000000..300537d3b2 --- /dev/null +++ b/test/language/expressions/arrow-function/params-dflt-arg-val-undefined.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dflt-params/arg-val-undefined.case +// - src/dflt-params/default/arrow-function.template +/*--- +description: Use of intializer when argument value is `undefined` (arrow function expression) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +es6id: 14.2.16 +features: [default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + [...] + 23. Let iteratorRecord be Record {[[Iterator]]: + CreateListIterator(argumentsList), [[Done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + a. Perform ? IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +var callCount = 0; +var f; +f = (fromLiteral = 23, fromExpr = 45, fromHole = 99) => { + assert.sameValue(fromLiteral, 23); + assert.sameValue(fromExpr, 45); + assert.sameValue(fromHole, 99); + callCount = callCount + 1; +}; + +f(undefined, void 0); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); diff --git a/test/language/expressions/arrow-function/params-dflt-duplicates.js b/test/language/expressions/arrow-function/params-dflt-duplicates.js new file mode 100644 index 0000000000..8b338f7e42 --- /dev/null +++ b/test/language/expressions/arrow-function/params-dflt-duplicates.js @@ -0,0 +1,57 @@ +// This file was procedurally generated from the following sources: +// - src/dflt-params/duplicates.case +// - src/dflt-params/syntax/arrow-function.template +/*--- +description: It is a Syntax Error if BoundNames of FormalParameters contains any duplicate elements. (arrow function expression) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +es6id: 14.2.16 +features: [default-parameters] +flags: [generated] +negative: SyntaxError +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.2 Static Semantics: Early Errors + + StrictFormalParameters : FormalParameters + + - It is a Syntax Error if BoundNames of FormalParameters contains any + duplicate elements. + + FormalParameters : FormalParameterList + + - It is a Syntax Error if IsSimpleParameterList of FormalParameterList is + false and BoundNames of FormalParameterList contains any duplicate + elements. +---*/ + +0, (x = 0, x) => { + +}; diff --git a/test/language/expressions/arrow-function/params-dflt-ref-later.js b/test/language/expressions/arrow-function/params-dflt-ref-later.js new file mode 100644 index 0000000000..96789cbf65 --- /dev/null +++ b/test/language/expressions/arrow-function/params-dflt-ref-later.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dflt-params/ref-later.case +// - src/dflt-params/error/arrow-function.template +/*--- +description: Referencing a parameter that occurs later in the ParameterList (arrow function expression) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +es6id: 14.2.16 +features: [default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + 1. Let status be the result of performing IteratorBindingInitialization for + FormalsList using iteratorRecord and environment as the arguments. + 2. ReturnIfAbrupt(status). + 3. Return the result of performing IteratorBindingInitialization for + FormalParameter using iteratorRecord and environment as the arguments. +---*/ +var x = 0; + +var callCount = 0; +var f; +f = (x = y, y) => { + + callCount = callCount + 1; +}; + +assert.throws(ReferenceError, function() { + f(); +}); +assert.sameValue(callCount, 0, 'arrow function body not evaluated'); diff --git a/test/language/expressions/arrow-function/params-dflt-ref-prior.js b/test/language/expressions/arrow-function/params-dflt-ref-prior.js new file mode 100644 index 0000000000..b34679a104 --- /dev/null +++ b/test/language/expressions/arrow-function/params-dflt-ref-prior.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dflt-params/ref-prior.case +// - src/dflt-params/default/arrow-function.template +/*--- +description: Referencing a parameter that occurs earlier in the ParameterList (arrow function expression) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +es6id: 14.2.16 +features: [default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + 1. Let status be the result of performing IteratorBindingInitialization for + FormalsList using iteratorRecord and environment as the arguments. + 2. ReturnIfAbrupt(status). + 3. Return the result of performing IteratorBindingInitialization for + FormalParameter using iteratorRecord and environment as the arguments. +---*/ +var x = 0; + +var callCount = 0; +var f; +f = (x, y = x, z = y) => { + assert.sameValue(x, 3, 'first argument value'); + assert.sameValue(y, 3, 'second argument value'); + assert.sameValue(z, 3, 'third argument value'); + callCount = callCount + 1; +}; + +f(3); +assert.sameValue(callCount, 1, 'arrow function invoked exactly once'); diff --git a/test/language/expressions/arrow-function/params-dflt-ref-self.js b/test/language/expressions/arrow-function/params-dflt-ref-self.js new file mode 100644 index 0000000000..8f45c38968 --- /dev/null +++ b/test/language/expressions/arrow-function/params-dflt-ref-self.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dflt-params/ref-self.case +// - src/dflt-params/error/arrow-function.template +/*--- +description: Referencing a parameter from within its own initializer (arrow function expression) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +es6id: 14.2.16 +features: [default-parameters] +flags: [generated] +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + 1. Let status be the result of performing IteratorBindingInitialization for + FormalsList using iteratorRecord and environment as the arguments. + 2. ReturnIfAbrupt(status). + 3. Return the result of performing IteratorBindingInitialization for + FormalParameter using iteratorRecord and environment as the arguments. +---*/ +var x = 0; + +var callCount = 0; +var f; +f = (x = x) => { + + callCount = callCount + 1; +}; + +assert.throws(ReferenceError, function() { + f(); +}); +assert.sameValue(callCount, 0, 'arrow function body not evaluated'); diff --git a/test/language/expressions/arrow-function/params-dflt-rest.js b/test/language/expressions/arrow-function/params-dflt-rest.js new file mode 100644 index 0000000000..5981599564 --- /dev/null +++ b/test/language/expressions/arrow-function/params-dflt-rest.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dflt-params/rest.case +// - src/dflt-params/syntax/arrow-function.template +/*--- +description: RestParameter does not support an initializer (arrow function expression) +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +es6id: 14.2.16 +features: [default-parameters] +flags: [generated] +negative: SyntaxError +info: | + ArrowFunction : ArrowParameters => ConciseBody + + [...] + 4. Let closure be FunctionCreate(Arrow, parameters, ConciseBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1 Function Definitions + + Syntax + + FunctionRestParameter[Yield] : + + BindingRestElement[?Yield] + + 13.3.3 Destructuring Binding Patterns + + Syntax + + BindingRestElement[Yield] : + + ...BindingIdentifier[?Yield] + ...BindingPattern[?Yield] + +---*/ + +0, (...x = []) => { + +}; diff --git a/test/language/expressions/class/params-dflt-gen-meth-abrupt.js b/test/language/expressions/class/params-dflt-gen-meth-abrupt.js new file mode 100644 index 0000000000..889bd23139 --- /dev/null +++ b/test/language/expressions/class/params-dflt-gen-meth-abrupt.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dflt-params/abrupt.case +// - src/dflt-params/error/cls-expr-gen-meth.template +/*--- +description: Abrupt completion returned by evaluation of initializer (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + 1. Let status be the result of performing IteratorBindingInitialization for + FormalsList using iteratorRecord and environment as the arguments. + 2. ReturnIfAbrupt(status). + 3. Return the result of performing IteratorBindingInitialization for + FormalParameter using iteratorRecord and environment as the arguments. +---*/ + +var callCount = 0; +var C = class { + *method(_ = (function() { throw new Test262Error(); }())) { + + callCount = callCount + 1; + } +}; + +assert.throws(Test262Error, function() { + C.prototype.method(); +}); +assert.sameValue(callCount, 0, 'method body not evaluated'); diff --git a/test/language/expressions/class/params-dflt-gen-meth-arg-val-not-undefined.js b/test/language/expressions/class/params-dflt-gen-meth-arg-val-not-undefined.js new file mode 100644 index 0000000000..68e84f1551 --- /dev/null +++ b/test/language/expressions/class/params-dflt-gen-meth-arg-val-not-undefined.js @@ -0,0 +1,108 @@ +// This file was procedurally generated from the following sources: +// - src/dflt-params/arg-val-not-undefined.case +// - src/dflt-params/default/cls-expr-gen-meth.template +/*--- +description: Use of intializer when argument value is not `undefined` (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + [...] + 23. Let iteratorRecord be Record {[[Iterator]]: + CreateListIterator(argumentsList), [[Done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + a. Perform ? IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var obj = {}; +var falseCount = 0; +var stringCount = 0; +var nanCount = 0; +var zeroCount = 0; +var nullCount = 0; +var objCount = 0; + +var callCount = 0; +var C = class { + *method(aFalse = falseCount +=1, aString = stringCount += 1, aNaN = nanCount += 1, a0 = zeroCount += 1, aNull = nullCount += 1, aObj = objCount +=1) { + assert.sameValue(aFalse, false); + assert.sameValue(aString, ''); + assert.sameValue(aNaN, NaN); + assert.sameValue(a0, 0); + assert.sameValue(aNull, null); + assert.sameValue(aObj, obj); + callCount = callCount + 1; + } +}; + +C.prototype.method(false, '', NaN, 0, null, obj).next(); + +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +assert.sameValue(falseCount, 0, 'initializer not evaluated: false'); +assert.sameValue(stringCount, 0, 'initializer not evaluated: string'); +assert.sameValue(nanCount, 0, 'initializer not evaluated: NaN'); +assert.sameValue(zeroCount, 0, 'initializer not evaluated: 0'); +assert.sameValue(nullCount, 0, 'initializer not evaluated: null'); +assert.sameValue(objCount, 0, 'initializer not evaluated: object'); diff --git a/test/language/expressions/class/params-dflt-gen-meth-arg-val-undefined.js b/test/language/expressions/class/params-dflt-gen-meth-arg-val-undefined.js new file mode 100644 index 0000000000..5a412e0b52 --- /dev/null +++ b/test/language/expressions/class/params-dflt-gen-meth-arg-val-undefined.js @@ -0,0 +1,91 @@ +// This file was procedurally generated from the following sources: +// - src/dflt-params/arg-val-undefined.case +// - src/dflt-params/default/cls-expr-gen-meth.template +/*--- +description: Use of intializer when argument value is `undefined` (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + [...] + 23. Let iteratorRecord be Record {[[Iterator]]: + CreateListIterator(argumentsList), [[Done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + a. Perform ? IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +var callCount = 0; +var C = class { + *method(fromLiteral = 23, fromExpr = 45, fromHole = 99) { + assert.sameValue(fromLiteral, 23); + assert.sameValue(fromExpr, 45); + assert.sameValue(fromHole, 99); + callCount = callCount + 1; + } +}; + +C.prototype.method(undefined, void 0).next(); + +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/params-dflt-gen-meth-duplicates.js b/test/language/expressions/class/params-dflt-gen-meth-duplicates.js new file mode 100644 index 0000000000..64e8a6de67 --- /dev/null +++ b/test/language/expressions/class/params-dflt-gen-meth-duplicates.js @@ -0,0 +1,83 @@ +// This file was procedurally generated from the following sources: +// - src/dflt-params/duplicates.case +// - src/dflt-params/syntax/cls-expr-gen-meth.template +/*--- +description: It is a Syntax Error if BoundNames of FormalParameters contains any duplicate elements. (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [default-parameters] +flags: [generated] +negative: SyntaxError +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.2 Static Semantics: Early Errors + + StrictFormalParameters : FormalParameters + + - It is a Syntax Error if BoundNames of FormalParameters contains any + duplicate elements. + + FormalParameters : FormalParameterList + + - It is a Syntax Error if IsSimpleParameterList of FormalParameterList is + false and BoundNames of FormalParameterList contains any duplicate + elements. +---*/ + +0, class { + *method(x = 0, x) { + + } +}; diff --git a/test/language/expressions/class/params-dflt-gen-meth-ref-later.js b/test/language/expressions/class/params-dflt-gen-meth-ref-later.js new file mode 100644 index 0000000000..8187aab07a --- /dev/null +++ b/test/language/expressions/class/params-dflt-gen-meth-ref-later.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dflt-params/ref-later.case +// - src/dflt-params/error/cls-expr-gen-meth.template +/*--- +description: Referencing a parameter that occurs later in the ParameterList (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + 1. Let status be the result of performing IteratorBindingInitialization for + FormalsList using iteratorRecord and environment as the arguments. + 2. ReturnIfAbrupt(status). + 3. Return the result of performing IteratorBindingInitialization for + FormalParameter using iteratorRecord and environment as the arguments. +---*/ +var x = 0; + +var callCount = 0; +var C = class { + *method(x = y, y) { + + callCount = callCount + 1; + } +}; + +assert.throws(ReferenceError, function() { + C.prototype.method(); +}); +assert.sameValue(callCount, 0, 'method body not evaluated'); diff --git a/test/language/expressions/class/params-dflt-gen-meth-ref-prior.js b/test/language/expressions/class/params-dflt-gen-meth-ref-prior.js new file mode 100644 index 0000000000..e5a098a17a --- /dev/null +++ b/test/language/expressions/class/params-dflt-gen-meth-ref-prior.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dflt-params/ref-prior.case +// - src/dflt-params/default/cls-expr-gen-meth.template +/*--- +description: Referencing a parameter that occurs earlier in the ParameterList (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + 1. Let status be the result of performing IteratorBindingInitialization for + FormalsList using iteratorRecord and environment as the arguments. + 2. ReturnIfAbrupt(status). + 3. Return the result of performing IteratorBindingInitialization for + FormalParameter using iteratorRecord and environment as the arguments. +---*/ +var x = 0; + +var callCount = 0; +var C = class { + *method(x, y = x, z = y) { + assert.sameValue(x, 3, 'first argument value'); + assert.sameValue(y, 3, 'second argument value'); + assert.sameValue(z, 3, 'third argument value'); + callCount = callCount + 1; + } +}; + +C.prototype.method(3).next(); + +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/params-dflt-gen-meth-ref-self.js b/test/language/expressions/class/params-dflt-gen-meth-ref-self.js new file mode 100644 index 0000000000..35ee467af1 --- /dev/null +++ b/test/language/expressions/class/params-dflt-gen-meth-ref-self.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dflt-params/ref-self.case +// - src/dflt-params/error/cls-expr-gen-meth.template +/*--- +description: Referencing a parameter from within its own initializer (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + 1. Let status be the result of performing IteratorBindingInitialization for + FormalsList using iteratorRecord and environment as the arguments. + 2. ReturnIfAbrupt(status). + 3. Return the result of performing IteratorBindingInitialization for + FormalParameter using iteratorRecord and environment as the arguments. +---*/ +var x = 0; + +var callCount = 0; +var C = class { + *method(x = x) { + + callCount = callCount + 1; + } +}; + +assert.throws(ReferenceError, function() { + C.prototype.method(); +}); +assert.sameValue(callCount, 0, 'method body not evaluated'); diff --git a/test/language/expressions/class/params-dflt-gen-meth-rest.js b/test/language/expressions/class/params-dflt-gen-meth-rest.js new file mode 100644 index 0000000000..3047f2288f --- /dev/null +++ b/test/language/expressions/class/params-dflt-gen-meth-rest.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dflt-params/rest.case +// - src/dflt-params/syntax/cls-expr-gen-meth.template +/*--- +description: RestParameter does not support an initializer (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [default-parameters] +flags: [generated] +negative: SyntaxError +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1 Function Definitions + + Syntax + + FunctionRestParameter[Yield] : + + BindingRestElement[?Yield] + + 13.3.3 Destructuring Binding Patterns + + Syntax + + BindingRestElement[Yield] : + + ...BindingIdentifier[?Yield] + ...BindingPattern[?Yield] + +---*/ + +0, class { + *method(...x = []) { + + } +}; diff --git a/test/language/expressions/class/params-dflt-gen-meth-static-abrupt.js b/test/language/expressions/class/params-dflt-gen-meth-static-abrupt.js new file mode 100644 index 0000000000..c0ec1c62b9 --- /dev/null +++ b/test/language/expressions/class/params-dflt-gen-meth-static-abrupt.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dflt-params/abrupt.case +// - src/dflt-params/error/cls-expr-gen-meth-static.template +/*--- +description: Abrupt completion returned by evaluation of initializer (static class expression generator method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + 1. Let status be the result of performing IteratorBindingInitialization for + FormalsList using iteratorRecord and environment as the arguments. + 2. ReturnIfAbrupt(status). + 3. Return the result of performing IteratorBindingInitialization for + FormalParameter using iteratorRecord and environment as the arguments. +---*/ + +var callCount = 0; +var C = class { + static *method(_ = (function() { throw new Test262Error(); }())) { + + callCount = callCount + 1; + } +}; + +assert.throws(Test262Error, function() { + C.method(); +}); +assert.sameValue(callCount, 0, 'method body not evaluated'); diff --git a/test/language/expressions/class/params-dflt-gen-meth-static-arg-val-not-undefined.js b/test/language/expressions/class/params-dflt-gen-meth-static-arg-val-not-undefined.js new file mode 100644 index 0000000000..5908b88cb9 --- /dev/null +++ b/test/language/expressions/class/params-dflt-gen-meth-static-arg-val-not-undefined.js @@ -0,0 +1,108 @@ +// This file was procedurally generated from the following sources: +// - src/dflt-params/arg-val-not-undefined.case +// - src/dflt-params/default/cls-expr-gen-meth-static.template +/*--- +description: Use of intializer when argument value is not `undefined` (static class expression generator method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + [...] + 23. Let iteratorRecord be Record {[[Iterator]]: + CreateListIterator(argumentsList), [[Done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + a. Perform ? IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var obj = {}; +var falseCount = 0; +var stringCount = 0; +var nanCount = 0; +var zeroCount = 0; +var nullCount = 0; +var objCount = 0; + +var callCount = 0; +var C = class { + static *method(aFalse = falseCount +=1, aString = stringCount += 1, aNaN = nanCount += 1, a0 = zeroCount += 1, aNull = nullCount += 1, aObj = objCount +=1) { + assert.sameValue(aFalse, false); + assert.sameValue(aString, ''); + assert.sameValue(aNaN, NaN); + assert.sameValue(a0, 0); + assert.sameValue(aNull, null); + assert.sameValue(aObj, obj); + callCount = callCount + 1; + } +}; + +C.method(false, '', NaN, 0, null, obj).next(); + +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +assert.sameValue(falseCount, 0, 'initializer not evaluated: false'); +assert.sameValue(stringCount, 0, 'initializer not evaluated: string'); +assert.sameValue(nanCount, 0, 'initializer not evaluated: NaN'); +assert.sameValue(zeroCount, 0, 'initializer not evaluated: 0'); +assert.sameValue(nullCount, 0, 'initializer not evaluated: null'); +assert.sameValue(objCount, 0, 'initializer not evaluated: object'); diff --git a/test/language/expressions/class/params-dflt-gen-meth-static-arg-val-undefined.js b/test/language/expressions/class/params-dflt-gen-meth-static-arg-val-undefined.js new file mode 100644 index 0000000000..c5312c7bdf --- /dev/null +++ b/test/language/expressions/class/params-dflt-gen-meth-static-arg-val-undefined.js @@ -0,0 +1,91 @@ +// This file was procedurally generated from the following sources: +// - src/dflt-params/arg-val-undefined.case +// - src/dflt-params/default/cls-expr-gen-meth-static.template +/*--- +description: Use of intializer when argument value is `undefined` (static class expression generator method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + [...] + 23. Let iteratorRecord be Record {[[Iterator]]: + CreateListIterator(argumentsList), [[Done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + a. Perform ? IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +var callCount = 0; +var C = class { + static *method(fromLiteral = 23, fromExpr = 45, fromHole = 99) { + assert.sameValue(fromLiteral, 23); + assert.sameValue(fromExpr, 45); + assert.sameValue(fromHole, 99); + callCount = callCount + 1; + } +}; + +C.method(undefined, void 0).next(); + +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/params-dflt-gen-meth-static-duplicates.js b/test/language/expressions/class/params-dflt-gen-meth-static-duplicates.js new file mode 100644 index 0000000000..eb5663a6b3 --- /dev/null +++ b/test/language/expressions/class/params-dflt-gen-meth-static-duplicates.js @@ -0,0 +1,83 @@ +// This file was procedurally generated from the following sources: +// - src/dflt-params/duplicates.case +// - src/dflt-params/syntax/cls-expr-gen-meth-static.template +/*--- +description: It is a Syntax Error if BoundNames of FormalParameters contains any duplicate elements. (static class expression generator method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [default-parameters] +flags: [generated] +negative: SyntaxError +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation + for m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.2 Static Semantics: Early Errors + + StrictFormalParameters : FormalParameters + + - It is a Syntax Error if BoundNames of FormalParameters contains any + duplicate elements. + + FormalParameters : FormalParameterList + + - It is a Syntax Error if IsSimpleParameterList of FormalParameterList is + false and BoundNames of FormalParameterList contains any duplicate + elements. +---*/ + +0, class { + static *method(x = 0, x) { + + } +}; diff --git a/test/language/expressions/class/params-dflt-gen-meth-static-ref-later.js b/test/language/expressions/class/params-dflt-gen-meth-static-ref-later.js new file mode 100644 index 0000000000..41da2d30d5 --- /dev/null +++ b/test/language/expressions/class/params-dflt-gen-meth-static-ref-later.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dflt-params/ref-later.case +// - src/dflt-params/error/cls-expr-gen-meth-static.template +/*--- +description: Referencing a parameter that occurs later in the ParameterList (static class expression generator method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + 1. Let status be the result of performing IteratorBindingInitialization for + FormalsList using iteratorRecord and environment as the arguments. + 2. ReturnIfAbrupt(status). + 3. Return the result of performing IteratorBindingInitialization for + FormalParameter using iteratorRecord and environment as the arguments. +---*/ +var x = 0; + +var callCount = 0; +var C = class { + static *method(x = y, y) { + + callCount = callCount + 1; + } +}; + +assert.throws(ReferenceError, function() { + C.method(); +}); +assert.sameValue(callCount, 0, 'method body not evaluated'); diff --git a/test/language/expressions/class/params-dflt-gen-meth-static-ref-prior.js b/test/language/expressions/class/params-dflt-gen-meth-static-ref-prior.js new file mode 100644 index 0000000000..993d308096 --- /dev/null +++ b/test/language/expressions/class/params-dflt-gen-meth-static-ref-prior.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dflt-params/ref-prior.case +// - src/dflt-params/default/cls-expr-gen-meth-static.template +/*--- +description: Referencing a parameter that occurs earlier in the ParameterList (static class expression generator method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + 1. Let status be the result of performing IteratorBindingInitialization for + FormalsList using iteratorRecord and environment as the arguments. + 2. ReturnIfAbrupt(status). + 3. Return the result of performing IteratorBindingInitialization for + FormalParameter using iteratorRecord and environment as the arguments. +---*/ +var x = 0; + +var callCount = 0; +var C = class { + static *method(x, y = x, z = y) { + assert.sameValue(x, 3, 'first argument value'); + assert.sameValue(y, 3, 'second argument value'); + assert.sameValue(z, 3, 'third argument value'); + callCount = callCount + 1; + } +}; + +C.method(3).next(); + +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/params-dflt-gen-meth-static-ref-self.js b/test/language/expressions/class/params-dflt-gen-meth-static-ref-self.js new file mode 100644 index 0000000000..2d5c619c37 --- /dev/null +++ b/test/language/expressions/class/params-dflt-gen-meth-static-ref-self.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dflt-params/ref-self.case +// - src/dflt-params/error/cls-expr-gen-meth-static.template +/*--- +description: Referencing a parameter from within its own initializer (static class expression generator method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + 1. Let status be the result of performing IteratorBindingInitialization for + FormalsList using iteratorRecord and environment as the arguments. + 2. ReturnIfAbrupt(status). + 3. Return the result of performing IteratorBindingInitialization for + FormalParameter using iteratorRecord and environment as the arguments. +---*/ +var x = 0; + +var callCount = 0; +var C = class { + static *method(x = x) { + + callCount = callCount + 1; + } +}; + +assert.throws(ReferenceError, function() { + C.method(); +}); +assert.sameValue(callCount, 0, 'method body not evaluated'); diff --git a/test/language/expressions/class/params-dflt-gen-meth-static-rest.js b/test/language/expressions/class/params-dflt-gen-meth-static-rest.js new file mode 100644 index 0000000000..92a5a6fffd --- /dev/null +++ b/test/language/expressions/class/params-dflt-gen-meth-static-rest.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dflt-params/rest.case +// - src/dflt-params/syntax/cls-expr-gen-meth-static.template +/*--- +description: RestParameter does not support an initializer (static class expression generator method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [default-parameters] +flags: [generated] +negative: SyntaxError +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation + for m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1 Function Definitions + + Syntax + + FunctionRestParameter[Yield] : + + BindingRestElement[?Yield] + + 13.3.3 Destructuring Binding Patterns + + Syntax + + BindingRestElement[Yield] : + + ...BindingIdentifier[?Yield] + ...BindingPattern[?Yield] + +---*/ + +0, class { + static *method(...x = []) { + + } +}; diff --git a/test/language/expressions/class/params-dflt-meth-abrupt.js b/test/language/expressions/class/params-dflt-meth-abrupt.js new file mode 100644 index 0000000000..7e0d921f7e --- /dev/null +++ b/test/language/expressions/class/params-dflt-meth-abrupt.js @@ -0,0 +1,83 @@ +// This file was procedurally generated from the following sources: +// - src/dflt-params/abrupt.case +// - src/dflt-params/error/cls-expr-meth.template +/*--- +description: Abrupt completion returned by evaluation of initializer (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + 1. Let status be the result of performing IteratorBindingInitialization for + FormalsList using iteratorRecord and environment as the arguments. + 2. ReturnIfAbrupt(status). + 3. Return the result of performing IteratorBindingInitialization for + FormalParameter using iteratorRecord and environment as the arguments. +---*/ + +var callCount = 0; +var C = class { + method(_ = (function() { throw new Test262Error(); }())) { + + callCount = callCount + 1; + } +}; + +assert.throws(Test262Error, function() { + C.prototype.method(); +}); +assert.sameValue(callCount, 0, 'method body not evaluated'); diff --git a/test/language/expressions/class/params-dflt-meth-arg-val-not-undefined.js b/test/language/expressions/class/params-dflt-meth-arg-val-not-undefined.js new file mode 100644 index 0000000000..792198b412 --- /dev/null +++ b/test/language/expressions/class/params-dflt-meth-arg-val-not-undefined.js @@ -0,0 +1,105 @@ +// This file was procedurally generated from the following sources: +// - src/dflt-params/arg-val-not-undefined.case +// - src/dflt-params/default/cls-expr-meth.template +/*--- +description: Use of intializer when argument value is not `undefined` (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + [...] + 23. Let iteratorRecord be Record {[[Iterator]]: + CreateListIterator(argumentsList), [[Done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + a. Perform ? IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var obj = {}; +var falseCount = 0; +var stringCount = 0; +var nanCount = 0; +var zeroCount = 0; +var nullCount = 0; +var objCount = 0; + +var callCount = 0; +var C = class { + method(aFalse = falseCount +=1, aString = stringCount += 1, aNaN = nanCount += 1, a0 = zeroCount += 1, aNull = nullCount += 1, aObj = objCount +=1) { + assert.sameValue(aFalse, false); + assert.sameValue(aString, ''); + assert.sameValue(aNaN, NaN); + assert.sameValue(a0, 0); + assert.sameValue(aNull, null); + assert.sameValue(aObj, obj); + callCount = callCount + 1; + } +}; + +C.prototype.method(false, '', NaN, 0, null, obj); + +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +assert.sameValue(falseCount, 0, 'initializer not evaluated: false'); +assert.sameValue(stringCount, 0, 'initializer not evaluated: string'); +assert.sameValue(nanCount, 0, 'initializer not evaluated: NaN'); +assert.sameValue(zeroCount, 0, 'initializer not evaluated: 0'); +assert.sameValue(nullCount, 0, 'initializer not evaluated: null'); +assert.sameValue(objCount, 0, 'initializer not evaluated: object'); diff --git a/test/language/expressions/class/params-dflt-meth-arg-val-undefined.js b/test/language/expressions/class/params-dflt-meth-arg-val-undefined.js new file mode 100644 index 0000000000..e9a40bd677 --- /dev/null +++ b/test/language/expressions/class/params-dflt-meth-arg-val-undefined.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dflt-params/arg-val-undefined.case +// - src/dflt-params/default/cls-expr-meth.template +/*--- +description: Use of intializer when argument value is `undefined` (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + [...] + 23. Let iteratorRecord be Record {[[Iterator]]: + CreateListIterator(argumentsList), [[Done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + a. Perform ? IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +var callCount = 0; +var C = class { + method(fromLiteral = 23, fromExpr = 45, fromHole = 99) { + assert.sameValue(fromLiteral, 23); + assert.sameValue(fromExpr, 45); + assert.sameValue(fromHole, 99); + callCount = callCount + 1; + } +}; + +C.prototype.method(undefined, void 0); + +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/params-dflt-meth-duplicates.js b/test/language/expressions/class/params-dflt-meth-duplicates.js new file mode 100644 index 0000000000..d7f7bf30ce --- /dev/null +++ b/test/language/expressions/class/params-dflt-meth-duplicates.js @@ -0,0 +1,80 @@ +// This file was procedurally generated from the following sources: +// - src/dflt-params/duplicates.case +// - src/dflt-params/syntax/cls-expr-meth.template +/*--- +description: It is a Syntax Error if BoundNames of FormalParameters contains any duplicate elements. (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [default-parameters] +flags: [generated] +negative: SyntaxError +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.2 Static Semantics: Early Errors + + StrictFormalParameters : FormalParameters + + - It is a Syntax Error if BoundNames of FormalParameters contains any + duplicate elements. + + FormalParameters : FormalParameterList + + - It is a Syntax Error if IsSimpleParameterList of FormalParameterList is + false and BoundNames of FormalParameterList contains any duplicate + elements. +---*/ + +0, class { + method(x = 0, x) { + + } +}; diff --git a/test/language/expressions/class/params-dflt-meth-ref-later.js b/test/language/expressions/class/params-dflt-meth-ref-later.js new file mode 100644 index 0000000000..ca04f536dc --- /dev/null +++ b/test/language/expressions/class/params-dflt-meth-ref-later.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dflt-params/ref-later.case +// - src/dflt-params/error/cls-expr-meth.template +/*--- +description: Referencing a parameter that occurs later in the ParameterList (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + 1. Let status be the result of performing IteratorBindingInitialization for + FormalsList using iteratorRecord and environment as the arguments. + 2. ReturnIfAbrupt(status). + 3. Return the result of performing IteratorBindingInitialization for + FormalParameter using iteratorRecord and environment as the arguments. +---*/ +var x = 0; + +var callCount = 0; +var C = class { + method(x = y, y) { + + callCount = callCount + 1; + } +}; + +assert.throws(ReferenceError, function() { + C.prototype.method(); +}); +assert.sameValue(callCount, 0, 'method body not evaluated'); diff --git a/test/language/expressions/class/params-dflt-meth-ref-prior.js b/test/language/expressions/class/params-dflt-meth-ref-prior.js new file mode 100644 index 0000000000..eceb7cd01c --- /dev/null +++ b/test/language/expressions/class/params-dflt-meth-ref-prior.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dflt-params/ref-prior.case +// - src/dflt-params/default/cls-expr-meth.template +/*--- +description: Referencing a parameter that occurs earlier in the ParameterList (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + 1. Let status be the result of performing IteratorBindingInitialization for + FormalsList using iteratorRecord and environment as the arguments. + 2. ReturnIfAbrupt(status). + 3. Return the result of performing IteratorBindingInitialization for + FormalParameter using iteratorRecord and environment as the arguments. +---*/ +var x = 0; + +var callCount = 0; +var C = class { + method(x, y = x, z = y) { + assert.sameValue(x, 3, 'first argument value'); + assert.sameValue(y, 3, 'second argument value'); + assert.sameValue(z, 3, 'third argument value'); + callCount = callCount + 1; + } +}; + +C.prototype.method(3); + +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/params-dflt-meth-ref-self.js b/test/language/expressions/class/params-dflt-meth-ref-self.js new file mode 100644 index 0000000000..7ec1a9bb96 --- /dev/null +++ b/test/language/expressions/class/params-dflt-meth-ref-self.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dflt-params/ref-self.case +// - src/dflt-params/error/cls-expr-meth.template +/*--- +description: Referencing a parameter from within its own initializer (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [default-parameters] +flags: [generated] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + 1. Let status be the result of performing IteratorBindingInitialization for + FormalsList using iteratorRecord and environment as the arguments. + 2. ReturnIfAbrupt(status). + 3. Return the result of performing IteratorBindingInitialization for + FormalParameter using iteratorRecord and environment as the arguments. +---*/ +var x = 0; + +var callCount = 0; +var C = class { + method(x = x) { + + callCount = callCount + 1; + } +}; + +assert.throws(ReferenceError, function() { + C.prototype.method(); +}); +assert.sameValue(callCount, 0, 'method body not evaluated'); diff --git a/test/language/expressions/class/params-dflt-meth-rest.js b/test/language/expressions/class/params-dflt-meth-rest.js new file mode 100644 index 0000000000..20e2a79ec3 --- /dev/null +++ b/test/language/expressions/class/params-dflt-meth-rest.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dflt-params/rest.case +// - src/dflt-params/syntax/cls-expr-meth.template +/*--- +description: RestParameter does not support an initializer (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [default-parameters] +flags: [generated] +negative: SyntaxError +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1 Function Definitions + + Syntax + + FunctionRestParameter[Yield] : + + BindingRestElement[?Yield] + + 13.3.3 Destructuring Binding Patterns + + Syntax + + BindingRestElement[Yield] : + + ...BindingIdentifier[?Yield] + ...BindingPattern[?Yield] + +---*/ + +0, class { + method(...x = []) { + + } +}; diff --git a/test/language/expressions/class/params-dflt-meth-static-abrupt.js b/test/language/expressions/class/params-dflt-meth-static-abrupt.js new file mode 100644 index 0000000000..4c7724491f --- /dev/null +++ b/test/language/expressions/class/params-dflt-meth-static-abrupt.js @@ -0,0 +1,83 @@ +// This file was procedurally generated from the following sources: +// - src/dflt-params/abrupt.case +// - src/dflt-params/error/cls-expr-meth-static.template +/*--- +description: Abrupt completion returned by evaluation of initializer (static class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + 1. Let status be the result of performing IteratorBindingInitialization for + FormalsList using iteratorRecord and environment as the arguments. + 2. ReturnIfAbrupt(status). + 3. Return the result of performing IteratorBindingInitialization for + FormalParameter using iteratorRecord and environment as the arguments. +---*/ + +var callCount = 0; +var C = class { + static method(_ = (function() { throw new Test262Error(); }())) { + + callCount = callCount + 1; + } +}; + +assert.throws(Test262Error, function() { + C.method(); +}); +assert.sameValue(callCount, 0, 'method body not evaluated'); diff --git a/test/language/expressions/class/params-dflt-meth-static-arg-val-not-undefined.js b/test/language/expressions/class/params-dflt-meth-static-arg-val-not-undefined.js new file mode 100644 index 0000000000..5a0a0c52d6 --- /dev/null +++ b/test/language/expressions/class/params-dflt-meth-static-arg-val-not-undefined.js @@ -0,0 +1,105 @@ +// This file was procedurally generated from the following sources: +// - src/dflt-params/arg-val-not-undefined.case +// - src/dflt-params/default/cls-expr-meth-static.template +/*--- +description: Use of intializer when argument value is not `undefined` (static class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + [...] + 23. Let iteratorRecord be Record {[[Iterator]]: + CreateListIterator(argumentsList), [[Done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + a. Perform ? IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var obj = {}; +var falseCount = 0; +var stringCount = 0; +var nanCount = 0; +var zeroCount = 0; +var nullCount = 0; +var objCount = 0; + +var callCount = 0; +var C = class { + static method(aFalse = falseCount +=1, aString = stringCount += 1, aNaN = nanCount += 1, a0 = zeroCount += 1, aNull = nullCount += 1, aObj = objCount +=1) { + assert.sameValue(aFalse, false); + assert.sameValue(aString, ''); + assert.sameValue(aNaN, NaN); + assert.sameValue(a0, 0); + assert.sameValue(aNull, null); + assert.sameValue(aObj, obj); + callCount = callCount + 1; + } +}; + +C.method(false, '', NaN, 0, null, obj); + +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +assert.sameValue(falseCount, 0, 'initializer not evaluated: false'); +assert.sameValue(stringCount, 0, 'initializer not evaluated: string'); +assert.sameValue(nanCount, 0, 'initializer not evaluated: NaN'); +assert.sameValue(zeroCount, 0, 'initializer not evaluated: 0'); +assert.sameValue(nullCount, 0, 'initializer not evaluated: null'); +assert.sameValue(objCount, 0, 'initializer not evaluated: object'); diff --git a/test/language/expressions/class/params-dflt-meth-static-arg-val-undefined.js b/test/language/expressions/class/params-dflt-meth-static-arg-val-undefined.js new file mode 100644 index 0000000000..13ac0287fe --- /dev/null +++ b/test/language/expressions/class/params-dflt-meth-static-arg-val-undefined.js @@ -0,0 +1,88 @@ +// This file was procedurally generated from the following sources: +// - src/dflt-params/arg-val-undefined.case +// - src/dflt-params/default/cls-expr-meth-static.template +/*--- +description: Use of intializer when argument value is `undefined` (static class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + [...] + 23. Let iteratorRecord be Record {[[Iterator]]: + CreateListIterator(argumentsList), [[Done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + a. Perform ? IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +var callCount = 0; +var C = class { + static method(fromLiteral = 23, fromExpr = 45, fromHole = 99) { + assert.sameValue(fromLiteral, 23); + assert.sameValue(fromExpr, 45); + assert.sameValue(fromHole, 99); + callCount = callCount + 1; + } +}; + +C.method(undefined, void 0); + +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/params-dflt-meth-static-duplicates.js b/test/language/expressions/class/params-dflt-meth-static-duplicates.js new file mode 100644 index 0000000000..6d68a6a053 --- /dev/null +++ b/test/language/expressions/class/params-dflt-meth-static-duplicates.js @@ -0,0 +1,80 @@ +// This file was procedurally generated from the following sources: +// - src/dflt-params/duplicates.case +// - src/dflt-params/syntax/cls-expr-meth-static.template +/*--- +description: It is a Syntax Error if BoundNames of FormalParameters contains any duplicate elements. (static class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [default-parameters] +flags: [generated] +negative: SyntaxError +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.2 Static Semantics: Early Errors + + StrictFormalParameters : FormalParameters + + - It is a Syntax Error if BoundNames of FormalParameters contains any + duplicate elements. + + FormalParameters : FormalParameterList + + - It is a Syntax Error if IsSimpleParameterList of FormalParameterList is + false and BoundNames of FormalParameterList contains any duplicate + elements. +---*/ + +0, class { + static method(x = 0, x) { + + } +}; diff --git a/test/language/expressions/class/params-dflt-meth-static-ref-later.js b/test/language/expressions/class/params-dflt-meth-static-ref-later.js new file mode 100644 index 0000000000..a28ef9f809 --- /dev/null +++ b/test/language/expressions/class/params-dflt-meth-static-ref-later.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dflt-params/ref-later.case +// - src/dflt-params/error/cls-expr-meth-static.template +/*--- +description: Referencing a parameter that occurs later in the ParameterList (static class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + 1. Let status be the result of performing IteratorBindingInitialization for + FormalsList using iteratorRecord and environment as the arguments. + 2. ReturnIfAbrupt(status). + 3. Return the result of performing IteratorBindingInitialization for + FormalParameter using iteratorRecord and environment as the arguments. +---*/ +var x = 0; + +var callCount = 0; +var C = class { + static method(x = y, y) { + + callCount = callCount + 1; + } +}; + +assert.throws(ReferenceError, function() { + C.method(); +}); +assert.sameValue(callCount, 0, 'method body not evaluated'); diff --git a/test/language/expressions/class/params-dflt-meth-static-ref-prior.js b/test/language/expressions/class/params-dflt-meth-static-ref-prior.js new file mode 100644 index 0000000000..cf8be79437 --- /dev/null +++ b/test/language/expressions/class/params-dflt-meth-static-ref-prior.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dflt-params/ref-prior.case +// - src/dflt-params/default/cls-expr-meth-static.template +/*--- +description: Referencing a parameter that occurs earlier in the ParameterList (static class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + 1. Let status be the result of performing IteratorBindingInitialization for + FormalsList using iteratorRecord and environment as the arguments. + 2. ReturnIfAbrupt(status). + 3. Return the result of performing IteratorBindingInitialization for + FormalParameter using iteratorRecord and environment as the arguments. +---*/ +var x = 0; + +var callCount = 0; +var C = class { + static method(x, y = x, z = y) { + assert.sameValue(x, 3, 'first argument value'); + assert.sameValue(y, 3, 'second argument value'); + assert.sameValue(z, 3, 'third argument value'); + callCount = callCount + 1; + } +}; + +C.method(3); + +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/params-dflt-meth-static-ref-self.js b/test/language/expressions/class/params-dflt-meth-static-ref-self.js new file mode 100644 index 0000000000..93a1ad3252 --- /dev/null +++ b/test/language/expressions/class/params-dflt-meth-static-ref-self.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dflt-params/ref-self.case +// - src/dflt-params/error/cls-expr-meth-static.template +/*--- +description: Referencing a parameter from within its own initializer (static class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + 1. Let status be the result of performing IteratorBindingInitialization for + FormalsList using iteratorRecord and environment as the arguments. + 2. ReturnIfAbrupt(status). + 3. Return the result of performing IteratorBindingInitialization for + FormalParameter using iteratorRecord and environment as the arguments. +---*/ +var x = 0; + +var callCount = 0; +var C = class { + static method(x = x) { + + callCount = callCount + 1; + } +}; + +assert.throws(ReferenceError, function() { + C.method(); +}); +assert.sameValue(callCount, 0, 'method body not evaluated'); diff --git a/test/language/expressions/class/params-dflt-meth-static-rest.js b/test/language/expressions/class/params-dflt-meth-static-rest.js new file mode 100644 index 0000000000..1772004b57 --- /dev/null +++ b/test/language/expressions/class/params-dflt-meth-static-rest.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dflt-params/rest.case +// - src/dflt-params/syntax/cls-expr-meth-static.template +/*--- +description: RestParameter does not support an initializer (static class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [default-parameters] +flags: [generated] +negative: SyntaxError +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1 Function Definitions + + Syntax + + FunctionRestParameter[Yield] : + + BindingRestElement[?Yield] + + 13.3.3 Destructuring Binding Patterns + + Syntax + + BindingRestElement[Yield] : + + ...BindingIdentifier[?Yield] + ...BindingPattern[?Yield] + +---*/ + +0, class { + static method(...x = []) { + + } +}; diff --git a/test/language/expressions/function/params-dflt-abrupt.js b/test/language/expressions/function/params-dflt-abrupt.js new file mode 100644 index 0000000000..8fbc1c7fd6 --- /dev/null +++ b/test/language/expressions/function/params-dflt-abrupt.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dflt-params/abrupt.case +// - src/dflt-params/error/func-expr.template +/*--- +description: Abrupt completion returned by evaluation of initializer (function expression) +esid: sec-function-definitions-runtime-semantics-evaluation +es6id: 14.1.20 +features: [default-parameters] +flags: [generated] +info: | + FunctionExpression : function ( FormalParameters ) { FunctionBody } + + [...] + 3. Let closure be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + 1. Let status be the result of performing IteratorBindingInitialization for + FormalsList using iteratorRecord and environment as the arguments. + 2. ReturnIfAbrupt(status). + 3. Return the result of performing IteratorBindingInitialization for + FormalParameter using iteratorRecord and environment as the arguments. +---*/ + +var callCount = 0; +var f; +f = function(_ = (function() { throw new Test262Error(); }())) { + + callCount = callCount + 1; +}; + +assert.throws(Test262Error, function() { + f(); +}); +assert.sameValue(callCount, 0, 'function body not evaluated'); diff --git a/test/language/expressions/function/params-dflt-arg-val-not-undefined.js b/test/language/expressions/function/params-dflt-arg-val-not-undefined.js new file mode 100644 index 0000000000..3a1604d8b3 --- /dev/null +++ b/test/language/expressions/function/params-dflt-arg-val-not-undefined.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dflt-params/arg-val-not-undefined.case +// - src/dflt-params/default/func-expr.template +/*--- +description: Use of intializer when argument value is not `undefined` (function expression) +esid: sec-function-definitions-runtime-semantics-evaluation +es6id: 14.1.20 +features: [default-parameters] +flags: [generated] +info: | + FunctionExpression : function ( FormalParameters ) { FunctionBody } + + [...] + 3. Let closure be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + [...] + 23. Let iteratorRecord be Record {[[Iterator]]: + CreateListIterator(argumentsList), [[Done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + a. Perform ? IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var obj = {}; +var falseCount = 0; +var stringCount = 0; +var nanCount = 0; +var zeroCount = 0; +var nullCount = 0; +var objCount = 0; + +var callCount = 0; +var f; +f = function(aFalse = falseCount +=1, aString = stringCount += 1, aNaN = nanCount += 1, a0 = zeroCount += 1, aNull = nullCount += 1, aObj = objCount +=1) { + assert.sameValue(aFalse, false); + assert.sameValue(aString, ''); + assert.sameValue(aNaN, NaN); + assert.sameValue(a0, 0); + assert.sameValue(aNull, null); + assert.sameValue(aObj, obj); + callCount = callCount + 1; +}; + +f(false, '', NaN, 0, null, obj); + +assert.sameValue(callCount, 1, 'function invoked exactly once'); + +assert.sameValue(falseCount, 0, 'initializer not evaluated: false'); +assert.sameValue(stringCount, 0, 'initializer not evaluated: string'); +assert.sameValue(nanCount, 0, 'initializer not evaluated: NaN'); +assert.sameValue(zeroCount, 0, 'initializer not evaluated: 0'); +assert.sameValue(nullCount, 0, 'initializer not evaluated: null'); +assert.sameValue(objCount, 0, 'initializer not evaluated: object'); diff --git a/test/language/expressions/function/params-dflt-arg-val-undefined.js b/test/language/expressions/function/params-dflt-arg-val-undefined.js new file mode 100644 index 0000000000..cec9fa0a13 --- /dev/null +++ b/test/language/expressions/function/params-dflt-arg-val-undefined.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dflt-params/arg-val-undefined.case +// - src/dflt-params/default/func-expr.template +/*--- +description: Use of intializer when argument value is `undefined` (function expression) +esid: sec-function-definitions-runtime-semantics-evaluation +es6id: 14.1.20 +features: [default-parameters] +flags: [generated] +info: | + FunctionExpression : function ( FormalParameters ) { FunctionBody } + + [...] + 3. Let closure be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + [...] + 23. Let iteratorRecord be Record {[[Iterator]]: + CreateListIterator(argumentsList), [[Done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + a. Perform ? IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +var callCount = 0; +var f; +f = function(fromLiteral = 23, fromExpr = 45, fromHole = 99) { + assert.sameValue(fromLiteral, 23); + assert.sameValue(fromExpr, 45); + assert.sameValue(fromHole, 99); + callCount = callCount + 1; +}; + +f(undefined, void 0); + +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/expressions/function/params-dflt-duplicates.js b/test/language/expressions/function/params-dflt-duplicates.js new file mode 100644 index 0000000000..2d98b532f7 --- /dev/null +++ b/test/language/expressions/function/params-dflt-duplicates.js @@ -0,0 +1,58 @@ +// This file was procedurally generated from the following sources: +// - src/dflt-params/duplicates.case +// - src/dflt-params/syntax/func-expr.template +/*--- +description: It is a Syntax Error if BoundNames of FormalParameters contains any duplicate elements. (function expression) +esid: sec-function-definitions-runtime-semantics-evaluation +es6id: 14.1.20 +features: [default-parameters] +flags: [generated] +negative: SyntaxError +info: | + FunctionExpression : function ( FormalParameters ) { FunctionBody } + + [...] + 3. Let closure be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.2 Static Semantics: Early Errors + + StrictFormalParameters : FormalParameters + + - It is a Syntax Error if BoundNames of FormalParameters contains any + duplicate elements. + + FormalParameters : FormalParameterList + + - It is a Syntax Error if IsSimpleParameterList of FormalParameterList is + false and BoundNames of FormalParameterList contains any duplicate + elements. +---*/ + +0, function(x = 0, x) { + +}; diff --git a/test/language/expressions/function/params-dflt-ref-later.js b/test/language/expressions/function/params-dflt-ref-later.js new file mode 100644 index 0000000000..0e1122a564 --- /dev/null +++ b/test/language/expressions/function/params-dflt-ref-later.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dflt-params/ref-later.case +// - src/dflt-params/error/func-expr.template +/*--- +description: Referencing a parameter that occurs later in the ParameterList (function expression) +esid: sec-function-definitions-runtime-semantics-evaluation +es6id: 14.1.20 +features: [default-parameters] +flags: [generated] +info: | + FunctionExpression : function ( FormalParameters ) { FunctionBody } + + [...] + 3. Let closure be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + 1. Let status be the result of performing IteratorBindingInitialization for + FormalsList using iteratorRecord and environment as the arguments. + 2. ReturnIfAbrupt(status). + 3. Return the result of performing IteratorBindingInitialization for + FormalParameter using iteratorRecord and environment as the arguments. +---*/ +var x = 0; + +var callCount = 0; +var f; +f = function(x = y, y) { + + callCount = callCount + 1; +}; + +assert.throws(ReferenceError, function() { + f(); +}); +assert.sameValue(callCount, 0, 'function body not evaluated'); diff --git a/test/language/expressions/function/params-dflt-ref-prior.js b/test/language/expressions/function/params-dflt-ref-prior.js new file mode 100644 index 0000000000..0d6619d5ca --- /dev/null +++ b/test/language/expressions/function/params-dflt-ref-prior.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dflt-params/ref-prior.case +// - src/dflt-params/default/func-expr.template +/*--- +description: Referencing a parameter that occurs earlier in the ParameterList (function expression) +esid: sec-function-definitions-runtime-semantics-evaluation +es6id: 14.1.20 +features: [default-parameters] +flags: [generated] +info: | + FunctionExpression : function ( FormalParameters ) { FunctionBody } + + [...] + 3. Let closure be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + 1. Let status be the result of performing IteratorBindingInitialization for + FormalsList using iteratorRecord and environment as the arguments. + 2. ReturnIfAbrupt(status). + 3. Return the result of performing IteratorBindingInitialization for + FormalParameter using iteratorRecord and environment as the arguments. +---*/ +var x = 0; + +var callCount = 0; +var f; +f = function(x, y = x, z = y) { + assert.sameValue(x, 3, 'first argument value'); + assert.sameValue(y, 3, 'second argument value'); + assert.sameValue(z, 3, 'third argument value'); + callCount = callCount + 1; +}; + +f(3); + +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/expressions/function/params-dflt-ref-self.js b/test/language/expressions/function/params-dflt-ref-self.js new file mode 100644 index 0000000000..0e1f974f27 --- /dev/null +++ b/test/language/expressions/function/params-dflt-ref-self.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dflt-params/ref-self.case +// - src/dflt-params/error/func-expr.template +/*--- +description: Referencing a parameter from within its own initializer (function expression) +esid: sec-function-definitions-runtime-semantics-evaluation +es6id: 14.1.20 +features: [default-parameters] +flags: [generated] +info: | + FunctionExpression : function ( FormalParameters ) { FunctionBody } + + [...] + 3. Let closure be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + 1. Let status be the result of performing IteratorBindingInitialization for + FormalsList using iteratorRecord and environment as the arguments. + 2. ReturnIfAbrupt(status). + 3. Return the result of performing IteratorBindingInitialization for + FormalParameter using iteratorRecord and environment as the arguments. +---*/ +var x = 0; + +var callCount = 0; +var f; +f = function(x = x) { + + callCount = callCount + 1; +}; + +assert.throws(ReferenceError, function() { + f(); +}); +assert.sameValue(callCount, 0, 'function body not evaluated'); diff --git a/test/language/expressions/function/params-dflt-rest.js b/test/language/expressions/function/params-dflt-rest.js new file mode 100644 index 0000000000..9c837d7eca --- /dev/null +++ b/test/language/expressions/function/params-dflt-rest.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dflt-params/rest.case +// - src/dflt-params/syntax/func-expr.template +/*--- +description: RestParameter does not support an initializer (function expression) +esid: sec-function-definitions-runtime-semantics-evaluation +es6id: 14.1.20 +features: [default-parameters] +flags: [generated] +negative: SyntaxError +info: | + FunctionExpression : function ( FormalParameters ) { FunctionBody } + + [...] + 3. Let closure be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1 Function Definitions + + Syntax + + FunctionRestParameter[Yield] : + + BindingRestElement[?Yield] + + 13.3.3 Destructuring Binding Patterns + + Syntax + + BindingRestElement[Yield] : + + ...BindingIdentifier[?Yield] + ...BindingPattern[?Yield] + +---*/ + +0, function(...x = []) { + +}; diff --git a/test/language/expressions/generators/params-dflt-abrupt.js b/test/language/expressions/generators/params-dflt-abrupt.js new file mode 100644 index 0000000000..ed1b7d6191 --- /dev/null +++ b/test/language/expressions/generators/params-dflt-abrupt.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dflt-params/abrupt.case +// - src/dflt-params/error/gen-func-expr.template +/*--- +description: Abrupt completion returned by evaluation of initializer (generator function expression) +esid: sec-generator-function-definitions-runtime-semantics-evaluation +es6id: 14.4.14 +features: [default-parameters] +flags: [generated] +info: | + GeneratorExpression : function * ( FormalParameters ) { GeneratorBody } + + [...] + 3. Let closure be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + 1. Let status be the result of performing IteratorBindingInitialization for + FormalsList using iteratorRecord and environment as the arguments. + 2. ReturnIfAbrupt(status). + 3. Return the result of performing IteratorBindingInitialization for + FormalParameter using iteratorRecord and environment as the arguments. +---*/ + +var callCount = 0; +var f; +f = function*(_ = (function() { throw new Test262Error(); }())) { + + callCount = callCount + 1; +}; + +assert.throws(Test262Error, function() { + f(); +}); +assert.sameValue(callCount, 0, 'generator function body not evaluated'); diff --git a/test/language/expressions/generators/params-dflt-arg-val-not-undefined.js b/test/language/expressions/generators/params-dflt-arg-val-not-undefined.js new file mode 100644 index 0000000000..7761519475 --- /dev/null +++ b/test/language/expressions/generators/params-dflt-arg-val-not-undefined.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dflt-params/arg-val-not-undefined.case +// - src/dflt-params/default/gen-func-expr.template +/*--- +description: Use of intializer when argument value is not `undefined` (generator function expression) +esid: sec-generator-function-definitions-runtime-semantics-evaluation +es6id: 14.4.14 +features: [default-parameters] +flags: [generated] +info: | + GeneratorExpression : function * ( FormalParameters ) { GeneratorBody } + + [...] + 3. Let closure be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + [...] + 23. Let iteratorRecord be Record {[[Iterator]]: + CreateListIterator(argumentsList), [[Done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + a. Perform ? IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var obj = {}; +var falseCount = 0; +var stringCount = 0; +var nanCount = 0; +var zeroCount = 0; +var nullCount = 0; +var objCount = 0; + +var callCount = 0; +var f; +f = function*(aFalse = falseCount +=1, aString = stringCount += 1, aNaN = nanCount += 1, a0 = zeroCount += 1, aNull = nullCount += 1, aObj = objCount +=1) { + assert.sameValue(aFalse, false); + assert.sameValue(aString, ''); + assert.sameValue(aNaN, NaN); + assert.sameValue(a0, 0); + assert.sameValue(aNull, null); + assert.sameValue(aObj, obj); + callCount = callCount + 1; +}; + +f(false, '', NaN, 0, null, obj).next(); + +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); + +assert.sameValue(falseCount, 0, 'initializer not evaluated: false'); +assert.sameValue(stringCount, 0, 'initializer not evaluated: string'); +assert.sameValue(nanCount, 0, 'initializer not evaluated: NaN'); +assert.sameValue(zeroCount, 0, 'initializer not evaluated: 0'); +assert.sameValue(nullCount, 0, 'initializer not evaluated: null'); +assert.sameValue(objCount, 0, 'initializer not evaluated: object'); diff --git a/test/language/expressions/generators/params-dflt-arg-val-undefined.js b/test/language/expressions/generators/params-dflt-arg-val-undefined.js new file mode 100644 index 0000000000..9c1802394d --- /dev/null +++ b/test/language/expressions/generators/params-dflt-arg-val-undefined.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dflt-params/arg-val-undefined.case +// - src/dflt-params/default/gen-func-expr.template +/*--- +description: Use of intializer when argument value is `undefined` (generator function expression) +esid: sec-generator-function-definitions-runtime-semantics-evaluation +es6id: 14.4.14 +features: [default-parameters] +flags: [generated] +info: | + GeneratorExpression : function * ( FormalParameters ) { GeneratorBody } + + [...] + 3. Let closure be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + [...] + 23. Let iteratorRecord be Record {[[Iterator]]: + CreateListIterator(argumentsList), [[Done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + a. Perform ? IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +var callCount = 0; +var f; +f = function*(fromLiteral = 23, fromExpr = 45, fromHole = 99) { + assert.sameValue(fromLiteral, 23); + assert.sameValue(fromExpr, 45); + assert.sameValue(fromHole, 99); + callCount = callCount + 1; +}; + +f(undefined, void 0).next(); + +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/expressions/generators/params-dflt-duplicates.js b/test/language/expressions/generators/params-dflt-duplicates.js new file mode 100644 index 0000000000..e3f678e6de --- /dev/null +++ b/test/language/expressions/generators/params-dflt-duplicates.js @@ -0,0 +1,58 @@ +// This file was procedurally generated from the following sources: +// - src/dflt-params/duplicates.case +// - src/dflt-params/syntax/gen-func-expr.template +/*--- +description: It is a Syntax Error if BoundNames of FormalParameters contains any duplicate elements. (generator function expression) +esid: sec-generator-function-definitions-runtime-semantics-evaluation +es6id: 14.4.14 +features: [default-parameters] +flags: [generated] +negative: SyntaxError +info: | + GeneratorExpression : function * ( FormalParameters ) { GeneratorBody } + + [...] + 3. Let closure be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.2 Static Semantics: Early Errors + + StrictFormalParameters : FormalParameters + + - It is a Syntax Error if BoundNames of FormalParameters contains any + duplicate elements. + + FormalParameters : FormalParameterList + + - It is a Syntax Error if IsSimpleParameterList of FormalParameterList is + false and BoundNames of FormalParameterList contains any duplicate + elements. +---*/ + +0, function*(x = 0, x) { + +}; diff --git a/test/language/expressions/generators/params-dflt-ref-later.js b/test/language/expressions/generators/params-dflt-ref-later.js new file mode 100644 index 0000000000..14d668116e --- /dev/null +++ b/test/language/expressions/generators/params-dflt-ref-later.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dflt-params/ref-later.case +// - src/dflt-params/error/gen-func-expr.template +/*--- +description: Referencing a parameter that occurs later in the ParameterList (generator function expression) +esid: sec-generator-function-definitions-runtime-semantics-evaluation +es6id: 14.4.14 +features: [default-parameters] +flags: [generated] +info: | + GeneratorExpression : function * ( FormalParameters ) { GeneratorBody } + + [...] + 3. Let closure be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + 1. Let status be the result of performing IteratorBindingInitialization for + FormalsList using iteratorRecord and environment as the arguments. + 2. ReturnIfAbrupt(status). + 3. Return the result of performing IteratorBindingInitialization for + FormalParameter using iteratorRecord and environment as the arguments. +---*/ +var x = 0; + +var callCount = 0; +var f; +f = function*(x = y, y) { + + callCount = callCount + 1; +}; + +assert.throws(ReferenceError, function() { + f(); +}); +assert.sameValue(callCount, 0, 'generator function body not evaluated'); diff --git a/test/language/expressions/generators/params-dflt-ref-prior.js b/test/language/expressions/generators/params-dflt-ref-prior.js new file mode 100644 index 0000000000..af750a8dcb --- /dev/null +++ b/test/language/expressions/generators/params-dflt-ref-prior.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dflt-params/ref-prior.case +// - src/dflt-params/default/gen-func-expr.template +/*--- +description: Referencing a parameter that occurs earlier in the ParameterList (generator function expression) +esid: sec-generator-function-definitions-runtime-semantics-evaluation +es6id: 14.4.14 +features: [default-parameters] +flags: [generated] +info: | + GeneratorExpression : function * ( FormalParameters ) { GeneratorBody } + + [...] + 3. Let closure be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + 1. Let status be the result of performing IteratorBindingInitialization for + FormalsList using iteratorRecord and environment as the arguments. + 2. ReturnIfAbrupt(status). + 3. Return the result of performing IteratorBindingInitialization for + FormalParameter using iteratorRecord and environment as the arguments. +---*/ +var x = 0; + +var callCount = 0; +var f; +f = function*(x, y = x, z = y) { + assert.sameValue(x, 3, 'first argument value'); + assert.sameValue(y, 3, 'second argument value'); + assert.sameValue(z, 3, 'third argument value'); + callCount = callCount + 1; +}; + +f(3).next(); + +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/expressions/generators/params-dflt-ref-self.js b/test/language/expressions/generators/params-dflt-ref-self.js new file mode 100644 index 0000000000..8cf2c9461c --- /dev/null +++ b/test/language/expressions/generators/params-dflt-ref-self.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dflt-params/ref-self.case +// - src/dflt-params/error/gen-func-expr.template +/*--- +description: Referencing a parameter from within its own initializer (generator function expression) +esid: sec-generator-function-definitions-runtime-semantics-evaluation +es6id: 14.4.14 +features: [default-parameters] +flags: [generated] +info: | + GeneratorExpression : function * ( FormalParameters ) { GeneratorBody } + + [...] + 3. Let closure be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + 1. Let status be the result of performing IteratorBindingInitialization for + FormalsList using iteratorRecord and environment as the arguments. + 2. ReturnIfAbrupt(status). + 3. Return the result of performing IteratorBindingInitialization for + FormalParameter using iteratorRecord and environment as the arguments. +---*/ +var x = 0; + +var callCount = 0; +var f; +f = function*(x = x) { + + callCount = callCount + 1; +}; + +assert.throws(ReferenceError, function() { + f(); +}); +assert.sameValue(callCount, 0, 'generator function body not evaluated'); diff --git a/test/language/expressions/generators/params-dflt-rest.js b/test/language/expressions/generators/params-dflt-rest.js new file mode 100644 index 0000000000..132b5c3ca7 --- /dev/null +++ b/test/language/expressions/generators/params-dflt-rest.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dflt-params/rest.case +// - src/dflt-params/syntax/gen-func-expr.template +/*--- +description: RestParameter does not support an initializer (generator function expression) +esid: sec-generator-function-definitions-runtime-semantics-evaluation +es6id: 14.4.14 +features: [default-parameters] +flags: [generated] +negative: SyntaxError +info: | + GeneratorExpression : function * ( FormalParameters ) { GeneratorBody } + + [...] + 3. Let closure be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1 Function Definitions + + Syntax + + FunctionRestParameter[Yield] : + + BindingRestElement[?Yield] + + 13.3.3 Destructuring Binding Patterns + + Syntax + + BindingRestElement[Yield] : + + ...BindingIdentifier[?Yield] + ...BindingPattern[?Yield] + +---*/ + +0, function*(...x = []) { + +}; diff --git a/test/language/expressions/object/method-definition/params-dflt-gen-meth-abrupt.js b/test/language/expressions/object/method-definition/params-dflt-gen-meth-abrupt.js new file mode 100644 index 0000000000..47af741479 --- /dev/null +++ b/test/language/expressions/object/method-definition/params-dflt-gen-meth-abrupt.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dflt-params/abrupt.case +// - src/dflt-params/error/gen-meth.template +/*--- +description: Abrupt completion returned by evaluation of initializer (generator method) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +es6id: 14.4.13 +features: [default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + 1. Let status be the result of performing IteratorBindingInitialization for + FormalsList using iteratorRecord and environment as the arguments. + 2. ReturnIfAbrupt(status). + 3. Return the result of performing IteratorBindingInitialization for + FormalParameter using iteratorRecord and environment as the arguments. +---*/ + +var callCount = 0; +var obj = { + *method(_ = (function() { throw new Test262Error(); }())) { + + callCount = callCount + 1; + } +}; + +assert.throws(Test262Error, function() { + obj.method(); +}); +assert.sameValue(callCount, 0, 'generator method body not evaluated'); diff --git a/test/language/expressions/object/method-definition/params-dflt-gen-meth-arg-val-not-undefined.js b/test/language/expressions/object/method-definition/params-dflt-gen-meth-arg-val-not-undefined.js new file mode 100644 index 0000000000..469ff9fb43 --- /dev/null +++ b/test/language/expressions/object/method-definition/params-dflt-gen-meth-arg-val-not-undefined.js @@ -0,0 +1,90 @@ +// This file was procedurally generated from the following sources: +// - src/dflt-params/arg-val-not-undefined.case +// - src/dflt-params/default/gen-meth.template +/*--- +description: Use of intializer when argument value is not `undefined` (generator method) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +es6id: 14.4.13 +features: [default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + [...] + 23. Let iteratorRecord be Record {[[Iterator]]: + CreateListIterator(argumentsList), [[Done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + a. Perform ? IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var obj = {}; +var falseCount = 0; +var stringCount = 0; +var nanCount = 0; +var zeroCount = 0; +var nullCount = 0; +var objCount = 0; + +var callCount = 0; +var obj = { + *method(aFalse = falseCount +=1, aString = stringCount += 1, aNaN = nanCount += 1, a0 = zeroCount += 1, aNull = nullCount += 1, aObj = objCount +=1) { + assert.sameValue(aFalse, false); + assert.sameValue(aString, ''); + assert.sameValue(aNaN, NaN); + assert.sameValue(a0, 0); + assert.sameValue(aNull, null); + assert.sameValue(aObj, obj); + callCount = callCount + 1; + } +}; + +obj.method(false, '', NaN, 0, null, obj).next(); + +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); + +assert.sameValue(falseCount, 0, 'initializer not evaluated: false'); +assert.sameValue(stringCount, 0, 'initializer not evaluated: string'); +assert.sameValue(nanCount, 0, 'initializer not evaluated: NaN'); +assert.sameValue(zeroCount, 0, 'initializer not evaluated: 0'); +assert.sameValue(nullCount, 0, 'initializer not evaluated: null'); +assert.sameValue(objCount, 0, 'initializer not evaluated: object'); diff --git a/test/language/expressions/object/method-definition/params-dflt-gen-meth-arg-val-undefined.js b/test/language/expressions/object/method-definition/params-dflt-gen-meth-arg-val-undefined.js new file mode 100644 index 0000000000..6ad5e3af25 --- /dev/null +++ b/test/language/expressions/object/method-definition/params-dflt-gen-meth-arg-val-undefined.js @@ -0,0 +1,73 @@ +// This file was procedurally generated from the following sources: +// - src/dflt-params/arg-val-undefined.case +// - src/dflt-params/default/gen-meth.template +/*--- +description: Use of intializer when argument value is `undefined` (generator method) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +es6id: 14.4.13 +features: [default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + [...] + 23. Let iteratorRecord be Record {[[Iterator]]: + CreateListIterator(argumentsList), [[Done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + a. Perform ? IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +var callCount = 0; +var obj = { + *method(fromLiteral = 23, fromExpr = 45, fromHole = 99) { + assert.sameValue(fromLiteral, 23); + assert.sameValue(fromExpr, 45); + assert.sameValue(fromHole, 99); + callCount = callCount + 1; + } +}; + +obj.method(undefined, void 0).next(); + +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); diff --git a/test/language/expressions/object/method-definition/params-dflt-gen-meth-duplicates.js b/test/language/expressions/object/method-definition/params-dflt-gen-meth-duplicates.js new file mode 100644 index 0000000000..254363d98b --- /dev/null +++ b/test/language/expressions/object/method-definition/params-dflt-gen-meth-duplicates.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dflt-params/duplicates.case +// - src/dflt-params/syntax/gen-meth.template +/*--- +description: It is a Syntax Error if BoundNames of FormalParameters contains any duplicate elements. (generator method) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +es6id: 14.4.13 +features: [default-parameters] +flags: [generated] +negative: SyntaxError +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.2 Static Semantics: Early Errors + + StrictFormalParameters : FormalParameters + + - It is a Syntax Error if BoundNames of FormalParameters contains any + duplicate elements. + + FormalParameters : FormalParameterList + + - It is a Syntax Error if IsSimpleParameterList of FormalParameterList is + false and BoundNames of FormalParameterList contains any duplicate + elements. +---*/ + +0, { + *method(x = 0, x) { + + } +}; diff --git a/test/language/expressions/object/method-definition/params-dflt-gen-meth-ref-later.js b/test/language/expressions/object/method-definition/params-dflt-gen-meth-ref-later.js new file mode 100644 index 0000000000..d729ae01b1 --- /dev/null +++ b/test/language/expressions/object/method-definition/params-dflt-gen-meth-ref-later.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/dflt-params/ref-later.case +// - src/dflt-params/error/gen-meth.template +/*--- +description: Referencing a parameter that occurs later in the ParameterList (generator method) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +es6id: 14.4.13 +features: [default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + 1. Let status be the result of performing IteratorBindingInitialization for + FormalsList using iteratorRecord and environment as the arguments. + 2. ReturnIfAbrupt(status). + 3. Return the result of performing IteratorBindingInitialization for + FormalParameter using iteratorRecord and environment as the arguments. +---*/ +var x = 0; + +var callCount = 0; +var obj = { + *method(x = y, y) { + + callCount = callCount + 1; + } +}; + +assert.throws(ReferenceError, function() { + obj.method(); +}); +assert.sameValue(callCount, 0, 'generator method body not evaluated'); diff --git a/test/language/expressions/object/method-definition/params-dflt-gen-meth-ref-prior.js b/test/language/expressions/object/method-definition/params-dflt-gen-meth-ref-prior.js new file mode 100644 index 0000000000..c0b3ded9da --- /dev/null +++ b/test/language/expressions/object/method-definition/params-dflt-gen-meth-ref-prior.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/dflt-params/ref-prior.case +// - src/dflt-params/default/gen-meth.template +/*--- +description: Referencing a parameter that occurs earlier in the ParameterList (generator method) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +es6id: 14.4.13 +features: [default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + 1. Let status be the result of performing IteratorBindingInitialization for + FormalsList using iteratorRecord and environment as the arguments. + 2. ReturnIfAbrupt(status). + 3. Return the result of performing IteratorBindingInitialization for + FormalParameter using iteratorRecord and environment as the arguments. +---*/ +var x = 0; + +var callCount = 0; +var obj = { + *method(x, y = x, z = y) { + assert.sameValue(x, 3, 'first argument value'); + assert.sameValue(y, 3, 'second argument value'); + assert.sameValue(z, 3, 'third argument value'); + callCount = callCount + 1; + } +}; + +obj.method(3).next(); + +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); diff --git a/test/language/expressions/object/method-definition/params-dflt-gen-meth-ref-self.js b/test/language/expressions/object/method-definition/params-dflt-gen-meth-ref-self.js new file mode 100644 index 0000000000..2c0e653635 --- /dev/null +++ b/test/language/expressions/object/method-definition/params-dflt-gen-meth-ref-self.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/dflt-params/ref-self.case +// - src/dflt-params/error/gen-meth.template +/*--- +description: Referencing a parameter from within its own initializer (generator method) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +es6id: 14.4.13 +features: [default-parameters] +flags: [generated] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + 1. Let status be the result of performing IteratorBindingInitialization for + FormalsList using iteratorRecord and environment as the arguments. + 2. ReturnIfAbrupt(status). + 3. Return the result of performing IteratorBindingInitialization for + FormalParameter using iteratorRecord and environment as the arguments. +---*/ +var x = 0; + +var callCount = 0; +var obj = { + *method(x = x) { + + callCount = callCount + 1; + } +}; + +assert.throws(ReferenceError, function() { + obj.method(); +}); +assert.sameValue(callCount, 0, 'generator method body not evaluated'); diff --git a/test/language/expressions/object/method-definition/params-dflt-gen-meth-rest.js b/test/language/expressions/object/method-definition/params-dflt-gen-meth-rest.js new file mode 100644 index 0000000000..6e313f186e --- /dev/null +++ b/test/language/expressions/object/method-definition/params-dflt-gen-meth-rest.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/dflt-params/rest.case +// - src/dflt-params/syntax/gen-meth.template +/*--- +description: RestParameter does not support an initializer (generator method) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +es6id: 14.4.13 +features: [default-parameters] +flags: [generated] +negative: SyntaxError +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1 Function Definitions + + Syntax + + FunctionRestParameter[Yield] : + + BindingRestElement[?Yield] + + 13.3.3 Destructuring Binding Patterns + + Syntax + + BindingRestElement[Yield] : + + ...BindingIdentifier[?Yield] + ...BindingPattern[?Yield] + +---*/ + +0, { + *method(...x = []) { + + } +}; diff --git a/test/language/expressions/object/method-definition/params-dflt-meth-abrupt.js b/test/language/expressions/object/method-definition/params-dflt-meth-abrupt.js new file mode 100644 index 0000000000..ceea6067b7 --- /dev/null +++ b/test/language/expressions/object/method-definition/params-dflt-meth-abrupt.js @@ -0,0 +1,65 @@ +// This file was procedurally generated from the following sources: +// - src/dflt-params/abrupt.case +// - src/dflt-params/error/meth.template +/*--- +description: Abrupt completion returned by evaluation of initializer (method) +esid: sec-runtime-semantics-definemethod +es6id: 14.3.8 +features: [default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + 1. Let status be the result of performing IteratorBindingInitialization for + FormalsList using iteratorRecord and environment as the arguments. + 2. ReturnIfAbrupt(status). + 3. Return the result of performing IteratorBindingInitialization for + FormalParameter using iteratorRecord and environment as the arguments. +---*/ + +var callCount = 0; +var obj = { + method(_ = (function() { throw new Test262Error(); }())) { + + callCount = callCount + 1; + } +}; + +assert.throws(Test262Error, function() { + obj.method(); +}); +assert.sameValue(callCount, 0, 'method body not evaluated'); diff --git a/test/language/expressions/object/method-definition/params-dflt-meth-arg-val-not-undefined.js b/test/language/expressions/object/method-definition/params-dflt-meth-arg-val-not-undefined.js new file mode 100644 index 0000000000..4d8f4f3af7 --- /dev/null +++ b/test/language/expressions/object/method-definition/params-dflt-meth-arg-val-not-undefined.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dflt-params/arg-val-not-undefined.case +// - src/dflt-params/default/meth.template +/*--- +description: Use of intializer when argument value is not `undefined` (method) +esid: sec-runtime-semantics-definemethod +es6id: 14.3.8 +features: [default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + [...] + 23. Let iteratorRecord be Record {[[Iterator]]: + CreateListIterator(argumentsList), [[Done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + a. Perform ? IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var obj = {}; +var falseCount = 0; +var stringCount = 0; +var nanCount = 0; +var zeroCount = 0; +var nullCount = 0; +var objCount = 0; + +var callCount = 0; +var obj = { + method(aFalse = falseCount +=1, aString = stringCount += 1, aNaN = nanCount += 1, a0 = zeroCount += 1, aNull = nullCount += 1, aObj = objCount +=1) { + assert.sameValue(aFalse, false); + assert.sameValue(aString, ''); + assert.sameValue(aNaN, NaN); + assert.sameValue(a0, 0); + assert.sameValue(aNull, null); + assert.sameValue(aObj, obj); + callCount = callCount + 1; + } +}; + +obj.method(false, '', NaN, 0, null, obj); + +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +assert.sameValue(falseCount, 0, 'initializer not evaluated: false'); +assert.sameValue(stringCount, 0, 'initializer not evaluated: string'); +assert.sameValue(nanCount, 0, 'initializer not evaluated: NaN'); +assert.sameValue(zeroCount, 0, 'initializer not evaluated: 0'); +assert.sameValue(nullCount, 0, 'initializer not evaluated: null'); +assert.sameValue(objCount, 0, 'initializer not evaluated: object'); diff --git a/test/language/expressions/object/method-definition/params-dflt-meth-arg-val-undefined.js b/test/language/expressions/object/method-definition/params-dflt-meth-arg-val-undefined.js new file mode 100644 index 0000000000..c95f192e47 --- /dev/null +++ b/test/language/expressions/object/method-definition/params-dflt-meth-arg-val-undefined.js @@ -0,0 +1,70 @@ +// This file was procedurally generated from the following sources: +// - src/dflt-params/arg-val-undefined.case +// - src/dflt-params/default/meth.template +/*--- +description: Use of intializer when argument value is `undefined` (method) +esid: sec-runtime-semantics-definemethod +es6id: 14.3.8 +features: [default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + [...] + 23. Let iteratorRecord be Record {[[Iterator]]: + CreateListIterator(argumentsList), [[Done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + a. Perform ? IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +var callCount = 0; +var obj = { + method(fromLiteral = 23, fromExpr = 45, fromHole = 99) { + assert.sameValue(fromLiteral, 23); + assert.sameValue(fromExpr, 45); + assert.sameValue(fromHole, 99); + callCount = callCount + 1; + } +}; + +obj.method(undefined, void 0); + +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/object/method-definition/params-dflt-meth-duplicates.js b/test/language/expressions/object/method-definition/params-dflt-meth-duplicates.js new file mode 100644 index 0000000000..3f996e27d3 --- /dev/null +++ b/test/language/expressions/object/method-definition/params-dflt-meth-duplicates.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dflt-params/duplicates.case +// - src/dflt-params/syntax/meth.template +/*--- +description: It is a Syntax Error if BoundNames of FormalParameters contains any duplicate elements. (method) +esid: sec-runtime-semantics-definemethod +es6id: 14.3.8 +features: [default-parameters] +flags: [generated] +negative: SyntaxError +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.2 Static Semantics: Early Errors + + StrictFormalParameters : FormalParameters + + - It is a Syntax Error if BoundNames of FormalParameters contains any + duplicate elements. + + FormalParameters : FormalParameterList + + - It is a Syntax Error if IsSimpleParameterList of FormalParameterList is + false and BoundNames of FormalParameterList contains any duplicate + elements. +---*/ + +0, { + method(x = 0, x) { + + } +}; diff --git a/test/language/expressions/object/method-definition/params-dflt-meth-ref-later.js b/test/language/expressions/object/method-definition/params-dflt-meth-ref-later.js new file mode 100644 index 0000000000..e1fb94fbfd --- /dev/null +++ b/test/language/expressions/object/method-definition/params-dflt-meth-ref-later.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dflt-params/ref-later.case +// - src/dflt-params/error/meth.template +/*--- +description: Referencing a parameter that occurs later in the ParameterList (method) +esid: sec-runtime-semantics-definemethod +es6id: 14.3.8 +features: [default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + 1. Let status be the result of performing IteratorBindingInitialization for + FormalsList using iteratorRecord and environment as the arguments. + 2. ReturnIfAbrupt(status). + 3. Return the result of performing IteratorBindingInitialization for + FormalParameter using iteratorRecord and environment as the arguments. +---*/ +var x = 0; + +var callCount = 0; +var obj = { + method(x = y, y) { + + callCount = callCount + 1; + } +}; + +assert.throws(ReferenceError, function() { + obj.method(); +}); +assert.sameValue(callCount, 0, 'method body not evaluated'); diff --git a/test/language/expressions/object/method-definition/params-dflt-meth-ref-prior.js b/test/language/expressions/object/method-definition/params-dflt-meth-ref-prior.js new file mode 100644 index 0000000000..7b221b18d4 --- /dev/null +++ b/test/language/expressions/object/method-definition/params-dflt-meth-ref-prior.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dflt-params/ref-prior.case +// - src/dflt-params/default/meth.template +/*--- +description: Referencing a parameter that occurs earlier in the ParameterList (method) +esid: sec-runtime-semantics-definemethod +es6id: 14.3.8 +features: [default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + 1. Let status be the result of performing IteratorBindingInitialization for + FormalsList using iteratorRecord and environment as the arguments. + 2. ReturnIfAbrupt(status). + 3. Return the result of performing IteratorBindingInitialization for + FormalParameter using iteratorRecord and environment as the arguments. +---*/ +var x = 0; + +var callCount = 0; +var obj = { + method(x, y = x, z = y) { + assert.sameValue(x, 3, 'first argument value'); + assert.sameValue(y, 3, 'second argument value'); + assert.sameValue(z, 3, 'third argument value'); + callCount = callCount + 1; + } +}; + +obj.method(3); + +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/object/method-definition/params-dflt-meth-ref-self.js b/test/language/expressions/object/method-definition/params-dflt-meth-ref-self.js new file mode 100644 index 0000000000..a260573c96 --- /dev/null +++ b/test/language/expressions/object/method-definition/params-dflt-meth-ref-self.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dflt-params/ref-self.case +// - src/dflt-params/error/meth.template +/*--- +description: Referencing a parameter from within its own initializer (method) +esid: sec-runtime-semantics-definemethod +es6id: 14.3.8 +features: [default-parameters] +flags: [generated] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + 1. Let status be the result of performing IteratorBindingInitialization for + FormalsList using iteratorRecord and environment as the arguments. + 2. ReturnIfAbrupt(status). + 3. Return the result of performing IteratorBindingInitialization for + FormalParameter using iteratorRecord and environment as the arguments. +---*/ +var x = 0; + +var callCount = 0; +var obj = { + method(x = x) { + + callCount = callCount + 1; + } +}; + +assert.throws(ReferenceError, function() { + obj.method(); +}); +assert.sameValue(callCount, 0, 'method body not evaluated'); diff --git a/test/language/expressions/object/method-definition/params-dflt-meth-rest.js b/test/language/expressions/object/method-definition/params-dflt-meth-rest.js new file mode 100644 index 0000000000..258dabf587 --- /dev/null +++ b/test/language/expressions/object/method-definition/params-dflt-meth-rest.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dflt-params/rest.case +// - src/dflt-params/syntax/meth.template +/*--- +description: RestParameter does not support an initializer (method) +esid: sec-runtime-semantics-definemethod +es6id: 14.3.8 +features: [default-parameters] +flags: [generated] +negative: SyntaxError +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1 Function Definitions + + Syntax + + FunctionRestParameter[Yield] : + + BindingRestElement[?Yield] + + 13.3.3 Destructuring Binding Patterns + + Syntax + + BindingRestElement[Yield] : + + ...BindingIdentifier[?Yield] + ...BindingPattern[?Yield] + +---*/ + +0, { + method(...x = []) { + + } +}; diff --git a/test/language/statements/class/params-dflt-gen-meth-abrupt.js b/test/language/statements/class/params-dflt-gen-meth-abrupt.js new file mode 100644 index 0000000000..e13f949a65 --- /dev/null +++ b/test/language/statements/class/params-dflt-gen-meth-abrupt.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dflt-params/abrupt.case +// - src/dflt-params/error/cls-decl-gen-meth.template +/*--- +description: Abrupt completion returned by evaluation of initializer (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + 1. Let status be the result of performing IteratorBindingInitialization for + FormalsList using iteratorRecord and environment as the arguments. + 2. ReturnIfAbrupt(status). + 3. Return the result of performing IteratorBindingInitialization for + FormalParameter using iteratorRecord and environment as the arguments. +---*/ + +var callCount = 0; +class C { + *method(_ = (function() { throw new Test262Error(); }())) { + + callCount = callCount + 1; + } +} + +assert.throws(Test262Error, function() { + C.prototype.method(); +}); +assert.sameValue(callCount, 0, 'method body not evaluated'); diff --git a/test/language/statements/class/params-dflt-gen-meth-arg-val-not-undefined.js b/test/language/statements/class/params-dflt-gen-meth-arg-val-not-undefined.js new file mode 100644 index 0000000000..34cca4966c --- /dev/null +++ b/test/language/statements/class/params-dflt-gen-meth-arg-val-not-undefined.js @@ -0,0 +1,106 @@ +// This file was procedurally generated from the following sources: +// - src/dflt-params/arg-val-not-undefined.case +// - src/dflt-params/default/cls-decl-gen-meth.template +/*--- +description: Use of intializer when argument value is not `undefined` (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + [...] + 23. Let iteratorRecord be Record {[[Iterator]]: + CreateListIterator(argumentsList), [[Done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + a. Perform ? IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var obj = {}; +var falseCount = 0; +var stringCount = 0; +var nanCount = 0; +var zeroCount = 0; +var nullCount = 0; +var objCount = 0; + +var callCount = 0; +class C { + *method(aFalse = falseCount +=1, aString = stringCount += 1, aNaN = nanCount += 1, a0 = zeroCount += 1, aNull = nullCount += 1, aObj = objCount +=1) { + assert.sameValue(aFalse, false); + assert.sameValue(aString, ''); + assert.sameValue(aNaN, NaN); + assert.sameValue(a0, 0); + assert.sameValue(aNull, null); + assert.sameValue(aObj, obj); + callCount = callCount + 1; + } +} + +C.prototype.method(false, '', NaN, 0, null, obj).next(); + +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +assert.sameValue(falseCount, 0, 'initializer not evaluated: false'); +assert.sameValue(stringCount, 0, 'initializer not evaluated: string'); +assert.sameValue(nanCount, 0, 'initializer not evaluated: NaN'); +assert.sameValue(zeroCount, 0, 'initializer not evaluated: 0'); +assert.sameValue(nullCount, 0, 'initializer not evaluated: null'); +assert.sameValue(objCount, 0, 'initializer not evaluated: object'); diff --git a/test/language/statements/class/params-dflt-gen-meth-arg-val-undefined.js b/test/language/statements/class/params-dflt-gen-meth-arg-val-undefined.js new file mode 100644 index 0000000000..c37777c163 --- /dev/null +++ b/test/language/statements/class/params-dflt-gen-meth-arg-val-undefined.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dflt-params/arg-val-undefined.case +// - src/dflt-params/default/cls-decl-gen-meth.template +/*--- +description: Use of intializer when argument value is `undefined` (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + [...] + 23. Let iteratorRecord be Record {[[Iterator]]: + CreateListIterator(argumentsList), [[Done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + a. Perform ? IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +var callCount = 0; +class C { + *method(fromLiteral = 23, fromExpr = 45, fromHole = 99) { + assert.sameValue(fromLiteral, 23); + assert.sameValue(fromExpr, 45); + assert.sameValue(fromHole, 99); + callCount = callCount + 1; + } +} + +C.prototype.method(undefined, void 0).next(); + +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/params-dflt-gen-meth-duplicates.js b/test/language/statements/class/params-dflt-gen-meth-duplicates.js new file mode 100644 index 0000000000..332f0623f0 --- /dev/null +++ b/test/language/statements/class/params-dflt-gen-meth-duplicates.js @@ -0,0 +1,81 @@ +// This file was procedurally generated from the following sources: +// - src/dflt-params/duplicates.case +// - src/dflt-params/syntax/cls-decl-gen-meth.template +/*--- +description: It is a Syntax Error if BoundNames of FormalParameters contains any duplicate elements. (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [default-parameters] +flags: [generated] +negative: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.2 Static Semantics: Early Errors + + StrictFormalParameters : FormalParameters + + - It is a Syntax Error if BoundNames of FormalParameters contains any + duplicate elements. + + FormalParameters : FormalParameterList + + - It is a Syntax Error if IsSimpleParameterList of FormalParameterList is + false and BoundNames of FormalParameterList contains any duplicate + elements. +---*/ + +class C { + *method(x = 0, x) { + + } +} diff --git a/test/language/statements/class/params-dflt-gen-meth-ref-later.js b/test/language/statements/class/params-dflt-gen-meth-ref-later.js new file mode 100644 index 0000000000..9135d8693d --- /dev/null +++ b/test/language/statements/class/params-dflt-gen-meth-ref-later.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dflt-params/ref-later.case +// - src/dflt-params/error/cls-decl-gen-meth.template +/*--- +description: Referencing a parameter that occurs later in the ParameterList (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + 1. Let status be the result of performing IteratorBindingInitialization for + FormalsList using iteratorRecord and environment as the arguments. + 2. ReturnIfAbrupt(status). + 3. Return the result of performing IteratorBindingInitialization for + FormalParameter using iteratorRecord and environment as the arguments. +---*/ +var x = 0; + +var callCount = 0; +class C { + *method(x = y, y) { + + callCount = callCount + 1; + } +} + +assert.throws(ReferenceError, function() { + C.prototype.method(); +}); +assert.sameValue(callCount, 0, 'method body not evaluated'); diff --git a/test/language/statements/class/params-dflt-gen-meth-ref-prior.js b/test/language/statements/class/params-dflt-gen-meth-ref-prior.js new file mode 100644 index 0000000000..669e36b06e --- /dev/null +++ b/test/language/statements/class/params-dflt-gen-meth-ref-prior.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dflt-params/ref-prior.case +// - src/dflt-params/default/cls-decl-gen-meth.template +/*--- +description: Referencing a parameter that occurs earlier in the ParameterList (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + 1. Let status be the result of performing IteratorBindingInitialization for + FormalsList using iteratorRecord and environment as the arguments. + 2. ReturnIfAbrupt(status). + 3. Return the result of performing IteratorBindingInitialization for + FormalParameter using iteratorRecord and environment as the arguments. +---*/ +var x = 0; + +var callCount = 0; +class C { + *method(x, y = x, z = y) { + assert.sameValue(x, 3, 'first argument value'); + assert.sameValue(y, 3, 'second argument value'); + assert.sameValue(z, 3, 'third argument value'); + callCount = callCount + 1; + } +} + +C.prototype.method(3).next(); + +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/params-dflt-gen-meth-ref-self.js b/test/language/statements/class/params-dflt-gen-meth-ref-self.js new file mode 100644 index 0000000000..d222690a9f --- /dev/null +++ b/test/language/statements/class/params-dflt-gen-meth-ref-self.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dflt-params/ref-self.case +// - src/dflt-params/error/cls-decl-gen-meth.template +/*--- +description: Referencing a parameter from within its own initializer (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + 1. Let status be the result of performing IteratorBindingInitialization for + FormalsList using iteratorRecord and environment as the arguments. + 2. ReturnIfAbrupt(status). + 3. Return the result of performing IteratorBindingInitialization for + FormalParameter using iteratorRecord and environment as the arguments. +---*/ +var x = 0; + +var callCount = 0; +class C { + *method(x = x) { + + callCount = callCount + 1; + } +} + +assert.throws(ReferenceError, function() { + C.prototype.method(); +}); +assert.sameValue(callCount, 0, 'method body not evaluated'); diff --git a/test/language/statements/class/params-dflt-gen-meth-rest.js b/test/language/statements/class/params-dflt-gen-meth-rest.js new file mode 100644 index 0000000000..29a37231a0 --- /dev/null +++ b/test/language/statements/class/params-dflt-gen-meth-rest.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dflt-params/rest.case +// - src/dflt-params/syntax/cls-decl-gen-meth.template +/*--- +description: RestParameter does not support an initializer (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [default-parameters] +flags: [generated] +negative: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1 Function Definitions + + Syntax + + FunctionRestParameter[Yield] : + + BindingRestElement[?Yield] + + 13.3.3 Destructuring Binding Patterns + + Syntax + + BindingRestElement[Yield] : + + ...BindingIdentifier[?Yield] + ...BindingPattern[?Yield] + +---*/ + +class C { + *method(...x = []) { + + } +} diff --git a/test/language/statements/class/params-dflt-gen-meth-static-abrupt.js b/test/language/statements/class/params-dflt-gen-meth-static-abrupt.js new file mode 100644 index 0000000000..509c791b3c --- /dev/null +++ b/test/language/statements/class/params-dflt-gen-meth-static-abrupt.js @@ -0,0 +1,85 @@ +// This file was procedurally generated from the following sources: +// - src/dflt-params/abrupt.case +// - src/dflt-params/error/cls-decl-gen-meth-static.template +/*--- +description: Abrupt completion returned by evaluation of initializer (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + 1. Let status be the result of performing IteratorBindingInitialization for + FormalsList using iteratorRecord and environment as the arguments. + 2. ReturnIfAbrupt(status). + 3. Return the result of performing IteratorBindingInitialization for + FormalParameter using iteratorRecord and environment as the arguments. +---*/ + +var callCount = 0; +class C { + static *method(_ = (function() { throw new Test262Error(); }())) { + + callCount = callCount + 1; + } +} + +assert.throws(Test262Error, function() { + C.method(); +}); + +assert.sameValue(callCount, 0, 'method body not evaluated'); diff --git a/test/language/statements/class/params-dflt-gen-meth-static-arg-val-not-undefined.js b/test/language/statements/class/params-dflt-gen-meth-static-arg-val-not-undefined.js new file mode 100644 index 0000000000..b90ad27f4b --- /dev/null +++ b/test/language/statements/class/params-dflt-gen-meth-static-arg-val-not-undefined.js @@ -0,0 +1,106 @@ +// This file was procedurally generated from the following sources: +// - src/dflt-params/arg-val-not-undefined.case +// - src/dflt-params/default/cls-decl-gen-meth-static.template +/*--- +description: Use of intializer when argument value is not `undefined` (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + [...] + 23. Let iteratorRecord be Record {[[Iterator]]: + CreateListIterator(argumentsList), [[Done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + a. Perform ? IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var obj = {}; +var falseCount = 0; +var stringCount = 0; +var nanCount = 0; +var zeroCount = 0; +var nullCount = 0; +var objCount = 0; + +var callCount = 0; +class C { + static *method(aFalse = falseCount +=1, aString = stringCount += 1, aNaN = nanCount += 1, a0 = zeroCount += 1, aNull = nullCount += 1, aObj = objCount +=1) { + assert.sameValue(aFalse, false); + assert.sameValue(aString, ''); + assert.sameValue(aNaN, NaN); + assert.sameValue(a0, 0); + assert.sameValue(aNull, null); + assert.sameValue(aObj, obj); + callCount = callCount + 1; + } +} + +C.method(false, '', NaN, 0, null, obj).next(); + +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +assert.sameValue(falseCount, 0, 'initializer not evaluated: false'); +assert.sameValue(stringCount, 0, 'initializer not evaluated: string'); +assert.sameValue(nanCount, 0, 'initializer not evaluated: NaN'); +assert.sameValue(zeroCount, 0, 'initializer not evaluated: 0'); +assert.sameValue(nullCount, 0, 'initializer not evaluated: null'); +assert.sameValue(objCount, 0, 'initializer not evaluated: object'); diff --git a/test/language/statements/class/params-dflt-gen-meth-static-arg-val-undefined.js b/test/language/statements/class/params-dflt-gen-meth-static-arg-val-undefined.js new file mode 100644 index 0000000000..a1f02fb247 --- /dev/null +++ b/test/language/statements/class/params-dflt-gen-meth-static-arg-val-undefined.js @@ -0,0 +1,89 @@ +// This file was procedurally generated from the following sources: +// - src/dflt-params/arg-val-undefined.case +// - src/dflt-params/default/cls-decl-gen-meth-static.template +/*--- +description: Use of intializer when argument value is `undefined` (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + [...] + 23. Let iteratorRecord be Record {[[Iterator]]: + CreateListIterator(argumentsList), [[Done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + a. Perform ? IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +var callCount = 0; +class C { + static *method(fromLiteral = 23, fromExpr = 45, fromHole = 99) { + assert.sameValue(fromLiteral, 23); + assert.sameValue(fromExpr, 45); + assert.sameValue(fromHole, 99); + callCount = callCount + 1; + } +} + +C.method(undefined, void 0).next(); + +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/params-dflt-gen-meth-static-duplicates.js b/test/language/statements/class/params-dflt-gen-meth-static-duplicates.js new file mode 100644 index 0000000000..f7c866e762 --- /dev/null +++ b/test/language/statements/class/params-dflt-gen-meth-static-duplicates.js @@ -0,0 +1,81 @@ +// This file was procedurally generated from the following sources: +// - src/dflt-params/duplicates.case +// - src/dflt-params/syntax/cls-decl-gen-meth-static.template +/*--- +description: It is a Syntax Error if BoundNames of FormalParameters contains any duplicate elements. (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [default-parameters] +flags: [generated] +negative: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.2 Static Semantics: Early Errors + + StrictFormalParameters : FormalParameters + + - It is a Syntax Error if BoundNames of FormalParameters contains any + duplicate elements. + + FormalParameters : FormalParameterList + + - It is a Syntax Error if IsSimpleParameterList of FormalParameterList is + false and BoundNames of FormalParameterList contains any duplicate + elements. +---*/ + +class C { + static *method(x = 0, x) { + + } +} diff --git a/test/language/statements/class/params-dflt-gen-meth-static-ref-later.js b/test/language/statements/class/params-dflt-gen-meth-static-ref-later.js new file mode 100644 index 0000000000..54e345bd8f --- /dev/null +++ b/test/language/statements/class/params-dflt-gen-meth-static-ref-later.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dflt-params/ref-later.case +// - src/dflt-params/error/cls-decl-gen-meth-static.template +/*--- +description: Referencing a parameter that occurs later in the ParameterList (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + 1. Let status be the result of performing IteratorBindingInitialization for + FormalsList using iteratorRecord and environment as the arguments. + 2. ReturnIfAbrupt(status). + 3. Return the result of performing IteratorBindingInitialization for + FormalParameter using iteratorRecord and environment as the arguments. +---*/ +var x = 0; + +var callCount = 0; +class C { + static *method(x = y, y) { + + callCount = callCount + 1; + } +} + +assert.throws(ReferenceError, function() { + C.method(); +}); + +assert.sameValue(callCount, 0, 'method body not evaluated'); diff --git a/test/language/statements/class/params-dflt-gen-meth-static-ref-prior.js b/test/language/statements/class/params-dflt-gen-meth-static-ref-prior.js new file mode 100644 index 0000000000..2eb401b3f2 --- /dev/null +++ b/test/language/statements/class/params-dflt-gen-meth-static-ref-prior.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dflt-params/ref-prior.case +// - src/dflt-params/default/cls-decl-gen-meth-static.template +/*--- +description: Referencing a parameter that occurs earlier in the ParameterList (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + 1. Let status be the result of performing IteratorBindingInitialization for + FormalsList using iteratorRecord and environment as the arguments. + 2. ReturnIfAbrupt(status). + 3. Return the result of performing IteratorBindingInitialization for + FormalParameter using iteratorRecord and environment as the arguments. +---*/ +var x = 0; + +var callCount = 0; +class C { + static *method(x, y = x, z = y) { + assert.sameValue(x, 3, 'first argument value'); + assert.sameValue(y, 3, 'second argument value'); + assert.sameValue(z, 3, 'third argument value'); + callCount = callCount + 1; + } +} + +C.method(3).next(); + +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/params-dflt-gen-meth-static-ref-self.js b/test/language/statements/class/params-dflt-gen-meth-static-ref-self.js new file mode 100644 index 0000000000..0832563011 --- /dev/null +++ b/test/language/statements/class/params-dflt-gen-meth-static-ref-self.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dflt-params/ref-self.case +// - src/dflt-params/error/cls-decl-gen-meth-static.template +/*--- +description: Referencing a parameter from within its own initializer (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + 1. Let status be the result of performing IteratorBindingInitialization for + FormalsList using iteratorRecord and environment as the arguments. + 2. ReturnIfAbrupt(status). + 3. Return the result of performing IteratorBindingInitialization for + FormalParameter using iteratorRecord and environment as the arguments. +---*/ +var x = 0; + +var callCount = 0; +class C { + static *method(x = x) { + + callCount = callCount + 1; + } +} + +assert.throws(ReferenceError, function() { + C.method(); +}); + +assert.sameValue(callCount, 0, 'method body not evaluated'); diff --git a/test/language/statements/class/params-dflt-gen-meth-static-rest.js b/test/language/statements/class/params-dflt-gen-meth-static-rest.js new file mode 100644 index 0000000000..61fd2b4525 --- /dev/null +++ b/test/language/statements/class/params-dflt-gen-meth-static-rest.js @@ -0,0 +1,86 @@ +// This file was procedurally generated from the following sources: +// - src/dflt-params/rest.case +// - src/dflt-params/syntax/cls-decl-gen-meth-static.template +/*--- +description: RestParameter does not support an initializer (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [default-parameters] +flags: [generated] +negative: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1 Function Definitions + + Syntax + + FunctionRestParameter[Yield] : + + BindingRestElement[?Yield] + + 13.3.3 Destructuring Binding Patterns + + Syntax + + BindingRestElement[Yield] : + + ...BindingIdentifier[?Yield] + ...BindingPattern[?Yield] + +---*/ + +class C { + static *method(...x = []) { + + } +} diff --git a/test/language/statements/class/params-dflt-meth-abrupt.js b/test/language/statements/class/params-dflt-meth-abrupt.js new file mode 100644 index 0000000000..a05ce4108e --- /dev/null +++ b/test/language/statements/class/params-dflt-meth-abrupt.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/dflt-params/abrupt.case +// - src/dflt-params/error/cls-decl-meth.template +/*--- +description: Abrupt completion returned by evaluation of initializer (class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + 1. Let status be the result of performing IteratorBindingInitialization for + FormalsList using iteratorRecord and environment as the arguments. + 2. ReturnIfAbrupt(status). + 3. Return the result of performing IteratorBindingInitialization for + FormalParameter using iteratorRecord and environment as the arguments. +---*/ + +var callCount = 0; +class C { + method(_ = (function() { throw new Test262Error(); }())) { + + callCount = callCount + 1; + } +} + +assert.throws(Test262Error, function() { + C.prototype.method(); +}); +assert.sameValue(callCount, 0, 'method body not evaluated'); diff --git a/test/language/statements/class/params-dflt-meth-arg-val-not-undefined.js b/test/language/statements/class/params-dflt-meth-arg-val-not-undefined.js new file mode 100644 index 0000000000..49ee863364 --- /dev/null +++ b/test/language/statements/class/params-dflt-meth-arg-val-not-undefined.js @@ -0,0 +1,104 @@ +// This file was procedurally generated from the following sources: +// - src/dflt-params/arg-val-not-undefined.case +// - src/dflt-params/default/cls-decl-meth.template +/*--- +description: Use of intializer when argument value is not `undefined` (class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + [...] + 23. Let iteratorRecord be Record {[[Iterator]]: + CreateListIterator(argumentsList), [[Done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + a. Perform ? IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var obj = {}; +var falseCount = 0; +var stringCount = 0; +var nanCount = 0; +var zeroCount = 0; +var nullCount = 0; +var objCount = 0; + +var callCount = 0; +class C { + method(aFalse = falseCount +=1, aString = stringCount += 1, aNaN = nanCount += 1, a0 = zeroCount += 1, aNull = nullCount += 1, aObj = objCount +=1) { + assert.sameValue(aFalse, false); + assert.sameValue(aString, ''); + assert.sameValue(aNaN, NaN); + assert.sameValue(a0, 0); + assert.sameValue(aNull, null); + assert.sameValue(aObj, obj); + callCount = callCount + 1; + } +} + +C.prototype.method(false, '', NaN, 0, null, obj); + +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +assert.sameValue(falseCount, 0, 'initializer not evaluated: false'); +assert.sameValue(stringCount, 0, 'initializer not evaluated: string'); +assert.sameValue(nanCount, 0, 'initializer not evaluated: NaN'); +assert.sameValue(zeroCount, 0, 'initializer not evaluated: 0'); +assert.sameValue(nullCount, 0, 'initializer not evaluated: null'); +assert.sameValue(objCount, 0, 'initializer not evaluated: object'); diff --git a/test/language/statements/class/params-dflt-meth-arg-val-undefined.js b/test/language/statements/class/params-dflt-meth-arg-val-undefined.js new file mode 100644 index 0000000000..f290c6f245 --- /dev/null +++ b/test/language/statements/class/params-dflt-meth-arg-val-undefined.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dflt-params/arg-val-undefined.case +// - src/dflt-params/default/cls-decl-meth.template +/*--- +description: Use of intializer when argument value is `undefined` (class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + [...] + 23. Let iteratorRecord be Record {[[Iterator]]: + CreateListIterator(argumentsList), [[Done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + a. Perform ? IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +var callCount = 0; +class C { + method(fromLiteral = 23, fromExpr = 45, fromHole = 99) { + assert.sameValue(fromLiteral, 23); + assert.sameValue(fromExpr, 45); + assert.sameValue(fromHole, 99); + callCount = callCount + 1; + } +} + +C.prototype.method(undefined, void 0); + +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/params-dflt-meth-duplicates.js b/test/language/statements/class/params-dflt-meth-duplicates.js new file mode 100644 index 0000000000..80ec29e6e0 --- /dev/null +++ b/test/language/statements/class/params-dflt-meth-duplicates.js @@ -0,0 +1,79 @@ +// This file was procedurally generated from the following sources: +// - src/dflt-params/duplicates.case +// - src/dflt-params/syntax/cls-decl-meth.template +/*--- +description: It is a Syntax Error if BoundNames of FormalParameters contains any duplicate elements. (class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [default-parameters] +flags: [generated] +negative: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.2 Static Semantics: Early Errors + + StrictFormalParameters : FormalParameters + + - It is a Syntax Error if BoundNames of FormalParameters contains any + duplicate elements. + + FormalParameters : FormalParameterList + + - It is a Syntax Error if IsSimpleParameterList of FormalParameterList is + false and BoundNames of FormalParameterList contains any duplicate + elements. +---*/ + +class C { + method(x = 0, x) { + + } +} diff --git a/test/language/statements/class/params-dflt-meth-ref-later.js b/test/language/statements/class/params-dflt-meth-ref-later.js new file mode 100644 index 0000000000..f097abbbdf --- /dev/null +++ b/test/language/statements/class/params-dflt-meth-ref-later.js @@ -0,0 +1,83 @@ +// This file was procedurally generated from the following sources: +// - src/dflt-params/ref-later.case +// - src/dflt-params/error/cls-decl-meth.template +/*--- +description: Referencing a parameter that occurs later in the ParameterList (class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + 1. Let status be the result of performing IteratorBindingInitialization for + FormalsList using iteratorRecord and environment as the arguments. + 2. ReturnIfAbrupt(status). + 3. Return the result of performing IteratorBindingInitialization for + FormalParameter using iteratorRecord and environment as the arguments. +---*/ +var x = 0; + +var callCount = 0; +class C { + method(x = y, y) { + + callCount = callCount + 1; + } +} + +assert.throws(ReferenceError, function() { + C.prototype.method(); +}); +assert.sameValue(callCount, 0, 'method body not evaluated'); diff --git a/test/language/statements/class/params-dflt-meth-ref-prior.js b/test/language/statements/class/params-dflt-meth-ref-prior.js new file mode 100644 index 0000000000..82f9ef21f3 --- /dev/null +++ b/test/language/statements/class/params-dflt-meth-ref-prior.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dflt-params/ref-prior.case +// - src/dflt-params/default/cls-decl-meth.template +/*--- +description: Referencing a parameter that occurs earlier in the ParameterList (class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + 1. Let status be the result of performing IteratorBindingInitialization for + FormalsList using iteratorRecord and environment as the arguments. + 2. ReturnIfAbrupt(status). + 3. Return the result of performing IteratorBindingInitialization for + FormalParameter using iteratorRecord and environment as the arguments. +---*/ +var x = 0; + +var callCount = 0; +class C { + method(x, y = x, z = y) { + assert.sameValue(x, 3, 'first argument value'); + assert.sameValue(y, 3, 'second argument value'); + assert.sameValue(z, 3, 'third argument value'); + callCount = callCount + 1; + } +} + +C.prototype.method(3); + +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/params-dflt-meth-ref-self.js b/test/language/statements/class/params-dflt-meth-ref-self.js new file mode 100644 index 0000000000..cf5282510e --- /dev/null +++ b/test/language/statements/class/params-dflt-meth-ref-self.js @@ -0,0 +1,83 @@ +// This file was procedurally generated from the following sources: +// - src/dflt-params/ref-self.case +// - src/dflt-params/error/cls-decl-meth.template +/*--- +description: Referencing a parameter from within its own initializer (class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + 1. Let status be the result of performing IteratorBindingInitialization for + FormalsList using iteratorRecord and environment as the arguments. + 2. ReturnIfAbrupt(status). + 3. Return the result of performing IteratorBindingInitialization for + FormalParameter using iteratorRecord and environment as the arguments. +---*/ +var x = 0; + +var callCount = 0; +class C { + method(x = x) { + + callCount = callCount + 1; + } +} + +assert.throws(ReferenceError, function() { + C.prototype.method(); +}); +assert.sameValue(callCount, 0, 'method body not evaluated'); diff --git a/test/language/statements/class/params-dflt-meth-rest.js b/test/language/statements/class/params-dflt-meth-rest.js new file mode 100644 index 0000000000..4a5c2530dc --- /dev/null +++ b/test/language/statements/class/params-dflt-meth-rest.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dflt-params/rest.case +// - src/dflt-params/syntax/cls-decl-meth.template +/*--- +description: RestParameter does not support an initializer (class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [default-parameters] +flags: [generated] +negative: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1 Function Definitions + + Syntax + + FunctionRestParameter[Yield] : + + BindingRestElement[?Yield] + + 13.3.3 Destructuring Binding Patterns + + Syntax + + BindingRestElement[Yield] : + + ...BindingIdentifier[?Yield] + ...BindingPattern[?Yield] + +---*/ + +class C { + method(...x = []) { + + } +} diff --git a/test/language/statements/class/params-dflt-meth-static-abrupt.js b/test/language/statements/class/params-dflt-meth-static-abrupt.js new file mode 100644 index 0000000000..f9b8319dc3 --- /dev/null +++ b/test/language/statements/class/params-dflt-meth-static-abrupt.js @@ -0,0 +1,82 @@ +// This file was procedurally generated from the following sources: +// - src/dflt-params/abrupt.case +// - src/dflt-params/error/cls-decl-meth-static.template +/*--- +description: Abrupt completion returned by evaluation of initializer (static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + 1. Let status be the result of performing IteratorBindingInitialization for + FormalsList using iteratorRecord and environment as the arguments. + 2. ReturnIfAbrupt(status). + 3. Return the result of performing IteratorBindingInitialization for + FormalParameter using iteratorRecord and environment as the arguments. +---*/ + +var callCount = 0; +class C { + static method(_ = (function() { throw new Test262Error(); }())) { + + callCount = callCount + 1; + } +} + +assert.throws(Test262Error, function() { + C.method(); +}); +assert.sameValue(callCount, 0, 'method body not evaluated'); diff --git a/test/language/statements/class/params-dflt-meth-static-arg-val-not-undefined.js b/test/language/statements/class/params-dflt-meth-static-arg-val-not-undefined.js new file mode 100644 index 0000000000..fe2d8391db --- /dev/null +++ b/test/language/statements/class/params-dflt-meth-static-arg-val-not-undefined.js @@ -0,0 +1,104 @@ +// This file was procedurally generated from the following sources: +// - src/dflt-params/arg-val-not-undefined.case +// - src/dflt-params/default/cls-decl-meth-static.template +/*--- +description: Use of intializer when argument value is not `undefined` (static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + [...] + 23. Let iteratorRecord be Record {[[Iterator]]: + CreateListIterator(argumentsList), [[Done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + a. Perform ? IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var obj = {}; +var falseCount = 0; +var stringCount = 0; +var nanCount = 0; +var zeroCount = 0; +var nullCount = 0; +var objCount = 0; + +var callCount = 0; +class C { + static method(aFalse = falseCount +=1, aString = stringCount += 1, aNaN = nanCount += 1, a0 = zeroCount += 1, aNull = nullCount += 1, aObj = objCount +=1) { + assert.sameValue(aFalse, false); + assert.sameValue(aString, ''); + assert.sameValue(aNaN, NaN); + assert.sameValue(a0, 0); + assert.sameValue(aNull, null); + assert.sameValue(aObj, obj); + callCount = callCount + 1; + } +} + +C.method(false, '', NaN, 0, null, obj); + +assert.sameValue(callCount, 1, 'method invoked exactly once'); + +assert.sameValue(falseCount, 0, 'initializer not evaluated: false'); +assert.sameValue(stringCount, 0, 'initializer not evaluated: string'); +assert.sameValue(nanCount, 0, 'initializer not evaluated: NaN'); +assert.sameValue(zeroCount, 0, 'initializer not evaluated: 0'); +assert.sameValue(nullCount, 0, 'initializer not evaluated: null'); +assert.sameValue(objCount, 0, 'initializer not evaluated: object'); diff --git a/test/language/statements/class/params-dflt-meth-static-arg-val-undefined.js b/test/language/statements/class/params-dflt-meth-static-arg-val-undefined.js new file mode 100644 index 0000000000..df22ab4032 --- /dev/null +++ b/test/language/statements/class/params-dflt-meth-static-arg-val-undefined.js @@ -0,0 +1,87 @@ +// This file was procedurally generated from the following sources: +// - src/dflt-params/arg-val-undefined.case +// - src/dflt-params/default/cls-decl-meth-static.template +/*--- +description: Use of intializer when argument value is `undefined` (static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + [...] + 23. Let iteratorRecord be Record {[[Iterator]]: + CreateListIterator(argumentsList), [[Done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + a. Perform ? IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +var callCount = 0; +class C { + static method(fromLiteral = 23, fromExpr = 45, fromHole = 99) { + assert.sameValue(fromLiteral, 23); + assert.sameValue(fromExpr, 45); + assert.sameValue(fromHole, 99); + callCount = callCount + 1; + } +} + +C.method(undefined, void 0); + +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/params-dflt-meth-static-duplicates.js b/test/language/statements/class/params-dflt-meth-static-duplicates.js new file mode 100644 index 0000000000..63eb7c0feb --- /dev/null +++ b/test/language/statements/class/params-dflt-meth-static-duplicates.js @@ -0,0 +1,79 @@ +// This file was procedurally generated from the following sources: +// - src/dflt-params/duplicates.case +// - src/dflt-params/syntax/cls-decl-meth-static.template +/*--- +description: It is a Syntax Error if BoundNames of FormalParameters contains any duplicate elements. (static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [default-parameters] +flags: [generated] +negative: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.2 Static Semantics: Early Errors + + StrictFormalParameters : FormalParameters + + - It is a Syntax Error if BoundNames of FormalParameters contains any + duplicate elements. + + FormalParameters : FormalParameterList + + - It is a Syntax Error if IsSimpleParameterList of FormalParameterList is + false and BoundNames of FormalParameterList contains any duplicate + elements. +---*/ + +class C { + static method(x = 0, x) { + + } +} diff --git a/test/language/statements/class/params-dflt-meth-static-ref-later.js b/test/language/statements/class/params-dflt-meth-static-ref-later.js new file mode 100644 index 0000000000..5ba90a1fb8 --- /dev/null +++ b/test/language/statements/class/params-dflt-meth-static-ref-later.js @@ -0,0 +1,83 @@ +// This file was procedurally generated from the following sources: +// - src/dflt-params/ref-later.case +// - src/dflt-params/error/cls-decl-meth-static.template +/*--- +description: Referencing a parameter that occurs later in the ParameterList (static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + 1. Let status be the result of performing IteratorBindingInitialization for + FormalsList using iteratorRecord and environment as the arguments. + 2. ReturnIfAbrupt(status). + 3. Return the result of performing IteratorBindingInitialization for + FormalParameter using iteratorRecord and environment as the arguments. +---*/ +var x = 0; + +var callCount = 0; +class C { + static method(x = y, y) { + + callCount = callCount + 1; + } +} + +assert.throws(ReferenceError, function() { + C.method(); +}); +assert.sameValue(callCount, 0, 'method body not evaluated'); diff --git a/test/language/statements/class/params-dflt-meth-static-ref-prior.js b/test/language/statements/class/params-dflt-meth-static-ref-prior.js new file mode 100644 index 0000000000..633f02f3b0 --- /dev/null +++ b/test/language/statements/class/params-dflt-meth-static-ref-prior.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dflt-params/ref-prior.case +// - src/dflt-params/default/cls-decl-meth-static.template +/*--- +description: Referencing a parameter that occurs earlier in the ParameterList (static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + 1. Let status be the result of performing IteratorBindingInitialization for + FormalsList using iteratorRecord and environment as the arguments. + 2. ReturnIfAbrupt(status). + 3. Return the result of performing IteratorBindingInitialization for + FormalParameter using iteratorRecord and environment as the arguments. +---*/ +var x = 0; + +var callCount = 0; +class C { + static method(x, y = x, z = y) { + assert.sameValue(x, 3, 'first argument value'); + assert.sameValue(y, 3, 'second argument value'); + assert.sameValue(z, 3, 'third argument value'); + callCount = callCount + 1; + } +} + +C.method(3); + +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/params-dflt-meth-static-ref-self.js b/test/language/statements/class/params-dflt-meth-static-ref-self.js new file mode 100644 index 0000000000..47e295d5f1 --- /dev/null +++ b/test/language/statements/class/params-dflt-meth-static-ref-self.js @@ -0,0 +1,83 @@ +// This file was procedurally generated from the following sources: +// - src/dflt-params/ref-self.case +// - src/dflt-params/error/cls-decl-meth-static.template +/*--- +description: Referencing a parameter from within its own initializer (static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + 1. Let status be the result of performing IteratorBindingInitialization for + FormalsList using iteratorRecord and environment as the arguments. + 2. ReturnIfAbrupt(status). + 3. Return the result of performing IteratorBindingInitialization for + FormalParameter using iteratorRecord and environment as the arguments. +---*/ +var x = 0; + +var callCount = 0; +class C { + static method(x = x) { + + callCount = callCount + 1; + } +} + +assert.throws(ReferenceError, function() { + C.method(); +}); +assert.sameValue(callCount, 0, 'method body not evaluated'); diff --git a/test/language/statements/class/params-dflt-meth-static-rest.js b/test/language/statements/class/params-dflt-meth-static-rest.js new file mode 100644 index 0000000000..5d47e12dbc --- /dev/null +++ b/test/language/statements/class/params-dflt-meth-static-rest.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dflt-params/rest.case +// - src/dflt-params/syntax/cls-decl-meth-static.template +/*--- +description: RestParameter does not support an initializer (static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [default-parameters] +flags: [generated] +negative: SyntaxError +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1 Function Definitions + + Syntax + + FunctionRestParameter[Yield] : + + BindingRestElement[?Yield] + + 13.3.3 Destructuring Binding Patterns + + Syntax + + BindingRestElement[Yield] : + + ...BindingIdentifier[?Yield] + ...BindingPattern[?Yield] + +---*/ + +class C { + static method(...x = []) { + + } +} diff --git a/test/language/statements/function/params-dflt-abrupt.js b/test/language/statements/function/params-dflt-abrupt.js new file mode 100644 index 0000000000..7de9d77e55 --- /dev/null +++ b/test/language/statements/function/params-dflt-abrupt.js @@ -0,0 +1,61 @@ +// This file was procedurally generated from the following sources: +// - src/dflt-params/abrupt.case +// - src/dflt-params/error/func-decl.template +/*--- +description: Abrupt completion returned by evaluation of initializer (function declaration) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.1.19 +features: [default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + 1. Let status be the result of performing IteratorBindingInitialization for + FormalsList using iteratorRecord and environment as the arguments. + 2. ReturnIfAbrupt(status). + 3. Return the result of performing IteratorBindingInitialization for + FormalParameter using iteratorRecord and environment as the arguments. +---*/ + +var callCount = 0; +function f(_ = (function() { throw new Test262Error(); }())) { + + callCount = callCount + 1; +} +assert.throws(Test262Error, function() { + f(); +}); +assert.sameValue(callCount, 0, 'function body not evaluated'); diff --git a/test/language/statements/function/params-dflt-arg-val-not-undefined.js b/test/language/statements/function/params-dflt-arg-val-not-undefined.js new file mode 100644 index 0000000000..cd8937f37c --- /dev/null +++ b/test/language/statements/function/params-dflt-arg-val-not-undefined.js @@ -0,0 +1,84 @@ +// This file was procedurally generated from the following sources: +// - src/dflt-params/arg-val-not-undefined.case +// - src/dflt-params/default/func-decl.template +/*--- +description: Use of intializer when argument value is not `undefined` (function declaration) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.1.19 +features: [default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + [...] + 23. Let iteratorRecord be Record {[[Iterator]]: + CreateListIterator(argumentsList), [[Done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + a. Perform ? IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var obj = {}; +var falseCount = 0; +var stringCount = 0; +var nanCount = 0; +var zeroCount = 0; +var nullCount = 0; +var objCount = 0; + +var callCount = 0; +function f(aFalse = falseCount +=1, aString = stringCount += 1, aNaN = nanCount += 1, a0 = zeroCount += 1, aNull = nullCount += 1, aObj = objCount +=1) { + assert.sameValue(aFalse, false); + assert.sameValue(aString, ''); + assert.sameValue(aNaN, NaN); + assert.sameValue(a0, 0); + assert.sameValue(aNull, null); + assert.sameValue(aObj, obj); + callCount = callCount + 1; +} + +f(false, '', NaN, 0, null, obj); + +assert.sameValue(callCount, 1, 'function invoked exactly once'); + +assert.sameValue(falseCount, 0, 'initializer not evaluated: false'); +assert.sameValue(stringCount, 0, 'initializer not evaluated: string'); +assert.sameValue(nanCount, 0, 'initializer not evaluated: NaN'); +assert.sameValue(zeroCount, 0, 'initializer not evaluated: 0'); +assert.sameValue(nullCount, 0, 'initializer not evaluated: null'); +assert.sameValue(objCount, 0, 'initializer not evaluated: object'); diff --git a/test/language/statements/function/params-dflt-arg-val-undefined.js b/test/language/statements/function/params-dflt-arg-val-undefined.js new file mode 100644 index 0000000000..5aebf35be0 --- /dev/null +++ b/test/language/statements/function/params-dflt-arg-val-undefined.js @@ -0,0 +1,67 @@ +// This file was procedurally generated from the following sources: +// - src/dflt-params/arg-val-undefined.case +// - src/dflt-params/default/func-decl.template +/*--- +description: Use of intializer when argument value is `undefined` (function declaration) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.1.19 +features: [default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + [...] + 23. Let iteratorRecord be Record {[[Iterator]]: + CreateListIterator(argumentsList), [[Done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + a. Perform ? IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +var callCount = 0; +function f(fromLiteral = 23, fromExpr = 45, fromHole = 99) { + assert.sameValue(fromLiteral, 23); + assert.sameValue(fromExpr, 45); + assert.sameValue(fromHole, 99); + callCount = callCount + 1; +} + +f(undefined, void 0); + +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/statements/function/params-dflt-duplicates.js b/test/language/statements/function/params-dflt-duplicates.js new file mode 100644 index 0000000000..8596f0c19a --- /dev/null +++ b/test/language/statements/function/params-dflt-duplicates.js @@ -0,0 +1,59 @@ +// This file was procedurally generated from the following sources: +// - src/dflt-params/duplicates.case +// - src/dflt-params/syntax/func-decl.template +/*--- +description: It is a Syntax Error if BoundNames of FormalParameters contains any duplicate elements. (function declaration) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.1.19 +features: [default-parameters] +flags: [generated] +negative: SyntaxError +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.2 Static Semantics: Early Errors + + StrictFormalParameters : FormalParameters + + - It is a Syntax Error if BoundNames of FormalParameters contains any + duplicate elements. + + FormalParameters : FormalParameterList + + - It is a Syntax Error if IsSimpleParameterList of FormalParameterList is + false and BoundNames of FormalParameterList contains any duplicate + elements. +---*/ + +function f(x = 0, x) { + +} diff --git a/test/language/statements/function/params-dflt-ref-later.js b/test/language/statements/function/params-dflt-ref-later.js new file mode 100644 index 0000000000..9bcd3e9388 --- /dev/null +++ b/test/language/statements/function/params-dflt-ref-later.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dflt-params/ref-later.case +// - src/dflt-params/error/func-decl.template +/*--- +description: Referencing a parameter that occurs later in the ParameterList (function declaration) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.1.19 +features: [default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + 1. Let status be the result of performing IteratorBindingInitialization for + FormalsList using iteratorRecord and environment as the arguments. + 2. ReturnIfAbrupt(status). + 3. Return the result of performing IteratorBindingInitialization for + FormalParameter using iteratorRecord and environment as the arguments. +---*/ +var x = 0; + +var callCount = 0; +function f(x = y, y) { + + callCount = callCount + 1; +} +assert.throws(ReferenceError, function() { + f(); +}); +assert.sameValue(callCount, 0, 'function body not evaluated'); diff --git a/test/language/statements/function/params-dflt-ref-prior.js b/test/language/statements/function/params-dflt-ref-prior.js new file mode 100644 index 0000000000..972551976d --- /dev/null +++ b/test/language/statements/function/params-dflt-ref-prior.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dflt-params/ref-prior.case +// - src/dflt-params/default/func-decl.template +/*--- +description: Referencing a parameter that occurs earlier in the ParameterList (function declaration) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.1.19 +features: [default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + 1. Let status be the result of performing IteratorBindingInitialization for + FormalsList using iteratorRecord and environment as the arguments. + 2. ReturnIfAbrupt(status). + 3. Return the result of performing IteratorBindingInitialization for + FormalParameter using iteratorRecord and environment as the arguments. +---*/ +var x = 0; + +var callCount = 0; +function f(x, y = x, z = y) { + assert.sameValue(x, 3, 'first argument value'); + assert.sameValue(y, 3, 'second argument value'); + assert.sameValue(z, 3, 'third argument value'); + callCount = callCount + 1; +} + +f(3); + +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/statements/function/params-dflt-ref-self.js b/test/language/statements/function/params-dflt-ref-self.js new file mode 100644 index 0000000000..de76d71584 --- /dev/null +++ b/test/language/statements/function/params-dflt-ref-self.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dflt-params/ref-self.case +// - src/dflt-params/error/func-decl.template +/*--- +description: Referencing a parameter from within its own initializer (function declaration) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.1.19 +features: [default-parameters] +flags: [generated] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + 1. Let status be the result of performing IteratorBindingInitialization for + FormalsList using iteratorRecord and environment as the arguments. + 2. ReturnIfAbrupt(status). + 3. Return the result of performing IteratorBindingInitialization for + FormalParameter using iteratorRecord and environment as the arguments. +---*/ +var x = 0; + +var callCount = 0; +function f(x = x) { + + callCount = callCount + 1; +} +assert.throws(ReferenceError, function() { + f(); +}); +assert.sameValue(callCount, 0, 'function body not evaluated'); diff --git a/test/language/statements/function/params-dflt-rest.js b/test/language/statements/function/params-dflt-rest.js new file mode 100644 index 0000000000..532ac9669f --- /dev/null +++ b/test/language/statements/function/params-dflt-rest.js @@ -0,0 +1,64 @@ +// This file was procedurally generated from the following sources: +// - src/dflt-params/rest.case +// - src/dflt-params/syntax/func-decl.template +/*--- +description: RestParameter does not support an initializer (function declaration) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.1.19 +features: [default-parameters] +flags: [generated] +negative: SyntaxError +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1 Function Definitions + + Syntax + + FunctionRestParameter[Yield] : + + BindingRestElement[?Yield] + + 13.3.3 Destructuring Binding Patterns + + Syntax + + BindingRestElement[Yield] : + + ...BindingIdentifier[?Yield] + ...BindingPattern[?Yield] + +---*/ + +function f(...x = []) { + +} diff --git a/test/language/statements/generators/params-dflt-abrupt.js b/test/language/statements/generators/params-dflt-abrupt.js new file mode 100644 index 0000000000..88aacc649c --- /dev/null +++ b/test/language/statements/generators/params-dflt-abrupt.js @@ -0,0 +1,62 @@ +// This file was procedurally generated from the following sources: +// - src/dflt-params/abrupt.case +// - src/dflt-params/error/gen-func-decl.template +/*--- +description: Abrupt completion returned by evaluation of initializer (generator function declaration) +esid: sec-generator-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.4.12 +features: [default-parameters] +flags: [generated] +info: | + GeneratorDeclaration : function * ( FormalParameters ) { GeneratorBody } + + [...] + 2. Let F be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + 1. Let status be the result of performing IteratorBindingInitialization for + FormalsList using iteratorRecord and environment as the arguments. + 2. ReturnIfAbrupt(status). + 3. Return the result of performing IteratorBindingInitialization for + FormalParameter using iteratorRecord and environment as the arguments. +---*/ + +var callCount = 0; +function* f(_ = (function() { throw new Test262Error(); }())) { + + callCount = callCount + 1; +} + +assert.throws(Test262Error, function() { + f(); +}); + +assert.sameValue(callCount, 0, 'generator function body not evaluated'); diff --git a/test/language/statements/generators/params-dflt-arg-val-not-undefined.js b/test/language/statements/generators/params-dflt-arg-val-not-undefined.js new file mode 100644 index 0000000000..a4b38ac36a --- /dev/null +++ b/test/language/statements/generators/params-dflt-arg-val-not-undefined.js @@ -0,0 +1,83 @@ +// This file was procedurally generated from the following sources: +// - src/dflt-params/arg-val-not-undefined.case +// - src/dflt-params/default/gen-func-decl.template +/*--- +description: Use of intializer when argument value is not `undefined` (generator function declaration) +esid: sec-generator-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.4.12 +features: [default-parameters] +flags: [generated] +info: | + GeneratorDeclaration : function * ( FormalParameters ) { GeneratorBody } + + [...] + 2. Let F be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + [...] + 23. Let iteratorRecord be Record {[[Iterator]]: + CreateListIterator(argumentsList), [[Done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + a. Perform ? IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ +var obj = {}; +var falseCount = 0; +var stringCount = 0; +var nanCount = 0; +var zeroCount = 0; +var nullCount = 0; +var objCount = 0; + +var callCount = 0; +function* f(aFalse = falseCount +=1, aString = stringCount += 1, aNaN = nanCount += 1, a0 = zeroCount += 1, aNull = nullCount += 1, aObj = objCount +=1) { + assert.sameValue(aFalse, false); + assert.sameValue(aString, ''); + assert.sameValue(aNaN, NaN); + assert.sameValue(a0, 0); + assert.sameValue(aNull, null); + assert.sameValue(aObj, obj); + callCount = callCount + 1; +} + +f(false, '', NaN, 0, null, obj).next(); + +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); + +assert.sameValue(falseCount, 0, 'initializer not evaluated: false'); +assert.sameValue(stringCount, 0, 'initializer not evaluated: string'); +assert.sameValue(nanCount, 0, 'initializer not evaluated: NaN'); +assert.sameValue(zeroCount, 0, 'initializer not evaluated: 0'); +assert.sameValue(nullCount, 0, 'initializer not evaluated: null'); +assert.sameValue(objCount, 0, 'initializer not evaluated: object'); diff --git a/test/language/statements/generators/params-dflt-arg-val-undefined.js b/test/language/statements/generators/params-dflt-arg-val-undefined.js new file mode 100644 index 0000000000..e675be80df --- /dev/null +++ b/test/language/statements/generators/params-dflt-arg-val-undefined.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/dflt-params/arg-val-undefined.case +// - src/dflt-params/default/gen-func-decl.template +/*--- +description: Use of intializer when argument value is `undefined` (generator function declaration) +esid: sec-generator-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.4.12 +features: [default-parameters] +flags: [generated] +info: | + GeneratorDeclaration : function * ( FormalParameters ) { GeneratorBody } + + [...] + 2. Let F be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + [...] + 23. Let iteratorRecord be Record {[[Iterator]]: + CreateListIterator(argumentsList), [[Done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + a. Perform ? IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] +---*/ + +var callCount = 0; +function* f(fromLiteral = 23, fromExpr = 45, fromHole = 99) { + assert.sameValue(fromLiteral, 23); + assert.sameValue(fromExpr, 45); + assert.sameValue(fromHole, 99); + callCount = callCount + 1; +} + +f(undefined, void 0).next(); + +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/statements/generators/params-dflt-duplicates.js b/test/language/statements/generators/params-dflt-duplicates.js new file mode 100644 index 0000000000..eb4c445943 --- /dev/null +++ b/test/language/statements/generators/params-dflt-duplicates.js @@ -0,0 +1,58 @@ +// This file was procedurally generated from the following sources: +// - src/dflt-params/duplicates.case +// - src/dflt-params/syntax/gen-func-decl.template +/*--- +description: It is a Syntax Error if BoundNames of FormalParameters contains any duplicate elements. (generator function declaration) +esid: sec-generator-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.4.12 +features: [default-parameters] +flags: [generated] +negative: SyntaxError +info: | + GeneratorDeclaration : function * ( FormalParameters ) { GeneratorBody } + + [...] + 2. Let F be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.2 Static Semantics: Early Errors + + StrictFormalParameters : FormalParameters + + - It is a Syntax Error if BoundNames of FormalParameters contains any + duplicate elements. + + FormalParameters : FormalParameterList + + - It is a Syntax Error if IsSimpleParameterList of FormalParameterList is + false and BoundNames of FormalParameterList contains any duplicate + elements. +---*/ + +function* f(x = 0, x) { + +} diff --git a/test/language/statements/generators/params-dflt-ref-later.js b/test/language/statements/generators/params-dflt-ref-later.js new file mode 100644 index 0000000000..6b988e5d18 --- /dev/null +++ b/test/language/statements/generators/params-dflt-ref-later.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dflt-params/ref-later.case +// - src/dflt-params/error/gen-func-decl.template +/*--- +description: Referencing a parameter that occurs later in the ParameterList (generator function declaration) +esid: sec-generator-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.4.12 +features: [default-parameters] +flags: [generated] +info: | + GeneratorDeclaration : function * ( FormalParameters ) { GeneratorBody } + + [...] + 2. Let F be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + 1. Let status be the result of performing IteratorBindingInitialization for + FormalsList using iteratorRecord and environment as the arguments. + 2. ReturnIfAbrupt(status). + 3. Return the result of performing IteratorBindingInitialization for + FormalParameter using iteratorRecord and environment as the arguments. +---*/ +var x = 0; + +var callCount = 0; +function* f(x = y, y) { + + callCount = callCount + 1; +} + +assert.throws(ReferenceError, function() { + f(); +}); + +assert.sameValue(callCount, 0, 'generator function body not evaluated'); diff --git a/test/language/statements/generators/params-dflt-ref-prior.js b/test/language/statements/generators/params-dflt-ref-prior.js new file mode 100644 index 0000000000..42a4e20cb6 --- /dev/null +++ b/test/language/statements/generators/params-dflt-ref-prior.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dflt-params/ref-prior.case +// - src/dflt-params/default/gen-func-decl.template +/*--- +description: Referencing a parameter that occurs earlier in the ParameterList (generator function declaration) +esid: sec-generator-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.4.12 +features: [default-parameters] +flags: [generated] +info: | + GeneratorDeclaration : function * ( FormalParameters ) { GeneratorBody } + + [...] + 2. Let F be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + 1. Let status be the result of performing IteratorBindingInitialization for + FormalsList using iteratorRecord and environment as the arguments. + 2. ReturnIfAbrupt(status). + 3. Return the result of performing IteratorBindingInitialization for + FormalParameter using iteratorRecord and environment as the arguments. +---*/ +var x = 0; + +var callCount = 0; +function* f(x, y = x, z = y) { + assert.sameValue(x, 3, 'first argument value'); + assert.sameValue(y, 3, 'second argument value'); + assert.sameValue(z, 3, 'third argument value'); + callCount = callCount + 1; +} + +f(3).next(); + +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/statements/generators/params-dflt-ref-self.js b/test/language/statements/generators/params-dflt-ref-self.js new file mode 100644 index 0000000000..71c29e010e --- /dev/null +++ b/test/language/statements/generators/params-dflt-ref-self.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dflt-params/ref-self.case +// - src/dflt-params/error/gen-func-decl.template +/*--- +description: Referencing a parameter from within its own initializer (generator function declaration) +esid: sec-generator-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.4.12 +features: [default-parameters] +flags: [generated] +info: | + GeneratorDeclaration : function * ( FormalParameters ) { GeneratorBody } + + [...] + 2. Let F be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + 1. Let status be the result of performing IteratorBindingInitialization for + FormalsList using iteratorRecord and environment as the arguments. + 2. ReturnIfAbrupt(status). + 3. Return the result of performing IteratorBindingInitialization for + FormalParameter using iteratorRecord and environment as the arguments. +---*/ +var x = 0; + +var callCount = 0; +function* f(x = x) { + + callCount = callCount + 1; +} + +assert.throws(ReferenceError, function() { + f(); +}); + +assert.sameValue(callCount, 0, 'generator function body not evaluated'); diff --git a/test/language/statements/generators/params-dflt-rest.js b/test/language/statements/generators/params-dflt-rest.js new file mode 100644 index 0000000000..c198c3f325 --- /dev/null +++ b/test/language/statements/generators/params-dflt-rest.js @@ -0,0 +1,63 @@ +// This file was procedurally generated from the following sources: +// - src/dflt-params/rest.case +// - src/dflt-params/syntax/gen-func-decl.template +/*--- +description: RestParameter does not support an initializer (generator function declaration) +esid: sec-generator-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.4.12 +features: [default-parameters] +flags: [generated] +negative: SyntaxError +info: | + GeneratorDeclaration : function * ( FormalParameters ) { GeneratorBody } + + [...] + 2. Let F be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1 Function Definitions + + Syntax + + FunctionRestParameter[Yield] : + + BindingRestElement[?Yield] + + 13.3.3 Destructuring Binding Patterns + + Syntax + + BindingRestElement[Yield] : + + ...BindingIdentifier[?Yield] + ...BindingPattern[?Yield] + +---*/ + +function* f(...x = []) { + +} -- GitLab From 7dcccfcca6e7999124233cc813781dae3d2e80b3 Mon Sep 17 00:00:00 2001 From: Mike Pennisi <mike@mikepennisi.com> Date: Thu, 2 Jun 2016 11:18:06 -0400 Subject: [PATCH 5/8] Add tests for use of `yield` in default parameters --- .../arrow-function/param-dflt-yield-expr.js | 24 +++++++++++++++ .../param-dflt-yield-id-non-strict.js | 25 ++++++++++++++++ .../param-dflt-yield-id-strict.js | 17 +++++++++++ .../class/gen-method-param-dflt-yield.js | 23 +++++++++++++++ .../class/method-param-dflt-yield.js | 18 ++++++++++++ .../static-gen-method-param-dflt-yield.js | 23 +++++++++++++++ .../class/static-method-param-dflt-yield.js | 18 ++++++++++++ .../function/param-dflt-yield-non-strict.js | 27 +++++++++++++++++ .../function/param-dflt-yield-strict.js | 21 ++++++++++++++ .../generators/param-dflt-yield.js | 21 ++++++++++++++ .../class/gen-method-param-dflt-yield.js | 23 +++++++++++++++ .../statements/class/method-param-yield.js | 18 ++++++++++++ .../static-gen-method-param-dflt-yield.js | 23 +++++++++++++++ .../class/static-method-param-yield.js | 18 ++++++++++++ .../function/param-dflt-yield-non-strict.js | 29 +++++++++++++++++++ .../function/param-dflt-yield-strict.js | 21 ++++++++++++++ .../statements/generators/param-dflt-yield.js | 20 +++++++++++++ 17 files changed, 369 insertions(+) create mode 100644 test/language/expressions/arrow-function/param-dflt-yield-expr.js create mode 100644 test/language/expressions/arrow-function/param-dflt-yield-id-non-strict.js create mode 100644 test/language/expressions/arrow-function/param-dflt-yield-id-strict.js create mode 100644 test/language/expressions/class/gen-method-param-dflt-yield.js create mode 100644 test/language/expressions/class/method-param-dflt-yield.js create mode 100644 test/language/expressions/class/static-gen-method-param-dflt-yield.js create mode 100644 test/language/expressions/class/static-method-param-dflt-yield.js create mode 100644 test/language/expressions/function/param-dflt-yield-non-strict.js create mode 100644 test/language/expressions/function/param-dflt-yield-strict.js create mode 100644 test/language/expressions/generators/param-dflt-yield.js create mode 100644 test/language/statements/class/gen-method-param-dflt-yield.js create mode 100644 test/language/statements/class/method-param-yield.js create mode 100644 test/language/statements/class/static-gen-method-param-dflt-yield.js create mode 100644 test/language/statements/class/static-method-param-yield.js create mode 100644 test/language/statements/function/param-dflt-yield-non-strict.js create mode 100644 test/language/statements/function/param-dflt-yield-strict.js create mode 100644 test/language/statements/generators/param-dflt-yield.js diff --git a/test/language/expressions/arrow-function/param-dflt-yield-expr.js b/test/language/expressions/arrow-function/param-dflt-yield-expr.js new file mode 100644 index 0000000000..20e6786187 --- /dev/null +++ b/test/language/expressions/arrow-function/param-dflt-yield-expr.js @@ -0,0 +1,24 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-arrow-function-definitions +es6id: 14.2 +description: > + The `yield` token is interpreted contextually outside of strict mode +info: | + ArrowFunction[In, Yield] : + + ArrowParameters[?Yield] [no LineTerminator here] => ConciseBody[?In] + + 14.2.1 Static Semantics: Early Errors# + + ArrowFunction : ArrowParameters=>ConciseBody + + - It is a Syntax Error if ArrowParameters Contains YieldExpression is true. +features: [generators, default-parameters] +negative: SyntaxError +---*/ + +function *g() { + (x = yield) => {}; +} diff --git a/test/language/expressions/arrow-function/param-dflt-yield-id-non-strict.js b/test/language/expressions/arrow-function/param-dflt-yield-id-non-strict.js new file mode 100644 index 0000000000..90ce97b2a7 --- /dev/null +++ b/test/language/expressions/arrow-function/param-dflt-yield-id-non-strict.js @@ -0,0 +1,25 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-arrow-function-definitions +es6id: 14.2 +description: > + The `yield` token is interpreted as an IdentifierReference outside of strict + mode and outside of generator function bodies. +info: | + ArrowFunction[In, Yield] : + + ArrowParameters[?Yield] [no LineTerminator here] => ConciseBody[?In] +features: [default-parameters] +flags: [onlyStrict] +negative: SyntaxError +---*/ + +var yield = 23; +var f, paramValue; + +f = (x = yield) => { paramValue = x; }; + +f(); + +assert.sameValue(paramValue, 23); diff --git a/test/language/expressions/arrow-function/param-dflt-yield-id-strict.js b/test/language/expressions/arrow-function/param-dflt-yield-id-strict.js new file mode 100644 index 0000000000..0e84b4b3fd --- /dev/null +++ b/test/language/expressions/arrow-function/param-dflt-yield-id-strict.js @@ -0,0 +1,17 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-arrow-function-definitions +es6id: 14.2 +description: > + The `yield` token is interpreted as a FutureReservedWord within strict mode +info: | + ArrowFunction[In, Yield] : + + ArrowParameters[?Yield] [no LineTerminator here] => ConciseBody[?In] +features: [default-parameters] +flags: [onlyStrict] +negative: SyntaxError +---*/ + +(x = yield) => {}; diff --git a/test/language/expressions/class/gen-method-param-dflt-yield.js b/test/language/expressions/class/gen-method-param-dflt-yield.js new file mode 100644 index 0000000000..da350ddbba --- /dev/null +++ b/test/language/expressions/class/gen-method-param-dflt-yield.js @@ -0,0 +1,23 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-generator-function-definitions +es6id: 14.4 +description: > + YieldExpression cannot be used within the FormalParameters of a generator + function +info: | + GeneratorMethod[Yield]: + + * PropertyName[?Yield] ( StrictFormalParameters[Yield] ) { GeneratorBody } + + YieldExpression cannot be used within the FormalParameters of a generator + function because any expressions that are part of FormalParameters are + evaluated before the resulting generator object is in a resumable state. +features: [generators, default-parameters] +negative: SyntaxError +---*/ + +0, class { + *g(x = yield) {} +}; diff --git a/test/language/expressions/class/method-param-dflt-yield.js b/test/language/expressions/class/method-param-dflt-yield.js new file mode 100644 index 0000000000..378e0e02f0 --- /dev/null +++ b/test/language/expressions/class/method-param-dflt-yield.js @@ -0,0 +1,18 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-method-definitions +es6id: 14.3 +description: > + YieldExpression cannot be used within the FormalParameters of a class method +info: | + MethodDefinition[Yield] : + + PropertyName[?Yield] ( StrictFormalParameters ) { FunctionBody } +features: [generators, default-parameters] +negative: SyntaxError +---*/ + +0, class { + m(x = yield) {} +}; diff --git a/test/language/expressions/class/static-gen-method-param-dflt-yield.js b/test/language/expressions/class/static-gen-method-param-dflt-yield.js new file mode 100644 index 0000000000..c24810c3bb --- /dev/null +++ b/test/language/expressions/class/static-gen-method-param-dflt-yield.js @@ -0,0 +1,23 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-generator-function-definitions +es6id: 14.4 +description: > + YieldExpression cannot be used within the FormalParameters of a generator + function +info: | + GeneratorMethod[Yield]: + + * PropertyName[?Yield] ( StrictFormalParameters[Yield] ) { GeneratorBody } + + YieldExpression cannot be used within the FormalParameters of a generator + function because any expressions that are part of FormalParameters are + evaluated before the resulting generator object is in a resumable state. +features: [generators, default-parameters] +negative: SyntaxError +---*/ + +0, class { + static *g(x = yield) {} +}; diff --git a/test/language/expressions/class/static-method-param-dflt-yield.js b/test/language/expressions/class/static-method-param-dflt-yield.js new file mode 100644 index 0000000000..a6b6d16acd --- /dev/null +++ b/test/language/expressions/class/static-method-param-dflt-yield.js @@ -0,0 +1,18 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-method-definitions +es6id: 14.3 +description: > + YieldExpression cannot be used within the FormalParameters of a class method +info: | + MethodDefinition[Yield] : + + PropertyName[?Yield] ( StrictFormalParameters ) { FunctionBody } +features: [generators, default-parameters] +negative: SyntaxError +---*/ + +0, class { + static m(x = yield) {} +}; diff --git a/test/language/expressions/function/param-dflt-yield-non-strict.js b/test/language/expressions/function/param-dflt-yield-non-strict.js new file mode 100644 index 0000000000..9149401c40 --- /dev/null +++ b/test/language/expressions/function/param-dflt-yield-non-strict.js @@ -0,0 +1,27 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-function-definitions +es6id: 14.1 +description: > + The `yield` token is interpreted as an IdentifierReference within a generator + and outside of strict mode +info: | + FunctionExpression : + function BindingIdentifieropt ( FormalParameters ) { FunctionBody } +features: [generators, default-parameters] +flags: [noStrict] +---*/ + +var yield = 23; +var paramValue; + +function *g() { + (function(x = yield) { + paramValue = x; + }()); +} + +g().next(); + +assert.sameValue(paramValue, 23); diff --git a/test/language/expressions/function/param-dflt-yield-strict.js b/test/language/expressions/function/param-dflt-yield-strict.js new file mode 100644 index 0000000000..875973f963 --- /dev/null +++ b/test/language/expressions/function/param-dflt-yield-strict.js @@ -0,0 +1,21 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-function-definitions +es6id: 14.1 +description: > + The `yield` token is interpreted as an IdentifierReference within a generator + and outside of strict mode +info: | + FunctionExpression : + function BindingIdentifieropt ( FormalParameters ) { FunctionBody } +features: [generators, default-parameters] +flags: [onlyStrict] +negative: SyntaxError +---*/ + +function *g() { + 0, function(x = yield) { + paramValue = x; + }; +} diff --git a/test/language/expressions/generators/param-dflt-yield.js b/test/language/expressions/generators/param-dflt-yield.js new file mode 100644 index 0000000000..98952a2974 --- /dev/null +++ b/test/language/expressions/generators/param-dflt-yield.js @@ -0,0 +1,21 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-generator-function-definitions +es6id: 14.4 +description: > + YieldExpression cannot be used within the FormalParameters of a generator + function +info: | + GeneratorExpression : + + function * BindingIdentifier[Yield]opt ( FormalParameters[Yield] ) { GeneratorBody } + + YieldExpression cannot be used within the FormalParameters of a generator + function because any expressions that are part of FormalParameters are + evaluated before the resulting generator object is in a resumable state. +features: [default-parameters] +negative: SyntaxError +---*/ + +0, function*(x = yield) {}; diff --git a/test/language/statements/class/gen-method-param-dflt-yield.js b/test/language/statements/class/gen-method-param-dflt-yield.js new file mode 100644 index 0000000000..708120b2b5 --- /dev/null +++ b/test/language/statements/class/gen-method-param-dflt-yield.js @@ -0,0 +1,23 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-generator-function-definitions +es6id: 14.4 +description: > + YieldExpression cannot be used within the FormalParameters of a generator + function +info: | + GeneratorMethod[Yield]: + + * PropertyName[?Yield] ( StrictFormalParameters[Yield] ) { GeneratorBody } + + YieldExpression cannot be used within the FormalParameters of a generator + function because any expressions that are part of FormalParameters are + evaluated before the resulting generator object is in a resumable state. +features: [generators, default-parameters] +negative: SyntaxError +---*/ + +class C { + *g(x = yield) {} +} diff --git a/test/language/statements/class/method-param-yield.js b/test/language/statements/class/method-param-yield.js new file mode 100644 index 0000000000..244c1e8945 --- /dev/null +++ b/test/language/statements/class/method-param-yield.js @@ -0,0 +1,18 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-method-definitions +es6id: 14.3 +description: > + YieldExpression cannot be used within the FormalParameters of a class method +info: | + MethodDefinition[Yield] : + + PropertyName[?Yield] ( StrictFormalParameters ) { FunctionBody } +features: [generators, default-parameters] +negative: SyntaxError +---*/ + +class C { + m(x = yield) {} +} diff --git a/test/language/statements/class/static-gen-method-param-dflt-yield.js b/test/language/statements/class/static-gen-method-param-dflt-yield.js new file mode 100644 index 0000000000..903c8eeba3 --- /dev/null +++ b/test/language/statements/class/static-gen-method-param-dflt-yield.js @@ -0,0 +1,23 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-generator-function-definitions +es6id: 14.4 +description: > + YieldExpression cannot be used within the FormalParameters of a generator + function +info: | + GeneratorMethod[Yield]: + + * PropertyName[?Yield] ( StrictFormalParameters[Yield] ) { GeneratorBody } + + YieldExpression cannot be used within the FormalParameters of a generator + function because any expressions that are part of FormalParameters are + evaluated before the resulting generator object is in a resumable state. +features: [generators, default-parameters] +negative: SyntaxError +---*/ + +class C { + static *g(x = yield) {} +} diff --git a/test/language/statements/class/static-method-param-yield.js b/test/language/statements/class/static-method-param-yield.js new file mode 100644 index 0000000000..be2fc13002 --- /dev/null +++ b/test/language/statements/class/static-method-param-yield.js @@ -0,0 +1,18 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-method-definitions +es6id: 14.3 +description: > + YieldExpression cannot be used within the FormalParameters of a class method +info: | + MethodDefinition[Yield] : + + PropertyName[?Yield] ( StrictFormalParameters ) { FunctionBody } +features: [generators, default-parameters] +negative: SyntaxError +---*/ + +class C { + static m(x = yield) {} +} diff --git a/test/language/statements/function/param-dflt-yield-non-strict.js b/test/language/statements/function/param-dflt-yield-non-strict.js new file mode 100644 index 0000000000..d04d8d5dd9 --- /dev/null +++ b/test/language/statements/function/param-dflt-yield-non-strict.js @@ -0,0 +1,29 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-function-definitions +es6id: 14.1 +description: > + The `yield` token is interpreted as an IdentifierReference within a generator + and outside of strict mode +info: | + FunctionDeclaration[Yield, Default] : + function BindingIdentifier[?Yield] ( FormalParameters ) { FunctionBody } +features: [generators, default-parameters] +flags: [noStrict] +---*/ + +var yield = 23; +var paramValue; + +function *g() { + function f(x = yield) { + paramValue = x; + } + + f(); +} + +g().next(); + +assert.sameValue(paramValue, 23); diff --git a/test/language/statements/function/param-dflt-yield-strict.js b/test/language/statements/function/param-dflt-yield-strict.js new file mode 100644 index 0000000000..39a14ad1d4 --- /dev/null +++ b/test/language/statements/function/param-dflt-yield-strict.js @@ -0,0 +1,21 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-function-definitions +es6id: 14.1 +description: > + The `yield` token is interpreted as an IdentifierReference within a generator + and outside of strict mode +info: | + FunctionDeclaration[Yield, Default] : + function BindingIdentifier[?Yield] ( FormalParameters ) { FunctionBody } +features: [generators, default-parameters] +flags: [onlyStrict] +negative: SyntaxError +---*/ + +function *g() { + function f(x = yield) { + paramValue = x; + } +} diff --git a/test/language/statements/generators/param-dflt-yield.js b/test/language/statements/generators/param-dflt-yield.js new file mode 100644 index 0000000000..6df68b3beb --- /dev/null +++ b/test/language/statements/generators/param-dflt-yield.js @@ -0,0 +1,20 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-generator-function-definitions +es6id: 14.4 +description: > + YieldExpression cannot be used within the FormalParameters of a generator + function +info: | + GeneratorDeclaration[Yield, Default] : + function * BindingIdentifier[?Yield] ( FormalParameters[Yield] ) { GeneratorBody } + + YieldExpression cannot be used within the FormalParameters of a generator + function because any expressions that are part of FormalParameters are + evaluated before the resulting generator object is in a resumable state. +features: [default-parameters] +negative: SyntaxError +---*/ + +function* g(x = yield) {} -- GitLab From 7e3019e382bfd231f8e9c2506ea097d751b9d5e4 Mon Sep 17 00:00:00 2001 From: Mike Pennisi <mike@mikepennisi.com> Date: Tue, 31 May 2016 17:30:41 -0400 Subject: [PATCH 6/8] Add tests for function length with dflt parameters --- .../default-parameters/function-length.js | 26 ------- .../expressions/arrow-function/length-dflt.js | 60 +++++++++++++++++ .../class/gen-method-length-dflt.js | 59 ++++++++++++++++ .../expressions/class/getter-param-dflt.js | 19 ++++++ .../expressions/class/method-length-dflt.js | 59 ++++++++++++++++ .../expressions/class/setter-length-dflt.js | 39 +++++++++++ .../class/static-method-length-dflt.js | 59 ++++++++++++++++ .../expressions/function/length-dflt.js | 60 +++++++++++++++++ .../expressions/generators/length-dflt.js | 60 +++++++++++++++++ .../expressions/object/getter-param-dflt.js | 19 ++++++ .../generator-length-dflt.js | 60 +++++++++++++++++ .../method-definition/name-length-dflt.js | 60 +++++++++++++++++ .../expressions/object/setter-length-dflt.js | 39 +++++++++++ .../class/gen-method-length-dflt.js | 67 +++++++++++++++++++ .../statements/class/getter-param-dflt.js | 19 ++++++ .../statements/class/method-length-dflt.js | 67 +++++++++++++++++++ .../statements/class/setter-length-dflt.js | 39 +++++++++++ .../class/static-method-length-dflt.js | 67 +++++++++++++++++++ .../statements/function/length-dflt.js | 60 +++++++++++++++++ .../statements/generators/length-dflt.js | 60 +++++++++++++++++ 20 files changed, 972 insertions(+), 26 deletions(-) delete mode 100644 test/language/default-parameters/function-length.js create mode 100644 test/language/expressions/arrow-function/length-dflt.js create mode 100644 test/language/expressions/class/gen-method-length-dflt.js create mode 100644 test/language/expressions/class/getter-param-dflt.js create mode 100644 test/language/expressions/class/method-length-dflt.js create mode 100644 test/language/expressions/class/setter-length-dflt.js create mode 100644 test/language/expressions/class/static-method-length-dflt.js create mode 100644 test/language/expressions/function/length-dflt.js create mode 100644 test/language/expressions/generators/length-dflt.js create mode 100644 test/language/expressions/object/getter-param-dflt.js create mode 100644 test/language/expressions/object/method-definition/generator-length-dflt.js create mode 100644 test/language/expressions/object/method-definition/name-length-dflt.js create mode 100644 test/language/expressions/object/setter-length-dflt.js create mode 100644 test/language/statements/class/gen-method-length-dflt.js create mode 100644 test/language/statements/class/getter-param-dflt.js create mode 100644 test/language/statements/class/method-length-dflt.js create mode 100644 test/language/statements/class/setter-length-dflt.js create mode 100644 test/language/statements/class/static-method-length-dflt.js create mode 100644 test/language/statements/function/length-dflt.js create mode 100644 test/language/statements/generators/length-dflt.js diff --git a/test/language/default-parameters/function-length.js b/test/language/default-parameters/function-length.js deleted file mode 100644 index c26f313a6e..0000000000 --- a/test/language/default-parameters/function-length.js +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (C) 2015 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -es6id: 14.1.6 -description: > - Default parameters' effect on function length -info: > - Function length is counted by the non initialized parameters in the left. - - FormalsList : FormalParameter - - 1. If HasInitializer of FormalParameter is true return 0 - 2. Return 1. - - FormalsList : FormalsList , FormalParameter - - 1. Let count be the ExpectedArgumentCount of FormalsList. - 2. If HasInitializer of FormalsList is true or HasInitializer of - FormalParameter is true, return count. - 3. Return count+1. ----*/ - -assert.sameValue((function (x = 42) {}).length, 0); -assert.sameValue((function (x = 42, y) {}).length, 0); -assert.sameValue((function (x, y = 42) {}).length, 1); -assert.sameValue((function (x, y = 42, z) {}).length, 1); diff --git a/test/language/expressions/arrow-function/length-dflt.js b/test/language/expressions/arrow-function/length-dflt.js new file mode 100644 index 0000000000..b06e5b1d5a --- /dev/null +++ b/test/language/expressions/arrow-function/length-dflt.js @@ -0,0 +1,60 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 14.1.6 +description: > + Default parameters' effect on function length +info: | + Function length is counted by the non initialized parameters in the left. + + 9.2.4 FunctionInitialize (F, kind, ParameterList, Body, Scope) + + [...] + 2. Let len be the ExpectedArgumentCount of ParameterList. + 3. Perform ! DefinePropertyOrThrow(F, "length", PropertyDescriptor{[[Value]]: + len, [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true}). + [...] + + FormalsList : FormalParameter + + 1. If HasInitializer of FormalParameter is true return 0 + 2. Return 1. + + FormalsList : FormalsList , FormalParameter + + 1. Let count be the ExpectedArgumentCount of FormalsList. + 2. If HasInitializer of FormalsList is true or HasInitializer of + FormalParameter is true, return count. + 3. Return count+1. +features: [default-parameters] +includes: [propertyHelper.js] +---*/ + + +var f1 = (x = 42) => {}; + +assert.sameValue(f1.length, 0, 'FormalsList: x = 42'); +verifyNotEnumerable(f1, 'length'); +verifyNotWritable(f1, 'length'); +verifyConfigurable(f1, 'length'); + +var f2 = (x = 42, y) => {}; + +assert.sameValue(f2.length, 0, 'FormalsList: x = 42, y'); +verifyNotEnumerable(f2, 'length'); +verifyNotWritable(f2, 'length'); +verifyConfigurable(f2, 'length'); + +var f3 = (x, y = 42) => {}; + +assert.sameValue(f3.length, 1, 'FormalsList: x, y = 42'); +verifyNotEnumerable(f3, 'length'); +verifyNotWritable(f3, 'length'); +verifyConfigurable(f3, 'length'); + +var f4 = (x, y = 42, z) => {}; + +assert.sameValue(f4.length, 1, 'FormalsList: x, y = 42, z'); +verifyNotEnumerable(f4, 'length'); +verifyNotWritable(f4, 'length'); +verifyConfigurable(f4, 'length'); diff --git a/test/language/expressions/class/gen-method-length-dflt.js b/test/language/expressions/class/gen-method-length-dflt.js new file mode 100644 index 0000000000..0de44b844c --- /dev/null +++ b/test/language/expressions/class/gen-method-length-dflt.js @@ -0,0 +1,59 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 14.1.6 +description: > + Default parameters' effect on function length +info: | + Function length is counted by the non initialized parameters in the left. + + 9.2.4 FunctionInitialize (F, kind, ParameterList, Body, Scope) + + [...] + 2. Let len be the ExpectedArgumentCount of ParameterList. + 3. Perform ! DefinePropertyOrThrow(F, "length", PropertyDescriptor{[[Value]]: + len, [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true}). + [...] + + FormalsList : FormalParameter + + 1. If HasInitializer of FormalParameter is true return 0 + 2. Return 1. + + FormalsList : FormalsList , FormalParameter + + 1. Let count be the ExpectedArgumentCount of FormalsList. + 2. If HasInitializer of FormalsList is true or HasInitializer of + FormalParameter is true, return count. + 3. Return count+1. +features: [default-parameters] +includes: [propertyHelper.js] +---*/ + +var m1 = class { *m(x = 42) {} }.prototype.m; + +assert.sameValue(m1.length, 0, 'formalslist: x = 42'); +verifyNotEnumerable(m1, 'length'); +verifyNotWritable(m1, 'length'); +verifyConfigurable(m1, 'length'); + +var m2 = class { *m(x = 42, y) {} }.prototype.m; + +assert.sameValue(m2.length, 0, 'formalslist: x = 42, y'); +verifyNotEnumerable(m2, 'length'); +verifyNotWritable(m2, 'length'); +verifyConfigurable(m2, 'length'); + +var m3 = class { *m(x, y = 42) {} }.prototype.m; + +assert.sameValue(m3.length, 1, 'formalslist: x, y = 42'); +verifyNotEnumerable(m3, 'length'); +verifyNotWritable(m3, 'length'); +verifyConfigurable(m3, 'length'); + +var m4 = class { *m(x, y = 42, z) {} }.prototype.m; + +assert.sameValue(m4.length, 1, 'formalslist: x, y = 42, z'); +verifyNotEnumerable(m4, 'length'); +verifyNotWritable(m4, 'length'); +verifyConfigurable(m4, 'length'); diff --git a/test/language/expressions/class/getter-param-dflt.js b/test/language/expressions/class/getter-param-dflt.js new file mode 100644 index 0000000000..a6cbb974ec --- /dev/null +++ b/test/language/expressions/class/getter-param-dflt.js @@ -0,0 +1,19 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-method-definitions +es6id: 14.3 +description: > + Get accessor method may not have a formal parameter (regardless of the + presence of an initializer) +info: | + Syntax + + MethodDefinition[Yield] : + + get PropertyName[?Yield] ( ) { FunctionBody } +features: [default-parameters] +negative: SyntaxError +---*/ + +0, class { get a(param = null) {} }; diff --git a/test/language/expressions/class/method-length-dflt.js b/test/language/expressions/class/method-length-dflt.js new file mode 100644 index 0000000000..7d86f69902 --- /dev/null +++ b/test/language/expressions/class/method-length-dflt.js @@ -0,0 +1,59 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 14.1.6 +description: > + Default parameters' effect on function length +info: | + Function length is counted by the non initialized parameters in the left. + + 9.2.4 FunctionInitialize (F, kind, ParameterList, Body, Scope) + + [...] + 2. Let len be the ExpectedArgumentCount of ParameterList. + 3. Perform ! DefinePropertyOrThrow(F, "length", PropertyDescriptor{[[Value]]: + len, [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true}). + [...] + + FormalsList : FormalParameter + + 1. If HasInitializer of FormalParameter is true return 0 + 2. Return 1. + + FormalsList : FormalsList , FormalParameter + + 1. Let count be the ExpectedArgumentCount of FormalsList. + 2. If HasInitializer of FormalsList is true or HasInitializer of + FormalParameter is true, return count. + 3. Return count+1. +features: [default-parameters] +includes: [propertyHelper.js] +---*/ + +var m1 = class { m(x = 42) {} }.prototype.m; + +assert.sameValue(m1.length, 0, 'formalslist: x = 42'); +verifyNotEnumerable(m1, 'length'); +verifyNotWritable(m1, 'length'); +verifyConfigurable(m1, 'length'); + +var m2 = class { m(x = 42, y) {} }.prototype.m; + +assert.sameValue(m2.length, 0, 'formalslist: x = 42, y'); +verifyNotEnumerable(m2, 'length'); +verifyNotWritable(m2, 'length'); +verifyConfigurable(m2, 'length'); + +var m3 = class { m(x, y = 42) {} }.prototype.m; + +assert.sameValue(m3.length, 1, 'formalslist: x, y = 42'); +verifyNotEnumerable(m3, 'length'); +verifyNotWritable(m3, 'length'); +verifyConfigurable(m3, 'length'); + +var m4 = class { m(x, y = 42, z) {} }.prototype.m; + +assert.sameValue(m4.length, 1, 'formalslist: x, y = 42, z'); +verifyNotEnumerable(m4, 'length'); +verifyNotWritable(m4, 'length'); +verifyConfigurable(m4, 'length'); diff --git a/test/language/expressions/class/setter-length-dflt.js b/test/language/expressions/class/setter-length-dflt.js new file mode 100644 index 0000000000..49ec1512dc --- /dev/null +++ b/test/language/expressions/class/setter-length-dflt.js @@ -0,0 +1,39 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 14.1.6 +description: > + Default parameters' effect on function length +info: | + Function length is counted by the non initialized parameters in the left. + + 9.2.4 FunctionInitialize (F, kind, ParameterList, Body, Scope) + + [...] + 2. Let len be the ExpectedArgumentCount of ParameterList. + 3. Perform ! DefinePropertyOrThrow(F, "length", PropertyDescriptor{[[Value]]: + len, [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true}). + [...] + + FormalsList : FormalParameter + + 1. If HasInitializer of FormalParameter is true return 0 + 2. Return 1. + + FormalsList : FormalsList , FormalParameter + + 1. Let count be the ExpectedArgumentCount of FormalsList. + 2. If HasInitializer of FormalsList is true or HasInitializer of + FormalParameter is true, return count. + 3. Return count+1. +features: [default-parameters] +includes: [propertyHelper.js] +---*/ + +var C = class { set m(x = 42) {} }; +var set = Object.getOwnPropertyDescriptor(C.prototype, 'm').set; + +assert.sameValue(set.length, 0, 'FormalsList: x = 42'); +verifyNotEnumerable(set, 'length'); +verifyNotWritable(set, 'length'); +verifyConfigurable(set, 'length'); diff --git a/test/language/expressions/class/static-method-length-dflt.js b/test/language/expressions/class/static-method-length-dflt.js new file mode 100644 index 0000000000..4e638ef2ad --- /dev/null +++ b/test/language/expressions/class/static-method-length-dflt.js @@ -0,0 +1,59 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 14.1.6 +description: > + Default parameters' effect on function length +info: | + Function length is counted by the non initialized parameters in the left. + + 9.2.4 FunctionInitialize (F, kind, ParameterList, Body, Scope) + + [...] + 2. Let len be the ExpectedArgumentCount of ParameterList. + 3. Perform ! DefinePropertyOrThrow(F, "length", PropertyDescriptor{[[Value]]: + len, [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true}). + [...] + + FormalsList : FormalParameter + + 1. If HasInitializer of FormalParameter is true return 0 + 2. Return 1. + + FormalsList : FormalsList , FormalParameter + + 1. Let count be the ExpectedArgumentCount of FormalsList. + 2. If HasInitializer of FormalsList is true or HasInitializer of + FormalParameter is true, return count. + 3. Return count+1. +features: [default-parameters] +includes: [propertyHelper.js] +---*/ + +var m1 = class { static m(x = 42) {} }.m; + +assert.sameValue(m1.length, 0, 'formalslist: x = 42'); +verifyNotEnumerable(m1, 'length'); +verifyNotWritable(m1, 'length'); +verifyConfigurable(m1, 'length'); + +var m2 = class { static m(x = 42, y) {} }.m; + +assert.sameValue(m2.length, 0, 'formalslist: x = 42, y'); +verifyNotEnumerable(m2, 'length'); +verifyNotWritable(m2, 'length'); +verifyConfigurable(m2, 'length'); + +var m3 = class { static m(x, y = 42) {} }.m; + +assert.sameValue(m3.length, 1, 'formalslist: x, y = 42'); +verifyNotEnumerable(m3, 'length'); +verifyNotWritable(m3, 'length'); +verifyConfigurable(m3, 'length'); + +var m4 = class { static m(x, y = 42, z) {} }.m; + +assert.sameValue(m4.length, 1, 'formalslist: x, y = 42, z'); +verifyNotEnumerable(m4, 'length'); +verifyNotWritable(m4, 'length'); +verifyConfigurable(m4, 'length'); diff --git a/test/language/expressions/function/length-dflt.js b/test/language/expressions/function/length-dflt.js new file mode 100644 index 0000000000..724e8f7443 --- /dev/null +++ b/test/language/expressions/function/length-dflt.js @@ -0,0 +1,60 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 14.1.6 +description: > + Default parameters' effect on function length +info: | + Function length is counted by the non initialized parameters in the left. + + 9.2.4 FunctionInitialize (F, kind, ParameterList, Body, Scope) + + [...] + 2. Let len be the ExpectedArgumentCount of ParameterList. + 3. Perform ! DefinePropertyOrThrow(F, "length", PropertyDescriptor{[[Value]]: + len, [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true}). + [...] + + FormalsList : FormalParameter + + 1. If HasInitializer of FormalParameter is true return 0 + 2. Return 1. + + FormalsList : FormalsList , FormalParameter + + 1. Let count be the ExpectedArgumentCount of FormalsList. + 2. If HasInitializer of FormalsList is true or HasInitializer of + FormalParameter is true, return count. + 3. Return count+1. +features: [default-parameters] +includes: [propertyHelper.js] +---*/ + + +var f1 = function (x = 42) {}; + +assert.sameValue(f1.length, 0, 'FormalsList: x = 42'); +verifyNotEnumerable(f1, 'length'); +verifyNotWritable(f1, 'length'); +verifyConfigurable(f1, 'length'); + +var f2 = function (x = 42, y) {}; + +assert.sameValue(f2.length, 0, 'FormalsList: x = 42, y'); +verifyNotEnumerable(f2, 'length'); +verifyNotWritable(f2, 'length'); +verifyConfigurable(f2, 'length'); + +var f3 = function (x, y = 42) {}; + +assert.sameValue(f3.length, 1, 'FormalsList: x, y = 42'); +verifyNotEnumerable(f3, 'length'); +verifyNotWritable(f3, 'length'); +verifyConfigurable(f3, 'length'); + +var f4 = function (x, y = 42, z) {}; + +assert.sameValue(f4.length, 1, 'FormalsList: x, y = 42, z'); +verifyNotEnumerable(f4, 'length'); +verifyNotWritable(f4, 'length'); +verifyConfigurable(f4, 'length'); diff --git a/test/language/expressions/generators/length-dflt.js b/test/language/expressions/generators/length-dflt.js new file mode 100644 index 0000000000..8ea33c7934 --- /dev/null +++ b/test/language/expressions/generators/length-dflt.js @@ -0,0 +1,60 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 14.1.6 +description: > + Default parameters' effect on function length +info: | + Function length is counted by the non initialized parameters in the left. + + 9.2.4 FunctionInitialize (F, kind, ParameterList, Body, Scope) + + [...] + 2. Let len be the ExpectedArgumentCount of ParameterList. + 3. Perform ! DefinePropertyOrThrow(F, "length", PropertyDescriptor{[[Value]]: + len, [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true}). + [...] + + FormalsList : FormalParameter + + 1. If HasInitializer of FormalParameter is true return 0 + 2. Return 1. + + FormalsList : FormalsList , FormalParameter + + 1. Let count be the ExpectedArgumentCount of FormalsList. + 2. If HasInitializer of FormalsList is true or HasInitializer of + FormalParameter is true, return count. + 3. Return count+1. +features: [default-parameters] +includes: [propertyHelper.js] +---*/ + + +var f1 = function* (x = 42) {}; + +assert.sameValue(f1.length, 0, 'FormalsList: x = 42'); +verifyNotEnumerable(f1, 'length'); +verifyNotWritable(f1, 'length'); +verifyConfigurable(f1, 'length'); + +var f2 = function* (x = 42, y) {}; + +assert.sameValue(f2.length, 0, 'FormalsList: x = 42, y'); +verifyNotEnumerable(f2, 'length'); +verifyNotWritable(f2, 'length'); +verifyConfigurable(f2, 'length'); + +var f3 = function* (x, y = 42) {}; + +assert.sameValue(f3.length, 1, 'FormalsList: x, y = 42'); +verifyNotEnumerable(f3, 'length'); +verifyNotWritable(f3, 'length'); +verifyConfigurable(f3, 'length'); + +var f4 = function* (x, y = 42, z) {}; + +assert.sameValue(f4.length, 1, 'FormalsList: x, y = 42, z'); +verifyNotEnumerable(f4, 'length'); +verifyNotWritable(f4, 'length'); +verifyConfigurable(f4, 'length'); diff --git a/test/language/expressions/object/getter-param-dflt.js b/test/language/expressions/object/getter-param-dflt.js new file mode 100644 index 0000000000..12d1a159a4 --- /dev/null +++ b/test/language/expressions/object/getter-param-dflt.js @@ -0,0 +1,19 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-method-definitions +es6id: 14.3 +description: > + Get accessor method may not have a formal parameter (regardless of the + presence of an initializer) +info: | + Syntax + + MethodDefinition[Yield] : + + get PropertyName[?Yield] ( ) { FunctionBody } +features: [default-parameters] +negative: SyntaxError +---*/ + +0, { get a(param = null) {} }; diff --git a/test/language/expressions/object/method-definition/generator-length-dflt.js b/test/language/expressions/object/method-definition/generator-length-dflt.js new file mode 100644 index 0000000000..97cfe97971 --- /dev/null +++ b/test/language/expressions/object/method-definition/generator-length-dflt.js @@ -0,0 +1,60 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 14.1.6 +description: > + Default parameters' effect on function length +info: | + Function length is counted by the non initialized parameters in the left. + + 9.2.4 FunctionInitialize (F, kind, ParameterList, Body, Scope) + + [...] + 2. Let len be the ExpectedArgumentCount of ParameterList. + 3. Perform ! DefinePropertyOrThrow(F, "length", PropertyDescriptor{[[Value]]: + len, [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true}). + [...] + + FormalsList : FormalParameter + + 1. If HasInitializer of FormalParameter is true return 0 + 2. Return 1. + + FormalsList : FormalsList , FormalParameter + + 1. Let count be the ExpectedArgumentCount of FormalsList. + 2. If HasInitializer of FormalsList is true or HasInitializer of + FormalParameter is true, return count. + 3. Return count+1. +features: [default-parameters] +includes: [propertyHelper.js] +---*/ + + +var f1 = { *m(x = 42) {} }.m; + +assert.sameValue(f1.length, 0, 'FormalsList: x = 42'); +verifyNotEnumerable(f1, 'length'); +verifyNotWritable(f1, 'length'); +verifyConfigurable(f1, 'length'); + +var f2 = { *m(x = 42, y) {} }.m; + +assert.sameValue(f2.length, 0, 'FormalsList: x = 42, y'); +verifyNotEnumerable(f2, 'length'); +verifyNotWritable(f2, 'length'); +verifyConfigurable(f2, 'length'); + +var f3 = { *m(x, y = 42) {} }.m; + +assert.sameValue(f3.length, 1, 'FormalsList: x, y = 42'); +verifyNotEnumerable(f3, 'length'); +verifyNotWritable(f3, 'length'); +verifyConfigurable(f3, 'length'); + +var f4 = { *m(x, y = 42, z) {} }.m; + +assert.sameValue(f4.length, 1, 'FormalsList: x, y = 42, z'); +verifyNotEnumerable(f4, 'length'); +verifyNotWritable(f4, 'length'); +verifyConfigurable(f4, 'length') diff --git a/test/language/expressions/object/method-definition/name-length-dflt.js b/test/language/expressions/object/method-definition/name-length-dflt.js new file mode 100644 index 0000000000..91db6172ad --- /dev/null +++ b/test/language/expressions/object/method-definition/name-length-dflt.js @@ -0,0 +1,60 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 14.1.6 +description: > + Default parameters' effect on function length +info: | + Function length is counted by the non initialized parameters in the left. + + 9.2.4 FunctionInitialize (F, kind, ParameterList, Body, Scope) + + [...] + 2. Let len be the ExpectedArgumentCount of ParameterList. + 3. Perform ! DefinePropertyOrThrow(F, "length", PropertyDescriptor{[[Value]]: + len, [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true}). + [...] + + FormalsList : FormalParameter + + 1. If HasInitializer of FormalParameter is true return 0 + 2. Return 1. + + FormalsList : FormalsList , FormalParameter + + 1. Let count be the ExpectedArgumentCount of FormalsList. + 2. If HasInitializer of FormalsList is true or HasInitializer of + FormalParameter is true, return count. + 3. Return count+1. +features: [default-parameters] +includes: [propertyHelper.js] +---*/ + + +var f1 = { m(x = 42) {} }.m; + +assert.sameValue(f1.length, 0, 'FormalsList: x = 42'); +verifyNotEnumerable(f1, 'length'); +verifyNotWritable(f1, 'length'); +verifyConfigurable(f1, 'length'); + +var f2 = { m(x = 42, y) {} }.m; + +assert.sameValue(f2.length, 0, 'FormalsList: x = 42, y'); +verifyNotEnumerable(f2, 'length'); +verifyNotWritable(f2, 'length'); +verifyConfigurable(f2, 'length'); + +var f3 = { m(x, y = 42) {} }.m; + +assert.sameValue(f3.length, 1, 'FormalsList: x, y = 42'); +verifyNotEnumerable(f3, 'length'); +verifyNotWritable(f3, 'length'); +verifyConfigurable(f3, 'length'); + +var f4 = { m(x, y = 42, z) {} }.m; + +assert.sameValue(f4.length, 1, 'FormalsList: x, y = 42, z'); +verifyNotEnumerable(f4, 'length'); +verifyNotWritable(f4, 'length'); +verifyConfigurable(f4, 'length'); diff --git a/test/language/expressions/object/setter-length-dflt.js b/test/language/expressions/object/setter-length-dflt.js new file mode 100644 index 0000000000..a5e44d602b --- /dev/null +++ b/test/language/expressions/object/setter-length-dflt.js @@ -0,0 +1,39 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 14.1.6 +description: > + Default parameters' effect on function length +info: | + Function length is counted by the non initialized parameters in the left. + + 9.2.4 FunctionInitialize (F, kind, ParameterList, Body, Scope) + + [...] + 2. Let len be the ExpectedArgumentCount of ParameterList. + 3. Perform ! DefinePropertyOrThrow(F, "length", PropertyDescriptor{[[Value]]: + len, [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true}). + [...] + + FormalsList : FormalParameter + + 1. If HasInitializer of FormalParameter is true return 0 + 2. Return 1. + + FormalsList : FormalsList , FormalParameter + + 1. Let count be the ExpectedArgumentCount of FormalsList. + 2. If HasInitializer of FormalsList is true or HasInitializer of + FormalParameter is true, return count. + 3. Return count+1. +features: [default-parameters] +includes: [propertyHelper.js] +---*/ + + +var set = Object.getOwnPropertyDescriptor({ set m(x = 42) {} }, 'm').set; + +assert.sameValue(set.length, 0, 'FormalsList: x = 42'); +verifyNotEnumerable(set, 'length'); +verifyNotWritable(set, 'length'); +verifyConfigurable(set, 'length'); diff --git a/test/language/statements/class/gen-method-length-dflt.js b/test/language/statements/class/gen-method-length-dflt.js new file mode 100644 index 0000000000..a26a287fe7 --- /dev/null +++ b/test/language/statements/class/gen-method-length-dflt.js @@ -0,0 +1,67 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 14.1.6 +description: > + Default parameters' effect on function length +info: | + Function length is counted by the non initialized parameters in the left. + + 9.2.4 FunctionInitialize (F, kind, ParameterList, Body, Scope) + + [...] + 2. Let len be the ExpectedArgumentCount of ParameterList. + 3. Perform ! DefinePropertyOrThrow(F, "length", PropertyDescriptor{[[Value]]: + len, [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true}). + [...] + + FormalsList : FormalParameter + + 1. If HasInitializer of FormalParameter is true return 0 + 2. Return 1. + + FormalsList : FormalsList , FormalParameter + + 1. Let count be the ExpectedArgumentCount of FormalsList. + 2. If HasInitializer of FormalsList is true or HasInitializer of + FormalParameter is true, return count. + 3. Return count+1. +features: [default-parameters] +includes: [propertyHelper.js] +---*/ + +class C1 { *m(x = 42) {} } + +var m1 = C1.prototype.m; + +assert.sameValue(m1.length, 0, 'formalslist: x = 42'); +verifyNotEnumerable(m1, 'length'); +verifyNotWritable(m1, 'length'); +verifyConfigurable(m1, 'length'); + +class C2 { *m(x = 42, y) {} } + +var m2 = C2.prototype.m; + +assert.sameValue(m2.length, 0, 'formalslist: x = 42, y'); +verifyNotEnumerable(m2, 'length'); +verifyNotWritable(m2, 'length'); +verifyConfigurable(m2, 'length'); + +class C3 { *m(x, y = 42) {} } + +var m3 = C3.prototype.m; + +assert.sameValue(m3.length, 1, 'formalslist: x, y = 42'); +verifyNotEnumerable(m3, 'length'); +verifyNotWritable(m3, 'length'); +verifyConfigurable(m3, 'length'); + +class C4 { *m(x, y = 42, z) {} } + +var m4 = C4.prototype.m; + +assert.sameValue(m4.length, 1, 'formalslist: x, y = 42, z'); +verifyNotEnumerable(m4, 'length'); +verifyNotWritable(m4, 'length'); +verifyConfigurable(m4, 'length'); diff --git a/test/language/statements/class/getter-param-dflt.js b/test/language/statements/class/getter-param-dflt.js new file mode 100644 index 0000000000..460bec80b8 --- /dev/null +++ b/test/language/statements/class/getter-param-dflt.js @@ -0,0 +1,19 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-method-definitions +es6id: 14.3 +description: > + Get accessor method may not have a formal parameter (regardless of the + presence of an initializer) +info: | + Syntax + + MethodDefinition[Yield] : + + get PropertyName[?Yield] ( ) { FunctionBody } +features: [default-parameters] +negative: SyntaxError +---*/ + +class C { get a(param = null) {} } diff --git a/test/language/statements/class/method-length-dflt.js b/test/language/statements/class/method-length-dflt.js new file mode 100644 index 0000000000..42a742ed4b --- /dev/null +++ b/test/language/statements/class/method-length-dflt.js @@ -0,0 +1,67 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 14.1.6 +description: > + Default parameters' effect on function length +info: | + Function length is counted by the non initialized parameters in the left. + + 9.2.4 FunctionInitialize (F, kind, ParameterList, Body, Scope) + + [...] + 2. Let len be the ExpectedArgumentCount of ParameterList. + 3. Perform ! DefinePropertyOrThrow(F, "length", PropertyDescriptor{[[Value]]: + len, [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true}). + [...] + + FormalsList : FormalParameter + + 1. If HasInitializer of FormalParameter is true return 0 + 2. Return 1. + + FormalsList : FormalsList , FormalParameter + + 1. Let count be the ExpectedArgumentCount of FormalsList. + 2. If HasInitializer of FormalsList is true or HasInitializer of + FormalParameter is true, return count. + 3. Return count+1. +features: [default-parameters] +includes: [propertyHelper.js] +---*/ + +class C1 { m(x = 42) {} } + +var m1 = C1.prototype.m; + +assert.sameValue(m1.length, 0, 'formalslist: x = 42'); +verifyNotEnumerable(m1, 'length'); +verifyNotWritable(m1, 'length'); +verifyConfigurable(m1, 'length'); + +class C2 { m(x = 42, y) {} } + +var m2 = C2.prototype.m; + +assert.sameValue(m2.length, 0, 'formalslist: x = 42, y'); +verifyNotEnumerable(m2, 'length'); +verifyNotWritable(m2, 'length'); +verifyConfigurable(m2, 'length'); + +class C3 { m(x, y = 42) {} } + +var m3 = C3.prototype.m; + +assert.sameValue(m3.length, 1, 'formalslist: x, y = 42'); +verifyNotEnumerable(m3, 'length'); +verifyNotWritable(m3, 'length'); +verifyConfigurable(m3, 'length'); + +class C4 { m(x, y = 42, z) {} } + +var m4 = C4.prototype.m; + +assert.sameValue(m4.length, 1, 'formalslist: x, y = 42, z'); +verifyNotEnumerable(m4, 'length'); +verifyNotWritable(m4, 'length'); +verifyConfigurable(m4, 'length'); diff --git a/test/language/statements/class/setter-length-dflt.js b/test/language/statements/class/setter-length-dflt.js new file mode 100644 index 0000000000..b6a962d686 --- /dev/null +++ b/test/language/statements/class/setter-length-dflt.js @@ -0,0 +1,39 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 14.1.6 +description: > + Default parameters' effect on function length +info: | + Function length is counted by the non initialized parameters in the left. + + 9.2.4 FunctionInitialize (F, kind, ParameterList, Body, Scope) + + [...] + 2. Let len be the ExpectedArgumentCount of ParameterList. + 3. Perform ! DefinePropertyOrThrow(F, "length", PropertyDescriptor{[[Value]]: + len, [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true}). + [...] + + FormalsList : FormalParameter + + 1. If HasInitializer of FormalParameter is true return 0 + 2. Return 1. + + FormalsList : FormalsList , FormalParameter + + 1. Let count be the ExpectedArgumentCount of FormalsList. + 2. If HasInitializer of FormalsList is true or HasInitializer of + FormalParameter is true, return count. + 3. Return count+1. +features: [default-parameters] +includes: [propertyHelper.js] +---*/ + +class C { set m(x = 42) {} } +var set = Object.getOwnPropertyDescriptor(C.prototype, 'm').set; + +assert.sameValue(set.length, 0, 'FormalsList: x = 42'); +verifyNotEnumerable(set, 'length'); +verifyNotWritable(set, 'length'); +verifyConfigurable(set, 'length'); diff --git a/test/language/statements/class/static-method-length-dflt.js b/test/language/statements/class/static-method-length-dflt.js new file mode 100644 index 0000000000..4a008d9fc8 --- /dev/null +++ b/test/language/statements/class/static-method-length-dflt.js @@ -0,0 +1,67 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 14.1.6 +description: > + Default parameters' effect on function length +info: | + Function length is counted by the non initialized parameters in the left. + + 9.2.4 FunctionInitialize (F, kind, ParameterList, Body, Scope) + + [...] + 2. Let len be the ExpectedArgumentCount of ParameterList. + 3. Perform ! DefinePropertyOrThrow(F, "length", PropertyDescriptor{[[Value]]: + len, [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true}). + [...] + + FormalsList : FormalParameter + + 1. If HasInitializer of FormalParameter is true return 0 + 2. Return 1. + + FormalsList : FormalsList , FormalParameter + + 1. Let count be the ExpectedArgumentCount of FormalsList. + 2. If HasInitializer of FormalsList is true or HasInitializer of + FormalParameter is true, return count. + 3. Return count+1. +features: [default-parameters] +includes: [propertyHelper.js] +---*/ + +class C1 { static m(x = 42) {} } + +var m1 = C1.m; + +assert.sameValue(m1.length, 0, 'formalslist: x = 42'); +verifyNotEnumerable(m1, 'length'); +verifyNotWritable(m1, 'length'); +verifyConfigurable(m1, 'length'); + +class C2 { static m(x = 42, y) {} } + +var m2 = C2.m; + +assert.sameValue(m2.length, 0, 'formalslist: x = 42, y'); +verifyNotEnumerable(m2, 'length'); +verifyNotWritable(m2, 'length'); +verifyConfigurable(m2, 'length'); + +class C3 { static m(x, y = 42) {} } + +var m3 = C3.m; + +assert.sameValue(m3.length, 1, 'formalslist: x, y = 42'); +verifyNotEnumerable(m3, 'length'); +verifyNotWritable(m3, 'length'); +verifyConfigurable(m3, 'length'); + +class C4 { static m(x, y = 42, z) {} } + +var m4 = C4.m; + +assert.sameValue(m4.length, 1, 'formalslist: x, y = 42, z'); +verifyNotEnumerable(m4, 'length'); +verifyNotWritable(m4, 'length'); +verifyConfigurable(m4, 'length'); diff --git a/test/language/statements/function/length-dflt.js b/test/language/statements/function/length-dflt.js new file mode 100644 index 0000000000..edcc10fb85 --- /dev/null +++ b/test/language/statements/function/length-dflt.js @@ -0,0 +1,60 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 14.1.6 +description: > + Default parameters' effect on function length +info: | + Function length is counted by the non initialized parameters in the left. + + 9.2.4 FunctionInitialize (F, kind, ParameterList, Body, Scope) + + [...] + 2. Let len be the ExpectedArgumentCount of ParameterList. + 3. Perform ! DefinePropertyOrThrow(F, "length", PropertyDescriptor{[[Value]]: + len, [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true}). + [...] + + FormalsList : FormalParameter + + 1. If HasInitializer of FormalParameter is true return 0 + 2. Return 1. + + FormalsList : FormalsList , FormalParameter + + 1. Let count be the ExpectedArgumentCount of FormalsList. + 2. If HasInitializer of FormalsList is true or HasInitializer of + FormalParameter is true, return count. + 3. Return count+1. +features: [default-parameters] +includes: [propertyHelper.js] +---*/ + + +function f1(x = 42) {} + +assert.sameValue(f1.length, 0, 'FormalsList: x = 42'); +verifyNotEnumerable(f1, 'length'); +verifyNotWritable(f1, 'length'); +verifyConfigurable(f1, 'length'); + +function f2(x = 42, y) {} + +assert.sameValue(f2.length, 0, 'FormalsList: x = 42, y'); +verifyNotEnumerable(f2, 'length'); +verifyNotWritable(f2, 'length'); +verifyConfigurable(f2, 'length'); + +function f3(x, y = 42) {} + +assert.sameValue(f3.length, 1, 'FormalsList: x, y = 42'); +verifyNotEnumerable(f3, 'length'); +verifyNotWritable(f3, 'length'); +verifyConfigurable(f3, 'length'); + +function f4(x, y = 42, z) {} + +assert.sameValue(f4.length, 1, 'FormalsList: x, y = 42, z'); +verifyNotEnumerable(f4, 'length'); +verifyNotWritable(f4, 'length'); +verifyConfigurable(f4, 'length'); diff --git a/test/language/statements/generators/length-dflt.js b/test/language/statements/generators/length-dflt.js new file mode 100644 index 0000000000..5fbf570467 --- /dev/null +++ b/test/language/statements/generators/length-dflt.js @@ -0,0 +1,60 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 14.1.6 +description: > + Default parameters' effect on function length +info: | + Function length is counted by the non initialized parameters in the left. + + 9.2.4 FunctionInitialize (F, kind, ParameterList, Body, Scope) + + [...] + 2. Let len be the ExpectedArgumentCount of ParameterList. + 3. Perform ! DefinePropertyOrThrow(F, "length", PropertyDescriptor{[[Value]]: + len, [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true}). + [...] + + FormalsList : FormalParameter + + 1. If HasInitializer of FormalParameter is true return 0 + 2. Return 1. + + FormalsList : FormalsList , FormalParameter + + 1. Let count be the ExpectedArgumentCount of FormalsList. + 2. If HasInitializer of FormalsList is true or HasInitializer of + FormalParameter is true, return count. + 3. Return count+1. +features: [default-parameters] +includes: [propertyHelper.js] +---*/ + + +function* f1(x = 42) {} + +assert.sameValue(f1.length, 0, 'FormalsList: x = 42'); +verifyNotEnumerable(f1, 'length'); +verifyNotWritable(f1, 'length'); +verifyConfigurable(f1, 'length'); + +function* f2(x = 42, y) {} + +assert.sameValue(f2.length, 0, 'FormalsList: x = 42, y'); +verifyNotEnumerable(f2, 'length'); +verifyNotWritable(f2, 'length'); +verifyConfigurable(f2, 'length'); + +function* f3(x, y = 42) {} + +assert.sameValue(f3.length, 1, 'FormalsList: x, y = 42'); +verifyNotEnumerable(f3, 'length'); +verifyNotWritable(f3, 'length'); +verifyConfigurable(f3, 'length'); + +function* f4(x, y = 42, z) {} + +assert.sameValue(f4.length, 1, 'FormalsList: x, y = 42, z'); +verifyNotEnumerable(f4, 'length'); +verifyNotWritable(f4, 'length'); +verifyConfigurable(f4, 'length'); -- GitLab From 655a8808520e450442011eaa8ee6e3cf549ad89e Mon Sep 17 00:00:00 2001 From: Mike Pennisi <mike@mikepennisi.com> Date: Thu, 2 Jun 2016 14:14:15 -0400 Subject: [PATCH 7/8] Add tests for arguments obj with dflt parameters --- .../params-dflt-gen-meth-args-unmapped.js | 106 ++++++++++++++++++ .../params-dflt-gen-meth-ref-arguments.js | 85 ++++++++++++++ ...rams-dflt-gen-meth-static-args-unmapped.js | 106 ++++++++++++++++++ ...rams-dflt-gen-meth-static-ref-arguments.js | 85 ++++++++++++++ .../class/params-dflt-meth-args-unmapped.js | 103 +++++++++++++++++ .../class/params-dflt-meth-ref-arguments.js | 82 ++++++++++++++ .../params-dflt-meth-static-args-unmapped.js | 103 +++++++++++++++++ .../params-dflt-meth-static-ref-arguments.js | 82 ++++++++++++++ .../function/params-dflt-args-unmapped.js | 82 ++++++++++++++ .../function/params-dflt-ref-arguments.js | 61 ++++++++++ .../generators/params-dflt-args-unmapped.js | 82 ++++++++++++++ .../generators/params-dflt-ref-arguments.js | 61 ++++++++++ .../params-dflt-gen-meth-args-unmapped.js | 88 +++++++++++++++ .../params-dflt-gen-meth-ref-arguments.js | 67 +++++++++++ .../params-dflt-meth-args-unmapped.js | 85 ++++++++++++++ .../params-dflt-meth-ref-arguments.js | 64 +++++++++++ .../params-dflt-gen-meth-args-unmapped.js | 104 +++++++++++++++++ .../params-dflt-gen-meth-ref-arguments.js | 83 ++++++++++++++ ...rams-dflt-gen-meth-static-args-unmapped.js | 104 +++++++++++++++++ ...rams-dflt-gen-meth-static-ref-arguments.js | 83 ++++++++++++++ .../class/params-dflt-meth-args-unmapped.js | 102 +++++++++++++++++ .../class/params-dflt-meth-ref-arguments.js | 81 +++++++++++++ .../params-dflt-meth-static-args-unmapped.js | 102 +++++++++++++++++ .../params-dflt-meth-static-ref-arguments.js | 81 +++++++++++++ .../function/params-dflt-args-unmapped.js | 82 ++++++++++++++ .../function/params-dflt-ref-arguments.js | 61 ++++++++++ .../generators/params-dflt-args-unmapped.js | 81 +++++++++++++ .../generators/params-dflt-ref-arguments.js | 60 ++++++++++ 28 files changed, 2366 insertions(+) create mode 100644 test/language/expressions/class/params-dflt-gen-meth-args-unmapped.js create mode 100644 test/language/expressions/class/params-dflt-gen-meth-ref-arguments.js create mode 100644 test/language/expressions/class/params-dflt-gen-meth-static-args-unmapped.js create mode 100644 test/language/expressions/class/params-dflt-gen-meth-static-ref-arguments.js create mode 100644 test/language/expressions/class/params-dflt-meth-args-unmapped.js create mode 100644 test/language/expressions/class/params-dflt-meth-ref-arguments.js create mode 100644 test/language/expressions/class/params-dflt-meth-static-args-unmapped.js create mode 100644 test/language/expressions/class/params-dflt-meth-static-ref-arguments.js create mode 100644 test/language/expressions/function/params-dflt-args-unmapped.js create mode 100644 test/language/expressions/function/params-dflt-ref-arguments.js create mode 100644 test/language/expressions/generators/params-dflt-args-unmapped.js create mode 100644 test/language/expressions/generators/params-dflt-ref-arguments.js create mode 100644 test/language/expressions/object/method-definition/params-dflt-gen-meth-args-unmapped.js create mode 100644 test/language/expressions/object/method-definition/params-dflt-gen-meth-ref-arguments.js create mode 100644 test/language/expressions/object/method-definition/params-dflt-meth-args-unmapped.js create mode 100644 test/language/expressions/object/method-definition/params-dflt-meth-ref-arguments.js create mode 100644 test/language/statements/class/params-dflt-gen-meth-args-unmapped.js create mode 100644 test/language/statements/class/params-dflt-gen-meth-ref-arguments.js create mode 100644 test/language/statements/class/params-dflt-gen-meth-static-args-unmapped.js create mode 100644 test/language/statements/class/params-dflt-gen-meth-static-ref-arguments.js create mode 100644 test/language/statements/class/params-dflt-meth-args-unmapped.js create mode 100644 test/language/statements/class/params-dflt-meth-ref-arguments.js create mode 100644 test/language/statements/class/params-dflt-meth-static-args-unmapped.js create mode 100644 test/language/statements/class/params-dflt-meth-static-ref-arguments.js create mode 100644 test/language/statements/function/params-dflt-args-unmapped.js create mode 100644 test/language/statements/function/params-dflt-ref-arguments.js create mode 100644 test/language/statements/generators/params-dflt-args-unmapped.js create mode 100644 test/language/statements/generators/params-dflt-ref-arguments.js diff --git a/test/language/expressions/class/params-dflt-gen-meth-args-unmapped.js b/test/language/expressions/class/params-dflt-gen-meth-args-unmapped.js new file mode 100644 index 0000000000..d34478a773 --- /dev/null +++ b/test/language/expressions/class/params-dflt-gen-meth-args-unmapped.js @@ -0,0 +1,106 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: Referencing the arguments object from a default parameter (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [default-parameters] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + 1. Let status be the result of performing IteratorBindingInitialization for + FormalsList using iteratorRecord and environment as the arguments. + 2. ReturnIfAbrupt(status). + 3. Return the result of performing IteratorBindingInitialization for + FormalParameter using iteratorRecord and environment as the arguments. +---*/ + +var callCount = 0; +var C = class { + *method(x, _ = 0) { + assert.sameValue(x, undefined, 'parameter binding value (initial)'); + assert.sameValue( + arguments[0], undefined, 'arguments property value (initial)' + ); + + arguments[0] = 1; + + assert.sameValue( + x, undefined, 'parameter binding value (after arguments modification)' + ); + assert.sameValue( + arguments[0], 1, 'arguments property value (after arguments modification)' + ); + + x = 2; + + assert.sameValue( + x, 2, 'parameter binding value (after parameter binding modification)' + ); + assert.sameValue( + arguments[0], + 1, + 'arguments property value (after parameter binding modification)' + ); + callCount = callCount + 1; + } +}; + +C.prototype.method().next(); + +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/params-dflt-gen-meth-ref-arguments.js b/test/language/expressions/class/params-dflt-gen-meth-ref-arguments.js new file mode 100644 index 0000000000..880a9466a3 --- /dev/null +++ b/test/language/expressions/class/params-dflt-gen-meth-ref-arguments.js @@ -0,0 +1,85 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: Referencing the arguments object from a default parameter (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [default-parameters] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + 1. Let status be the result of performing IteratorBindingInitialization for + FormalsList using iteratorRecord and environment as the arguments. + 2. ReturnIfAbrupt(status). + 3. Return the result of performing IteratorBindingInitialization for + FormalParameter using iteratorRecord and environment as the arguments. +---*/ + +var callCount = 0; +var C = class { + *method(x = arguments[2], y = arguments[3], z) { + assert.sameValue(x, 'third', 'first parameter'); + assert.sameValue(y, 'fourth', 'second parameter'); + assert.sameValue(z, 'third', 'third parameter'); + callCount = callCount + 1; + } +}; + +C.prototype.method(undefined, undefined, 'third', 'fourth').next(); + +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/params-dflt-gen-meth-static-args-unmapped.js b/test/language/expressions/class/params-dflt-gen-meth-static-args-unmapped.js new file mode 100644 index 0000000000..023b97c759 --- /dev/null +++ b/test/language/expressions/class/params-dflt-gen-meth-static-args-unmapped.js @@ -0,0 +1,106 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: Referencing the arguments object from a default parameter (static class expression generator method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + 1. Let status be the result of performing IteratorBindingInitialization for + FormalsList using iteratorRecord and environment as the arguments. + 2. ReturnIfAbrupt(status). + 3. Return the result of performing IteratorBindingInitialization for + FormalParameter using iteratorRecord and environment as the arguments. +---*/ + +var callCount = 0; +var C = class { + static *method(x, _ = 0) { + assert.sameValue(x, undefined, 'parameter binding value (initial)'); + assert.sameValue( + arguments[0], undefined, 'arguments property value (initial)' + ); + + arguments[0] = 1; + + assert.sameValue( + x, undefined, 'parameter binding value (after arguments modification)' + ); + assert.sameValue( + arguments[0], 1, 'arguments property value (after arguments modification)' + ); + + x = 2; + + assert.sameValue( + x, 2, 'parameter binding value (after parameter binding modification)' + ); + assert.sameValue( + arguments[0], + 1, + 'arguments property value (after parameter binding modification)' + ); + callCount = callCount + 1; + } +}; + +C.method().next(); + +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/params-dflt-gen-meth-static-ref-arguments.js b/test/language/expressions/class/params-dflt-gen-meth-static-ref-arguments.js new file mode 100644 index 0000000000..4cc5ed0b3b --- /dev/null +++ b/test/language/expressions/class/params-dflt-gen-meth-static-ref-arguments.js @@ -0,0 +1,85 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: Referencing the arguments object from a default parameter (static class expression generator method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + 1. Let status be the result of performing IteratorBindingInitialization for + FormalsList using iteratorRecord and environment as the arguments. + 2. ReturnIfAbrupt(status). + 3. Return the result of performing IteratorBindingInitialization for + FormalParameter using iteratorRecord and environment as the arguments. +---*/ + +var callCount = 0; +var C = class { + static *method(x = arguments[2], y = arguments[3], z) { + assert.sameValue(x, 'third', 'first parameter'); + assert.sameValue(y, 'fourth', 'second parameter'); + assert.sameValue(z, 'third', 'third parameter'); + callCount = callCount + 1; + } +}; + +C.method(undefined, undefined, 'third', 'fourth').next(); + +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/params-dflt-meth-args-unmapped.js b/test/language/expressions/class/params-dflt-meth-args-unmapped.js new file mode 100644 index 0000000000..13ec1699f9 --- /dev/null +++ b/test/language/expressions/class/params-dflt-meth-args-unmapped.js @@ -0,0 +1,103 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: Referencing the arguments object from a default parameter (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [default-parameters] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + 1. Let status be the result of performing IteratorBindingInitialization for + FormalsList using iteratorRecord and environment as the arguments. + 2. ReturnIfAbrupt(status). + 3. Return the result of performing IteratorBindingInitialization for + FormalParameter using iteratorRecord and environment as the arguments. +---*/ + +var callCount = 0; +var C = class { + method(x, _ = 0) { + assert.sameValue(x, undefined, 'parameter binding value (initial)'); + assert.sameValue( + arguments[0], undefined, 'arguments property value (initial)' + ); + + arguments[0] = 1; + + assert.sameValue( + x, undefined, 'parameter binding value (after arguments modification)' + ); + assert.sameValue( + arguments[0], 1, 'arguments property value (after arguments modification)' + ); + + x = 2; + + assert.sameValue( + x, 2, 'parameter binding value (after parameter binding modification)' + ); + assert.sameValue( + arguments[0], + 1, + 'arguments property value (after parameter binding modification)' + ); + callCount = callCount + 1; + } +}; + +C.prototype.method(); + +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/params-dflt-meth-ref-arguments.js b/test/language/expressions/class/params-dflt-meth-ref-arguments.js new file mode 100644 index 0000000000..6025474a6c --- /dev/null +++ b/test/language/expressions/class/params-dflt-meth-ref-arguments.js @@ -0,0 +1,82 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: Referencing the arguments object from a default parameter (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [default-parameters] +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + 1. Let status be the result of performing IteratorBindingInitialization for + FormalsList using iteratorRecord and environment as the arguments. + 2. ReturnIfAbrupt(status). + 3. Return the result of performing IteratorBindingInitialization for + FormalParameter using iteratorRecord and environment as the arguments. +---*/ + +var callCount = 0; +var C = class { + method(x = arguments[2], y = arguments[3], z) { + assert.sameValue(x, 'third', 'first parameter'); + assert.sameValue(y, 'fourth', 'second parameter'); + assert.sameValue(z, 'third', 'third parameter'); + callCount = callCount + 1; + } +}; + +C.prototype.method(undefined, undefined, 'third', 'fourth'); + +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/params-dflt-meth-static-args-unmapped.js b/test/language/expressions/class/params-dflt-meth-static-args-unmapped.js new file mode 100644 index 0000000000..570b434c73 --- /dev/null +++ b/test/language/expressions/class/params-dflt-meth-static-args-unmapped.js @@ -0,0 +1,103 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: Referencing the arguments object from a default parameter (static class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + 1. Let status be the result of performing IteratorBindingInitialization for + FormalsList using iteratorRecord and environment as the arguments. + 2. ReturnIfAbrupt(status). + 3. Return the result of performing IteratorBindingInitialization for + FormalParameter using iteratorRecord and environment as the arguments. +---*/ + +var callCount = 0; +var C = class { + static method(x, _ = 0) { + assert.sameValue(x, undefined, 'parameter binding value (initial)'); + assert.sameValue( + arguments[0], undefined, 'arguments property value (initial)' + ); + + arguments[0] = 1; + + assert.sameValue( + x, undefined, 'parameter binding value (after arguments modification)' + ); + assert.sameValue( + arguments[0], 1, 'arguments property value (after arguments modification)' + ); + + x = 2; + + assert.sameValue( + x, 2, 'parameter binding value (after parameter binding modification)' + ); + assert.sameValue( + arguments[0], + 1, + 'arguments property value (after parameter binding modification)' + ); + callCount = callCount + 1; + } +}; + +C.method(); + +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/class/params-dflt-meth-static-ref-arguments.js b/test/language/expressions/class/params-dflt-meth-static-ref-arguments.js new file mode 100644 index 0000000000..1e6c6fc754 --- /dev/null +++ b/test/language/expressions/class/params-dflt-meth-static-ref-arguments.js @@ -0,0 +1,82 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: Referencing the arguments object from a default parameter (static class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + 1. Let status be the result of performing IteratorBindingInitialization for + FormalsList using iteratorRecord and environment as the arguments. + 2. ReturnIfAbrupt(status). + 3. Return the result of performing IteratorBindingInitialization for + FormalParameter using iteratorRecord and environment as the arguments. +---*/ + +var callCount = 0; +var C = class { + static method(x = arguments[2], y = arguments[3], z) { + assert.sameValue(x, 'third', 'first parameter'); + assert.sameValue(y, 'fourth', 'second parameter'); + assert.sameValue(z, 'third', 'third parameter'); + callCount = callCount + 1; + } +}; + +C.method(undefined, undefined, 'third', 'fourth'); + +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/function/params-dflt-args-unmapped.js b/test/language/expressions/function/params-dflt-args-unmapped.js new file mode 100644 index 0000000000..ae40d5fcf8 --- /dev/null +++ b/test/language/expressions/function/params-dflt-args-unmapped.js @@ -0,0 +1,82 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: Referencing the arguments object from a default parameter (function expression) +esid: sec-function-definitions-runtime-semantics-evaluation +es6id: 14.1.20 +features: [default-parameters] +info: | + FunctionExpression : function ( FormalParameters ) { FunctionBody } + + [...] + 3. Let closure be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + 1. Let status be the result of performing IteratorBindingInitialization for + FormalsList using iteratorRecord and environment as the arguments. + 2. ReturnIfAbrupt(status). + 3. Return the result of performing IteratorBindingInitialization for + FormalParameter using iteratorRecord and environment as the arguments. +---*/ + +var callCount = 0; +var f; +f = function(x, _ = 0) { + assert.sameValue(x, undefined, 'parameter binding value (initial)'); + assert.sameValue( + arguments[0], undefined, 'arguments property value (initial)' + ); + + arguments[0] = 1; + + assert.sameValue( + x, undefined, 'parameter binding value (after arguments modification)' + ); + assert.sameValue( + arguments[0], 1, 'arguments property value (after arguments modification)' + ); + + x = 2; + + assert.sameValue( + x, 2, 'parameter binding value (after parameter binding modification)' + ); + assert.sameValue( + arguments[0], + 1, + 'arguments property value (after parameter binding modification)' + ); + callCount = callCount + 1; +}; + +f(); + +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/expressions/function/params-dflt-ref-arguments.js b/test/language/expressions/function/params-dflt-ref-arguments.js new file mode 100644 index 0000000000..9d7d137257 --- /dev/null +++ b/test/language/expressions/function/params-dflt-ref-arguments.js @@ -0,0 +1,61 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: Referencing the arguments object from a default parameter (function expression) +esid: sec-function-definitions-runtime-semantics-evaluation +es6id: 14.1.20 +features: [default-parameters] +info: | + FunctionExpression : function ( FormalParameters ) { FunctionBody } + + [...] + 3. Let closure be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + 1. Let status be the result of performing IteratorBindingInitialization for + FormalsList using iteratorRecord and environment as the arguments. + 2. ReturnIfAbrupt(status). + 3. Return the result of performing IteratorBindingInitialization for + FormalParameter using iteratorRecord and environment as the arguments. +---*/ + +var callCount = 0; +var f; +f = function(x = arguments[2], y = arguments[3], z) { + assert.sameValue(x, 'third', 'first parameter'); + assert.sameValue(y, 'fourth', 'second parameter'); + assert.sameValue(z, 'third', 'third parameter'); + callCount = callCount + 1; +}; + +f(undefined, undefined, 'third', 'fourth'); + +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/expressions/generators/params-dflt-args-unmapped.js b/test/language/expressions/generators/params-dflt-args-unmapped.js new file mode 100644 index 0000000000..4709ee5b10 --- /dev/null +++ b/test/language/expressions/generators/params-dflt-args-unmapped.js @@ -0,0 +1,82 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: Referencing the arguments object from a default parameter (generator function expression) +esid: sec-generator-function-definitions-runtime-semantics-evaluation +es6id: 14.4.14 +features: [default-parameters] +info: | + GeneratorExpression : function * ( FormalParameters ) { GeneratorBody } + + [...] + 3. Let closure be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + 1. Let status be the result of performing IteratorBindingInitialization for + FormalsList using iteratorRecord and environment as the arguments. + 2. ReturnIfAbrupt(status). + 3. Return the result of performing IteratorBindingInitialization for + FormalParameter using iteratorRecord and environment as the arguments. +---*/ + +var callCount = 0; +var f; +f = function*(x, _ = 0) { + assert.sameValue(x, undefined, 'parameter binding value (initial)'); + assert.sameValue( + arguments[0], undefined, 'arguments property value (initial)' + ); + + arguments[0] = 1; + + assert.sameValue( + x, undefined, 'parameter binding value (after arguments modification)' + ); + assert.sameValue( + arguments[0], 1, 'arguments property value (after arguments modification)' + ); + + x = 2; + + assert.sameValue( + x, 2, 'parameter binding value (after parameter binding modification)' + ); + assert.sameValue( + arguments[0], + 1, + 'arguments property value (after parameter binding modification)' + ); + callCount = callCount + 1; +}; + +f().next(); + +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/expressions/generators/params-dflt-ref-arguments.js b/test/language/expressions/generators/params-dflt-ref-arguments.js new file mode 100644 index 0000000000..7721f8881e --- /dev/null +++ b/test/language/expressions/generators/params-dflt-ref-arguments.js @@ -0,0 +1,61 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: Referencing the arguments object from a default parameter (generator function expression) +esid: sec-generator-function-definitions-runtime-semantics-evaluation +es6id: 14.4.14 +features: [default-parameters] +info: | + GeneratorExpression : function * ( FormalParameters ) { GeneratorBody } + + [...] + 3. Let closure be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + 1. Let status be the result of performing IteratorBindingInitialization for + FormalsList using iteratorRecord and environment as the arguments. + 2. ReturnIfAbrupt(status). + 3. Return the result of performing IteratorBindingInitialization for + FormalParameter using iteratorRecord and environment as the arguments. +---*/ + +var callCount = 0; +var f; +f = function*(x = arguments[2], y = arguments[3], z) { + assert.sameValue(x, 'third', 'first parameter'); + assert.sameValue(y, 'fourth', 'second parameter'); + assert.sameValue(z, 'third', 'third parameter'); + callCount = callCount + 1; +}; + +f(undefined, undefined, 'third', 'fourth').next(); + +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/expressions/object/method-definition/params-dflt-gen-meth-args-unmapped.js b/test/language/expressions/object/method-definition/params-dflt-gen-meth-args-unmapped.js new file mode 100644 index 0000000000..2705cc9770 --- /dev/null +++ b/test/language/expressions/object/method-definition/params-dflt-gen-meth-args-unmapped.js @@ -0,0 +1,88 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: Referencing the arguments object from a default parameter (generator method) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +es6id: 14.4.13 +features: [default-parameters] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + 1. Let status be the result of performing IteratorBindingInitialization for + FormalsList using iteratorRecord and environment as the arguments. + 2. ReturnIfAbrupt(status). + 3. Return the result of performing IteratorBindingInitialization for + FormalParameter using iteratorRecord and environment as the arguments. +---*/ + +var callCount = 0; +var obj = { + *method(x, _ = 0) { + assert.sameValue(x, undefined, 'parameter binding value (initial)'); + assert.sameValue( + arguments[0], undefined, 'arguments property value (initial)' + ); + + arguments[0] = 1; + + assert.sameValue( + x, undefined, 'parameter binding value (after arguments modification)' + ); + assert.sameValue( + arguments[0], 1, 'arguments property value (after arguments modification)' + ); + + x = 2; + + assert.sameValue( + x, 2, 'parameter binding value (after parameter binding modification)' + ); + assert.sameValue( + arguments[0], + 1, + 'arguments property value (after parameter binding modification)' + ); + callCount = callCount + 1; + } +}; + +obj.method().next(); + +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); diff --git a/test/language/expressions/object/method-definition/params-dflt-gen-meth-ref-arguments.js b/test/language/expressions/object/method-definition/params-dflt-gen-meth-ref-arguments.js new file mode 100644 index 0000000000..acd31981c8 --- /dev/null +++ b/test/language/expressions/object/method-definition/params-dflt-gen-meth-ref-arguments.js @@ -0,0 +1,67 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: Referencing the arguments object from a default parameter (generator method) +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +es6id: 14.4.13 +features: [default-parameters] +info: | + GeneratorMethod : + * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + 1. Let status be the result of performing IteratorBindingInitialization for + FormalsList using iteratorRecord and environment as the arguments. + 2. ReturnIfAbrupt(status). + 3. Return the result of performing IteratorBindingInitialization for + FormalParameter using iteratorRecord and environment as the arguments. +---*/ + +var callCount = 0; +var obj = { + *method(x = arguments[2], y = arguments[3], z) { + assert.sameValue(x, 'third', 'first parameter'); + assert.sameValue(y, 'fourth', 'second parameter'); + assert.sameValue(z, 'third', 'third parameter'); + callCount = callCount + 1; + } +}; + +obj.method(undefined, undefined, 'third', 'fourth').next(); + +assert.sameValue(callCount, 1, 'generator method invoked exactly once'); diff --git a/test/language/expressions/object/method-definition/params-dflt-meth-args-unmapped.js b/test/language/expressions/object/method-definition/params-dflt-meth-args-unmapped.js new file mode 100644 index 0000000000..dcbaca9b01 --- /dev/null +++ b/test/language/expressions/object/method-definition/params-dflt-meth-args-unmapped.js @@ -0,0 +1,85 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: Referencing the arguments object from a default parameter (method) +esid: sec-runtime-semantics-definemethod +es6id: 14.3.8 +features: [default-parameters] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + 1. Let status be the result of performing IteratorBindingInitialization for + FormalsList using iteratorRecord and environment as the arguments. + 2. ReturnIfAbrupt(status). + 3. Return the result of performing IteratorBindingInitialization for + FormalParameter using iteratorRecord and environment as the arguments. +---*/ + +var callCount = 0; +var obj = { + method(x, _ = 0) { + assert.sameValue(x, undefined, 'parameter binding value (initial)'); + assert.sameValue( + arguments[0], undefined, 'arguments property value (initial)' + ); + + arguments[0] = 1; + + assert.sameValue( + x, undefined, 'parameter binding value (after arguments modification)' + ); + assert.sameValue( + arguments[0], 1, 'arguments property value (after arguments modification)' + ); + + x = 2; + + assert.sameValue( + x, 2, 'parameter binding value (after parameter binding modification)' + ); + assert.sameValue( + arguments[0], + 1, + 'arguments property value (after parameter binding modification)' + ); + callCount = callCount + 1; + } +}; + +obj.method(); + +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/expressions/object/method-definition/params-dflt-meth-ref-arguments.js b/test/language/expressions/object/method-definition/params-dflt-meth-ref-arguments.js new file mode 100644 index 0000000000..1bad81a90b --- /dev/null +++ b/test/language/expressions/object/method-definition/params-dflt-meth-ref-arguments.js @@ -0,0 +1,64 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: Referencing the arguments object from a default parameter (method) +esid: sec-runtime-semantics-definemethod +es6id: 14.3.8 +features: [default-parameters] +info: | + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, + FunctionBody, scope, strict). If functionPrototype was passed as a + parameter then pass its value as the functionPrototype optional argument + of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + 1. Let status be the result of performing IteratorBindingInitialization for + FormalsList using iteratorRecord and environment as the arguments. + 2. ReturnIfAbrupt(status). + 3. Return the result of performing IteratorBindingInitialization for + FormalParameter using iteratorRecord and environment as the arguments. +---*/ + +var callCount = 0; +var obj = { + method(x = arguments[2], y = arguments[3], z) { + assert.sameValue(x, 'third', 'first parameter'); + assert.sameValue(y, 'fourth', 'second parameter'); + assert.sameValue(z, 'third', 'third parameter'); + callCount = callCount + 1; + } +}; + +obj.method(undefined, undefined, 'third', 'fourth'); + +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/params-dflt-gen-meth-args-unmapped.js b/test/language/statements/class/params-dflt-gen-meth-args-unmapped.js new file mode 100644 index 0000000000..0c854d66b6 --- /dev/null +++ b/test/language/statements/class/params-dflt-gen-meth-args-unmapped.js @@ -0,0 +1,104 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: Referencing the arguments object from a default parameter (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + 1. Let status be the result of performing IteratorBindingInitialization for + FormalsList using iteratorRecord and environment as the arguments. + 2. ReturnIfAbrupt(status). + 3. Return the result of performing IteratorBindingInitialization for + FormalParameter using iteratorRecord and environment as the arguments. +---*/ + +var callCount = 0; +class C { + *method(x, _ = 0) { + assert.sameValue(x, undefined, 'parameter binding value (initial)'); + assert.sameValue( + arguments[0], undefined, 'arguments property value (initial)' + ); + + arguments[0] = 1; + + assert.sameValue( + x, undefined, 'parameter binding value (after arguments modification)' + ); + assert.sameValue( + arguments[0], 1, 'arguments property value (after arguments modification)' + ); + + x = 2; + + assert.sameValue( + x, 2, 'parameter binding value (after parameter binding modification)' + ); + assert.sameValue( + arguments[0], + 1, + 'arguments property value (after parameter binding modification)' + ); + callCount = callCount + 1; + } +} + +C.prototype.method().next(); + +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/params-dflt-gen-meth-ref-arguments.js b/test/language/statements/class/params-dflt-gen-meth-ref-arguments.js new file mode 100644 index 0000000000..97b5773cbb --- /dev/null +++ b/test/language/statements/class/params-dflt-gen-meth-ref-arguments.js @@ -0,0 +1,83 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: Referencing the arguments object from a default parameter (class expression method) +esid: sec-class-definitions-runtime-semantics-evaluation +es6id: 14.5.16 +features: [default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + 1. Let status be the result of performing IteratorBindingInitialization for + FormalsList using iteratorRecord and environment as the arguments. + 2. ReturnIfAbrupt(status). + 3. Return the result of performing IteratorBindingInitialization for + FormalParameter using iteratorRecord and environment as the arguments. +---*/ + +var callCount = 0; +class C { + *method(x = arguments[2], y = arguments[3], z) { + assert.sameValue(x, 'third', 'first parameter'); + assert.sameValue(y, 'fourth', 'second parameter'); + assert.sameValue(z, 'third', 'third parameter'); + callCount = callCount + 1; + } +} + +C.prototype.method(undefined, undefined, 'third', 'fourth').next(); + +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/params-dflt-gen-meth-static-args-unmapped.js b/test/language/statements/class/params-dflt-gen-meth-static-args-unmapped.js new file mode 100644 index 0000000000..554565f338 --- /dev/null +++ b/test/language/statements/class/params-dflt-gen-meth-static-args-unmapped.js @@ -0,0 +1,104 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: Referencing the arguments object from a default parameter (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + 1. Let status be the result of performing IteratorBindingInitialization for + FormalsList using iteratorRecord and environment as the arguments. + 2. ReturnIfAbrupt(status). + 3. Return the result of performing IteratorBindingInitialization for + FormalParameter using iteratorRecord and environment as the arguments. +---*/ + +var callCount = 0; +class C { + static *method(x, _ = 0) { + assert.sameValue(x, undefined, 'parameter binding value (initial)'); + assert.sameValue( + arguments[0], undefined, 'arguments property value (initial)' + ); + + arguments[0] = 1; + + assert.sameValue( + x, undefined, 'parameter binding value (after arguments modification)' + ); + assert.sameValue( + arguments[0], 1, 'arguments property value (after arguments modification)' + ); + + x = 2; + + assert.sameValue( + x, 2, 'parameter binding value (after parameter binding modification)' + ); + assert.sameValue( + arguments[0], + 1, + 'arguments property value (after parameter binding modification)' + ); + callCount = callCount + 1; + } +} + +C.method().next(); + +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/params-dflt-gen-meth-static-ref-arguments.js b/test/language/statements/class/params-dflt-gen-meth-static-ref-arguments.js new file mode 100644 index 0000000000..9ac26245c4 --- /dev/null +++ b/test/language/statements/class/params-dflt-gen-meth-static-ref-arguments.js @@ -0,0 +1,83 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: Referencing the arguments object from a default parameter (static class expression generator method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [default-parameters] +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. + [...] + + 14.4.13 Runtime Semantics: PropertyDefinitionEvaluation + + GeneratorMethod : * PropertyName ( StrictFormalParameters ) { GeneratorBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this GeneratorMethod is strict mode code, + let strict be true. Otherwise let strict be false. + 4. Let scope be the running execution context's LexicalEnvironment. + 5. Let closure be GeneratorFunctionCreate(Method, + StrictFormalParameters, GeneratorBody, scope, strict). + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + 1. Let status be the result of performing IteratorBindingInitialization for + FormalsList using iteratorRecord and environment as the arguments. + 2. ReturnIfAbrupt(status). + 3. Return the result of performing IteratorBindingInitialization for + FormalParameter using iteratorRecord and environment as the arguments. +---*/ + +var callCount = 0; +class C { + static *method(x = arguments[2], y = arguments[3], z) { + assert.sameValue(x, 'third', 'first parameter'); + assert.sameValue(y, 'fourth', 'second parameter'); + assert.sameValue(z, 'third', 'third parameter'); + callCount = callCount + 1; + } +} + +C.method(undefined, undefined, 'third', 'fourth').next(); + +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/params-dflt-meth-args-unmapped.js b/test/language/statements/class/params-dflt-meth-args-unmapped.js new file mode 100644 index 0000000000..ba0679e748 --- /dev/null +++ b/test/language/statements/class/params-dflt-meth-args-unmapped.js @@ -0,0 +1,102 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: Referencing the arguments object from a default parameter (class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + 1. Let status be the result of performing IteratorBindingInitialization for + FormalsList using iteratorRecord and environment as the arguments. + 2. ReturnIfAbrupt(status). + 3. Return the result of performing IteratorBindingInitialization for + FormalParameter using iteratorRecord and environment as the arguments. +---*/ + +var callCount = 0; +class C { + method(x, _ = 0) { + assert.sameValue(x, undefined, 'parameter binding value (initial)'); + assert.sameValue( + arguments[0], undefined, 'arguments property value (initial)' + ); + + arguments[0] = 1; + + assert.sameValue( + x, undefined, 'parameter binding value (after arguments modification)' + ); + assert.sameValue( + arguments[0], 1, 'arguments property value (after arguments modification)' + ); + + x = 2; + + assert.sameValue( + x, 2, 'parameter binding value (after parameter binding modification)' + ); + assert.sameValue( + arguments[0], + 1, + 'arguments property value (after parameter binding modification)' + ); + callCount = callCount + 1; + } +} + +C.prototype.method(); + +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/params-dflt-meth-ref-arguments.js b/test/language/statements/class/params-dflt-meth-ref-arguments.js new file mode 100644 index 0000000000..dafeb78adb --- /dev/null +++ b/test/language/statements/class/params-dflt-meth-ref-arguments.js @@ -0,0 +1,81 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: Referencing the arguments object from a default parameter (class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + 1. Let status be the result of performing IteratorBindingInitialization for + FormalsList using iteratorRecord and environment as the arguments. + 2. ReturnIfAbrupt(status). + 3. Return the result of performing IteratorBindingInitialization for + FormalParameter using iteratorRecord and environment as the arguments. +---*/ + +var callCount = 0; +class C { + method(x = arguments[2], y = arguments[3], z) { + assert.sameValue(x, 'third', 'first parameter'); + assert.sameValue(y, 'fourth', 'second parameter'); + assert.sameValue(z, 'third', 'third parameter'); + callCount = callCount + 1; + } +} + +C.prototype.method(undefined, undefined, 'third', 'fourth'); + +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/params-dflt-meth-static-args-unmapped.js b/test/language/statements/class/params-dflt-meth-static-args-unmapped.js new file mode 100644 index 0000000000..a2ad6cb1e8 --- /dev/null +++ b/test/language/statements/class/params-dflt-meth-static-args-unmapped.js @@ -0,0 +1,102 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: Referencing the arguments object from a default parameter (static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + 1. Let status be the result of performing IteratorBindingInitialization for + FormalsList using iteratorRecord and environment as the arguments. + 2. ReturnIfAbrupt(status). + 3. Return the result of performing IteratorBindingInitialization for + FormalParameter using iteratorRecord and environment as the arguments. +---*/ + +var callCount = 0; +class C { + static method(x, _ = 0) { + assert.sameValue(x, undefined, 'parameter binding value (initial)'); + assert.sameValue( + arguments[0], undefined, 'arguments property value (initial)' + ); + + arguments[0] = 1; + + assert.sameValue( + x, undefined, 'parameter binding value (after arguments modification)' + ); + assert.sameValue( + arguments[0], 1, 'arguments property value (after arguments modification)' + ); + + x = 2; + + assert.sameValue( + x, 2, 'parameter binding value (after parameter binding modification)' + ); + assert.sameValue( + arguments[0], + 1, + 'arguments property value (after parameter binding modification)' + ); + callCount = callCount + 1; + } +} + +C.method(); + +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/class/params-dflt-meth-static-ref-arguments.js b/test/language/statements/class/params-dflt-meth-static-ref-arguments.js new file mode 100644 index 0000000000..7102782ae3 --- /dev/null +++ b/test/language/statements/class/params-dflt-meth-static-ref-arguments.js @@ -0,0 +1,81 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: Referencing the arguments object from a default parameter (static class expression method) +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +es6id: 14.5.15 +features: [default-parameters] +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. + [...] + + 14.3.8 Runtime Semantics: DefineMethod + + MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody } + + [...] + 6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody, + scope, strict). If functionPrototype was passed as a parameter then pass its + value as the functionPrototype optional argument of FunctionCreate. + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + 1. Let status be the result of performing IteratorBindingInitialization for + FormalsList using iteratorRecord and environment as the arguments. + 2. ReturnIfAbrupt(status). + 3. Return the result of performing IteratorBindingInitialization for + FormalParameter using iteratorRecord and environment as the arguments. +---*/ + +var callCount = 0; +class C { + static method(x = arguments[2], y = arguments[3], z) { + assert.sameValue(x, 'third', 'first parameter'); + assert.sameValue(y, 'fourth', 'second parameter'); + assert.sameValue(z, 'third', 'third parameter'); + callCount = callCount + 1; + } +} + +C.method(undefined, undefined, 'third', 'fourth'); + +assert.sameValue(callCount, 1, 'method invoked exactly once'); diff --git a/test/language/statements/function/params-dflt-args-unmapped.js b/test/language/statements/function/params-dflt-args-unmapped.js new file mode 100644 index 0000000000..53fffad608 --- /dev/null +++ b/test/language/statements/function/params-dflt-args-unmapped.js @@ -0,0 +1,82 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: Referencing the arguments object from a default parameter (function declaration) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.1.19 +features: [default-parameters] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + 1. Let status be the result of performing IteratorBindingInitialization for + FormalsList using iteratorRecord and environment as the arguments. + 2. ReturnIfAbrupt(status). + 3. Return the result of performing IteratorBindingInitialization for + FormalParameter using iteratorRecord and environment as the arguments. +---*/ + +var callCount = 0; +function f(x, _ = 0) { + assert.sameValue(x, undefined, 'parameter binding value (initial)'); + assert.sameValue( + arguments[0], undefined, 'arguments property value (initial)' + ); + + arguments[0] = 1; + + assert.sameValue( + x, undefined, 'parameter binding value (after arguments modification)' + ); + assert.sameValue( + arguments[0], 1, 'arguments property value (after arguments modification)' + ); + + x = 2; + + assert.sameValue( + x, 2, 'parameter binding value (after parameter binding modification)' + ); + assert.sameValue( + arguments[0], + 1, + 'arguments property value (after parameter binding modification)' + ); + callCount = callCount + 1; +} + +f(); + +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/statements/function/params-dflt-ref-arguments.js b/test/language/statements/function/params-dflt-ref-arguments.js new file mode 100644 index 0000000000..b0a6011f09 --- /dev/null +++ b/test/language/statements/function/params-dflt-ref-arguments.js @@ -0,0 +1,61 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: Referencing the arguments object from a default parameter (function declaration) +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.1.19 +features: [default-parameters] +info: | + FunctionDeclaration : + function BindingIdentifier ( FormalParameters ) { FunctionBody } + + [...] + 3. Let F be FunctionCreate(Normal, FormalParameters, FunctionBody, + scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + 1. Let status be the result of performing IteratorBindingInitialization for + FormalsList using iteratorRecord and environment as the arguments. + 2. ReturnIfAbrupt(status). + 3. Return the result of performing IteratorBindingInitialization for + FormalParameter using iteratorRecord and environment as the arguments. +---*/ + +var callCount = 0; +function f(x = arguments[2], y = arguments[3], z) { + assert.sameValue(x, 'third', 'first parameter'); + assert.sameValue(y, 'fourth', 'second parameter'); + assert.sameValue(z, 'third', 'third parameter'); + callCount = callCount + 1; +} + +f(undefined, undefined, 'third', 'fourth'); + +assert.sameValue(callCount, 1, 'function invoked exactly once'); diff --git a/test/language/statements/generators/params-dflt-args-unmapped.js b/test/language/statements/generators/params-dflt-args-unmapped.js new file mode 100644 index 0000000000..01c611de8a --- /dev/null +++ b/test/language/statements/generators/params-dflt-args-unmapped.js @@ -0,0 +1,81 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: Referencing the arguments object from a default parameter (generator function declaration) +esid: sec-generator-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.4.12 +features: [default-parameters] +info: | + GeneratorDeclaration : function * ( FormalParameters ) { GeneratorBody } + + [...] + 2. Let F be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + 1. Let status be the result of performing IteratorBindingInitialization for + FormalsList using iteratorRecord and environment as the arguments. + 2. ReturnIfAbrupt(status). + 3. Return the result of performing IteratorBindingInitialization for + FormalParameter using iteratorRecord and environment as the arguments. +---*/ + +var callCount = 0; +function* f(x, _ = 0) { + assert.sameValue(x, undefined, 'parameter binding value (initial)'); + assert.sameValue( + arguments[0], undefined, 'arguments property value (initial)' + ); + + arguments[0] = 1; + + assert.sameValue( + x, undefined, 'parameter binding value (after arguments modification)' + ); + assert.sameValue( + arguments[0], 1, 'arguments property value (after arguments modification)' + ); + + x = 2; + + assert.sameValue( + x, 2, 'parameter binding value (after parameter binding modification)' + ); + assert.sameValue( + arguments[0], + 1, + 'arguments property value (after parameter binding modification)' + ); + callCount = callCount + 1; +} + +f().next(); + +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); diff --git a/test/language/statements/generators/params-dflt-ref-arguments.js b/test/language/statements/generators/params-dflt-ref-arguments.js new file mode 100644 index 0000000000..e1c6b4873a --- /dev/null +++ b/test/language/statements/generators/params-dflt-ref-arguments.js @@ -0,0 +1,60 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +description: Referencing the arguments object from a default parameter (generator function declaration) +esid: sec-generator-function-definitions-runtime-semantics-instantiatefunctionobject +es6id: 14.4.12 +features: [default-parameters] +info: | + GeneratorDeclaration : function * ( FormalParameters ) { GeneratorBody } + + [...] + 2. Let F be GeneratorFunctionCreate(Normal, FormalParameters, + GeneratorBody, scope, strict). + [...] + + 9.2.1 [[Call]] ( thisArgument, argumentsList) + + [...] + 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). + [...] + + 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) + + 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). + [...] + + 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) + + [...] + 23. Let iteratorRecord be Record {[[iterator]]: + CreateListIterator(argumentsList), [[done]]: false}. + 24. If hasDuplicates is true, then + [...] + 25. Else, + b. Let formalStatus be IteratorBindingInitialization for formals with + iteratorRecord and env as arguments. + [...] + + 14.1.19 Runtime Semantics: IteratorBindingInitialization + + FormalsList : FormalsList , FormalParameter + + 1. Let status be the result of performing IteratorBindingInitialization for + FormalsList using iteratorRecord and environment as the arguments. + 2. ReturnIfAbrupt(status). + 3. Return the result of performing IteratorBindingInitialization for + FormalParameter using iteratorRecord and environment as the arguments. +---*/ + +var callCount = 0; +function* f(x = arguments[2], y = arguments[3], z) { + assert.sameValue(x, 'third', 'first parameter'); + assert.sameValue(y, 'fourth', 'second parameter'); + assert.sameValue(z, 'third', 'third parameter'); + callCount = callCount + 1; +} + +f(undefined, undefined, 'third', 'fourth').next(); + +assert.sameValue(callCount, 1, 'generator function invoked exactly once'); -- GitLab From 418386e33e6a49690616ee1fb66f2f0aa72c2def Mon Sep 17 00:00:00 2001 From: Mike Pennisi <mike@mikepennisi.com> Date: Thu, 2 Jun 2016 14:21:34 -0400 Subject: [PATCH 8/8] Remove redundant tests These tests have been re-factored to expand coverage of the "default parameter" language feature and to more closely adhere to this project's preferred file organization. --- .../default-parameters/call-define-values.js | 44 ------------- .../call-returns-reference-error.js | 13 ---- .../default-parameters/class-definitions.js | 21 ------- ...eters-always-provide-unmapped-arguments.js | 50 --------------- .../default-parameters/destructuring.js | 17 ------ .../function-constructor.js | 13 ---- .../language/default-parameters/generators.js | 24 -------- .../default-parameters/method-definitions.js | 14 ----- .../param-ref-initialized.js | 14 ----- .../param-ref-uninitialized.js | 24 -------- .../replace-default-values.js | 61 ------------------- .../default-parameters/rest-parameters.js | 10 --- .../returns-abrupt-from-property-value.js | 22 ------- test/language/default-parameters/scope.js | 50 --------------- ...r-on-duplicates-on-function-declaration.js | 16 ----- ...or-on-duplicates-on-function-expression.js | 16 ----- .../variable-initial-value-as-parameter.js | 40 ------------ .../variable-initial-value-undefined.js | 38 ------------ 18 files changed, 487 deletions(-) delete mode 100644 test/language/default-parameters/call-define-values.js delete mode 100644 test/language/default-parameters/call-returns-reference-error.js delete mode 100644 test/language/default-parameters/class-definitions.js delete mode 100644 test/language/default-parameters/default-parameters-always-provide-unmapped-arguments.js delete mode 100644 test/language/default-parameters/destructuring.js delete mode 100644 test/language/default-parameters/function-constructor.js delete mode 100644 test/language/default-parameters/generators.js delete mode 100644 test/language/default-parameters/method-definitions.js delete mode 100644 test/language/default-parameters/param-ref-initialized.js delete mode 100644 test/language/default-parameters/param-ref-uninitialized.js delete mode 100644 test/language/default-parameters/replace-default-values.js delete mode 100644 test/language/default-parameters/rest-parameters.js delete mode 100644 test/language/default-parameters/returns-abrupt-from-property-value.js delete mode 100644 test/language/default-parameters/scope.js delete mode 100644 test/language/default-parameters/syntaxerror-on-duplicates-on-function-declaration.js delete mode 100644 test/language/default-parameters/syntaxerror-on-duplicates-on-function-expression.js delete mode 100644 test/language/default-parameters/variable-initial-value-as-parameter.js delete mode 100644 test/language/default-parameters/variable-initial-value-undefined.js diff --git a/test/language/default-parameters/call-define-values.js b/test/language/default-parameters/call-define-values.js deleted file mode 100644 index 1a74cadebf..0000000000 --- a/test/language/default-parameters/call-define-values.js +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright (C) 2015 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -es6id: 9.2.12 -description: > - Function call define default values to arguments -info: > - 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) - - 24. If hasDuplicates is true, then - ... - 25. Else, - a. Let formalStatus be IteratorBindingInitialization for formals with - iteratorRecord and env as arguments. - - ES6 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). - ... ----*/ - -var results; - -var o = {}; - -function fn(a = 1, b = null, c = o, d) { - return [a, b, c, d]; -} - -results = fn(); - -assert.sameValue(results[0], 1, 'apply default values #1'); -assert.sameValue(results[1], null, 'apply default values #2'); -assert.sameValue(results[2], o, 'apply default values #3'); - -assert.sameValue( - results[3], undefined, - 'Parameters without defaults after default parameters defaults to undefined' -); diff --git a/test/language/default-parameters/call-returns-reference-error.js b/test/language/default-parameters/call-returns-reference-error.js deleted file mode 100644 index 2a6d9176cb..0000000000 --- a/test/language/default-parameters/call-returns-reference-error.js +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright (C) 2015 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -es6id: 13.3.3.7 -description: > - Throws a ReferenceError from a unsolvable reference as the default parameter. ----*/ - -function fn(a = unresolvableReference) {} - -assert.throws(ReferenceError, function() { - fn(); -}); diff --git a/test/language/default-parameters/class-definitions.js b/test/language/default-parameters/class-definitions.js deleted file mode 100644 index bb3ae02f24..0000000000 --- a/test/language/default-parameters/class-definitions.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2015 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -es6id: 14.5 -description: Set default parameters on class definitions ----*/ - -class C { - constructor(a = 1) { - this.a = a; - } - - m(x = 2) { - return x; - } -} - -var o = new C(); - -assert.sameValue(o.a, 1); -assert.sameValue(o.m(), 2); diff --git a/test/language/default-parameters/default-parameters-always-provide-unmapped-arguments.js b/test/language/default-parameters/default-parameters-always-provide-unmapped-arguments.js deleted file mode 100644 index 54ac40a111..0000000000 --- a/test/language/default-parameters/default-parameters-always-provide-unmapped-arguments.js +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright (C) 2015 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -es6id: 9.2.12 -description: > - Provide unmapped `arguments` if any parameter has a default value initializer. -info: > - 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) - - 22. If argumentsObjectNeeded is true, then - a. If strict is true or if simpleParameterList is false, then - i. Let ao be CreateUnmappedArgumentsObject(argumentsList). - ... - d. If strict is true, then - ... - e. Else, - i. Let status be envRec.CreateMutableBinding("arguments"). -flags: [noStrict] ----*/ - -var _c; - -function fn(a, b = 1, c = 1, d = 1) { - a = false; - arguments[2] = false; - _c = c; - return arguments; -} - -var result = fn(42, undefined, 43); - -assert.sameValue( - result[0], 42, - 'unmapped `arguments` are not bound to their parameters values' -); - -assert.sameValue( - result[1], undefined, - 'unmapped `arguments` preserve the given arguments values' -); - -assert.sameValue( - _c, 43, - 'parameters names are not mapped to be bound' -); - -assert.sameValue( - Object.hasOwnProperty(result, '3'), false, - 'unmapped `arguments` will only contain values from the arguments list' -); diff --git a/test/language/default-parameters/destructuring.js b/test/language/default-parameters/destructuring.js deleted file mode 100644 index 08b1c93d2c..0000000000 --- a/test/language/default-parameters/destructuring.js +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright (C) 2015 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -es6id: 13.3.3 -description: > - Destructuring values on default parameters. ----*/ - -function fn([a, b] = [1, 2], {c: c} = {c: 3}) { - return [a, b, c]; -} - -var results = fn(); - -assert.sameValue(results[0], 1); -assert.sameValue(results[1], 2); -assert.sameValue(results[2], 3); diff --git a/test/language/default-parameters/function-constructor.js b/test/language/default-parameters/function-constructor.js deleted file mode 100644 index 44345a81d4..0000000000 --- a/test/language/default-parameters/function-constructor.js +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright (C) 2015 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -es6id: 19.2.1.1 -description: > - Create new Function with default parameters ----*/ - -var fn = new Function('a = 42', 'b = "foo"', 'return [a, b]'); -var result = fn(); - -assert.sameValue(result[0], 42); -assert.sameValue(result[1], 'foo'); diff --git a/test/language/default-parameters/generators.js b/test/language/default-parameters/generators.js deleted file mode 100644 index b511d5f768..0000000000 --- a/test/language/default-parameters/generators.js +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (C) 2015 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -es6id: 14.4 -description: Set default parameters in generator functions ----*/ - -function *g(a = 1, b = 2, c = 3) { - var i = 0; - - while (i < 3) { - yield [a, b, c][i]; - i++; - } - - return 42; -} - -var iter = g(); - -assert.sameValue(iter.next().value, 1); -assert.sameValue(iter.next().value, 2); -assert.sameValue(iter.next().value, 3); -assert.sameValue(iter.next().done, true); diff --git a/test/language/default-parameters/method-definitions.js b/test/language/default-parameters/method-definitions.js deleted file mode 100644 index a0c859e677..0000000000 --- a/test/language/default-parameters/method-definitions.js +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright (C) 2015 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -es6id: 14.3 -description: Set default parameters on method definitions ----*/ - -var o = { - m(a = 1, b = 2) { - return a + b; - } -}; - -assert.sameValue(o.m(), 3); diff --git a/test/language/default-parameters/param-ref-initialized.js b/test/language/default-parameters/param-ref-initialized.js deleted file mode 100644 index d03d8deb46..0000000000 --- a/test/language/default-parameters/param-ref-initialized.js +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright (C) 2015 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -es6id: 9.2.12 -description: > - Parameters can refer to previous parameters ----*/ - -function fn(a = 42, b = a) { - return b; -} - -assert.sameValue(fn(), 42); -assert.sameValue(fn(17), 17); diff --git a/test/language/default-parameters/param-ref-uninitialized.js b/test/language/default-parameters/param-ref-uninitialized.js deleted file mode 100644 index 8410f61e7d..0000000000 --- a/test/language/default-parameters/param-ref-uninitialized.js +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (C) 2015 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -es6id: 9.2.12 -description: > - Parameters can't refer to not initialized parameters ----*/ - -function fn1(a = a) { - return a; -} - -assert.throws(ReferenceError, function() { - fn1(); -}); - - -function fn2(a = b, b = 42) { - return a; -} - -assert.throws(ReferenceError, function() { - fn2(); -}); diff --git a/test/language/default-parameters/replace-default-values.js b/test/language/default-parameters/replace-default-values.js deleted file mode 100644 index d1628d4a56..0000000000 --- a/test/language/default-parameters/replace-default-values.js +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright (C) 2015 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -es6id: 9.2.12 -description: > - Replace default values, unless argument is undefined -info: > - 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) - - 24. If hasDuplicates is true, then - ... - 25. Else, - a. Let formalStatus be IteratorBindingInitialization for formals with - iteratorRecord and env as arguments. - - ES6 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). - ... -features: [Symbol] ----*/ - -function fn(a = 1, b = 2, c = 3) { - return [a, b, c]; -} - -var results = fn('', 'foo', 'undefined'); -assert.sameValue(results[0], '', 'empty string replace default value'); -assert.sameValue(results[1], 'foo', 'string replaces default value'); -assert.sameValue( - results[2], 'undefined', - '"undefined" string replaces default value' -); - -results = fn(0, 42, -Infinity); -assert.sameValue(results[0], 0, 'Number (0) replaces default value'); -assert.sameValue(results[1], 42, 'number replaces default value'); -assert.sameValue(results[2], -Infinity, '-Infinity replaces default value'); - -var o = {}; -var arr = []; -results = fn(o, arr, null); -assert.sameValue(results[0], o, 'object replaces default value'); -assert.sameValue(results[1], arr, 'array replaces default value'); -assert.sameValue(results[2], null, 'null replaces default value'); - -var s = Symbol(''); -results = fn(true, false, s); -assert.sameValue(results[0], true, 'boolean true replaces default value'); -assert.sameValue(results[1], false, 'boolean false replaces default value'); -assert.sameValue(results[2], s, 'Symbol replaces default value'); - -results = fn(undefined, NaN, undefined); -assert.sameValue(results[0], 1, 'undefined argument does not replace default'); -assert.sameValue(results[1], NaN, 'NaN replaces default value'); -assert.sameValue(results[2], 3, 'undefined argument does not replace default'); diff --git a/test/language/default-parameters/rest-parameters.js b/test/language/default-parameters/rest-parameters.js deleted file mode 100644 index 9b63fab425..0000000000 --- a/test/language/default-parameters/rest-parameters.js +++ /dev/null @@ -1,10 +0,0 @@ -// Copyright (C) 2015 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -es6id: 14.1 -description: > - Rest parameters can not have a default -negative: SyntaxError ----*/ - -function fn(...args = [1]) {} diff --git a/test/language/default-parameters/returns-abrupt-from-property-value.js b/test/language/default-parameters/returns-abrupt-from-property-value.js deleted file mode 100644 index a19e82d5d9..0000000000 --- a/test/language/default-parameters/returns-abrupt-from-property-value.js +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (C) 2015 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -es6id: 13.3.3.7 -description: > - Return abrupt from a property value as a default argument. ----*/ - -var obj = {}; -Object.defineProperty(obj, 'err', { - get: function() { - throw new Test262Error(); - } -}); - -function fn(a = obj.err) { - return 42; -} - -assert.throws(Test262Error, function() { - fn(); -}); diff --git a/test/language/default-parameters/scope.js b/test/language/default-parameters/scope.js deleted file mode 100644 index 6f5c442d92..0000000000 --- a/test/language/default-parameters/scope.js +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright (C) 2015 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -es6id: 9.2.12 -description: > - Expressions as parameter default values share the top level context only. -info: > - 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) - - ... - 27. If hasParameterExpressions is false, then - ... - 28. Else, - a. NOTE A separate Environment Record is needed to ensure that - closures created by expressions in the formal parameter list do - not have visibility of declarations in the function body. - b. Let varEnv be NewDeclarativeEnvironment(env). - c. Let varEnvRec be varEnv’s EnvironmentRecord. - d. Set the VariableEnvironment of calleeContext to varEnv. ----*/ - -var x = 42; - -function fn1(a = x) { - return a; -} -assert.sameValue(fn1(), 42); - -function fn2(a = function() { return x; }) { - var x = 1; - - return a(); -} -assert.sameValue(fn2(), 42); - -function fn3(a = function() { var x = 0; }) { - a(); - - return x; -} -assert.sameValue(fn3(), 42); - -function fn4(a = y) { - var y = 1; -} - -// y is only defined on the inner scope of fn4 -assert.throws(ReferenceError, function() { - fn4(); -}); diff --git a/test/language/default-parameters/syntaxerror-on-duplicates-on-function-declaration.js b/test/language/default-parameters/syntaxerror-on-duplicates-on-function-declaration.js deleted file mode 100644 index f58099f3a2..0000000000 --- a/test/language/default-parameters/syntaxerror-on-duplicates-on-function-declaration.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2015 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -es6id: 14.1.2 -description: > - It is a SyntaxError if a a not simple parameters list contains duplicate names -info: > - FormalParameters : FormalParameterList - - It is a Syntax Error if IsSimpleParameterList of FormalParameterList is false - and BoundNames of FormalParameterList contains any duplicate elements. -flags: [noStrict] -negative: SyntaxError ----*/ - -function fn(a, a = 1) {} diff --git a/test/language/default-parameters/syntaxerror-on-duplicates-on-function-expression.js b/test/language/default-parameters/syntaxerror-on-duplicates-on-function-expression.js deleted file mode 100644 index 64e1b915fe..0000000000 --- a/test/language/default-parameters/syntaxerror-on-duplicates-on-function-expression.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2015 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -es6id: 14.1.2 -description: > - It is a SyntaxError if a a not simple parameters list contains duplicate names -info: > - FormalParameters : FormalParameterList - - It is a Syntax Error if IsSimpleParameterList of FormalParameterList is false - and BoundNames of FormalParameterList contains any duplicate elements. -flags: [noStrict] -negative: SyntaxError ----*/ - -var fn = function (a, a = 1) {}; diff --git a/test/language/default-parameters/variable-initial-value-as-parameter.js b/test/language/default-parameters/variable-initial-value-as-parameter.js deleted file mode 100644 index 42c59aff39..0000000000 --- a/test/language/default-parameters/variable-initial-value-as-parameter.js +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright (C) 2015 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -es6id: 9.2.12 -description: > - Vars whose names are in the parameters list, initially have the same value as - the corresponding initialized parameter. -info: > - 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) - - ... - 27. If hasParameterExpressions is false, then - ... - 28. Else, - a. NOTE A separate Environment Record is needed to ensure that closures - created by expressions in the formal parameter list do not have visibility - of declarations in the function body. - b. Let varEnv be NewDeclarativeEnvironment(env). - c. Let varEnvRec be varEnv’s EnvironmentRecord. - d. Set the VariableEnvironment of calleeContext to varEnv. - e. Let instantiatedVarNames be a new empty List. - f. For each n in varNames, do - i. If n is not an element of instantiatedVarNames, then - 1. Append n to instantiatedVarNames. - 2. Let status be varEnvRec.CreateMutableBinding(n). - 3. Assert: status is never an abrupt completion. - 4. If n is not an element of parameterNames or if n is an element of - functionNames, let initialValue be undefined. - 5. else, - a. Let initialValue be envRec.GetBindingValue(n, false). - ... ----*/ - -function fn(a = 1) { - var a; - - return a; -} - -assert.sameValue(fn(), 1); diff --git a/test/language/default-parameters/variable-initial-value-undefined.js b/test/language/default-parameters/variable-initial-value-undefined.js deleted file mode 100644 index 85f49d6a7b..0000000000 --- a/test/language/default-parameters/variable-initial-value-undefined.js +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright (C) 2015 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -es6id: 9.2.12 -description: > - A variable initial value is undefined if its name is not in the - parameters list. -info: > - 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) - - ... - 27. If hasParameterExpressions is false, then - ... - 28. Else, - a. NOTE A separate Environment Record is needed to ensure that closures - created by expressions in the formal parameter list do not have visibility - of declarations in the function body. - b. Let varEnv be NewDeclarativeEnvironment(env). - c. Let varEnvRec be varEnv’s EnvironmentRecord. - d. Set the VariableEnvironment of calleeContext to varEnv. - e. Let instantiatedVarNames be a new empty List. - f. For each n in varNames, do - i. If n is not an element of instantiatedVarNames, then - 1. Append n to instantiatedVarNames. - 2. Let status be varEnvRec.CreateMutableBinding(n). - 3. Assert: status is never an abrupt completion. - 4. If n is not an element of parameterNames or if n is an element of - functionNames, let initialValue be undefined. - ... ----*/ - -function fn(a = 1) { - var b; - - return b; -} - -assert.sameValue(fn(), undefined); -- GitLab