From de15143976283caa310b2b3818a3a73c3c8f3ca6 Mon Sep 17 00:00:00 2001 From: Leo Balter Date: Thu, 20 Apr 2017 15:03:06 -0400 Subject: [PATCH] Add Async Functions to function templates --- .../default/async-arrow-function.template | 41 +++++++++++++ .../default/async-func-decl.template | 26 +++++++++ .../default/async-func-expr-named.template | 27 +++++++++ .../default/async-func-expr-nameless.template | 27 +++++++++ .../default/async-meth.template | 29 ++++++++++ .../cls-decl-async-gen-meth-static.template | 2 +- .../default/cls-decl-async-gen-meth.template | 2 +- .../cls-decl-async-meth-static.template | 53 +++++++++++++++++ .../default/cls-decl-async-meth.template | 53 +++++++++++++++++ .../cls-expr-async-meth-static.template | 53 +++++++++++++++++ .../default/cls-expr-async-meth.template | 53 +++++++++++++++++ .../error/async-arrow-function.template | 45 +++++++++++++++ .../error/async-func-decl.template | 29 ++++++++++ .../error/async-func-expr-named.template | 29 ++++++++++ .../error/async-func-expr-nameless.template | 29 ++++++++++ src/function-forms/error/async-meth.template | 32 +++++++++++ .../error/cls-decl-async-meth-static.template | 55 ++++++++++++++++++ .../error/cls-decl-async-meth.template | 55 ++++++++++++++++++ .../error/cls-expr-async-meth-static.template | 57 +++++++++++++++++++ .../error/cls-expr-async-meth.template | 56 ++++++++++++++++++ .../syntax/async-arrow-function.template | 32 +++++++++++ .../syntax/async-func-decl.template | 17 ++++++ .../syntax/async-func-expr-named.template | 18 ++++++ .../syntax/async-func-expr-nameless.template | 17 ++++++ src/function-forms/syntax/async-meth.template | 19 +++++++ .../cls-decl-async-meth-static.template | 43 ++++++++++++++ .../syntax/cls-decl-async-meth.template | 44 ++++++++++++++ .../cls-expr-async-meth-static.template | 44 ++++++++++++++ .../syntax/cls-expr-async-meth.template | 44 ++++++++++++++ 29 files changed, 1029 insertions(+), 2 deletions(-) create mode 100644 src/function-forms/default/async-arrow-function.template create mode 100644 src/function-forms/default/async-func-decl.template create mode 100644 src/function-forms/default/async-func-expr-named.template create mode 100644 src/function-forms/default/async-func-expr-nameless.template create mode 100644 src/function-forms/default/async-meth.template create mode 100644 src/function-forms/default/cls-decl-async-meth-static.template create mode 100644 src/function-forms/default/cls-decl-async-meth.template create mode 100644 src/function-forms/default/cls-expr-async-meth-static.template create mode 100644 src/function-forms/default/cls-expr-async-meth.template create mode 100644 src/function-forms/error/async-arrow-function.template create mode 100644 src/function-forms/error/async-func-decl.template create mode 100644 src/function-forms/error/async-func-expr-named.template create mode 100644 src/function-forms/error/async-func-expr-nameless.template create mode 100644 src/function-forms/error/async-meth.template create mode 100644 src/function-forms/error/cls-decl-async-meth-static.template create mode 100644 src/function-forms/error/cls-decl-async-meth.template create mode 100644 src/function-forms/error/cls-expr-async-meth-static.template create mode 100644 src/function-forms/error/cls-expr-async-meth.template create mode 100644 src/function-forms/syntax/async-arrow-function.template create mode 100644 src/function-forms/syntax/async-func-decl.template create mode 100644 src/function-forms/syntax/async-func-expr-named.template create mode 100644 src/function-forms/syntax/async-func-expr-nameless.template create mode 100644 src/function-forms/syntax/async-meth.template create mode 100644 src/function-forms/syntax/cls-decl-async-meth-static.template create mode 100644 src/function-forms/syntax/cls-decl-async-meth.template create mode 100644 src/function-forms/syntax/cls-expr-async-meth-static.template create mode 100644 src/function-forms/syntax/cls-expr-async-meth.template diff --git a/src/function-forms/default/async-arrow-function.template b/src/function-forms/default/async-arrow-function.template new file mode 100644 index 0000000000..cdeec6f3e4 --- /dev/null +++ b/src/function-forms/default/async-arrow-function.template @@ -0,0 +1,41 @@ +// Copyright (C) 2017 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/expressions/async-arrow-function/ +name: async arrow function expression +esid: sec-async-arrow-function-definitions +info: | + 14.7 Async Arrow Function Definitions + + AsyncArrowFunction : + ... + CoverCallExpressionAndAsyncArrowHead => AsyncConciseBody + + AsyncConciseBody : + { AsyncFunctionBody } + + ... + + Supplemental Syntax + + When processing an instance of the production AsyncArrowFunction : + CoverCallExpressionAndAsyncArrowHead => AsyncConciseBody the interpretation of + CoverCallExpressionAndAsyncArrowHead is refined using the following grammar: + + AsyncArrowHead : + async ArrowFormalParameters +flags: [async] +---*/ + +var callCount = 0; + +// Stores a reference `ref` for case evaluation +var ref = async (/*{ params }*/) => { + /*{ body }*/ + callCount = callCount + 1; +}; + +ref(/*{ args }*/).then(() => { + assert.sameValue(callCount, 1, 'async arrow function invoked exactly once') +}).then($DONE, $DONE); diff --git a/src/function-forms/default/async-func-decl.template b/src/function-forms/default/async-func-decl.template new file mode 100644 index 0000000000..b9a21de58a --- /dev/null +++ b/src/function-forms/default/async-func-decl.template @@ -0,0 +1,26 @@ +// Copyright (C) 2017 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/statements/async-function/ +name: async function declaration +esid: sec-async-function-definitions +info: | + 14.6 Async Function Definitions + + AsyncFunctionDeclaration : + async function BindingIdentifier ( FormalParameters ) { AsyncFunctionBody } +flags: [async] +---*/ + +var callCount = 0; + +// Stores a reference `ref` for case evaluation +async function ref(/*{ params }*/) { + /*{ body }*/ + callCount = callCount + 1; +} + +ref(/*{ args }*/).then(() => { + assert.sameValue(callCount, 1, 'function invoked exactly once'); +}).then($DONE, $DONE); diff --git a/src/function-forms/default/async-func-expr-named.template b/src/function-forms/default/async-func-expr-named.template new file mode 100644 index 0000000000..daf87b2f1f --- /dev/null +++ b/src/function-forms/default/async-func-expr-named.template @@ -0,0 +1,27 @@ +// Copyright (C) 2017 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/expressions/async-function/named- +name: async function named expression +esid: sec-async-function-definitions +info: | + 14.6 Async Function Definitions + + AsyncFunctionExpression : + async function BindingIdentifier ( FormalParameters ) { AsyncFunctionBody } +flags: [async] +---*/ + +var callCount = 0; + +// Stores a reference `ref` for case evaluation +var ref; +ref = async function ref(/*{ params }*/) { + /*{ body }*/ + callCount = callCount + 1; +}; + +ref(/*{ args }*/).then(() => { + assert.sameValue(callCount, 1, 'function invoked exactly once'); +}).then($DONE, $DONE); diff --git a/src/function-forms/default/async-func-expr-nameless.template b/src/function-forms/default/async-func-expr-nameless.template new file mode 100644 index 0000000000..cade1a007f --- /dev/null +++ b/src/function-forms/default/async-func-expr-nameless.template @@ -0,0 +1,27 @@ +// Copyright (C) 2017 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/expressions/async-function/nameless- +name: async function nameless expression +esid: sec-async-function-definitions +info: | + 14.6 Async Function Definitions + + AsyncFunctionExpression : + async function ( FormalParameters ) { AsyncFunctionBody } +flags: [async] +---*/ + +var callCount = 0; + +// Stores a reference `ref` for case evaluation +var ref; +ref = async function(/*{ params }*/) { + /*{ body }*/ + callCount = callCount + 1; +}; + +ref(/*{ args }*/).then(() => { + assert.sameValue(callCount, 1, 'function invoked exactly once'); +}).then($DONE, $DONE); diff --git a/src/function-forms/default/async-meth.template b/src/function-forms/default/async-meth.template new file mode 100644 index 0000000000..7e0d3d9ee1 --- /dev/null +++ b/src/function-forms/default/async-meth.template @@ -0,0 +1,29 @@ +// Copyright (C) 2017 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/expressions/object/method-definition/async-meth- +name: async method +esid: sec-async-function-definitions +info: | + 14.6 Async Function Definitions + + AsyncMethod : + async PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } +flags: [async] +---*/ + +var callCount = 0; +var __obj = { + async method(/*{ params }*/) { + /*{ body }*/ + callCount = callCount + 1; + } +}; + +// Stores a reference `ref` for case evaluation +var ref = __obj.method; + +ref(/*{ args }*/).then(() => { + assert.sameValue(callCount, 1, 'async method invoked exactly once'); +}).then($DONE, $DONE); diff --git a/src/function-forms/default/cls-decl-async-gen-meth-static.template b/src/function-forms/default/cls-decl-async-gen-meth-static.template index 32fa9073a1..ae172b8eb6 100644 --- a/src/function-forms/default/cls-decl-async-gen-meth-static.template +++ b/src/function-forms/default/cls-decl-async-gen-meth-static.template @@ -3,7 +3,7 @@ /*--- path: language/statements/class/async-gen-meth-static- -name: static class expression generator method +name: static class declaration async generator method esid: sec-runtime-semantics-bindingclassdeclarationevaluation info: | ClassDeclaration : class BindingIdentifier ClassTail diff --git a/src/function-forms/default/cls-decl-async-gen-meth.template b/src/function-forms/default/cls-decl-async-gen-meth.template index d0ef01303b..400ad4c6cd 100644 --- a/src/function-forms/default/cls-decl-async-gen-meth.template +++ b/src/function-forms/default/cls-decl-async-gen-meth.template @@ -2,7 +2,7 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- path: language/statements/class/async-gen-meth- -name: class expression method +name: class declaration async generator method esid: sec-class-definitions-runtime-semantics-evaluation info: | ClassDeclaration : class BindingIdentifier ClassTail diff --git a/src/function-forms/default/cls-decl-async-meth-static.template b/src/function-forms/default/cls-decl-async-meth-static.template new file mode 100644 index 0000000000..70e1bd38b4 --- /dev/null +++ b/src/function-forms/default/cls-decl-async-meth-static.template @@ -0,0 +1,53 @@ +// Copyright (C) 2017 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/statements/class/async-meth-static- +name: static class declaration async method +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncMethod : async PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncMethod is strict mode code, let strict be true. Otherwise + let strict be false. + 4. Let scope be the LexicalEnvironment of the running execution context. + 5. Let closure be ! AsyncFunctionCreate(Method, UniqueFormalParameters, AsyncFunctionBody, + scope, strict). + [...] +flags: [async] +---*/ + +var callCount = 0; +class C { + static async method(/*{ params }*/) { + /*{ body }*/ + callCount = callCount + 1; + } +} + +// Stores a reference `ref` for case evaluation +var ref = C.method; + +ref(/*{ args }*/).then(() => { + assert.sameValue(callCount, 1, 'method invoked exactly once'); +}).then($DONE, $DONE); diff --git a/src/function-forms/default/cls-decl-async-meth.template b/src/function-forms/default/cls-decl-async-meth.template new file mode 100644 index 0000000000..a646af8834 --- /dev/null +++ b/src/function-forms/default/cls-decl-async-meth.template @@ -0,0 +1,53 @@ +// Copyright (C) 2017 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/statements/class/async-meth- +name: class declaration async method +esid: sec-class-definitions-runtime-semantics-evaluation +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncMethod : async PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncMethod is strict mode code, let strict be true. Otherwise + let strict be false. + 4. Let scope be the LexicalEnvironment of the running execution context. + 5. Let closure be ! AsyncFunctionCreate(Method, UniqueFormalParameters, AsyncFunctionBody, + scope, strict). + [...] +flags: [async] +---*/ + +var callCount = 0; +class C { + async method(/*{ params }*/) { + /*{ body }*/ + callCount = callCount + 1; + } +} + +// Stores a reference `ref` for case evaluation +var ref = C.prototype.method; + +ref(/*{ args }*/).then(() => { + assert.sameValue(callCount, 1, 'method invoked exactly once'); +}).then($DONE, $DONE); diff --git a/src/function-forms/default/cls-expr-async-meth-static.template b/src/function-forms/default/cls-expr-async-meth-static.template new file mode 100644 index 0000000000..0d5214165b --- /dev/null +++ b/src/function-forms/default/cls-expr-async-meth-static.template @@ -0,0 +1,53 @@ +// Copyright (C) 2017 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/expressions/class/async-meth-static- +name: static class expression async method +esid: sec-class-definitions-runtime-semantics-evaluation +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation + for m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncMethod : async PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncMethod is strict mode code, let strict be true. Otherwise + let strict be false. + 4. Let scope be the LexicalEnvironment of the running execution context. + 5. Let closure be ! AsyncFunctionCreate(Method, UniqueFormalParameters, AsyncFunctionBody, + scope, strict). + [...] +flags: [async] +---*/ + +var callCount = 0; +var C = class { + static async method(/*{ params }*/) { + /*{ body }*/ + callCount = callCount + 1; + } +} + +// Stores a reference `ref` for case evaluation +var ref = C.method; + +ref(/*{ args }*/).then(() => { + assert.sameValue(callCount, 1, 'method invoked exactly once'); +}).then($DONE, $DONE); diff --git a/src/function-forms/default/cls-expr-async-meth.template b/src/function-forms/default/cls-expr-async-meth.template new file mode 100644 index 0000000000..58c351c573 --- /dev/null +++ b/src/function-forms/default/cls-expr-async-meth.template @@ -0,0 +1,53 @@ +// Copyright (C) 2017 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/expressions/class/async-meth- +name: class expression async method +esid: sec-class-definitions-runtime-semantics-evaluation +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncMethod : async PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncMethod is strict mode code, let strict be true. Otherwise + let strict be false. + 4. Let scope be the LexicalEnvironment of the running execution context. + 5. Let closure be ! AsyncFunctionCreate(Method, UniqueFormalParameters, AsyncFunctionBody, + scope, strict). + [...] +flags: [async] +---*/ + +var callCount = 0; +var C = class { + async method(/*{ params }*/) { + /*{ body }*/ + callCount = callCount + 1; + } +} + +// Stores a reference `ref` for case evaluation +var ref = C.prototype.method; + +ref(/*{ args }*/).then(() => { + assert.sameValue(callCount, 1, 'method invoked exactly once'); +}).then($DONE, $DONE); diff --git a/src/function-forms/error/async-arrow-function.template b/src/function-forms/error/async-arrow-function.template new file mode 100644 index 0000000000..a64737742c --- /dev/null +++ b/src/function-forms/error/async-arrow-function.template @@ -0,0 +1,45 @@ +// Copyright (C) 2017 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/expressions/async-arrow-function/ +name: async arrow function expression +esid: sec-async-arrow-function-definitions +info: | + 14.7 Async Arrow Function Definitions + + AsyncArrowFunction : + ... + CoverCallExpressionAndAsyncArrowHead => AsyncConciseBody + + AsyncConciseBody : + { AsyncFunctionBody } + + ... + + Supplemental Syntax + + When processing an instance of the production AsyncArrowFunction : + CoverCallExpressionAndAsyncArrowHead => AsyncConciseBody the interpretation of + CoverCallExpressionAndAsyncArrowHead is refined using the following grammar: + + AsyncArrowHead : + async ArrowFormalParameters +flags: [async] +---*/ + +var callCount = 0; +var f; +f = async (/*{ params }*/) => { + /*{ body }*/ + callCount = callCount + 1; +}; + +f(/*{ args }*/) + .then(_ => { + throw new Test262Error('function should not be resolved'); + }, error => assert.sameValue(error.constructor, /*{ error }*/)) + .then(() => { + assert.sameValue(callCount, 0, 'function body is not evaluated'); + }, $DONE) + .then($DONE, $DONE); diff --git a/src/function-forms/error/async-func-decl.template b/src/function-forms/error/async-func-decl.template new file mode 100644 index 0000000000..35057673ea --- /dev/null +++ b/src/function-forms/error/async-func-decl.template @@ -0,0 +1,29 @@ +// Copyright (C) 2017 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/statements/async-function/ +name: async function declaration +esid: sec-async-function-definitions +info: | + 14.6 Async Function Definitions + + AsyncFunctionDeclaration : + async function BindingIdentifier ( FormalParameters ) { AsyncFunctionBody } +flags: [async] +---*/ + +var callCount = 0; +async function f(/*{ params }*/) { + /*{ body }*/ + callCount = callCount + 1; +} + +f(/*{ args }*/) + .then(_ => { + throw new Test262Error('function should not be resolved'); + }, error => assert.sameValue(error.constructor, /*{ error }*/)) + .then(() => { + assert.sameValue(callCount, 0, 'function body is not evaluated'); + }, $DONE) + .then($DONE, $DONE); diff --git a/src/function-forms/error/async-func-expr-named.template b/src/function-forms/error/async-func-expr-named.template new file mode 100644 index 0000000000..142d6ae79f --- /dev/null +++ b/src/function-forms/error/async-func-expr-named.template @@ -0,0 +1,29 @@ +// Copyright (C) 2017 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/expressions/async-function/named- +name: async function named expression +esid: sec-async-function-definitions +info: | + 14.6 Async Function Definitions + + AsyncFunctionExpression : + async function BindingIdentifier ( FormalParameters ) { AsyncFunctionBody } +flags: [async] +---*/ + +var callCount = 0; +var f = async function f(/*{ params }*/) { + /*{ body }*/ + callCount = callCount + 1; +} + +f(/*{ args }*/) + .then(_ => { + throw new Test262Error('function should not be resolved'); + }, error => assert.sameValue(error.constructor, /*{ error }*/)) + .then(() => { + assert.sameValue(callCount, 0, 'function body is not evaluated'); + }, $DONE) + .then($DONE, $DONE); diff --git a/src/function-forms/error/async-func-expr-nameless.template b/src/function-forms/error/async-func-expr-nameless.template new file mode 100644 index 0000000000..40d5dc0414 --- /dev/null +++ b/src/function-forms/error/async-func-expr-nameless.template @@ -0,0 +1,29 @@ +// Copyright (C) 2017 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/expressions/async-function/nameless- +name: async function nameless expression +esid: sec-async-function-definitions +info: | + 14.6 Async Function Definitions + + AsyncFunctionExpression : + async function ( FormalParameters ) { AsyncFunctionBody } +flags: [async] +---*/ + +var callCount = 0; +var f = async function(/*{ params }*/) { + /*{ body }*/ + callCount = callCount + 1; +} + +f(/*{ args }*/) + .then(_ => { + throw new Test262Error('function should not be resolved'); + }, error => assert.sameValue(error.constructor, /*{ error }*/)) + .then(() => { + assert.sameValue(callCount, 0, 'function body is not evaluated'); + }, $DONE) + .then($DONE, $DONE); diff --git a/src/function-forms/error/async-meth.template b/src/function-forms/error/async-meth.template new file mode 100644 index 0000000000..315f7ace49 --- /dev/null +++ b/src/function-forms/error/async-meth.template @@ -0,0 +1,32 @@ +// Copyright (C) 2017 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/expressions/object/method-definition/async-meth- +name: async method +esid: sec-async-function-definitions +info: | + 14.6 Async Function Definitions + + AsyncMethod : + async PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } +flags: [async] +---*/ + +var callCount = 0; + +var obj = { + async method(/*{ params }*/) { + /*{ body }*/ + callCount = callCount + 1; + } +}; + +obj.method(/*{ args }*/) + .then(_ => { + throw new Test262Error('function should not be resolved'); + }, error => assert.sameValue(error.constructor, /*{ error }*/)) + .then(() => { + assert.sameValue(callCount, 0, 'function body is not evaluated'); + }, $DONE) + .then($DONE, $DONE); diff --git a/src/function-forms/error/cls-decl-async-meth-static.template b/src/function-forms/error/cls-decl-async-meth-static.template new file mode 100644 index 0000000000..2056b336af --- /dev/null +++ b/src/function-forms/error/cls-decl-async-meth-static.template @@ -0,0 +1,55 @@ +// Copyright (C) 2017 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/statements/class/async-meth-static- +name: static class declaration async method +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncMethod : async PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncMethod is strict mode code, let strict be true. Otherwise + let strict be false. + 4. Let scope be the LexicalEnvironment of the running execution context. + 5. Let closure be ! AsyncFunctionCreate(Method, UniqueFormalParameters, AsyncFunctionBody, + scope, strict). + [...] +flags: [async] +---*/ + +var callCount = 0; +class C { + static async method(/*{ params }*/) { + /*{ body }*/ + callCount = callCount + 1; + } +} + +C.method(/*{ args }*/) + .then(_ => { + throw new Test262Error('function should not be resolved'); + }, error => assert.sameValue(error.constructor, /*{ error }*/)) + .then(() => { + assert.sameValue(callCount, 0, 'function body is not evaluated'); + }, $DONE) + .then($DONE, $DONE); diff --git a/src/function-forms/error/cls-decl-async-meth.template b/src/function-forms/error/cls-decl-async-meth.template new file mode 100644 index 0000000000..4a119e4971 --- /dev/null +++ b/src/function-forms/error/cls-decl-async-meth.template @@ -0,0 +1,55 @@ +// Copyright (C) 2017 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/statements/class/async-meth- +name: class declaration async method +esid: sec-class-definitions-runtime-semantics-evaluation +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncMethod : async PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncMethod is strict mode code, let strict be true. Otherwise + let strict be false. + 4. Let scope be the LexicalEnvironment of the running execution context. + 5. Let closure be ! AsyncFunctionCreate(Method, UniqueFormalParameters, AsyncFunctionBody, + scope, strict). + [...] +flags: [async] +---*/ + +var callCount = 0; +class C { + async method(/*{ params }*/) { + /*{ body }*/ + callCount = callCount + 1; + } +} + +C.prototype.method(/*{ args }*/) + .then(_ => { + throw new Test262Error('function should not be resolved'); + }, error => assert.sameValue(error.constructor, /*{ error }*/)) + .then(() => { + assert.sameValue(callCount, 0, 'function body is not evaluated'); + }, $DONE) + .then($DONE, $DONE); diff --git a/src/function-forms/error/cls-expr-async-meth-static.template b/src/function-forms/error/cls-expr-async-meth-static.template new file mode 100644 index 0000000000..e64dc3276d --- /dev/null +++ b/src/function-forms/error/cls-expr-async-meth-static.template @@ -0,0 +1,57 @@ +// Copyright (C) 2017 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/expressions/class/async-meth-static- +name: static class expression async method +esid: sec-class-definitions-runtime-semantics-evaluation +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation + for m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncMethod : async PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncMethod is strict mode code, let strict be true. Otherwise + let strict be false. + 4. Let scope be the LexicalEnvironment of the running execution context. + 5. Let closure be ! AsyncFunctionCreate(Method, UniqueFormalParameters, AsyncFunctionBody, + scope, strict). + [...] +flags: [async] +---*/ + +var callCount = 0; + +var C = class { + static async method(/*{ params }*/) { + /*{ body }*/ + callCount = callCount + 1; + } +}; + +C.method(/*{ args }*/) + .then(_ => { + throw new Test262Error('function should not be resolved'); + }, error => assert.sameValue(error.constructor, /*{ error }*/)) + .then(() => { + assert.sameValue(callCount, 0, 'function body is not evaluated'); + }, $DONE) + .then($DONE, $DONE); diff --git a/src/function-forms/error/cls-expr-async-meth.template b/src/function-forms/error/cls-expr-async-meth.template new file mode 100644 index 0000000000..e77de24117 --- /dev/null +++ b/src/function-forms/error/cls-expr-async-meth.template @@ -0,0 +1,56 @@ +// Copyright (C) 2017 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/expressions/class/async-meth- +name: class expression async method +esid: sec-class-definitions-runtime-semantics-evaluation +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncMethod : async PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncMethod is strict mode code, let strict be true. Otherwise + let strict be false. + 4. Let scope be the LexicalEnvironment of the running execution context. + 5. Let closure be ! AsyncFunctionCreate(Method, UniqueFormalParameters, AsyncFunctionBody, + scope, strict). + [...] +flags: [async] +---*/ + +var callCount = 0; +var C = class { + async method(/*{ params }*/) { + /*{ body }*/ + callCount = callCount + 1; + } +}; + +C.prototype.method(/*{ args }*/) + .then(_ => { + throw new Test262Error('function should not be resolved'); + }, error => assert.sameValue(error.constructor, /*{ error }*/)) + .then(() => { + assert.sameValue(callCount, 0, 'function body is not evaluated'); + }, $DONE) + .then($DONE, $DONE); diff --git a/src/function-forms/syntax/async-arrow-function.template b/src/function-forms/syntax/async-arrow-function.template new file mode 100644 index 0000000000..ddc99b7236 --- /dev/null +++ b/src/function-forms/syntax/async-arrow-function.template @@ -0,0 +1,32 @@ +// Copyright (C) 2017 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/expressions/async-arrow-function/ +name: async arrow function expression +esid: sec-async-arrow-function-definitions +info: | + 14.7 Async Arrow Function Definitions + + AsyncArrowFunction : + ... + CoverCallExpressionAndAsyncArrowHead => AsyncConciseBody + + AsyncConciseBody : + { AsyncFunctionBody } + + ... + + Supplemental Syntax + + When processing an instance of the production AsyncArrowFunction : + CoverCallExpressionAndAsyncArrowHead => AsyncConciseBody the interpretation of + CoverCallExpressionAndAsyncArrowHead is refined using the following grammar: + + AsyncArrowHead : + async ArrowFormalParameters +---*/ + +(async (/*{ params }*/) => { + /*{ body }*/ +}); diff --git a/src/function-forms/syntax/async-func-decl.template b/src/function-forms/syntax/async-func-decl.template new file mode 100644 index 0000000000..6f5beb0896 --- /dev/null +++ b/src/function-forms/syntax/async-func-decl.template @@ -0,0 +1,17 @@ +// Copyright (C) 2017 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/statements/async-function/ +name: async function declaration +esid: sec-async-function-definitions +info: | + 14.6 Async Function Definitions + + AsyncFunctionDeclaration : + async function BindingIdentifier ( FormalParameters ) { AsyncFunctionBody } +---*/ + +async function f(/*{ params }*/) { + /*{ body }*/ +} diff --git a/src/function-forms/syntax/async-func-expr-named.template b/src/function-forms/syntax/async-func-expr-named.template new file mode 100644 index 0000000000..b7efe5fc91 --- /dev/null +++ b/src/function-forms/syntax/async-func-expr-named.template @@ -0,0 +1,18 @@ +// Copyright (C) 2017 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/expressions/async-function/named- +name: async function named expression +esid: sec-async-function-definitions +info: | + 14.6 Async Function Definitions + + AsyncFunctionExpression : + async function BindingIdentifier ( FormalParameters ) { AsyncFunctionBody } + +---*/ + +(async function f(/*{ params }*/) { + /*{ body }*/ +}); diff --git a/src/function-forms/syntax/async-func-expr-nameless.template b/src/function-forms/syntax/async-func-expr-nameless.template new file mode 100644 index 0000000000..206fc5018f --- /dev/null +++ b/src/function-forms/syntax/async-func-expr-nameless.template @@ -0,0 +1,17 @@ +// Copyright (C) 2017 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/expressions/async-function/nameless- +name: async function nameless expression +esid: sec-async-function-definitions +info: | + 14.6 Async Function Definitions + + AsyncFunctionExpression : + async function ( FormalParameters ) { AsyncFunctionBody } +---*/ + +(async function(/*{ params }*/) { + /*{ body }*/ +}); diff --git a/src/function-forms/syntax/async-meth.template b/src/function-forms/syntax/async-meth.template new file mode 100644 index 0000000000..7200251a5c --- /dev/null +++ b/src/function-forms/syntax/async-meth.template @@ -0,0 +1,19 @@ +// Copyright (C) 2017 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/expressions/object/method-definition/async-meth- +name: async method +esid: sec-async-function-definitions +info: | + 14.6 Async Function Definitions + + AsyncMethod : + async PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } +---*/ + +({ + async *method(/*{ params }*/) { + /*{ body }*/ + } +}); diff --git a/src/function-forms/syntax/cls-decl-async-meth-static.template b/src/function-forms/syntax/cls-decl-async-meth-static.template new file mode 100644 index 0000000000..b0600cbce7 --- /dev/null +++ b/src/function-forms/syntax/cls-decl-async-meth-static.template @@ -0,0 +1,43 @@ +// Copyright (C) 2017 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/statements/class/async-meth-static- +name: static class declaration async method +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation for + m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncMethod : async PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncMethod is strict mode code, let strict be true. Otherwise + let strict be false. + 4. Let scope be the LexicalEnvironment of the running execution context. + 5. Let closure be ! AsyncFunctionCreate(Method, UniqueFormalParameters, AsyncFunctionBody, + scope, strict). + [...] +---*/ + +class C { + static async method(/*{ params }*/) { + /*{ body }*/ + } +} diff --git a/src/function-forms/syntax/cls-decl-async-meth.template b/src/function-forms/syntax/cls-decl-async-meth.template new file mode 100644 index 0000000000..b8bbe5ea34 --- /dev/null +++ b/src/function-forms/syntax/cls-decl-async-meth.template @@ -0,0 +1,44 @@ +// Copyright (C) 2017 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +path: language/statements/class/async-meth- +name: class declaration async method +esid: sec-class-definitions-runtime-semantics-evaluation +info: | + ClassDeclaration : class BindingIdentifier ClassTail + + 1. Let className be StringValue of BindingIdentifier. + 2. Let value be the result of ClassDefinitionEvaluation of ClassTail with + argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncMethod : async PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncMethod is strict mode code, let strict be true. Otherwise + let strict be false. + 4. Let scope be the LexicalEnvironment of the running execution context. + 5. Let closure be ! AsyncFunctionCreate(Method, UniqueFormalParameters, AsyncFunctionBody, + scope, strict). + [...] + +---*/ + +class C { + async method(/*{ params }*/) { + /*{ body }*/ + } +} diff --git a/src/function-forms/syntax/cls-expr-async-meth-static.template b/src/function-forms/syntax/cls-expr-async-meth-static.template new file mode 100644 index 0000000000..9fb25c1729 --- /dev/null +++ b/src/function-forms/syntax/cls-expr-async-meth-static.template @@ -0,0 +1,44 @@ +// Copyright (C) 2017 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/expressions/class/async-meth-static- +name: static class expression async method +esid: sec-class-definitions-runtime-semantics-evaluation +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + b. Else, + Let status be the result of performing PropertyDefinitionEvaluation + for m with arguments F and false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncMethod : async PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncMethod is strict mode code, let strict be true. Otherwise + let strict be false. + 4. Let scope be the LexicalEnvironment of the running execution context. + 5. Let closure be ! AsyncFunctionCreate(Method, UniqueFormalParameters, AsyncFunctionBody, + scope, strict). + [...] + +---*/ + +var C = class { + static async method(/*{ params }*/) { + /*{ body }*/ + } +}; diff --git a/src/function-forms/syntax/cls-expr-async-meth.template b/src/function-forms/syntax/cls-expr-async-meth.template new file mode 100644 index 0000000000..a7f86f364f --- /dev/null +++ b/src/function-forms/syntax/cls-expr-async-meth.template @@ -0,0 +1,44 @@ +// Copyright (C) 2017 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +path: language/expressions/class/async-meth- +name: class expression async method +esid: sec-class-definitions-runtime-semantics-evaluation +info: | + ClassExpression : class BindingIdentifieropt ClassTail + + 1. If BindingIdentifieropt is not present, let className be undefined. + 2. Else, let className be StringValue of BindingIdentifier. + 3. Let value be the result of ClassDefinitionEvaluation of ClassTail + with argument className. + [...] + + 14.5.14 Runtime Semantics: ClassDefinitionEvaluation + + 21. For each ClassElement m in order from methods + a. If IsStatic of m is false, then + i. Let status be the result of performing + PropertyDefinitionEvaluation for m with arguments proto and + false. + [...] + + Runtime Semantics: PropertyDefinitionEvaluation + + AsyncMethod : async PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody } + + 1. Let propKey be the result of evaluating PropertyName. + 2. ReturnIfAbrupt(propKey). + 3. If the function code for this AsyncMethod is strict mode code, let strict be true. Otherwise + let strict be false. + 4. Let scope be the LexicalEnvironment of the running execution context. + 5. Let closure be ! AsyncFunctionCreate(Method, UniqueFormalParameters, AsyncFunctionBody, + scope, strict). + [...] + +---*/ + +var C = class { + static async method(/*{ params }*/) { + /*{ body }*/ + } +};