From 74bff6b3d51421cc9d69efffdc059cb3adcc81d9 Mon Sep 17 00:00:00 2001 From: Mike Pennisi Date: Wed, 16 Mar 2016 13:58:29 -0400 Subject: [PATCH] Add initial set of generated test sources --- CONTRIBUTING.md | 34 +++++++ make.py | 57 +++++++++++ src/dstr-binding/ary-name-iter-val.case | 35 +++++++ .../default/arrow-function.template | 46 +++++++++ .../default/cls-decl-gen-meth-static.template | 69 ++++++++++++++ .../default/cls-decl-gen-meth.template | 69 ++++++++++++++ .../default/cls-decl-meth-static.template | 67 +++++++++++++ .../default/cls-decl-meth.template | 67 +++++++++++++ .../default/cls-expr-gen-meth-static.template | 71 ++++++++++++++ .../default/cls-expr-gen-meth.template | 71 ++++++++++++++ .../default/cls-expr-meth-static.template | 68 ++++++++++++++ .../default/cls-expr-meth.template | 68 ++++++++++++++ src/dstr-binding/default/const-stmt.template | 21 +++++ src/dstr-binding/default/func-decl.template | 46 +++++++++ src/dstr-binding/default/func-expr.template | 47 ++++++++++ .../default/gen-func-decl.template | 45 +++++++++ .../default/gen-func-expr.template | 47 ++++++++++ src/dstr-binding/default/gen-meth.template | 53 +++++++++++ src/dstr-binding/default/let-stmt.template | 21 +++++ src/dstr-binding/default/meth.template | 50 ++++++++++ src/dstr-binding/default/var-stmt.template | 20 ++++ src/spread/default/call-expr.template | 28 ++++++ src/spread/default/member-expr.template | 28 ++++++ src/spread/default/super-call.template | 34 +++++++ src/spread/error/call-expr.template | 23 +++++ src/spread/error/member-expr.template | 23 +++++ src/spread/error/super-call.template | 30 ++++++ src/spread/sngl-err-expr-throws.case | 22 +++++ src/spread/sngl-iter.case | 42 +++++++++ .../arrow-function/dstr-ary-name-iter-val.js | 69 ++++++++++++++ .../call/spread-err-sngl-err-expr-throws.js | 36 +++++++ .../expressions/call/spread-sngl-iter.js | 60 ++++++++++++ .../class/dstr-gen-meth-ary-name-iter-val.js | 94 +++++++++++++++++++ .../dstr-gen-meth-static-ary-name-iter-val.js | 94 +++++++++++++++++++ .../class/dstr-meth-ary-name-iter-val.js | 91 ++++++++++++++++++ .../dstr-meth-static-ary-name-iter-val.js | 91 ++++++++++++++++++ .../function/dstr-ary-name-iter-val.js | 70 ++++++++++++++ .../generators/dstr-ary-name-iter-val.js | 70 ++++++++++++++ .../new/spread-err-sngl-err-expr-throws.js | 35 +++++++ .../expressions/new/spread-sngl-iter.js | 59 ++++++++++++ .../object/dstr-gen-meth-ary-name-iter-val.js | 76 +++++++++++++++ .../object/dstr-meth-ary-name-iter-val.js | 73 ++++++++++++++ .../super/spread-err-sngl-err-expr-throws.js | 43 +++++++++ .../expressions/super/spread-sngl-iter.js | 66 +++++++++++++ .../class/dstr-gen-meth-ary-name-iter-val.js | 92 ++++++++++++++++++ .../dstr-gen-meth-static-ary-name-iter-val.js | 92 ++++++++++++++++++ .../class/dstr-meth-ary-name-iter-val.js | 90 ++++++++++++++++++ .../dstr-meth-static-ary-name-iter-val.js | 90 ++++++++++++++++++ .../const/dstr-ary-name-iter-val.js | 43 +++++++++ .../function/dstr-ary-name-iter-val.js | 69 ++++++++++++++ .../generators/dstr-ary-name-iter-val.js | 68 ++++++++++++++ .../statements/let/dstr-ary-name-iter-val.js | 43 +++++++++ .../variable/dstr-ary-name-iter-val.js | 42 +++++++++ 53 files changed, 2958 insertions(+) create mode 100755 make.py create mode 100644 src/dstr-binding/ary-name-iter-val.case create mode 100644 src/dstr-binding/default/arrow-function.template create mode 100644 src/dstr-binding/default/cls-decl-gen-meth-static.template create mode 100644 src/dstr-binding/default/cls-decl-gen-meth.template create mode 100644 src/dstr-binding/default/cls-decl-meth-static.template create mode 100644 src/dstr-binding/default/cls-decl-meth.template create mode 100644 src/dstr-binding/default/cls-expr-gen-meth-static.template create mode 100644 src/dstr-binding/default/cls-expr-gen-meth.template create mode 100644 src/dstr-binding/default/cls-expr-meth-static.template create mode 100644 src/dstr-binding/default/cls-expr-meth.template create mode 100644 src/dstr-binding/default/const-stmt.template create mode 100644 src/dstr-binding/default/func-decl.template create mode 100644 src/dstr-binding/default/func-expr.template create mode 100644 src/dstr-binding/default/gen-func-decl.template create mode 100644 src/dstr-binding/default/gen-func-expr.template create mode 100644 src/dstr-binding/default/gen-meth.template create mode 100644 src/dstr-binding/default/let-stmt.template create mode 100644 src/dstr-binding/default/meth.template create mode 100644 src/dstr-binding/default/var-stmt.template create mode 100644 src/spread/default/call-expr.template create mode 100644 src/spread/default/member-expr.template create mode 100644 src/spread/default/super-call.template create mode 100644 src/spread/error/call-expr.template create mode 100644 src/spread/error/member-expr.template create mode 100644 src/spread/error/super-call.template create mode 100644 src/spread/sngl-err-expr-throws.case create mode 100644 src/spread/sngl-iter.case create mode 100644 test/language/expressions/arrow-function/dstr-ary-name-iter-val.js create mode 100644 test/language/expressions/call/spread-err-sngl-err-expr-throws.js create mode 100644 test/language/expressions/call/spread-sngl-iter.js create mode 100644 test/language/expressions/class/dstr-gen-meth-ary-name-iter-val.js create mode 100644 test/language/expressions/class/dstr-gen-meth-static-ary-name-iter-val.js create mode 100644 test/language/expressions/class/dstr-meth-ary-name-iter-val.js create mode 100644 test/language/expressions/class/dstr-meth-static-ary-name-iter-val.js create mode 100644 test/language/expressions/function/dstr-ary-name-iter-val.js create mode 100644 test/language/expressions/generators/dstr-ary-name-iter-val.js create mode 100644 test/language/expressions/new/spread-err-sngl-err-expr-throws.js create mode 100644 test/language/expressions/new/spread-sngl-iter.js create mode 100644 test/language/expressions/object/dstr-gen-meth-ary-name-iter-val.js create mode 100644 test/language/expressions/object/dstr-meth-ary-name-iter-val.js create mode 100644 test/language/expressions/super/spread-err-sngl-err-expr-throws.js create mode 100644 test/language/expressions/super/spread-sngl-iter.js create mode 100644 test/language/statements/class/dstr-gen-meth-ary-name-iter-val.js create mode 100644 test/language/statements/class/dstr-gen-meth-static-ary-name-iter-val.js create mode 100644 test/language/statements/class/dstr-meth-ary-name-iter-val.js create mode 100644 test/language/statements/class/dstr-meth-static-ary-name-iter-val.js create mode 100644 test/language/statements/const/dstr-ary-name-iter-val.js create mode 100644 test/language/statements/function/dstr-ary-name-iter-val.js create mode 100644 test/language/statements/generators/dstr-ary-name-iter-val.js create mode 100644 test/language/statements/let/dstr-ary-name-iter-val.js create mode 100644 test/language/statements/variable/dstr-ary-name-iter-val.js diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 9788b58302..bcc82afd4c 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -244,3 +244,37 @@ p.then(function () { ``` As above, exceptions that are thrown from a `then` clause are passed to a later `$DONE` function and reported asynchronously. + +## Procedurally-generated tests + +Some language features are expressed through a number of distinct syntactic forms. Test262 maintains these tests as a set of "test cases" and "test templates" in order to ensure equivalent coverage across all forms. The sub-directories within the `src/` directory describe the various language features that benefit from this approach. + +Test cases and test templates specify meta-data using the same YAML frontmatter pattern as so-called "static" (i.e. non-generated) tests. The expected attributes differ between test cases and test templates: + +- test cases (`*.case`) + - `template` - name of the sub-directory to locate templates for this test + - `description` (see above) + - `info` (see above) + - `features` (see above; merged with value defined by test template) +- test templates (`*.template`) + - `path` - location within the published test hierarchy to output files created from this template + - `name` - human-readable name of the syntactic form described by this template (used to generate the test file's `description` field) + - `esid` (see above) + - `es5id` (see above) + - `es6id` (see above) + - `info` (see above) + - `features` (see above; merged with value defined by test case) + +Generated files are managed using the `make.py` Python script located in the root of this repository. + +To create files: + + make.py + +To remove all generated files: + + make.py clean + +The executable located at `tools/generation/generator.py` offers additional control over the generation procedure. + + ./tools/generation/generator.py --help diff --git a/make.py b/make.py new file mode 100755 index 0000000000..2d440b9724 --- /dev/null +++ b/make.py @@ -0,0 +1,57 @@ +#!/usr/bin/env python +# Copyright (C) 2016 the V8 project authors. All rights reserved. +# This code is governed by the BSD license found in the LICENSE file. + +import os, shutil, subprocess, sys + +OUT_DIR = os.environ.get('OUT_DIR') or 'test' +SRC_DIR = os.environ.get('SRC_DIR') or 'src' + +def shell(*args): + sp = subprocess.Popen(list(args), stdout=subprocess.PIPE) + cmd_str = ' '.join(args) + + print '> ' + cmd_str + + for line in iter(sp.stdout.readline, ''): + sys.stdout.write(line) + + sp.communicate() + + if sp.returncode == 1: + raise Exception('Command failed: ' + cmd_str) + +targets = dict() +def target(*deps): + def other(orig): + def wrapped(): + print 'Running target: ' + orig.__name__ + + for dep in deps: + targets[dep]() + return orig() + wrapped.__name__ = orig.__name__ + targets[orig.__name__] = wrapped + return wrapped + return other + +@target() +def build(): + shell(sys.executable, 'tools/generation/generator.py', + 'create', + '--out', OUT_DIR, + SRC_DIR) + +@target() +def clean(): + shell(sys.executable, 'tools/generation/generator.py', 'clean', OUT_DIR) + +if len(sys.argv) == 1: + targets['build']() + +for target in sys.argv[1:]: + if not target in targets: + sys.stderr.write('No target named: "' + target + '".\n' + + 'Available targets: ' + ', '.join(list(targets)) + '\n') + sys.exit(1) + targets[target]() diff --git a/src/dstr-binding/ary-name-iter-val.case b/src/dstr-binding/ary-name-iter-val.case new file mode 100644 index 0000000000..8c65a0868f --- /dev/null +++ b/src/dstr-binding/ary-name-iter-val.case @@ -0,0 +1,35 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: SingleNameBinding with normal value iteration +template: default +info: | + 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). +---*/ + +//- elems +[x, y, z] +//- vals +[1, 2, 3] +//- body +assert.sameValue(x, 1); +assert.sameValue(y, 2); +assert.sameValue(z, 3); diff --git a/src/dstr-binding/default/arrow-function.template b/src/dstr-binding/default/arrow-function.template new file mode 100644 index 0000000000..7e87227e99 --- /dev/null +++ b/src/dstr-binding/default/arrow-function.template @@ -0,0 +1,46 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/expressions/arrow-function/dstr- +name: arrow function expression +es6id: 14.2.16 +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 }*/) => { + /*{ body }*/ + callCount = callCount + 1; +}; + +f(/*{ vals }*/); +assert.sameValue(callCount, 1); diff --git a/src/dstr-binding/default/cls-decl-gen-meth-static.template b/src/dstr-binding/default/cls-decl-gen-meth-static.template new file mode 100644 index 0000000000..3f6b55e175 --- /dev/null +++ b/src/dstr-binding/default/cls-decl-gen-meth-static.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-static- +name: static class expression generator method +es6id: 14.5.15 +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If 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 }*/) { + /*{ body }*/ + callCount = callCount + 1; + } +}; + +C.method(/*{ vals }*/).next(); +assert.sameValue(callCount, 1); diff --git a/src/dstr-binding/default/cls-decl-gen-meth.template b/src/dstr-binding/default/cls-decl-gen-meth.template new file mode 100644 index 0000000000..0579b3ca6f --- /dev/null +++ b/src/dstr-binding/default/cls-decl-gen-meth.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- +name: class expression method +es6id: 14.5.16 +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. 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 }*/) { + /*{ body }*/ + callCount = callCount + 1; + } +}; + +new C().method(/*{ vals }*/).next(); +assert.sameValue(callCount, 1); diff --git a/src/dstr-binding/default/cls-decl-meth-static.template b/src/dstr-binding/default/cls-decl-meth-static.template new file mode 100644 index 0000000000..0f1fff2b7e --- /dev/null +++ b/src/dstr-binding/default/cls-decl-meth-static.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/statements/class/dstr-meth-static- +name: static class expression method +es6id: 14.5.15 +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If 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 }*/) { + /*{ body }*/ + callCount = callCount + 1; + } +}; + +C.method(/*{ vals }*/); +assert.sameValue(callCount, 1); diff --git a/src/dstr-binding/default/cls-decl-meth.template b/src/dstr-binding/default/cls-decl-meth.template new file mode 100644 index 0000000000..1a7ba2fc24 --- /dev/null +++ b/src/dstr-binding/default/cls-decl-meth.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/statements/class/dstr-meth- +name: class expression method +es6id: 14.5.15 +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. 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 }*/) { + /*{ body }*/ + callCount = callCount + 1; + } +}; + +new C().method(/*{ vals }*/); +assert.sameValue(callCount, 1); diff --git a/src/dstr-binding/default/cls-expr-gen-meth-static.template b/src/dstr-binding/default/cls-expr-gen-meth-static.template new file mode 100644 index 0000000000..340945db7b --- /dev/null +++ b/src/dstr-binding/default/cls-expr-gen-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/dstr-gen-meth-static- +name: static class expression generator method +es6id: 14.5.16 +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If 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 }*/) { + /*{ body }*/ + callCount = callCount + 1; + } +}; + +C.method(/*{ vals }*/).next(); +assert.sameValue(callCount, 1); diff --git a/src/dstr-binding/default/cls-expr-gen-meth.template b/src/dstr-binding/default/cls-expr-gen-meth.template new file mode 100644 index 0000000000..c4c0d4c8f4 --- /dev/null +++ b/src/dstr-binding/default/cls-expr-gen-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/dstr-gen-meth- +name: class expression method +es6id: 14.5.16 +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. 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 }*/) { + /*{ body }*/ + callCount = callCount + 1; + } +}; + +new C().method(/*{ vals }*/).next(); +assert.sameValue(callCount, 1); diff --git a/src/dstr-binding/default/cls-expr-meth-static.template b/src/dstr-binding/default/cls-expr-meth-static.template new file mode 100644 index 0000000000..aff8b8a63e --- /dev/null +++ b/src/dstr-binding/default/cls-expr-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/dstr-meth-static- +name: static class expression method +es6id: 14.5.16 +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If 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 }*/) { + /*{ body }*/ + callCount = callCount + 1; + } +}; + +C.method(/*{ vals }*/); +assert.sameValue(callCount, 1); diff --git a/src/dstr-binding/default/cls-expr-meth.template b/src/dstr-binding/default/cls-expr-meth.template new file mode 100644 index 0000000000..a97f94827c --- /dev/null +++ b/src/dstr-binding/default/cls-expr-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/dstr-meth- +name: class expression method +es6id: 14.5.16 +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. 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 }*/) { + /*{ body }*/ + callCount = callCount + 1; + } +}; + +new C().method(/*{ vals }*/); +assert.sameValue(callCount, 1); diff --git a/src/dstr-binding/default/const-stmt.template b/src/dstr-binding/default/const-stmt.template new file mode 100644 index 0000000000..aeddb7a8fc --- /dev/null +++ b/src/dstr-binding/default/const-stmt.template @@ -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. +/*--- +path: language/statements/const/dstr- +name: > + `const` statement +es6id: 13.3.1.4 +info: | + LexicalBinding : BindingPattern Initializer + + 1. Let rhs be the result of evaluating Initializer. + 2. Let value be GetValue(rhs). + 3. ReturnIfAbrupt(value). + 4. Let env be the running execution context's LexicalEnvironment. + 5. Return the result of performing BindingInitialization for BindingPattern + using value and env as the arguments. +---*/ + +const /*{ elems }*/ = /*{ vals }*/; + +/*{ body }*/ diff --git a/src/dstr-binding/default/func-decl.template b/src/dstr-binding/default/func-decl.template new file mode 100644 index 0000000000..7dd6b58f26 --- /dev/null +++ b/src/dstr-binding/default/func-decl.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- +name: function declaration +es6id: 14.1.19 +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 }*/) { + /*{ body }*/ + callCount = callCount + 1; +}; +f(/*{ vals }*/); +assert.sameValue(callCount, 1); diff --git a/src/dstr-binding/default/func-expr.template b/src/dstr-binding/default/func-expr.template new file mode 100644 index 0000000000..58d7cd99ac --- /dev/null +++ b/src/dstr-binding/default/func-expr.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/function/dstr- +name: function expression +es6id: 14.1.20 +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 }*/) { + /*{ body }*/ + callCount = callCount + 1; +}; + +f(/*{ vals }*/); +assert.sameValue(callCount, 1); diff --git a/src/dstr-binding/default/gen-func-decl.template b/src/dstr-binding/default/gen-func-decl.template new file mode 100644 index 0000000000..4e0403562e --- /dev/null +++ b/src/dstr-binding/default/gen-func-decl.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- +name: generator function declaration +es6id: 14.4.12 +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 }*/) { + /*{ body }*/ + callCount = callCount + 1; +}; +f(/*{ vals }*/).next(); +assert.sameValue(callCount, 1); diff --git a/src/dstr-binding/default/gen-func-expr.template b/src/dstr-binding/default/gen-func-expr.template new file mode 100644 index 0000000000..b930bc59e2 --- /dev/null +++ b/src/dstr-binding/default/gen-func-expr.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/generators/dstr- +name: generator function expression +es6id: 14.4.14 +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 }*/) { + /*{ body }*/ + callCount = callCount + 1; +}; + +f(/*{ vals }*/).next(); +assert.sameValue(callCount, 1); diff --git a/src/dstr-binding/default/gen-meth.template b/src/dstr-binding/default/gen-meth.template new file mode 100644 index 0000000000..5119178207 --- /dev/null +++ b/src/dstr-binding/default/gen-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/dstr-gen-meth- +name: generator method +es6id: 14.4.13 +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 }*/) { + /*{ body }*/ + callCount = callCount + 1; + } +}; + +obj.method(/*{ vals }*/).next(); +assert.sameValue(callCount, 1); diff --git a/src/dstr-binding/default/let-stmt.template b/src/dstr-binding/default/let-stmt.template new file mode 100644 index 0000000000..33ffd86125 --- /dev/null +++ b/src/dstr-binding/default/let-stmt.template @@ -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. +/*--- +path: language/statements/let/dstr- +name: > + `let` statement +es6id: 13.3.1.4 +info: | + LexicalBinding : BindingPattern Initializer + + 1. Let rhs be the result of evaluating Initializer. + 2. Let value be GetValue(rhs). + 3. ReturnIfAbrupt(value). + 4. Let env be the running execution context's LexicalEnvironment. + 5. Return the result of performing BindingInitialization for BindingPattern + using value and env as the arguments. +---*/ + +let /*{ elems }*/ = /*{ vals }*/; + +/*{ body }*/ diff --git a/src/dstr-binding/default/meth.template b/src/dstr-binding/default/meth.template new file mode 100644 index 0000000000..363cc16840 --- /dev/null +++ b/src/dstr-binding/default/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/dstr-meth- +name: method +es6id: 14.3.8 +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 }*/) { + /*{ body }*/ + callCount = callCount + 1; + } +}; + +obj.method(/*{ vals }*/); +assert.sameValue(callCount, 1); diff --git a/src/dstr-binding/default/var-stmt.template b/src/dstr-binding/default/var-stmt.template new file mode 100644 index 0000000000..a4511eb3b4 --- /dev/null +++ b/src/dstr-binding/default/var-stmt.template @@ -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. +/*--- +path: language/statements/variable/dstr- +name: > + `var` statement +es6id: 13.3.2.4 +info: | + VariableDeclaration : BindingPattern Initializer + + 1. Let rhs be the result of evaluating Initializer. + 2. Let rval be GetValue(rhs). + 3. ReturnIfAbrupt(rval). + 4. Return the result of performing BindingInitialization for + BindingPattern passing rval and undefined as arguments. +---*/ + +var /*{ elems }*/ = /*{ vals }*/; + +/*{ body }*/ diff --git a/src/spread/default/call-expr.template b/src/spread/default/call-expr.template new file mode 100644 index 0000000000..4f1017889a --- /dev/null +++ b/src/spread/default/call-expr.template @@ -0,0 +1,28 @@ +// 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/call/spread- +name: CallExpression +es6id: 12.3.4.1 +info: | + CallExpression : MemberExpression Arguments + + [...] + 9. Return EvaluateDirectCall(func, thisValue, Arguments, tailCall). + + 12.3.4.3 Runtime Semantics: EvaluateDirectCall + + 1. Let argList be ArgumentListEvaluation(arguments). + [...] + 6. Let result be Call(func, thisValue, argList). + [...] +---*/ + +var callCount = 0; + +(function(/*{ params }*/) { + /*{ body }*/ + callCount += 1; +}(/*{ args }*/)); + +assert.sameValue(callCount, 1); diff --git a/src/spread/default/member-expr.template b/src/spread/default/member-expr.template new file mode 100644 index 0000000000..6069bff04f --- /dev/null +++ b/src/spread/default/member-expr.template @@ -0,0 +1,28 @@ +// 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/new/spread- +name: > + `new` operator +es6id: 12.3.3.1 +info: | + MemberExpression : new MemberExpression Arguments + + 1. Return EvaluateNew(MemberExpression, Arguments). + + 12.3.3.1.1 Runtime Semantics: EvaluateNew + + 6. If arguments is empty, let argList be an empty List. + 7. Else, + a. Let argList be ArgumentListEvaluation of arguments. + [...] +---*/ + +var callCount = 0; + +new function(/*{ params }*/) { + /*{ body }*/ + callCount += 1; +}(/*{ args }*/); + +assert.sameValue(callCount, 1); diff --git a/src/spread/default/super-call.template b/src/spread/default/super-call.template new file mode 100644 index 0000000000..7a91e9d3cf --- /dev/null +++ b/src/spread/default/super-call.template @@ -0,0 +1,34 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/expressions/super/spread- +name: SuperCall +es6id: 12.3.5.1 +info: | + SuperCall : super Arguments + + 1. Let newTarget be GetNewTarget(). + 2. If newTarget is undefined, throw a ReferenceError exception. + 3. Let func be GetSuperConstructor(). + 4. ReturnIfAbrupt(func). + 5. Let argList be ArgumentListEvaluation of Arguments. + [...] +---*/ + +var callCount = 0; + +class Test262ParentClass { + constructor(/*{ params }*/) { + /*{ body }*/ + callCount += 1; + } +} + +class Test262ChildClass extends Test262ParentClass { + constructor() { + super(/*{ args }*/); + } +} + +new Test262ChildClass(); +assert.sameValue(callCount, 1); diff --git a/src/spread/error/call-expr.template b/src/spread/error/call-expr.template new file mode 100644 index 0000000000..69d6e380ef --- /dev/null +++ b/src/spread/error/call-expr.template @@ -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. +/*--- +path: language/expressions/call/spread-err- +name: CallExpression +es6id: 12.3.4.1 +info: | + CallExpression : MemberExpression Arguments + + [...] + 9. Return EvaluateDirectCall(func, thisValue, Arguments, tailCall). + + 12.3.4.3 Runtime Semantics: EvaluateDirectCall + + 1. Let argList be ArgumentListEvaluation(arguments). + [...] + 6. Let result be Call(func, thisValue, argList). + [...] +---*/ + +assert.throws(/*{ error }*/, function() { + (function(/*{ params }*/) {}(/*{ args }*/)); +}); diff --git a/src/spread/error/member-expr.template b/src/spread/error/member-expr.template new file mode 100644 index 0000000000..b70627f3cb --- /dev/null +++ b/src/spread/error/member-expr.template @@ -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. +/*--- +path: language/expressions/new/spread-err- +name: > + `new` operator +es6id: 12.3.3.1 +info: | + MemberExpression : new MemberExpression Arguments + + 1. Return EvaluateNew(MemberExpression, Arguments). + + 12.3.3.1.1 Runtime Semantics: EvaluateNew + + 6. If arguments is empty, let argList be an empty List. + 7. Else, + a. Let argList be ArgumentListEvaluation of arguments. + [...] +---*/ + +assert.throws(/*{ error }*/, function() { + new function(/*{ params }*/) {}(/*{ args }*/); +}); diff --git a/src/spread/error/super-call.template b/src/spread/error/super-call.template new file mode 100644 index 0000000000..eb3ec04661 --- /dev/null +++ b/src/spread/error/super-call.template @@ -0,0 +1,30 @@ +// 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/super/spread-err- +name: SuperCall +es6id: 12.3.5.1 +info: | + SuperCall : super Arguments + + 1. Let newTarget be GetNewTarget(). + 2. If newTarget is undefined, throw a ReferenceError exception. + 3. Let func be GetSuperConstructor(). + 4. ReturnIfAbrupt(func). + 5. Let argList be ArgumentListEvaluation of Arguments. + [...] +---*/ + +class Test262ParentClass { + constructor(/*{ params }*/) {} +} + +class Test262ChildClass extends Test262ParentClass { + constructor() { + super(/*{ args }*/); + } +} + +assert.throws(/*{ error }*/, function() { + new Test262ChildClass(); +}); diff --git a/src/spread/sngl-err-expr-throws.case b/src/spread/sngl-err-expr-throws.case new file mode 100644 index 0000000000..389a9366eb --- /dev/null +++ b/src/spread/sngl-err-expr-throws.case @@ -0,0 +1,22 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +desc: Spread operator applied to the only argument when evaluation throws +template: error +features: [generators] +info: | + 12.3.6.1 Runtime Semantics: ArgumentListEvaluation + + ArgumentList : ... AssignmentExpression + + 1. Let list be an empty List. + 2. Let spreadRef be the result of evaluating AssignmentExpression. + 3. Let spreadObj be GetValue(spreadRef). + 4. Let iterator be GetIterator(spreadObj). + 5. ReturnIfAbrupt(iterator). +---*/ + +//- error +Test262Error +//- args +...function*() { throw new Test262Error(); }() diff --git a/src/spread/sngl-iter.case b/src/spread/sngl-iter.case new file mode 100644 index 0000000000..594b072370 --- /dev/null +++ b/src/spread/sngl-iter.case @@ -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. +/*--- +desc: Spread operator applied to the only argument with a valid iterator +template: default +features: [Symbol.iterator] +info: | + 12.3.6.1 Runtime Semantics: ArgumentListEvaluation + + ArgumentList : ... AssignmentExpression + + 1. Let list be an empty List. + 2. Let spreadRef be the result of evaluating AssignmentExpression. + 3. Let spreadObj be GetValue(spreadRef). + 4. Let iterator be GetIterator(spreadObj). + 5. ReturnIfAbrupt(iterator). + 6. Repeat + a. Let next be IteratorStep(iterator). + b. ReturnIfAbrupt(next). + c. If next is false, return list. + d. Let nextArg be IteratorValue(next). + e. ReturnIfAbrupt(nextArg). + f. Append nextArg as the last element of list. +---*/ + +//- setup +var iter = {}; +iter[Symbol.iterator] = function() { + var callCount = 0; + return { + next: function() { + callCount += 1; + return { done: callCount === 3, value: callCount }; + } + }; +}; +//- args +...iter +//- body +assert.sameValue(arguments.length, 2); +assert.sameValue(arguments[0], 1); +assert.sameValue(arguments[1], 2); diff --git a/test/language/expressions/arrow-function/dstr-ary-name-iter-val.js b/test/language/expressions/arrow-function/dstr-ary-name-iter-val.js new file mode 100644 index 0000000000..fe684355ed --- /dev/null +++ b/test/language/expressions/arrow-function/dstr-ary-name-iter-val.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-name-iter-val.case +// - src/dstr-binding/default/arrow-function.template +/*--- +description: SingleNameBinding with normal value iteration (arrow function expression) +es6id: 14.2.16 +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]) => { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 3); + callCount = callCount + 1; +}; + +f([1, 2, 3]); +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/call/spread-err-sngl-err-expr-throws.js b/test/language/expressions/call/spread-err-sngl-err-expr-throws.js new file mode 100644 index 0000000000..2d70fa3d73 --- /dev/null +++ b/test/language/expressions/call/spread-err-sngl-err-expr-throws.js @@ -0,0 +1,36 @@ +// This file was procedurally generated from the following sources: +// - src/spread/sngl-err-expr-throws.case +// - src/spread/error/call-expr.template +/*--- +description: Spread operator applied to the only argument when evaluation throws (CallExpression) +es6id: 12.3.4.1 +features: [generators] + +flags: [generated] +info: > + CallExpression : MemberExpression Arguments + + [...] + 9. Return EvaluateDirectCall(func, thisValue, Arguments, tailCall). + + 12.3.4.3 Runtime Semantics: EvaluateDirectCall + + 1. Let argList be ArgumentListEvaluation(arguments). + [...] + 6. Let result be Call(func, thisValue, argList). + [...] + + 12.3.6.1 Runtime Semantics: ArgumentListEvaluation + + ArgumentList : ... AssignmentExpression + + 1. Let list be an empty List. + 2. Let spreadRef be the result of evaluating AssignmentExpression. + 3. Let spreadObj be GetValue(spreadRef). + 4. Let iterator be GetIterator(spreadObj). + 5. ReturnIfAbrupt(iterator). +---*/ + +assert.throws(Test262Error, function() { + (function() {}(...function*() { throw new Test262Error(); }())); +}); diff --git a/test/language/expressions/call/spread-sngl-iter.js b/test/language/expressions/call/spread-sngl-iter.js new file mode 100644 index 0000000000..d6d86102bf --- /dev/null +++ b/test/language/expressions/call/spread-sngl-iter.js @@ -0,0 +1,60 @@ +// This file was procedurally generated from the following sources: +// - src/spread/sngl-iter.case +// - src/spread/default/call-expr.template +/*--- +description: Spread operator applied to the only argument with a valid iterator (CallExpression) +es6id: 12.3.4.1 +features: [Symbol.iterator] + +flags: [generated] +info: > + CallExpression : MemberExpression Arguments + + [...] + 9. Return EvaluateDirectCall(func, thisValue, Arguments, tailCall). + + 12.3.4.3 Runtime Semantics: EvaluateDirectCall + + 1. Let argList be ArgumentListEvaluation(arguments). + [...] + 6. Let result be Call(func, thisValue, argList). + [...] + + 12.3.6.1 Runtime Semantics: ArgumentListEvaluation + + ArgumentList : ... AssignmentExpression + + 1. Let list be an empty List. + 2. Let spreadRef be the result of evaluating AssignmentExpression. + 3. Let spreadObj be GetValue(spreadRef). + 4. Let iterator be GetIterator(spreadObj). + 5. ReturnIfAbrupt(iterator). + 6. Repeat + a. Let next be IteratorStep(iterator). + b. ReturnIfAbrupt(next). + c. If next is false, return list. + d. Let nextArg be IteratorValue(next). + e. ReturnIfAbrupt(nextArg). + f. Append nextArg as the last element of list. +---*/ +var iter = {}; +iter[Symbol.iterator] = function() { + var callCount = 0; + return { + next: function() { + callCount += 1; + return { done: callCount === 3, value: callCount }; + } + }; +}; + +var callCount = 0; + +(function() { + assert.sameValue(arguments.length, 2); + assert.sameValue(arguments[0], 1); + assert.sameValue(arguments[1], 2); + callCount += 1; +}(...iter)); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/class/dstr-gen-meth-ary-name-iter-val.js b/test/language/expressions/class/dstr-gen-meth-ary-name-iter-val.js new file mode 100644 index 0000000000..10b822b6f3 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-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-expr-gen-meth.template +/*--- +description: SingleNameBinding with normal value iteration (class expression method) +es6id: 14.5.16 +flags: [generated] +info: > + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. 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]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 3); + callCount = callCount + 1; + } +}; + +new C().method([1, 2, 3]).next(); +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/class/dstr-gen-meth-static-ary-name-iter-val.js b/test/language/expressions/class/dstr-gen-meth-static-ary-name-iter-val.js new file mode 100644 index 0000000000..dab262ab38 --- /dev/null +++ b/test/language/expressions/class/dstr-gen-meth-static-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-expr-gen-meth-static.template +/*--- +description: SingleNameBinding with normal value iteration (static class expression generator method) +es6id: 14.5.16 +flags: [generated] +info: > + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If 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]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 3); + callCount = callCount + 1; + } +}; + +C.method([1, 2, 3]).next(); +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/class/dstr-meth-ary-name-iter-val.js b/test/language/expressions/class/dstr-meth-ary-name-iter-val.js new file mode 100644 index 0000000000..4bbf523732 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-ary-name-iter-val.js @@ -0,0 +1,91 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-name-iter-val.case +// - src/dstr-binding/default/cls-expr-meth.template +/*--- +description: SingleNameBinding with normal value iteration (class expression method) +es6id: 14.5.16 +flags: [generated] +info: > + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. 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]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 3); + callCount = callCount + 1; + } +}; + +new C().method([1, 2, 3]); +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/class/dstr-meth-static-ary-name-iter-val.js b/test/language/expressions/class/dstr-meth-static-ary-name-iter-val.js new file mode 100644 index 0000000000..bcf43ba715 --- /dev/null +++ b/test/language/expressions/class/dstr-meth-static-ary-name-iter-val.js @@ -0,0 +1,91 @@ +// 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.template +/*--- +description: SingleNameBinding with normal value iteration (static class expression method) +es6id: 14.5.16 +flags: [generated] +info: > + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If 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]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 3); + callCount = callCount + 1; + } +}; + +C.method([1, 2, 3]); +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/function/dstr-ary-name-iter-val.js b/test/language/expressions/function/dstr-ary-name-iter-val.js new file mode 100644 index 0000000000..b6861fbd0e --- /dev/null +++ b/test/language/expressions/function/dstr-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/func-expr.template +/*--- +description: SingleNameBinding with normal value iteration (function expression) +es6id: 14.1.20 +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]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 3); + callCount = callCount + 1; +}; + +f([1, 2, 3]); +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/generators/dstr-ary-name-iter-val.js b/test/language/expressions/generators/dstr-ary-name-iter-val.js new file mode 100644 index 0000000000..afa9503847 --- /dev/null +++ b/test/language/expressions/generators/dstr-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-expr.template +/*--- +description: SingleNameBinding with normal value iteration (generator function expression) +es6id: 14.4.14 +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]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 3); + callCount = callCount + 1; +}; + +f([1, 2, 3]).next(); +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/new/spread-err-sngl-err-expr-throws.js b/test/language/expressions/new/spread-err-sngl-err-expr-throws.js new file mode 100644 index 0000000000..a2b21ad2a2 --- /dev/null +++ b/test/language/expressions/new/spread-err-sngl-err-expr-throws.js @@ -0,0 +1,35 @@ +// This file was procedurally generated from the following sources: +// - src/spread/sngl-err-expr-throws.case +// - src/spread/error/member-expr.template +/*--- +description: Spread operator applied to the only argument when evaluation throws (`new` operator) +es6id: 12.3.3.1 +features: [generators] + +flags: [generated] +info: > + MemberExpression : new MemberExpression Arguments + + 1. Return EvaluateNew(MemberExpression, Arguments). + + 12.3.3.1.1 Runtime Semantics: EvaluateNew + + 6. If arguments is empty, let argList be an empty List. + 7. Else, + a. Let argList be ArgumentListEvaluation of arguments. + [...] + + 12.3.6.1 Runtime Semantics: ArgumentListEvaluation + + ArgumentList : ... AssignmentExpression + + 1. Let list be an empty List. + 2. Let spreadRef be the result of evaluating AssignmentExpression. + 3. Let spreadObj be GetValue(spreadRef). + 4. Let iterator be GetIterator(spreadObj). + 5. ReturnIfAbrupt(iterator). +---*/ + +assert.throws(Test262Error, function() { + new function() {}(...function*() { throw new Test262Error(); }()); +}); diff --git a/test/language/expressions/new/spread-sngl-iter.js b/test/language/expressions/new/spread-sngl-iter.js new file mode 100644 index 0000000000..af9cfe2332 --- /dev/null +++ b/test/language/expressions/new/spread-sngl-iter.js @@ -0,0 +1,59 @@ +// This file was procedurally generated from the following sources: +// - src/spread/sngl-iter.case +// - src/spread/default/member-expr.template +/*--- +description: Spread operator applied to the only argument with a valid iterator (`new` operator) +es6id: 12.3.3.1 +features: [Symbol.iterator] + +flags: [generated] +info: > + MemberExpression : new MemberExpression Arguments + + 1. Return EvaluateNew(MemberExpression, Arguments). + + 12.3.3.1.1 Runtime Semantics: EvaluateNew + + 6. If arguments is empty, let argList be an empty List. + 7. Else, + a. Let argList be ArgumentListEvaluation of arguments. + [...] + + 12.3.6.1 Runtime Semantics: ArgumentListEvaluation + + ArgumentList : ... AssignmentExpression + + 1. Let list be an empty List. + 2. Let spreadRef be the result of evaluating AssignmentExpression. + 3. Let spreadObj be GetValue(spreadRef). + 4. Let iterator be GetIterator(spreadObj). + 5. ReturnIfAbrupt(iterator). + 6. Repeat + a. Let next be IteratorStep(iterator). + b. ReturnIfAbrupt(next). + c. If next is false, return list. + d. Let nextArg be IteratorValue(next). + e. ReturnIfAbrupt(nextArg). + f. Append nextArg as the last element of list. +---*/ +var iter = {}; +iter[Symbol.iterator] = function() { + var callCount = 0; + return { + next: function() { + callCount += 1; + return { done: callCount === 3, value: callCount }; + } + }; +}; + +var callCount = 0; + +new function() { + assert.sameValue(arguments.length, 2); + assert.sameValue(arguments[0], 1); + assert.sameValue(arguments[1], 2); + callCount += 1; +}(...iter); + +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/object/dstr-gen-meth-ary-name-iter-val.js b/test/language/expressions/object/dstr-gen-meth-ary-name-iter-val.js new file mode 100644 index 0000000000..6533c3c74d --- /dev/null +++ b/test/language/expressions/object/dstr-gen-meth-ary-name-iter-val.js @@ -0,0 +1,76 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-name-iter-val.case +// - src/dstr-binding/default/gen-meth.template +/*--- +description: SingleNameBinding with normal value iteration (generator method) +es6id: 14.4.13 +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]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 3); + callCount = callCount + 1; + } +}; + +obj.method([1, 2, 3]).next(); +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/object/dstr-meth-ary-name-iter-val.js b/test/language/expressions/object/dstr-meth-ary-name-iter-val.js new file mode 100644 index 0000000000..d9bfb6f4d9 --- /dev/null +++ b/test/language/expressions/object/dstr-meth-ary-name-iter-val.js @@ -0,0 +1,73 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-name-iter-val.case +// - src/dstr-binding/default/meth.template +/*--- +description: SingleNameBinding with normal value iteration (method) +es6id: 14.3.8 +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]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 3); + callCount = callCount + 1; + } +}; + +obj.method([1, 2, 3]); +assert.sameValue(callCount, 1); diff --git a/test/language/expressions/super/spread-err-sngl-err-expr-throws.js b/test/language/expressions/super/spread-err-sngl-err-expr-throws.js new file mode 100644 index 0000000000..33809221ea --- /dev/null +++ b/test/language/expressions/super/spread-err-sngl-err-expr-throws.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/spread/sngl-err-expr-throws.case +// - src/spread/error/super-call.template +/*--- +description: Spread operator applied to the only argument when evaluation throws (SuperCall) +es6id: 12.3.5.1 +features: [generators] + +flags: [generated] +info: > + SuperCall : super Arguments + + 1. Let newTarget be GetNewTarget(). + 2. If newTarget is undefined, throw a ReferenceError exception. + 3. Let func be GetSuperConstructor(). + 4. ReturnIfAbrupt(func). + 5. Let argList be ArgumentListEvaluation of Arguments. + [...] + + 12.3.6.1 Runtime Semantics: ArgumentListEvaluation + + ArgumentList : ... AssignmentExpression + + 1. Let list be an empty List. + 2. Let spreadRef be the result of evaluating AssignmentExpression. + 3. Let spreadObj be GetValue(spreadRef). + 4. Let iterator be GetIterator(spreadObj). + 5. ReturnIfAbrupt(iterator). +---*/ + +class Test262ParentClass { + constructor() {} +} + +class Test262ChildClass extends Test262ParentClass { + constructor() { + super(...function*() { throw new Test262Error(); }()); + } +} + +assert.throws(Test262Error, function() { + new Test262ChildClass(); +}); diff --git a/test/language/expressions/super/spread-sngl-iter.js b/test/language/expressions/super/spread-sngl-iter.js new file mode 100644 index 0000000000..b4ae03e8b4 --- /dev/null +++ b/test/language/expressions/super/spread-sngl-iter.js @@ -0,0 +1,66 @@ +// This file was procedurally generated from the following sources: +// - src/spread/sngl-iter.case +// - src/spread/default/super-call.template +/*--- +description: Spread operator applied to the only argument with a valid iterator (SuperCall) +es6id: 12.3.5.1 +features: [Symbol.iterator] + +flags: [generated] +info: > + SuperCall : super Arguments + + 1. Let newTarget be GetNewTarget(). + 2. If newTarget is undefined, throw a ReferenceError exception. + 3. Let func be GetSuperConstructor(). + 4. ReturnIfAbrupt(func). + 5. Let argList be ArgumentListEvaluation of Arguments. + [...] + + 12.3.6.1 Runtime Semantics: ArgumentListEvaluation + + ArgumentList : ... AssignmentExpression + + 1. Let list be an empty List. + 2. Let spreadRef be the result of evaluating AssignmentExpression. + 3. Let spreadObj be GetValue(spreadRef). + 4. Let iterator be GetIterator(spreadObj). + 5. ReturnIfAbrupt(iterator). + 6. Repeat + a. Let next be IteratorStep(iterator). + b. ReturnIfAbrupt(next). + c. If next is false, return list. + d. Let nextArg be IteratorValue(next). + e. ReturnIfAbrupt(nextArg). + f. Append nextArg as the last element of list. +---*/ +var iter = {}; +iter[Symbol.iterator] = function() { + var callCount = 0; + return { + next: function() { + callCount += 1; + return { done: callCount === 3, value: callCount }; + } + }; +}; + +var callCount = 0; + +class Test262ParentClass { + constructor() { + assert.sameValue(arguments.length, 2); + assert.sameValue(arguments[0], 1); + assert.sameValue(arguments[1], 2); + callCount += 1; + } +} + +class Test262ChildClass extends Test262ParentClass { + constructor() { + super(...iter); + } +} + +new Test262ChildClass(); +assert.sameValue(callCount, 1); diff --git a/test/language/statements/class/dstr-gen-meth-ary-name-iter-val.js b/test/language/statements/class/dstr-gen-meth-ary-name-iter-val.js new file mode 100644 index 0000000000..5420f0f2a8 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-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-gen-meth.template +/*--- +description: SingleNameBinding with normal value iteration (class expression method) +es6id: 14.5.16 +flags: [generated] +info: > + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. 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]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 3); + callCount = callCount + 1; + } +}; + +new C().method([1, 2, 3]).next(); +assert.sameValue(callCount, 1); diff --git a/test/language/statements/class/dstr-gen-meth-static-ary-name-iter-val.js b/test/language/statements/class/dstr-gen-meth-static-ary-name-iter-val.js new file mode 100644 index 0000000000..33490cd0c4 --- /dev/null +++ b/test/language/statements/class/dstr-gen-meth-static-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-gen-meth-static.template +/*--- +description: SingleNameBinding with normal value iteration (static class expression generator method) +es6id: 14.5.15 +flags: [generated] +info: > + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If 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]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 3); + callCount = callCount + 1; + } +}; + +C.method([1, 2, 3]).next(); +assert.sameValue(callCount, 1); diff --git a/test/language/statements/class/dstr-meth-ary-name-iter-val.js b/test/language/statements/class/dstr-meth-ary-name-iter-val.js new file mode 100644 index 0000000000..d811ee11f4 --- /dev/null +++ b/test/language/statements/class/dstr-meth-ary-name-iter-val.js @@ -0,0 +1,90 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-name-iter-val.case +// - src/dstr-binding/default/cls-decl-meth.template +/*--- +description: SingleNameBinding with normal value iteration (class expression method) +es6id: 14.5.15 +flags: [generated] +info: > + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. 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]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 3); + callCount = callCount + 1; + } +}; + +new C().method([1, 2, 3]); +assert.sameValue(callCount, 1); diff --git a/test/language/statements/class/dstr-meth-static-ary-name-iter-val.js b/test/language/statements/class/dstr-meth-static-ary-name-iter-val.js new file mode 100644 index 0000000000..f760fc0e97 --- /dev/null +++ b/test/language/statements/class/dstr-meth-static-ary-name-iter-val.js @@ -0,0 +1,90 @@ +// 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.template +/*--- +description: SingleNameBinding with normal value iteration (static class expression method) +es6id: 14.5.15 +flags: [generated] +info: > + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If 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]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 3); + callCount = callCount + 1; + } +}; + +C.method([1, 2, 3]); +assert.sameValue(callCount, 1); diff --git a/test/language/statements/const/dstr-ary-name-iter-val.js b/test/language/statements/const/dstr-ary-name-iter-val.js new file mode 100644 index 0000000000..9c0dfe7d91 --- /dev/null +++ b/test/language/statements/const/dstr-ary-name-iter-val.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-name-iter-val.case +// - src/dstr-binding/default/const-stmt.template +/*--- +description: SingleNameBinding with normal value iteration (`const` statement) +es6id: 13.3.1.4 +flags: [generated] +info: > + LexicalBinding : BindingPattern Initializer + + 1. Let rhs be the result of evaluating Initializer. + 2. Let value be GetValue(rhs). + 3. ReturnIfAbrupt(value). + 4. Let env be the running execution context's LexicalEnvironment. + 5. Return the result of performing BindingInitialization for BindingPattern + using value and env 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). +---*/ + +const [x, y, z] = [1, 2, 3]; + +assert.sameValue(x, 1); +assert.sameValue(y, 2); +assert.sameValue(z, 3); diff --git a/test/language/statements/function/dstr-ary-name-iter-val.js b/test/language/statements/function/dstr-ary-name-iter-val.js new file mode 100644 index 0000000000..a1d408404b --- /dev/null +++ b/test/language/statements/function/dstr-ary-name-iter-val.js @@ -0,0 +1,69 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-name-iter-val.case +// - src/dstr-binding/default/func-decl.template +/*--- +description: SingleNameBinding with normal value iteration (function declaration) +es6id: 14.1.19 +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]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 3); + callCount = callCount + 1; +}; +f([1, 2, 3]); +assert.sameValue(callCount, 1); diff --git a/test/language/statements/generators/dstr-ary-name-iter-val.js b/test/language/statements/generators/dstr-ary-name-iter-val.js new file mode 100644 index 0000000000..74098d854c --- /dev/null +++ b/test/language/statements/generators/dstr-ary-name-iter-val.js @@ -0,0 +1,68 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-name-iter-val.case +// - src/dstr-binding/default/gen-func-decl.template +/*--- +description: SingleNameBinding with normal value iteration (generator function declaration) +es6id: 14.4.12 +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]) { + assert.sameValue(x, 1); + assert.sameValue(y, 2); + assert.sameValue(z, 3); + callCount = callCount + 1; +}; +f([1, 2, 3]).next(); +assert.sameValue(callCount, 1); diff --git a/test/language/statements/let/dstr-ary-name-iter-val.js b/test/language/statements/let/dstr-ary-name-iter-val.js new file mode 100644 index 0000000000..0fa4fcd8e0 --- /dev/null +++ b/test/language/statements/let/dstr-ary-name-iter-val.js @@ -0,0 +1,43 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-name-iter-val.case +// - src/dstr-binding/default/let-stmt.template +/*--- +description: SingleNameBinding with normal value iteration (`let` statement) +es6id: 13.3.1.4 +flags: [generated] +info: > + LexicalBinding : BindingPattern Initializer + + 1. Let rhs be the result of evaluating Initializer. + 2. Let value be GetValue(rhs). + 3. ReturnIfAbrupt(value). + 4. Let env be the running execution context's LexicalEnvironment. + 5. Return the result of performing BindingInitialization for BindingPattern + using value and env 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). +---*/ + +let [x, y, z] = [1, 2, 3]; + +assert.sameValue(x, 1); +assert.sameValue(y, 2); +assert.sameValue(z, 3); diff --git a/test/language/statements/variable/dstr-ary-name-iter-val.js b/test/language/statements/variable/dstr-ary-name-iter-val.js new file mode 100644 index 0000000000..a0a70ce74e --- /dev/null +++ b/test/language/statements/variable/dstr-ary-name-iter-val.js @@ -0,0 +1,42 @@ +// This file was procedurally generated from the following sources: +// - src/dstr-binding/ary-name-iter-val.case +// - src/dstr-binding/default/var-stmt.template +/*--- +description: SingleNameBinding with normal value iteration (`var` statement) +es6id: 13.3.2.4 +flags: [generated] +info: > + VariableDeclaration : BindingPattern Initializer + + 1. Let rhs be the result of evaluating Initializer. + 2. Let rval be GetValue(rhs). + 3. ReturnIfAbrupt(rval). + 4. Return the result of performing BindingInitialization for + BindingPattern passing rval and undefined 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 [x, y, z] = [1, 2, 3]; + +assert.sameValue(x, 1); +assert.sameValue(y, 2); +assert.sameValue(z, 3);