summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/language/statements/async-function
diff options
context:
space:
mode:
Diffstat (limited to 'js/src/tests/test262/language/statements/async-function')
-rw-r--r--js/src/tests/test262/language/statements/async-function/array-destructuring-param-strict-body.js110
-rw-r--r--js/src/tests/test262/language/statements/async-function/await-as-binding-identifier-escaped.js31
-rw-r--r--js/src/tests/test262/language/statements/async-function/await-as-binding-identifier.js31
-rw-r--r--js/src/tests/test262/language/statements/async-function/await-as-identifier-reference-escaped.js31
-rw-r--r--js/src/tests/test262/language/statements/async-function/await-as-identifier-reference.js31
-rw-r--r--js/src/tests/test262/language/statements/async-function/await-as-label-identifier-escaped.js31
-rw-r--r--js/src/tests/test262/language/statements/async-function/await-as-label-identifier.js31
-rw-r--r--js/src/tests/test262/language/statements/async-function/browser.js0
-rw-r--r--js/src/tests/test262/language/statements/async-function/cptn-decl.js15
-rw-r--r--js/src/tests/test262/language/statements/async-function/declaration-returns-promise.js15
-rw-r--r--js/src/tests/test262/language/statements/async-function/dflt-params-abrupt.js43
-rw-r--r--js/src/tests/test262/language/statements/async-function/dflt-params-arg-val-not-undefined.js63
-rw-r--r--js/src/tests/test262/language/statements/async-function/dflt-params-arg-val-undefined.js46
-rw-r--r--js/src/tests/test262/language/statements/async-function/dflt-params-duplicates.js39
-rw-r--r--js/src/tests/test262/language/statements/async-function/dflt-params-ref-later.js44
-rw-r--r--js/src/tests/test262/language/statements/async-function/dflt-params-ref-prior.js43
-rw-r--r--js/src/tests/test262/language/statements/async-function/dflt-params-ref-self.js44
-rw-r--r--js/src/tests/test262/language/statements/async-function/dflt-params-rest.js43
-rw-r--r--js/src/tests/test262/language/statements/async-function/dflt-params-trailing-comma.js38
-rw-r--r--js/src/tests/test262/language/statements/async-function/early-errors-declaration-NSPL-with-USD.js17
-rw-r--r--js/src/tests/test262/language/statements/async-function/early-errors-declaration-arguments-in-formal-parameters-strict.js19
-rw-r--r--js/src/tests/test262/language/statements/async-function/early-errors-declaration-await-in-formals-default.js15
-rw-r--r--js/src/tests/test262/language/statements/async-function/early-errors-declaration-await-in-formals.js15
-rw-r--r--js/src/tests/test262/language/statements/async-function/early-errors-declaration-binding-identifier-arguments-strict.js19
-rw-r--r--js/src/tests/test262/language/statements/async-function/early-errors-declaration-binding-identifier-eval-strict.js18
-rw-r--r--js/src/tests/test262/language/statements/async-function/early-errors-declaration-body-contains-super-call.js16
-rw-r--r--js/src/tests/test262/language/statements/async-function/early-errors-declaration-body-contains-super-property.js16
-rw-r--r--js/src/tests/test262/language/statements/async-function/early-errors-declaration-duplicate-parameters-strict.js19
-rw-r--r--js/src/tests/test262/language/statements/async-function/early-errors-declaration-eval-in-formal-parameters-strict.js18
-rw-r--r--js/src/tests/test262/language/statements/async-function/early-errors-declaration-formals-body-duplicate.js16
-rw-r--r--js/src/tests/test262/language/statements/async-function/early-errors-declaration-formals-contains-super-call.js16
-rw-r--r--js/src/tests/test262/language/statements/async-function/early-errors-declaration-formals-contains-super-property.js16
-rw-r--r--js/src/tests/test262/language/statements/async-function/escaped-async.js25
-rw-r--r--js/src/tests/test262/language/statements/async-function/eval-var-scope-syntax-err.js39
-rw-r--r--js/src/tests/test262/language/statements/async-function/evaluation-body-that-returns-after-await.js22
-rw-r--r--js/src/tests/test262/language/statements/async-function/evaluation-body-that-returns.js20
-rw-r--r--js/src/tests/test262/language/statements/async-function/evaluation-body-that-throws-after-await.js25
-rw-r--r--js/src/tests/test262/language/statements/async-function/evaluation-body-that-throws.js23
-rw-r--r--js/src/tests/test262/language/statements/async-function/evaluation-body.js20
-rw-r--r--js/src/tests/test262/language/statements/async-function/evaluation-default-that-throws.js21
-rw-r--r--js/src/tests/test262/language/statements/async-function/evaluation-mapped-arguments.js23
-rw-r--r--js/src/tests/test262/language/statements/async-function/evaluation-this-value-global.js19
-rw-r--r--js/src/tests/test262/language/statements/async-function/evaluation-this-value-passed.js19
-rw-r--r--js/src/tests/test262/language/statements/async-function/evaluation-unmapped-arguments.js24
-rw-r--r--js/src/tests/test262/language/statements/async-function/forbidden-ext/b1/async-func-decl-forbidden-ext-direct-access-prop-arguments.js38
-rw-r--r--js/src/tests/test262/language/statements/async-function/forbidden-ext/b1/async-func-decl-forbidden-ext-direct-access-prop-caller.js38
-rw-r--r--js/src/tests/test262/language/statements/async-function/forbidden-ext/b1/browser.js0
-rw-r--r--js/src/tests/test262/language/statements/async-function/forbidden-ext/b1/shell.js0
-rw-r--r--js/src/tests/test262/language/statements/async-function/forbidden-ext/b2/async-func-decl-forbidden-ext-indirect-access-own-prop-caller-get.js64
-rw-r--r--js/src/tests/test262/language/statements/async-function/forbidden-ext/b2/async-func-decl-forbidden-ext-indirect-access-own-prop-caller-value.js64
-rw-r--r--js/src/tests/test262/language/statements/async-function/forbidden-ext/b2/async-func-decl-forbidden-ext-indirect-access-prop-caller.js64
-rw-r--r--js/src/tests/test262/language/statements/async-function/forbidden-ext/b2/browser.js0
-rw-r--r--js/src/tests/test262/language/statements/async-function/forbidden-ext/b2/shell.js0
-rw-r--r--js/src/tests/test262/language/statements/async-function/forbidden-ext/browser.js0
-rw-r--r--js/src/tests/test262/language/statements/async-function/forbidden-ext/shell.js0
-rw-r--r--js/src/tests/test262/language/statements/async-function/let-newline-await-in-async-function.js25
-rw-r--r--js/src/tests/test262/language/statements/async-function/object-destructuring-param-strict-body.js110
-rw-r--r--js/src/tests/test262/language/statements/async-function/params-trailing-comma-multiple.js38
-rw-r--r--js/src/tests/test262/language/statements/async-function/params-trailing-comma-single.js37
-rw-r--r--js/src/tests/test262/language/statements/async-function/rest-param-strict-body.js110
-rw-r--r--js/src/tests/test262/language/statements/async-function/rest-params-trailing-comma-early-error.js36
-rw-r--r--js/src/tests/test262/language/statements/async-function/returns-async-arrow-returns-arguments-from-parent-function.js31
-rw-r--r--js/src/tests/test262/language/statements/async-function/returns-async-arrow-returns-newtarget.js30
-rw-r--r--js/src/tests/test262/language/statements/async-function/returns-async-arrow.js30
-rw-r--r--js/src/tests/test262/language/statements/async-function/returns-async-function-returns-arguments-from-own-function.js31
-rw-r--r--js/src/tests/test262/language/statements/async-function/returns-async-function-returns-newtarget.js30
-rw-r--r--js/src/tests/test262/language/statements/async-function/returns-async-function.js30
-rw-r--r--js/src/tests/test262/language/statements/async-function/shell.js113
-rw-r--r--js/src/tests/test262/language/statements/async-function/syntax-declaration-line-terminators-allowed.js19
-rw-r--r--js/src/tests/test262/language/statements/async-function/syntax-declaration-no-line-terminator.js15
-rw-r--r--js/src/tests/test262/language/statements/async-function/syntax-declaration.js16
-rw-r--r--js/src/tests/test262/language/statements/async-function/try-reject-finally-reject.js28
-rw-r--r--js/src/tests/test262/language/statements/async-function/try-reject-finally-return.js26
-rw-r--r--js/src/tests/test262/language/statements/async-function/try-reject-finally-throw.js26
-rw-r--r--js/src/tests/test262/language/statements/async-function/try-return-finally-reject.js26
-rw-r--r--js/src/tests/test262/language/statements/async-function/try-return-finally-return.js26
-rw-r--r--js/src/tests/test262/language/statements/async-function/try-return-finally-throw.js24
-rw-r--r--js/src/tests/test262/language/statements/async-function/try-throw-finally-reject.js26
-rw-r--r--js/src/tests/test262/language/statements/async-function/try-throw-finally-return.js26
-rw-r--r--js/src/tests/test262/language/statements/async-function/try-throw-finally-throw.js24
-rw-r--r--js/src/tests/test262/language/statements/async-function/unscopables-with-in-nested-fn.js80
-rw-r--r--js/src/tests/test262/language/statements/async-function/unscopables-with.js74
82 files changed, 2584 insertions, 0 deletions
diff --git a/js/src/tests/test262/language/statements/async-function/array-destructuring-param-strict-body.js b/js/src/tests/test262/language/statements/async-function/array-destructuring-param-strict-body.js
new file mode 100644
index 0000000000..d2eda62d6d
--- /dev/null
+++ b/js/src/tests/test262/language/statements/async-function/array-destructuring-param-strict-body.js
@@ -0,0 +1,110 @@
+// |reftest| error:SyntaxError
+// This file was procedurally generated from the following sources:
+// - src/function-forms/array-destructuring-param-strict-body.case
+// - src/function-forms/syntax/async-func-decl.template
+/*---
+description: ArrayBindingPattern and Use Strict Directive are not allowed to coexist for the same function. (async function declaration)
+esid: sec-async-function-definitions
+features: [rest-parameters, async-functions]
+flags: [generated]
+negative:
+ phase: parse
+ type: SyntaxError
+info: |
+ 14.6 Async Function Definitions
+
+ AsyncFunctionDeclaration :
+ async function BindingIdentifier ( FormalParameters ) { AsyncFunctionBody }
+
+
+ 13.3.3.4 Static Semantics: IsSimpleParameterList
+
+ BindingElement : BindingPattern
+
+ 1. Return false.
+
+ 14.1.2 Static Semantics: Early Errors
+
+ FunctionDeclaration : function BindingIdentifier ( FormalParameters ) { FunctionBody }
+ FunctionDeclaration : function ( FormalParameters ) { FunctionBody }
+ FunctionExpression : function BindingIdentifier ( FormalParameters ) { FunctionBody }
+
+ - It is a Syntax Error if ContainsUseStrict of FunctionBody is true and
+ IsSimpleParameterList of FormalParameters is false.
+
+ 14.2.1 Static Semantics: Early Errors
+
+ ArrowFunction : ArrowParameters => ConciseBody
+
+ - It is a Syntax Error if ContainsUseStrict of ConciseBody is true and
+ IsSimpleParameterList of ArrowParameters is false.
+
+ 14.3.1 Static Semantics: Early Errors
+
+ MethodDefinition : PropertyName ( UniqueFormalParameters ) { FunctionBody }
+
+ - It is a Syntax Error if ContainsUseStrict of FunctionBody is true and
+ IsSimpleParameterList of UniqueFormalParameters is false.
+
+ MethodDefinition : set PropertyName ( PropertySetParameterList ) { FunctionBody }
+
+ - It is a Syntax Error if ContainsUseStrict of FunctionBody is true and
+ IsSimpleParameterList of PropertySetParameterList is false.
+
+ 14.4.1 Static Semantics: Early Errors
+
+ GeneratorMethod : * PropertyName ( UniqueFormalParameters ) { GeneratorBody }
+
+ - It is a Syntax Error if ContainsUseStrict of GeneratorBody is true and
+ IsSimpleParameterList of UniqueFormalParameters is false.
+
+ GeneratorDeclaration : function * BindingIdentifier ( FormalParameters ) { GeneratorBody }
+ GeneratorDeclaration : function * ( FormalParameters ) { GeneratorBody }
+ GeneratorExpression : function * BindingIdentifier ( FormalParameters ) { GeneratorBody }
+
+ - It is a Syntax Error if ContainsUseStrict of GeneratorBody is true and
+ IsSimpleParameterList of UniqueFormalParameters is false.
+
+ 14.5.1 Static Semantics: Early Errors
+
+ AsyncGeneratorMethod : async * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody }
+
+ - It is a Syntax Error if ContainsUseStrict of AsyncGeneratorBody is true and
+ IsSimpleParameterList of UniqueFormalParameters is false.
+
+ AsyncGeneratorDeclaration : async function * BindingIdentifier ( FormalParameters ) { AsyncGeneratorBody }
+ AsyncGeneratorDeclaration : async function * ( FormalParameters ) { AsyncGeneratorBody }
+ AsyncGeneratorExpression : async function * BindingIdentifier ( FormalParameters ) { AsyncGeneratorBody }
+
+ - It is a Syntax Error if ContainsUseStrict of AsyncGeneratorBody is true and
+ IsSimpleParameterList of FormalParameters is false.
+
+ 14.7.1 Static Semantics: Early Errors
+
+ AsyncMethod : async PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody }
+
+ - It is a Syntax Error if ContainsUseStrict of AsyncFunctionBody is true and
+ IsSimpleParameterList of UniqueFormalParameters is false.
+
+ AsyncFunctionDeclaration : async function BindingIdentifier ( FormalParameters ) { AsyncFunctionBody }
+ AsyncFunctionDeclaration : async function ( FormalParameters ) { AsyncFunctionBody }
+ AsyncFunctionExpression : async function ( FormalParameters ) { AsyncFunctionBody }
+ AsyncFunctionExpression : async function BindingIdentifier ( FormalParameters ) { AsyncFunctionBody }
+
+ - It is a Syntax Error if ContainsUseStrict of AsyncFunctionBody is true and
+ IsSimpleParameterList of FormalParameters is false.
+
+ 14.8.1 Static Semantics: Early Errors
+
+ AsyncArrowFunction : CoverCallExpressionAndAsyncArrowHead => AsyncConciseBody
+
+ - It is a Syntax Error if ContainsUseStrict of AsyncConciseBody is true and
+ IsSimpleParameterList of CoverCallExpressionAndAsyncArrowHead is false.
+
+---*/
+$DONOTEVALUATE();
+
+
+async function f([element]) {
+ "use strict";
+}
diff --git a/js/src/tests/test262/language/statements/async-function/await-as-binding-identifier-escaped.js b/js/src/tests/test262/language/statements/async-function/await-as-binding-identifier-escaped.js
new file mode 100644
index 0000000000..433fa550eb
--- /dev/null
+++ b/js/src/tests/test262/language/statements/async-function/await-as-binding-identifier-escaped.js
@@ -0,0 +1,31 @@
+// |reftest| error:SyntaxError
+// This file was procedurally generated from the following sources:
+// - src/async-functions/await-as-binding-identifier-escaped.case
+// - src/async-functions/syntax/async-declaration.template
+/*---
+description: await is a reserved keyword within generator function bodies and may not be used as a binding identifier. (Async function declaration)
+esid: prod-AsyncFunctionDeclaration
+features: [async-functions]
+flags: [generated]
+negative:
+ phase: parse
+ type: SyntaxError
+info: |
+ Async Function Definitions
+
+ AsyncFunctionDeclaration:
+ async [no LineTerminator here] function BindingIdentifier ( FormalParameters ) { AsyncFunctionBody }
+
+
+ BindingIdentifier : Identifier
+
+ It is a Syntax Error if this production has a [Await] parameter and
+ StringValue of Identifier is "await".
+
+---*/
+$DONOTEVALUATE();
+
+
+async function asyncFn() {
+ var \u0061wait;
+}
diff --git a/js/src/tests/test262/language/statements/async-function/await-as-binding-identifier.js b/js/src/tests/test262/language/statements/async-function/await-as-binding-identifier.js
new file mode 100644
index 0000000000..4705212167
--- /dev/null
+++ b/js/src/tests/test262/language/statements/async-function/await-as-binding-identifier.js
@@ -0,0 +1,31 @@
+// |reftest| error:SyntaxError
+// This file was procedurally generated from the following sources:
+// - src/async-functions/await-as-binding-identifier.case
+// - src/async-functions/syntax/async-declaration.template
+/*---
+description: await is a reserved keyword within generator function bodies and may not be used as a binding identifier. (Async function declaration)
+esid: prod-AsyncFunctionDeclaration
+features: [async-functions]
+flags: [generated]
+negative:
+ phase: parse
+ type: SyntaxError
+info: |
+ Async Function Definitions
+
+ AsyncFunctionDeclaration:
+ async [no LineTerminator here] function BindingIdentifier ( FormalParameters ) { AsyncFunctionBody }
+
+
+ BindingIdentifier : Identifier
+
+ It is a Syntax Error if this production has a [Await] parameter and
+ StringValue of Identifier is "await".
+
+---*/
+$DONOTEVALUATE();
+
+
+async function asyncFn() {
+ var await;
+}
diff --git a/js/src/tests/test262/language/statements/async-function/await-as-identifier-reference-escaped.js b/js/src/tests/test262/language/statements/async-function/await-as-identifier-reference-escaped.js
new file mode 100644
index 0000000000..a88596ad99
--- /dev/null
+++ b/js/src/tests/test262/language/statements/async-function/await-as-identifier-reference-escaped.js
@@ -0,0 +1,31 @@
+// |reftest| error:SyntaxError
+// This file was procedurally generated from the following sources:
+// - src/async-functions/await-as-identifier-reference-escaped.case
+// - src/async-functions/syntax/async-declaration.template
+/*---
+description: await is a reserved keyword within generator function bodies and may not be used as an identifier reference. (Async function declaration)
+esid: prod-AsyncFunctionDeclaration
+features: [async-functions]
+flags: [generated]
+negative:
+ phase: parse
+ type: SyntaxError
+info: |
+ Async Function Definitions
+
+ AsyncFunctionDeclaration:
+ async [no LineTerminator here] function BindingIdentifier ( FormalParameters ) { AsyncFunctionBody }
+
+
+ IdentifierReference : Identifier
+
+ It is a Syntax Error if this production has a [Await] parameter and
+ StringValue of Identifier is "await".
+
+---*/
+$DONOTEVALUATE();
+
+
+async function asyncFn() {
+ void \u0061wait;
+}
diff --git a/js/src/tests/test262/language/statements/async-function/await-as-identifier-reference.js b/js/src/tests/test262/language/statements/async-function/await-as-identifier-reference.js
new file mode 100644
index 0000000000..fe4155f679
--- /dev/null
+++ b/js/src/tests/test262/language/statements/async-function/await-as-identifier-reference.js
@@ -0,0 +1,31 @@
+// |reftest| error:SyntaxError
+// This file was procedurally generated from the following sources:
+// - src/async-functions/await-as-identifier-reference.case
+// - src/async-functions/syntax/async-declaration.template
+/*---
+description: await is a reserved keyword within generator function bodies and may not be used as an identifier reference. (Async function declaration)
+esid: prod-AsyncFunctionDeclaration
+features: [async-functions]
+flags: [generated]
+negative:
+ phase: parse
+ type: SyntaxError
+info: |
+ Async Function Definitions
+
+ AsyncFunctionDeclaration:
+ async [no LineTerminator here] function BindingIdentifier ( FormalParameters ) { AsyncFunctionBody }
+
+
+ IdentifierReference : Identifier
+
+ It is a Syntax Error if this production has a [Await] parameter and
+ StringValue of Identifier is "await".
+
+---*/
+$DONOTEVALUATE();
+
+
+async function asyncFn() {
+ void await;
+}
diff --git a/js/src/tests/test262/language/statements/async-function/await-as-label-identifier-escaped.js b/js/src/tests/test262/language/statements/async-function/await-as-label-identifier-escaped.js
new file mode 100644
index 0000000000..37bfe0f0fb
--- /dev/null
+++ b/js/src/tests/test262/language/statements/async-function/await-as-label-identifier-escaped.js
@@ -0,0 +1,31 @@
+// |reftest| error:SyntaxError
+// This file was procedurally generated from the following sources:
+// - src/async-functions/await-as-label-identifier-escaped.case
+// - src/async-functions/syntax/async-declaration.template
+/*---
+description: await is a reserved keyword within generator function bodies and may not be used as a label identifier. (Async function declaration)
+esid: prod-AsyncFunctionDeclaration
+features: [async-functions]
+flags: [generated]
+negative:
+ phase: parse
+ type: SyntaxError
+info: |
+ Async Function Definitions
+
+ AsyncFunctionDeclaration:
+ async [no LineTerminator here] function BindingIdentifier ( FormalParameters ) { AsyncFunctionBody }
+
+
+ LabelIdentifier : Identifier
+
+ It is a Syntax Error if this production has a [Await] parameter and
+ StringValue of Identifier is "await".
+
+---*/
+$DONOTEVALUATE();
+
+
+async function asyncFn() {
+ \u0061wait: ;
+}
diff --git a/js/src/tests/test262/language/statements/async-function/await-as-label-identifier.js b/js/src/tests/test262/language/statements/async-function/await-as-label-identifier.js
new file mode 100644
index 0000000000..050a0747e6
--- /dev/null
+++ b/js/src/tests/test262/language/statements/async-function/await-as-label-identifier.js
@@ -0,0 +1,31 @@
+// |reftest| error:SyntaxError
+// This file was procedurally generated from the following sources:
+// - src/async-functions/await-as-label-identifier.case
+// - src/async-functions/syntax/async-declaration.template
+/*---
+description: await is a reserved keyword within generator function bodies and may not be used as a label identifier. (Async function declaration)
+esid: prod-AsyncFunctionDeclaration
+features: [async-functions]
+flags: [generated]
+negative:
+ phase: parse
+ type: SyntaxError
+info: |
+ Async Function Definitions
+
+ AsyncFunctionDeclaration:
+ async [no LineTerminator here] function BindingIdentifier ( FormalParameters ) { AsyncFunctionBody }
+
+
+ LabelIdentifier : Identifier
+
+ It is a Syntax Error if this production has a [Await] parameter and
+ StringValue of Identifier is "await".
+
+---*/
+$DONOTEVALUATE();
+
+
+async function asyncFn() {
+ await: ;
+}
diff --git a/js/src/tests/test262/language/statements/async-function/browser.js b/js/src/tests/test262/language/statements/async-function/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/language/statements/async-function/browser.js
diff --git a/js/src/tests/test262/language/statements/async-function/cptn-decl.js b/js/src/tests/test262/language/statements/async-function/cptn-decl.js
new file mode 100644
index 0000000000..31cf99ab11
--- /dev/null
+++ b/js/src/tests/test262/language/statements/async-function/cptn-decl.js
@@ -0,0 +1,15 @@
+// Copyright (C) 2017 Apple Inc. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+esid: sec-async-function-definitions-runtime-semantics-evaluation
+description: Async function declaration completion value is empty.
+info: |
+ AsyncFunctionDeclaration : async [no LineTerminator here] function BindingIdentifier ( FormalParameters ) { AsyncFunctionBody }
+
+ 1. Return NormalCompletion(empty).
+---*/
+
+assert.sameValue(eval('async function f() {}'), undefined);
+assert.sameValue(eval('1; async function f() {}'), 1);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/async-function/declaration-returns-promise.js b/js/src/tests/test262/language/statements/async-function/declaration-returns-promise.js
new file mode 100644
index 0000000000..5cbd29e2a9
--- /dev/null
+++ b/js/src/tests/test262/language/statements/async-function/declaration-returns-promise.js
@@ -0,0 +1,15 @@
+// Copyright 2016 Microsoft, Inc. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+author: Brian Terlson <brian.terlson@microsoft.com>
+esid: pending
+description: >
+ Async functions return promises
+---*/
+
+async function foo() { };
+var p = foo();
+assert(p instanceof Promise, "async functions return promise instances");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/async-function/dflt-params-abrupt.js b/js/src/tests/test262/language/statements/async-function/dflt-params-abrupt.js
new file mode 100644
index 0000000000..fd2a6705ae
--- /dev/null
+++ b/js/src/tests/test262/language/statements/async-function/dflt-params-abrupt.js
@@ -0,0 +1,43 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/function-forms/dflt-params-abrupt.case
+// - src/function-forms/error/async-func-decl.template
+/*---
+description: Abrupt completion returned by evaluation of initializer (async function declaration)
+esid: sec-async-function-definitions
+features: [default-parameters, async-functions]
+flags: [generated, async]
+info: |
+ 14.6 Async Function Definitions
+
+ AsyncFunctionDeclaration :
+ async function BindingIdentifier ( FormalParameters ) { AsyncFunctionBody }
+
+
+ 14.1.19 Runtime Semantics: IteratorBindingInitialization
+
+ FormalsList : FormalsList , FormalParameter
+
+ 1. Let status be the result of performing IteratorBindingInitialization for
+ FormalsList using iteratorRecord and environment as the arguments.
+ 2. ReturnIfAbrupt(status).
+ 3. Return the result of performing IteratorBindingInitialization for
+ FormalParameter using iteratorRecord and environment as the arguments.
+
+---*/
+
+
+var callCount = 0;
+async function f(_ = (function() { throw new Test262Error(); }())) {
+
+ callCount = callCount + 1;
+}
+
+f()
+ .then(_ => {
+ throw new Test262Error('function should not be resolved');
+ }, error => assert.sameValue(error.constructor, Test262Error))
+ .then(() => {
+ assert.sameValue(callCount, 0, 'function body is not evaluated');
+ }, $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/async-function/dflt-params-arg-val-not-undefined.js b/js/src/tests/test262/language/statements/async-function/dflt-params-arg-val-not-undefined.js
new file mode 100644
index 0000000000..7636e6752a
--- /dev/null
+++ b/js/src/tests/test262/language/statements/async-function/dflt-params-arg-val-not-undefined.js
@@ -0,0 +1,63 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/function-forms/dflt-params-arg-val-not-undefined.case
+// - src/function-forms/default/async-func-decl.template
+/*---
+description: Use of initializer when argument value is not `undefined` (async function declaration)
+esid: sec-async-function-definitions
+features: [default-parameters, async-functions]
+flags: [generated, async]
+info: |
+ 14.6 Async Function Definitions
+
+ AsyncFunctionDeclaration :
+ async function BindingIdentifier ( FormalParameters ) { AsyncFunctionBody }
+
+
+ 14.1.19 Runtime Semantics: IteratorBindingInitialization
+
+ FormalsList : FormalsList , FormalParameter
+
+ [...]
+ 23. Let iteratorRecord be Record {[[Iterator]]:
+ CreateListIterator(argumentsList), [[Done]]: false}.
+ 24. If hasDuplicates is true, then
+ [...]
+ 25. Else,
+ a. Perform ? IteratorBindingInitialization for formals with
+ iteratorRecord and env as arguments.
+ [...]
+
+---*/
+var obj = {};
+var falseCount = 0;
+var stringCount = 0;
+var nanCount = 0;
+var zeroCount = 0;
+var nullCount = 0;
+var objCount = 0;
+
+
+var callCount = 0;
+
+// Stores a reference `ref` for case evaluation
+async function ref(aFalse = falseCount +=1, aString = stringCount += 1, aNaN = nanCount += 1, a0 = zeroCount += 1, aNull = nullCount += 1, aObj = objCount +=1) {
+ assert.sameValue(aFalse, false);
+ assert.sameValue(aString, '');
+ assert.sameValue(aNaN, NaN);
+ assert.sameValue(a0, 0);
+ assert.sameValue(aNull, null);
+ assert.sameValue(aObj, obj);
+ callCount = callCount + 1;
+}
+
+ref(false, '', NaN, 0, null, obj).then(() => {
+ assert.sameValue(callCount, 1, 'function invoked exactly once');
+}).then($DONE, $DONE);
+
+assert.sameValue(falseCount, 0, 'initializer not evaluated: false');
+assert.sameValue(stringCount, 0, 'initializer not evaluated: string');
+assert.sameValue(nanCount, 0, 'initializer not evaluated: NaN');
+assert.sameValue(zeroCount, 0, 'initializer not evaluated: 0');
+assert.sameValue(nullCount, 0, 'initializer not evaluated: null');
+assert.sameValue(objCount, 0, 'initializer not evaluated: object');
diff --git a/js/src/tests/test262/language/statements/async-function/dflt-params-arg-val-undefined.js b/js/src/tests/test262/language/statements/async-function/dflt-params-arg-val-undefined.js
new file mode 100644
index 0000000000..1e993209ea
--- /dev/null
+++ b/js/src/tests/test262/language/statements/async-function/dflt-params-arg-val-undefined.js
@@ -0,0 +1,46 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/function-forms/dflt-params-arg-val-undefined.case
+// - src/function-forms/default/async-func-decl.template
+/*---
+description: Use of initializer when argument value is `undefined` (async function declaration)
+esid: sec-async-function-definitions
+features: [default-parameters, async-functions]
+flags: [generated, async]
+info: |
+ 14.6 Async Function Definitions
+
+ AsyncFunctionDeclaration :
+ async function BindingIdentifier ( FormalParameters ) { AsyncFunctionBody }
+
+
+ 14.1.19 Runtime Semantics: IteratorBindingInitialization
+
+ FormalsList : FormalsList , FormalParameter
+
+ [...]
+ 23. Let iteratorRecord be Record {[[Iterator]]:
+ CreateListIterator(argumentsList), [[Done]]: false}.
+ 24. If hasDuplicates is true, then
+ [...]
+ 25. Else,
+ a. Perform ? IteratorBindingInitialization for formals with
+ iteratorRecord and env as arguments.
+ [...]
+
+---*/
+
+
+var callCount = 0;
+
+// Stores a reference `ref` for case evaluation
+async function ref(fromLiteral = 23, fromExpr = 45, fromHole = 99) {
+ assert.sameValue(fromLiteral, 23);
+ assert.sameValue(fromExpr, 45);
+ assert.sameValue(fromHole, 99);
+ callCount = callCount + 1;
+}
+
+ref(undefined, void 0).then(() => {
+ assert.sameValue(callCount, 1, 'function invoked exactly once');
+}).then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/async-function/dflt-params-duplicates.js b/js/src/tests/test262/language/statements/async-function/dflt-params-duplicates.js
new file mode 100644
index 0000000000..2ea2494afb
--- /dev/null
+++ b/js/src/tests/test262/language/statements/async-function/dflt-params-duplicates.js
@@ -0,0 +1,39 @@
+// |reftest| error:SyntaxError
+// This file was procedurally generated from the following sources:
+// - src/function-forms/dflt-params-duplicates.case
+// - src/function-forms/syntax/async-func-decl.template
+/*---
+description: It is a Syntax Error if BoundNames of FormalParameters contains any duplicate elements. (async function declaration)
+esid: sec-async-function-definitions
+features: [default-parameters, async-functions]
+flags: [generated]
+negative:
+ phase: parse
+ type: SyntaxError
+info: |
+ 14.6 Async Function Definitions
+
+ AsyncFunctionDeclaration :
+ async function BindingIdentifier ( FormalParameters ) { AsyncFunctionBody }
+
+
+ 14.1.2 Static Semantics: Early Errors
+
+ StrictFormalParameters : FormalParameters
+
+ - It is a Syntax Error if BoundNames of FormalParameters contains any
+ duplicate elements.
+
+ FormalParameters : FormalParameterList
+
+ - It is a Syntax Error if IsSimpleParameterList of FormalParameterList is
+ false and BoundNames of FormalParameterList contains any duplicate
+ elements.
+
+---*/
+$DONOTEVALUATE();
+
+
+async function f(x = 0, x) {
+
+}
diff --git a/js/src/tests/test262/language/statements/async-function/dflt-params-ref-later.js b/js/src/tests/test262/language/statements/async-function/dflt-params-ref-later.js
new file mode 100644
index 0000000000..5ae817357f
--- /dev/null
+++ b/js/src/tests/test262/language/statements/async-function/dflt-params-ref-later.js
@@ -0,0 +1,44 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/function-forms/dflt-params-ref-later.case
+// - src/function-forms/error/async-func-decl.template
+/*---
+description: Referencing a parameter that occurs later in the ParameterList (async function declaration)
+esid: sec-async-function-definitions
+features: [default-parameters, async-functions]
+flags: [generated, async]
+info: |
+ 14.6 Async Function Definitions
+
+ AsyncFunctionDeclaration :
+ async function BindingIdentifier ( FormalParameters ) { AsyncFunctionBody }
+
+
+ 14.1.19 Runtime Semantics: IteratorBindingInitialization
+
+ FormalsList : FormalsList , FormalParameter
+
+ 1. Let status be the result of performing IteratorBindingInitialization for
+ FormalsList using iteratorRecord and environment as the arguments.
+ 2. ReturnIfAbrupt(status).
+ 3. Return the result of performing IteratorBindingInitialization for
+ FormalParameter using iteratorRecord and environment as the arguments.
+
+---*/
+var x = 0;
+
+
+var callCount = 0;
+async function f(x = y, y) {
+
+ callCount = callCount + 1;
+}
+
+f()
+ .then(_ => {
+ throw new Test262Error('function should not be resolved');
+ }, error => assert.sameValue(error.constructor, ReferenceError))
+ .then(() => {
+ assert.sameValue(callCount, 0, 'function body is not evaluated');
+ }, $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/async-function/dflt-params-ref-prior.js b/js/src/tests/test262/language/statements/async-function/dflt-params-ref-prior.js
new file mode 100644
index 0000000000..2e4a12da71
--- /dev/null
+++ b/js/src/tests/test262/language/statements/async-function/dflt-params-ref-prior.js
@@ -0,0 +1,43 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/function-forms/dflt-params-ref-prior.case
+// - src/function-forms/default/async-func-decl.template
+/*---
+description: Referencing a parameter that occurs earlier in the ParameterList (async function declaration)
+esid: sec-async-function-definitions
+features: [default-parameters, async-functions]
+flags: [generated, async]
+info: |
+ 14.6 Async Function Definitions
+
+ AsyncFunctionDeclaration :
+ async function BindingIdentifier ( FormalParameters ) { AsyncFunctionBody }
+
+
+ 14.1.19 Runtime Semantics: IteratorBindingInitialization
+
+ FormalsList : FormalsList , FormalParameter
+
+ 1. Let status be the result of performing IteratorBindingInitialization for
+ FormalsList using iteratorRecord and environment as the arguments.
+ 2. ReturnIfAbrupt(status).
+ 3. Return the result of performing IteratorBindingInitialization for
+ FormalParameter using iteratorRecord and environment as the arguments.
+
+---*/
+var x = 0;
+
+
+var callCount = 0;
+
+// Stores a reference `ref` for case evaluation
+async function ref(x, y = x, z = y) {
+ assert.sameValue(x, 3, 'first argument value');
+ assert.sameValue(y, 3, 'second argument value');
+ assert.sameValue(z, 3, 'third argument value');
+ callCount = callCount + 1;
+}
+
+ref(3).then(() => {
+ assert.sameValue(callCount, 1, 'function invoked exactly once');
+}).then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/async-function/dflt-params-ref-self.js b/js/src/tests/test262/language/statements/async-function/dflt-params-ref-self.js
new file mode 100644
index 0000000000..37786435e7
--- /dev/null
+++ b/js/src/tests/test262/language/statements/async-function/dflt-params-ref-self.js
@@ -0,0 +1,44 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/function-forms/dflt-params-ref-self.case
+// - src/function-forms/error/async-func-decl.template
+/*---
+description: Referencing a parameter from within its own initializer (async function declaration)
+esid: sec-async-function-definitions
+features: [default-parameters, async-functions]
+flags: [generated, async]
+info: |
+ 14.6 Async Function Definitions
+
+ AsyncFunctionDeclaration :
+ async function BindingIdentifier ( FormalParameters ) { AsyncFunctionBody }
+
+
+ 14.1.19 Runtime Semantics: IteratorBindingInitialization
+
+ FormalsList : FormalsList , FormalParameter
+
+ 1. Let status be the result of performing IteratorBindingInitialization for
+ FormalsList using iteratorRecord and environment as the arguments.
+ 2. ReturnIfAbrupt(status).
+ 3. Return the result of performing IteratorBindingInitialization for
+ FormalParameter using iteratorRecord and environment as the arguments.
+
+---*/
+var x = 0;
+
+
+var callCount = 0;
+async function f(x = x) {
+
+ callCount = callCount + 1;
+}
+
+f()
+ .then(_ => {
+ throw new Test262Error('function should not be resolved');
+ }, error => assert.sameValue(error.constructor, ReferenceError))
+ .then(() => {
+ assert.sameValue(callCount, 0, 'function body is not evaluated');
+ }, $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/async-function/dflt-params-rest.js b/js/src/tests/test262/language/statements/async-function/dflt-params-rest.js
new file mode 100644
index 0000000000..5e8a1926b4
--- /dev/null
+++ b/js/src/tests/test262/language/statements/async-function/dflt-params-rest.js
@@ -0,0 +1,43 @@
+// |reftest| error:SyntaxError
+// This file was procedurally generated from the following sources:
+// - src/function-forms/dflt-params-rest.case
+// - src/function-forms/syntax/async-func-decl.template
+/*---
+description: RestParameter does not support an initializer (async function declaration)
+esid: sec-async-function-definitions
+features: [default-parameters, async-functions]
+flags: [generated]
+negative:
+ phase: parse
+ type: SyntaxError
+info: |
+ 14.6 Async Function Definitions
+
+ AsyncFunctionDeclaration :
+ async function BindingIdentifier ( FormalParameters ) { AsyncFunctionBody }
+
+
+ 14.1 Function Definitions
+
+ Syntax
+
+ FunctionRestParameter[Yield] :
+
+ BindingRestElement[?Yield]
+
+ 13.3.3 Destructuring Binding Patterns
+
+ Syntax
+
+ BindingRestElement[Yield] :
+
+ ...BindingIdentifier[?Yield]
+ ...BindingPattern[?Yield]
+
+---*/
+$DONOTEVALUATE();
+
+
+async function f(...x = []) {
+
+}
diff --git a/js/src/tests/test262/language/statements/async-function/dflt-params-trailing-comma.js b/js/src/tests/test262/language/statements/async-function/dflt-params-trailing-comma.js
new file mode 100644
index 0000000000..2a8141f351
--- /dev/null
+++ b/js/src/tests/test262/language/statements/async-function/dflt-params-trailing-comma.js
@@ -0,0 +1,38 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/function-forms/dflt-params-trailing-comma.case
+// - src/function-forms/default/async-func-decl.template
+/*---
+description: A trailing comma should not increase the respective length, using default parameters (async function declaration)
+esid: sec-async-function-definitions
+features: [async-functions]
+flags: [generated, async]
+info: |
+ 14.6 Async Function Definitions
+
+ AsyncFunctionDeclaration :
+ async function BindingIdentifier ( FormalParameters ) { AsyncFunctionBody }
+
+
+ Trailing comma in the parameters list
+
+ 14.1 Function Definitions
+
+ FormalParameters[Yield, Await] : FormalParameterList[?Yield, ?Await] ,
+---*/
+
+
+var callCount = 0;
+
+// Stores a reference `ref` for case evaluation
+async function ref(a, b = 39,) {
+ assert.sameValue(a, 42);
+ assert.sameValue(b, 39);
+ callCount = callCount + 1;
+}
+
+ref(42, undefined, 1).then(() => {
+ assert.sameValue(callCount, 1, 'function invoked exactly once');
+}).then($DONE, $DONE);
+
+assert.sameValue(ref.length, 1, 'length is properly set');
diff --git a/js/src/tests/test262/language/statements/async-function/early-errors-declaration-NSPL-with-USD.js b/js/src/tests/test262/language/statements/async-function/early-errors-declaration-NSPL-with-USD.js
new file mode 100644
index 0000000000..324d132e16
--- /dev/null
+++ b/js/src/tests/test262/language/statements/async-function/early-errors-declaration-NSPL-with-USD.js
@@ -0,0 +1,17 @@
+// |reftest| error:SyntaxError
+// Copyright 2016 Microsoft, Inc. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+author: Brian Terlson <brian.terlson@microsoft.com>
+esid: pending
+description: >
+ It is a Syntax Error if ContainsUseStrict of AsyncConciseBody is *true* and IsSimpleParameterList of ArrowParameters is *false*.
+negative:
+ phase: parse
+ type: SyntaxError
+---*/
+
+$DONOTEVALUATE();
+
+async function foo(x = 1){"use strict"}
diff --git a/js/src/tests/test262/language/statements/async-function/early-errors-declaration-arguments-in-formal-parameters-strict.js b/js/src/tests/test262/language/statements/async-function/early-errors-declaration-arguments-in-formal-parameters-strict.js
new file mode 100644
index 0000000000..58c95919b1
--- /dev/null
+++ b/js/src/tests/test262/language/statements/async-function/early-errors-declaration-arguments-in-formal-parameters-strict.js
@@ -0,0 +1,19 @@
+// |reftest| error:SyntaxError
+'use strict';
+// Copyright 2016 Microsoft, Inc. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+author: Brian Terlson <brian.terlson@microsoft.com>
+esid: pending
+description: It is a SyntaxError if FormalParameters contains arguments in strict mode
+negative:
+ phase: parse
+ type: SyntaxError
+flags: [onlyStrict]
+---*/
+
+$DONOTEVALUATE();
+
+async function foo (arguments) { }
+
diff --git a/js/src/tests/test262/language/statements/async-function/early-errors-declaration-await-in-formals-default.js b/js/src/tests/test262/language/statements/async-function/early-errors-declaration-await-in-formals-default.js
new file mode 100644
index 0000000000..927d1d111f
--- /dev/null
+++ b/js/src/tests/test262/language/statements/async-function/early-errors-declaration-await-in-formals-default.js
@@ -0,0 +1,15 @@
+// |reftest| error:SyntaxError
+// Copyright 2016 Microsoft, Inc. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+author: Brian Terlson <brian.terlson@microsoft.com>
+esid: pending
+description: It is a SyntaxError if FormalParameters' default expressions contains await
+negative:
+ phase: parse
+ type: SyntaxError
+---*/
+
+$DONOTEVALUATE();
+async function foo (x = await) { }
diff --git a/js/src/tests/test262/language/statements/async-function/early-errors-declaration-await-in-formals.js b/js/src/tests/test262/language/statements/async-function/early-errors-declaration-await-in-formals.js
new file mode 100644
index 0000000000..ac072a3ae3
--- /dev/null
+++ b/js/src/tests/test262/language/statements/async-function/early-errors-declaration-await-in-formals.js
@@ -0,0 +1,15 @@
+// |reftest| error:SyntaxError
+// Copyright 2016 Microsoft, Inc. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+author: Brian Terlson <brian.terlson@microsoft.com>
+esid: pending
+description: It is a SyntaxError if FormalParameters contains await
+negative:
+ phase: parse
+ type: SyntaxError
+---*/
+
+$DONOTEVALUATE();
+async function foo (await) { }
diff --git a/js/src/tests/test262/language/statements/async-function/early-errors-declaration-binding-identifier-arguments-strict.js b/js/src/tests/test262/language/statements/async-function/early-errors-declaration-binding-identifier-arguments-strict.js
new file mode 100644
index 0000000000..00728103fb
--- /dev/null
+++ b/js/src/tests/test262/language/statements/async-function/early-errors-declaration-binding-identifier-arguments-strict.js
@@ -0,0 +1,19 @@
+// |reftest| error:SyntaxError
+'use strict';
+// Copyright 2016 Microsoft, Inc. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+author: Brian Terlson <brian.terlson@microsoft.com>
+esid: pending
+description: >
+ If the source code matching this production is strict code, it is a Syntax Error if BindingIdentifier is the IdentifierName arguments.
+negative:
+ phase: parse
+ type: SyntaxError
+flags: [onlyStrict]
+---*/
+
+$DONOTEVALUATE();
+async function arguments () { }
+
diff --git a/js/src/tests/test262/language/statements/async-function/early-errors-declaration-binding-identifier-eval-strict.js b/js/src/tests/test262/language/statements/async-function/early-errors-declaration-binding-identifier-eval-strict.js
new file mode 100644
index 0000000000..247169a87d
--- /dev/null
+++ b/js/src/tests/test262/language/statements/async-function/early-errors-declaration-binding-identifier-eval-strict.js
@@ -0,0 +1,18 @@
+// |reftest| error:SyntaxError
+'use strict';
+// Copyright 2016 Microsoft, Inc. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+author: Brian Terlson <brian.terlson@microsoft.com>
+esid: pending
+description: >
+ If the source code matching this production is strict code, it is a Syntax Error if BindingIdentifier is the IdentifierName eval.
+negative:
+ phase: parse
+ type: SyntaxError
+flags: [onlyStrict]
+---*/
+
+$DONOTEVALUATE();
+async function eval () { }
diff --git a/js/src/tests/test262/language/statements/async-function/early-errors-declaration-body-contains-super-call.js b/js/src/tests/test262/language/statements/async-function/early-errors-declaration-body-contains-super-call.js
new file mode 100644
index 0000000000..ed401145f4
--- /dev/null
+++ b/js/src/tests/test262/language/statements/async-function/early-errors-declaration-body-contains-super-call.js
@@ -0,0 +1,16 @@
+// |reftest| error:SyntaxError
+// Copyright 2016 Microsoft, Inc. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+author: Brian Terlson <brian.terlson@microsoft.com>
+esid: pending
+description: It is a syntax error if AsyncFunctionBody contains SuperCall is true
+negative:
+ phase: parse
+ type: SyntaxError
+---*/
+
+$DONOTEVALUATE();
+
+async function foo (foo) { super() };
diff --git a/js/src/tests/test262/language/statements/async-function/early-errors-declaration-body-contains-super-property.js b/js/src/tests/test262/language/statements/async-function/early-errors-declaration-body-contains-super-property.js
new file mode 100644
index 0000000000..0c451621e7
--- /dev/null
+++ b/js/src/tests/test262/language/statements/async-function/early-errors-declaration-body-contains-super-property.js
@@ -0,0 +1,16 @@
+// |reftest| error:SyntaxError
+// Copyright 2016 Microsoft, Inc. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+author: Brian Terlson <brian.terlson@microsoft.com>
+esid: pending
+description: It is a syntax error if AsyncFunctionBody contains SuperProperty is true
+negative:
+ phase: parse
+ type: SyntaxError
+---*/
+
+$DONOTEVALUATE();
+
+async function foo (foo) { super.prop };
diff --git a/js/src/tests/test262/language/statements/async-function/early-errors-declaration-duplicate-parameters-strict.js b/js/src/tests/test262/language/statements/async-function/early-errors-declaration-duplicate-parameters-strict.js
new file mode 100644
index 0000000000..afec6627ec
--- /dev/null
+++ b/js/src/tests/test262/language/statements/async-function/early-errors-declaration-duplicate-parameters-strict.js
@@ -0,0 +1,19 @@
+// |reftest| error:SyntaxError
+'use strict';
+// Copyright 2016 Microsoft, Inc. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+author: Brian Terlson <brian.terlson@microsoft.com>
+esid: pending
+description: >
+ If strict mode, early error rules for StrictFormalParameters are applied
+negative:
+ phase: parse
+ type: SyntaxError
+flags: [onlyStrict]
+---*/
+
+$DONOTEVALUATE();
+
+async function foo(a, a) { }
diff --git a/js/src/tests/test262/language/statements/async-function/early-errors-declaration-eval-in-formal-parameters-strict.js b/js/src/tests/test262/language/statements/async-function/early-errors-declaration-eval-in-formal-parameters-strict.js
new file mode 100644
index 0000000000..46463fdcbe
--- /dev/null
+++ b/js/src/tests/test262/language/statements/async-function/early-errors-declaration-eval-in-formal-parameters-strict.js
@@ -0,0 +1,18 @@
+// |reftest| error:SyntaxError
+'use strict';
+// Copyright 2016 Microsoft, Inc. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+author: Brian Terlson <brian.terlson@microsoft.com>
+esid: pending
+description: It is a SyntaxError if FormalParameters contains eval in strict mode
+negative:
+ phase: parse
+ type: SyntaxError
+flags: [onlyStrict]
+---*/
+
+$DONOTEVALUATE();
+
+async function foo (eval) { }
diff --git a/js/src/tests/test262/language/statements/async-function/early-errors-declaration-formals-body-duplicate.js b/js/src/tests/test262/language/statements/async-function/early-errors-declaration-formals-body-duplicate.js
new file mode 100644
index 0000000000..b1eac325e4
--- /dev/null
+++ b/js/src/tests/test262/language/statements/async-function/early-errors-declaration-formals-body-duplicate.js
@@ -0,0 +1,16 @@
+// |reftest| error:SyntaxError
+// Copyright 2016 Microsoft, Inc. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+author: Brian Terlson <brian.terlson@microsoft.com>
+esid: pending
+description: It is a SyntaxError if BoundNames of FormalParameters also occurs in the LexicallyDeclaredNames of AsyncFunctionBody
+negative:
+ phase: parse
+ type: SyntaxError
+---*/
+
+$DONOTEVALUATE();
+
+async function foo (bar) { let bar; }
diff --git a/js/src/tests/test262/language/statements/async-function/early-errors-declaration-formals-contains-super-call.js b/js/src/tests/test262/language/statements/async-function/early-errors-declaration-formals-contains-super-call.js
new file mode 100644
index 0000000000..c1932d8ed9
--- /dev/null
+++ b/js/src/tests/test262/language/statements/async-function/early-errors-declaration-formals-contains-super-call.js
@@ -0,0 +1,16 @@
+// |reftest| error:SyntaxError
+// Copyright 2016 Microsoft, Inc. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+author: Brian Terlson <brian.terlson@microsoft.com>
+esid: pending
+description: It is a syntax error if FormalParameters contains SuperCall is true
+negative:
+ phase: parse
+ type: SyntaxError
+---*/
+
+$DONOTEVALUATE();
+
+async function foo (foo = super()) { let bar; }
diff --git a/js/src/tests/test262/language/statements/async-function/early-errors-declaration-formals-contains-super-property.js b/js/src/tests/test262/language/statements/async-function/early-errors-declaration-formals-contains-super-property.js
new file mode 100644
index 0000000000..5e7e301b79
--- /dev/null
+++ b/js/src/tests/test262/language/statements/async-function/early-errors-declaration-formals-contains-super-property.js
@@ -0,0 +1,16 @@
+// |reftest| error:SyntaxError
+// Copyright 2016 Microsoft, Inc. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+author: Brian Terlson <brian.terlson@microsoft.com>
+esid: pending
+description: It is a syntax error if FormalParameters contains SuperCall is true
+negative:
+ phase: parse
+ type: SyntaxError
+---*/
+
+$DONOTEVALUATE();
+
+async function foo (foo = super.foo) { let bar; }
diff --git a/js/src/tests/test262/language/statements/async-function/escaped-async.js b/js/src/tests/test262/language/statements/async-function/escaped-async.js
new file mode 100644
index 0000000000..2a0502aff1
--- /dev/null
+++ b/js/src/tests/test262/language/statements/async-function/escaped-async.js
@@ -0,0 +1,25 @@
+// |reftest| error:SyntaxError
+// Copyright (C) 2017 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-grammar-notation
+description: >
+ The `async` contextual keyword must not contain Unicode escape sequences.
+info: |
+ Terminal symbols are shown
+ in fixed width font, both in the productions of the grammars and throughout this
+ specification whenever the text directly refers to such a terminal symbol. These
+ are to appear in a script exactly as written. All terminal symbol code points
+ specified in this way are to be understood as the appropriate Unicode code points
+ from the Basic Latin range, as opposed to any similar-looking code points from
+ other Unicode ranges.
+negative:
+ phase: parse
+ type: SyntaxError
+features: [async-functions]
+---*/
+
+$DONOTEVALUATE();
+
+\u0061sync function f(){}
diff --git a/js/src/tests/test262/language/statements/async-function/eval-var-scope-syntax-err.js b/js/src/tests/test262/language/statements/async-function/eval-var-scope-syntax-err.js
new file mode 100644
index 0000000000..5e797937a7
--- /dev/null
+++ b/js/src/tests/test262/language/statements/async-function/eval-var-scope-syntax-err.js
@@ -0,0 +1,39 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/function-forms/eval-var-scope-syntax-err.case
+// - src/function-forms/error-no-strict/async-func-decl.template
+/*---
+description: sloppy direct eval in params introduces var (async function declaration in sloppy code)
+esid: sec-async-function-definitions
+features: [default-parameters, async-functions]
+flags: [generated, async, noStrict]
+info: |
+ 14.6 Async Function Definitions
+
+ AsyncFunctionDeclaration :
+ async function BindingIdentifier ( FormalParameters ) { AsyncFunctionBody }
+
+
+
+ Runtime Semantics: IteratorBindingInitialization
+ FormalParameter : BindingElement
+
+ 1. Return the result of performing IteratorBindingInitialization for BindingElement with arguments iteratorRecord and environment.
+
+---*/
+
+
+var callCount = 0;
+async function f(a = eval("var a = 42")) {
+
+ callCount = callCount + 1;
+}
+
+f()
+ .then(_ => {
+ throw new Test262Error('function should not be resolved');
+ }, error => assert.sameValue(error.constructor, SyntaxError))
+ .then(() => {
+ assert.sameValue(callCount, 0, 'function body is not evaluated');
+ }, $DONE)
+ .then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/async-function/evaluation-body-that-returns-after-await.js b/js/src/tests/test262/language/statements/async-function/evaluation-body-that-returns-after-await.js
new file mode 100644
index 0000000000..f89a24d7a8
--- /dev/null
+++ b/js/src/tests/test262/language/statements/async-function/evaluation-body-that-returns-after-await.js
@@ -0,0 +1,22 @@
+// |reftest| async
+// Copyright 2016 Microsoft, Inc. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+author: Brian Terlson <brian.terlson@microsoft.com>
+esid: pending
+description: >
+ The return value of the async function resolves the promise
+flags: [async]
+---*/
+
+async function foo() {
+ await Promise.resolve();
+ return 42;
+}
+
+foo().then(function (v) {
+ assert.sameValue(v, 42);
+ $DONE();
+}, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/async-function/evaluation-body-that-returns.js b/js/src/tests/test262/language/statements/async-function/evaluation-body-that-returns.js
new file mode 100644
index 0000000000..6d57a3b973
--- /dev/null
+++ b/js/src/tests/test262/language/statements/async-function/evaluation-body-that-returns.js
@@ -0,0 +1,20 @@
+// |reftest| async
+// Copyright 2016 Microsoft, Inc. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+author: Brian Terlson <brian.terlson@microsoft.com>
+esid: pending
+description: >
+ The return value of the async function resolves the promise
+flags: [async]
+---*/
+
+async function foo() {
+ return 42;
+}
+
+foo().then(function (v) {
+ assert.sameValue(v, 42);
+ $DONE();
+}, $DONE);
diff --git a/js/src/tests/test262/language/statements/async-function/evaluation-body-that-throws-after-await.js b/js/src/tests/test262/language/statements/async-function/evaluation-body-that-throws-after-await.js
new file mode 100644
index 0000000000..c2a0e758bf
--- /dev/null
+++ b/js/src/tests/test262/language/statements/async-function/evaluation-body-that-throws-after-await.js
@@ -0,0 +1,25 @@
+// |reftest| async
+// Copyright 2016 Microsoft, Inc. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+author: Brian Terlson <brian.terlson@microsoft.com>
+esid: pending
+description: >
+ Errors thrown from the async function body reject the returned promise
+flags: [async]
+---*/
+
+async function foo() {
+ await Promise.resolve();
+ throw 1;
+}
+
+foo().then(function () {
+ $DONE("Should not be called");
+}, function (e) {
+ assert.sameValue(e, 1);
+ $DONE();
+});
+
+
diff --git a/js/src/tests/test262/language/statements/async-function/evaluation-body-that-throws.js b/js/src/tests/test262/language/statements/async-function/evaluation-body-that-throws.js
new file mode 100644
index 0000000000..3bde4aedff
--- /dev/null
+++ b/js/src/tests/test262/language/statements/async-function/evaluation-body-that-throws.js
@@ -0,0 +1,23 @@
+// |reftest| async
+// Copyright 2016 Microsoft, Inc. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+author: Brian Terlson <brian.terlson@microsoft.com>
+esid: pending
+description: >
+ Errors thrown from the async function body reject the returned promise
+flags: [async]
+---*/
+
+async function foo() {
+ throw 1;
+}
+
+foo().then(function () {
+ $DONE("Should not be called");
+}, function (e) {
+ assert.sameValue(e, 1);
+ $DONE();
+});
+
diff --git a/js/src/tests/test262/language/statements/async-function/evaluation-body.js b/js/src/tests/test262/language/statements/async-function/evaluation-body.js
new file mode 100644
index 0000000000..80935ed9b6
--- /dev/null
+++ b/js/src/tests/test262/language/statements/async-function/evaluation-body.js
@@ -0,0 +1,20 @@
+// copyright 2016 microsoft, inc. all rights reserved.
+// this code is governed by the bsd license found in the license file.
+
+/*---
+author: brian terlson <brian.terlson@microsoft.com>
+esid: pending
+description: >
+ async function bodies are executed immediately (unlike generators)
+---*/
+
+let called;
+async function foo() {
+ called = true;
+ await new Promise();
+}
+
+foo();
+assert(called);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/async-function/evaluation-default-that-throws.js b/js/src/tests/test262/language/statements/async-function/evaluation-default-that-throws.js
new file mode 100644
index 0000000000..6e7afb4cce
--- /dev/null
+++ b/js/src/tests/test262/language/statements/async-function/evaluation-default-that-throws.js
@@ -0,0 +1,21 @@
+// |reftest| async
+// Copyright 2016 Microsoft, Inc. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+author: Brian Terlson <brian.terlson@microsoft.com>
+esid: pending
+description: >
+ If a default expression throws, the promise is rejected.
+info: |
+ This is different from generators which will throw the error out of the generator
+ when it is called.
+flags: [async]
+---*/
+var y = null;
+async function foo(x = y()) {}
+foo().then(function () {
+ $DONE('promise should be rejected');
+}, function () {
+ $DONE();
+});
diff --git a/js/src/tests/test262/language/statements/async-function/evaluation-mapped-arguments.js b/js/src/tests/test262/language/statements/async-function/evaluation-mapped-arguments.js
new file mode 100644
index 0000000000..62f9ba958e
--- /dev/null
+++ b/js/src/tests/test262/language/statements/async-function/evaluation-mapped-arguments.js
@@ -0,0 +1,23 @@
+// |reftest| async
+// Copyright 2016 Microsoft, Inc. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+author: Brian Terlson <brian.terlson@microsoft.com>
+esid: pending
+description: >
+ Mapped arguments object is used when the async function has a
+ simple parameter list.
+flags: [noStrict, async]
+---*/
+
+
+async function foo(a) {
+ arguments[0] = 2;
+ assert.sameValue(a, 2);
+
+ a = 3;
+ assert.sameValue(arguments[0], 3);
+}
+
+foo(1).then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/async-function/evaluation-this-value-global.js b/js/src/tests/test262/language/statements/async-function/evaluation-this-value-global.js
new file mode 100644
index 0000000000..75f9f331b8
--- /dev/null
+++ b/js/src/tests/test262/language/statements/async-function/evaluation-this-value-global.js
@@ -0,0 +1,19 @@
+// |reftest| async
+// Copyright 2016 Microsoft, Inc. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+author: Brian Terlson <brian.terlson@microsoft.com>
+esid: pending
+description: >
+ The this value is set to the global object when not passed in sloppy mode.
+flags: [noStrict, async]
+includes: [asyncHelpers.js]
+---*/
+
+var glob = this;
+async function foo() {
+ assert.sameValue(this, glob);
+}
+
+asyncTest(foo);
diff --git a/js/src/tests/test262/language/statements/async-function/evaluation-this-value-passed.js b/js/src/tests/test262/language/statements/async-function/evaluation-this-value-passed.js
new file mode 100644
index 0000000000..ac6bb9f99f
--- /dev/null
+++ b/js/src/tests/test262/language/statements/async-function/evaluation-this-value-passed.js
@@ -0,0 +1,19 @@
+// |reftest| async
+// Copyright 2016 Microsoft, Inc. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+author: Brian Terlson <brian.terlson@microsoft.com>
+esid: pending
+description: >
+ The this value from the caller is present in the async function body
+flags: [async]
+---*/
+
+
+async function foo(a) {
+ assert.sameValue(this, a)
+}
+var obj = {};
+foo.call(obj, obj).then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/async-function/evaluation-unmapped-arguments.js b/js/src/tests/test262/language/statements/async-function/evaluation-unmapped-arguments.js
new file mode 100644
index 0000000000..1f94e09bb8
--- /dev/null
+++ b/js/src/tests/test262/language/statements/async-function/evaluation-unmapped-arguments.js
@@ -0,0 +1,24 @@
+// |reftest| async
+// Copyright 2016 Microsoft, Inc. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+author: Brian Terlson <brian.terlson@microsoft.com>
+esid: pending
+description: >
+ Unmapped arguments object is used when the async function doesn't have a
+ simple parameter list.
+flags: [async]
+---*/
+
+
+async function foo(a = 42) {
+ arguments[0] = 2;
+ assert.sameValue(a, 1);
+
+ a = 3;
+ assert.sameValue(arguments[0], 2);
+}
+
+foo(1).then($DONE, $DONE);
+
diff --git a/js/src/tests/test262/language/statements/async-function/forbidden-ext/b1/async-func-decl-forbidden-ext-direct-access-prop-arguments.js b/js/src/tests/test262/language/statements/async-function/forbidden-ext/b1/async-func-decl-forbidden-ext-direct-access-prop-arguments.js
new file mode 100644
index 0000000000..93513936b1
--- /dev/null
+++ b/js/src/tests/test262/language/statements/async-function/forbidden-ext/b1/async-func-decl-forbidden-ext-direct-access-prop-arguments.js
@@ -0,0 +1,38 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/function-forms/forbidden-ext-direct-access-prop-arguments.case
+// - src/function-forms/forbidden-extensions/bullet-one/async-func-decl.template
+/*---
+description: Forbidden extension, f.arguments (async function declaration)
+esid: sec-async-function-definitions
+features: [arrow-function, async-functions]
+flags: [generated, noStrict, async]
+info: |
+ AsyncFunctionDeclaration :
+ async function BindingIdentifier ( FormalParameters ) { AsyncFunctionBody }
+
+
+ ECMAScript function objects defined using syntactic constructors in strict mode code must
+ not be created with own properties named "caller" or "arguments". Such own properties also
+ must not be created for function objects defined using an ArrowFunction, MethodDefinition,
+ GeneratorDeclaration, GeneratorExpression, AsyncGeneratorDeclaration, AsyncGeneratorExpression,
+ ClassDeclaration, ClassExpression, AsyncFunctionDeclaration, AsyncFunctionExpression, or
+ AsyncArrowFunction regardless of whether the definition is contained in strict mode code.
+ Built-in functions, strict functions created using the Function constructor, generator functions
+ created using the Generator constructor, async functions created using the AsyncFunction
+ constructor, and functions created using the bind method also must not be created with such own
+ properties.
+
+---*/
+
+
+var callCount = 0;
+async function f() {
+ assert.sameValue(f.hasOwnProperty("arguments"), false);
+ callCount++;
+}
+
+f()
+ .then(() => {
+ assert.sameValue(callCount, 1, 'function body evaluated');
+ }, $DONE).then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/async-function/forbidden-ext/b1/async-func-decl-forbidden-ext-direct-access-prop-caller.js b/js/src/tests/test262/language/statements/async-function/forbidden-ext/b1/async-func-decl-forbidden-ext-direct-access-prop-caller.js
new file mode 100644
index 0000000000..3afd748784
--- /dev/null
+++ b/js/src/tests/test262/language/statements/async-function/forbidden-ext/b1/async-func-decl-forbidden-ext-direct-access-prop-caller.js
@@ -0,0 +1,38 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/function-forms/forbidden-ext-direct-access-prop-caller.case
+// - src/function-forms/forbidden-extensions/bullet-one/async-func-decl.template
+/*---
+description: Forbidden extension, o.caller (async function declaration)
+esid: sec-async-function-definitions
+features: [arrow-function, async-functions]
+flags: [generated, noStrict, async]
+info: |
+ AsyncFunctionDeclaration :
+ async function BindingIdentifier ( FormalParameters ) { AsyncFunctionBody }
+
+
+ ECMAScript function objects defined using syntactic constructors in strict mode code must
+ not be created with own properties named "caller" or "arguments". Such own properties also
+ must not be created for function objects defined using an ArrowFunction, MethodDefinition,
+ GeneratorDeclaration, GeneratorExpression, AsyncGeneratorDeclaration, AsyncGeneratorExpression,
+ ClassDeclaration, ClassExpression, AsyncFunctionDeclaration, AsyncFunctionExpression, or
+ AsyncArrowFunction regardless of whether the definition is contained in strict mode code.
+ Built-in functions, strict functions created using the Function constructor, generator functions
+ created using the Generator constructor, async functions created using the AsyncFunction
+ constructor, and functions created using the bind method also must not be created with such own
+ properties.
+
+---*/
+
+
+var callCount = 0;
+async function f() {
+ assert.sameValue(f.hasOwnProperty("caller"), false);
+ callCount++;
+}
+
+f()
+ .then(() => {
+ assert.sameValue(callCount, 1, 'function body evaluated');
+ }, $DONE).then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/async-function/forbidden-ext/b1/browser.js b/js/src/tests/test262/language/statements/async-function/forbidden-ext/b1/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/language/statements/async-function/forbidden-ext/b1/browser.js
diff --git a/js/src/tests/test262/language/statements/async-function/forbidden-ext/b1/shell.js b/js/src/tests/test262/language/statements/async-function/forbidden-ext/b1/shell.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/language/statements/async-function/forbidden-ext/b1/shell.js
diff --git a/js/src/tests/test262/language/statements/async-function/forbidden-ext/b2/async-func-decl-forbidden-ext-indirect-access-own-prop-caller-get.js b/js/src/tests/test262/language/statements/async-function/forbidden-ext/b2/async-func-decl-forbidden-ext-indirect-access-own-prop-caller-get.js
new file mode 100644
index 0000000000..01aa1a889f
--- /dev/null
+++ b/js/src/tests/test262/language/statements/async-function/forbidden-ext/b2/async-func-decl-forbidden-ext-indirect-access-own-prop-caller-get.js
@@ -0,0 +1,64 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/function-forms/forbidden-ext-indirect-access-own-prop-caller-get.case
+// - src/function-forms/forbidden-extensions/bullet-two/async-func-decl.template
+/*---
+description: Forbidden extension, o.caller (async function declaration)
+esid: sec-async-definitions
+features: [arrow-function, async-functions]
+flags: [generated, noStrict, async]
+info: |
+ AsyncFunctionDeclaration :
+ async function BindingIdentifier ( FormalParameters ) { AsyncFunctionBody }
+
+
+ If an implementation extends any function object with an own property named "caller" the value of
+ that property, as observed using [[Get]] or [[GetOwnProperty]], must not be a strict function
+ object. If it is an accessor property, the function that is the value of the property's [[Get]]
+ attribute must never return a strict function when called.
+
+---*/
+var CALLER_OWN_PROPERTY_DOES_NOT_EXIST = Symbol();
+function inner() {
+ // This property may exist, but is forbidden from having a value that is a strict function object
+ return inner.hasOwnProperty("caller")
+ ? inner.caller
+ : CALLER_OWN_PROPERTY_DOES_NOT_EXIST;
+}
+
+
+var callCount = 0;
+async function f() {
+ "use strict";
+ // This and the following conditional value is set in the test's .case file.
+ // For every test that has a "true" value here, there is a
+ // corresponding test that has a "false" value here.
+ // They are generated from two different case files, which use
+ // the same templates.
+ let descriptor = Object.getOwnPropertyDescriptor(inner, "caller");
+ if (descriptor && descriptor.configurable && true) {
+ Object.defineProperty(inner, "caller", {get(){return 1}});
+ }
+ var result = inner();
+ if (descriptor && descriptor.configurable && true) {
+ assert.sameValue(result, 1, 'If this test defined an own "caller" property on the inner function, then it should be accessible and should return the value it was set to.');
+ }
+ // "CALLER_OWN_PROPERTY_DOES_NOT_EXIST" is from
+ // forbidden-ext-indirect-access-prop-caller.case
+ //
+ // If the function object "inner" has an own property
+ // named "caller", then its value will be returned.
+ //
+ // If the function object "inner" DOES NOT have an
+ // own property named "caller", then the symbol
+ // CALLER_OWN_PROPERTY_DOES_NOT_EXIST will be returned.
+ if (result !== CALLER_OWN_PROPERTY_DOES_NOT_EXIST) {
+ assert.notSameValue(result, f);
+ }
+ callCount++;
+}
+
+f()
+ .then(() => {
+ assert.sameValue(callCount, 1, 'function body evaluated');
+ }, $DONE).then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/async-function/forbidden-ext/b2/async-func-decl-forbidden-ext-indirect-access-own-prop-caller-value.js b/js/src/tests/test262/language/statements/async-function/forbidden-ext/b2/async-func-decl-forbidden-ext-indirect-access-own-prop-caller-value.js
new file mode 100644
index 0000000000..d67e324fad
--- /dev/null
+++ b/js/src/tests/test262/language/statements/async-function/forbidden-ext/b2/async-func-decl-forbidden-ext-indirect-access-own-prop-caller-value.js
@@ -0,0 +1,64 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/function-forms/forbidden-ext-indirect-access-own-prop-caller-value.case
+// - src/function-forms/forbidden-extensions/bullet-two/async-func-decl.template
+/*---
+description: Forbidden extension, o.caller (async function declaration)
+esid: sec-async-definitions
+features: [arrow-function, async-functions]
+flags: [generated, noStrict, async]
+info: |
+ AsyncFunctionDeclaration :
+ async function BindingIdentifier ( FormalParameters ) { AsyncFunctionBody }
+
+
+ If an implementation extends any function object with an own property named "caller" the value of
+ that property, as observed using [[Get]] or [[GetOwnProperty]], must not be a strict function
+ object. If it is an accessor property, the function that is the value of the property's [[Get]]
+ attribute must never return a strict function when called.
+
+---*/
+var CALLER_OWN_PROPERTY_DOES_NOT_EXIST = Symbol();
+function inner() {
+ // This property may exist, but is forbidden from having a value that is a strict function object
+ return inner.hasOwnProperty("caller")
+ ? inner.caller
+ : CALLER_OWN_PROPERTY_DOES_NOT_EXIST;
+}
+
+
+var callCount = 0;
+async function f() {
+ "use strict";
+ // This and the following conditional value is set in the test's .case file.
+ // For every test that has a "true" value here, there is a
+ // corresponding test that has a "false" value here.
+ // They are generated from two different case files, which use
+ // the same templates.
+ let descriptor = Object.getOwnPropertyDescriptor(inner, "caller");
+ if (descriptor && descriptor.configurable && true) {
+ Object.defineProperty(inner, "caller", {value: 1});
+ }
+ var result = inner();
+ if (descriptor && descriptor.configurable && true) {
+ assert.sameValue(result, 1, 'If this test defined an own "caller" property on the inner function, then it should be accessible and should return the value it was set to.');
+ }
+ // "CALLER_OWN_PROPERTY_DOES_NOT_EXIST" is from
+ // forbidden-ext-indirect-access-prop-caller.case
+ //
+ // If the function object "inner" has an own property
+ // named "caller", then its value will be returned.
+ //
+ // If the function object "inner" DOES NOT have an
+ // own property named "caller", then the symbol
+ // CALLER_OWN_PROPERTY_DOES_NOT_EXIST will be returned.
+ if (result !== CALLER_OWN_PROPERTY_DOES_NOT_EXIST) {
+ assert.notSameValue(result, f);
+ }
+ callCount++;
+}
+
+f()
+ .then(() => {
+ assert.sameValue(callCount, 1, 'function body evaluated');
+ }, $DONE).then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/async-function/forbidden-ext/b2/async-func-decl-forbidden-ext-indirect-access-prop-caller.js b/js/src/tests/test262/language/statements/async-function/forbidden-ext/b2/async-func-decl-forbidden-ext-indirect-access-prop-caller.js
new file mode 100644
index 0000000000..c9ce6d0156
--- /dev/null
+++ b/js/src/tests/test262/language/statements/async-function/forbidden-ext/b2/async-func-decl-forbidden-ext-indirect-access-prop-caller.js
@@ -0,0 +1,64 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/function-forms/forbidden-ext-indirect-access-prop-caller.case
+// - src/function-forms/forbidden-extensions/bullet-two/async-func-decl.template
+/*---
+description: Forbidden extension, o.caller (async function declaration)
+esid: sec-async-definitions
+features: [arrow-function, async-functions]
+flags: [generated, noStrict, async]
+info: |
+ AsyncFunctionDeclaration :
+ async function BindingIdentifier ( FormalParameters ) { AsyncFunctionBody }
+
+
+ If an implementation extends any function object with an own property named "caller" the value of
+ that property, as observed using [[Get]] or [[GetOwnProperty]], must not be a strict function
+ object. If it is an accessor property, the function that is the value of the property's [[Get]]
+ attribute must never return a strict function when called.
+
+---*/
+var CALLER_OWN_PROPERTY_DOES_NOT_EXIST = Symbol();
+function inner() {
+ // This property may exist, but is forbidden from having a value that is a strict function object
+ return inner.hasOwnProperty("caller")
+ ? inner.caller
+ : CALLER_OWN_PROPERTY_DOES_NOT_EXIST;
+}
+
+
+var callCount = 0;
+async function f() {
+ "use strict";
+ // This and the following conditional value is set in the test's .case file.
+ // For every test that has a "true" value here, there is a
+ // corresponding test that has a "false" value here.
+ // They are generated from two different case files, which use
+ // the same templates.
+ let descriptor = Object.getOwnPropertyDescriptor(inner, "caller");
+ if (descriptor && descriptor.configurable && false) {
+ Object.defineProperty(inner, "caller", {});
+ }
+ var result = inner();
+ if (descriptor && descriptor.configurable && false) {
+ assert.sameValue(result, 1, 'If this test defined an own "caller" property on the inner function, then it should be accessible and should return the value it was set to.');
+ }
+ // "CALLER_OWN_PROPERTY_DOES_NOT_EXIST" is from
+ // forbidden-ext-indirect-access-prop-caller.case
+ //
+ // If the function object "inner" has an own property
+ // named "caller", then its value will be returned.
+ //
+ // If the function object "inner" DOES NOT have an
+ // own property named "caller", then the symbol
+ // CALLER_OWN_PROPERTY_DOES_NOT_EXIST will be returned.
+ if (result !== CALLER_OWN_PROPERTY_DOES_NOT_EXIST) {
+ assert.notSameValue(result, f);
+ }
+ callCount++;
+}
+
+f()
+ .then(() => {
+ assert.sameValue(callCount, 1, 'function body evaluated');
+ }, $DONE).then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/async-function/forbidden-ext/b2/browser.js b/js/src/tests/test262/language/statements/async-function/forbidden-ext/b2/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/language/statements/async-function/forbidden-ext/b2/browser.js
diff --git a/js/src/tests/test262/language/statements/async-function/forbidden-ext/b2/shell.js b/js/src/tests/test262/language/statements/async-function/forbidden-ext/b2/shell.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/language/statements/async-function/forbidden-ext/b2/shell.js
diff --git a/js/src/tests/test262/language/statements/async-function/forbidden-ext/browser.js b/js/src/tests/test262/language/statements/async-function/forbidden-ext/browser.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/language/statements/async-function/forbidden-ext/browser.js
diff --git a/js/src/tests/test262/language/statements/async-function/forbidden-ext/shell.js b/js/src/tests/test262/language/statements/async-function/forbidden-ext/shell.js
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/js/src/tests/test262/language/statements/async-function/forbidden-ext/shell.js
diff --git a/js/src/tests/test262/language/statements/async-function/let-newline-await-in-async-function.js b/js/src/tests/test262/language/statements/async-function/let-newline-await-in-async-function.js
new file mode 100644
index 0000000000..3f9b97ac42
--- /dev/null
+++ b/js/src/tests/test262/language/statements/async-function/let-newline-await-in-async-function.js
@@ -0,0 +1,25 @@
+// |reftest| error:SyntaxError
+// Copyright (C) 2017 Mozilla Corporation. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+author: Jeff Walden <jwalden+code@mit.edu>
+esid: sec-let-and-const-declarations
+description: >
+ `let await` does not permit ASI in between, as `await` is a BindingIdentifier
+info: |
+ `await` is a perfectly cromulent binding name in any context grammatically, just
+ prohibited by static semantics in some contexts. Therefore ASI can never apply
+ between `let` (where a LexicalDeclaration is permitted) and `await`,
+ so a subsequent `0` where `=` was expected is a syntax error.
+negative:
+ phase: parse
+ type: SyntaxError
+---*/
+
+$DONOTEVALUATE();
+
+async function f() {
+ let
+ await 0;
+}
diff --git a/js/src/tests/test262/language/statements/async-function/object-destructuring-param-strict-body.js b/js/src/tests/test262/language/statements/async-function/object-destructuring-param-strict-body.js
new file mode 100644
index 0000000000..e9129e8b7b
--- /dev/null
+++ b/js/src/tests/test262/language/statements/async-function/object-destructuring-param-strict-body.js
@@ -0,0 +1,110 @@
+// |reftest| error:SyntaxError
+// This file was procedurally generated from the following sources:
+// - src/function-forms/object-destructuring-param-strict-body.case
+// - src/function-forms/syntax/async-func-decl.template
+/*---
+description: ObjectBindingPattern and Use Strict Directive are not allowed to coexist for the same function. (async function declaration)
+esid: sec-async-function-definitions
+features: [rest-parameters, async-functions]
+flags: [generated]
+negative:
+ phase: parse
+ type: SyntaxError
+info: |
+ 14.6 Async Function Definitions
+
+ AsyncFunctionDeclaration :
+ async function BindingIdentifier ( FormalParameters ) { AsyncFunctionBody }
+
+
+ 13.3.3.4 Static Semantics: IsSimpleParameterList
+
+ BindingElement : BindingPattern
+
+ 1. Return false.
+
+ 14.1.2 Static Semantics: Early Errors
+
+ FunctionDeclaration : function BindingIdentifier ( FormalParameters ) { FunctionBody }
+ FunctionDeclaration : function ( FormalParameters ) { FunctionBody }
+ FunctionExpression : function BindingIdentifier ( FormalParameters ) { FunctionBody }
+
+ - It is a Syntax Error if ContainsUseStrict of FunctionBody is true and
+ IsSimpleParameterList of FormalParameters is false.
+
+ 14.2.1 Static Semantics: Early Errors
+
+ ArrowFunction : ArrowParameters => ConciseBody
+
+ - It is a Syntax Error if ContainsUseStrict of ConciseBody is true and
+ IsSimpleParameterList of ArrowParameters is false.
+
+ 14.3.1 Static Semantics: Early Errors
+
+ MethodDefinition : PropertyName ( UniqueFormalParameters ) { FunctionBody }
+
+ - It is a Syntax Error if ContainsUseStrict of FunctionBody is true and
+ IsSimpleParameterList of UniqueFormalParameters is false.
+
+ MethodDefinition : set PropertyName ( PropertySetParameterList ) { FunctionBody }
+
+ - It is a Syntax Error if ContainsUseStrict of FunctionBody is true and
+ IsSimpleParameterList of PropertySetParameterList is false.
+
+ 14.4.1 Static Semantics: Early Errors
+
+ GeneratorMethod : * PropertyName ( UniqueFormalParameters ) { GeneratorBody }
+
+ - It is a Syntax Error if ContainsUseStrict of GeneratorBody is true and
+ IsSimpleParameterList of UniqueFormalParameters is false.
+
+ GeneratorDeclaration : function * BindingIdentifier ( FormalParameters ) { GeneratorBody }
+ GeneratorDeclaration : function * ( FormalParameters ) { GeneratorBody }
+ GeneratorExpression : function * BindingIdentifier ( FormalParameters ) { GeneratorBody }
+
+ - It is a Syntax Error if ContainsUseStrict of GeneratorBody is true and
+ IsSimpleParameterList of UniqueFormalParameters is false.
+
+ 14.5.1 Static Semantics: Early Errors
+
+ AsyncGeneratorMethod : async * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody }
+
+ - It is a Syntax Error if ContainsUseStrict of AsyncGeneratorBody is true and
+ IsSimpleParameterList of UniqueFormalParameters is false.
+
+ AsyncGeneratorDeclaration : async function * BindingIdentifier ( FormalParameters ) { AsyncGeneratorBody }
+ AsyncGeneratorDeclaration : async function * ( FormalParameters ) { AsyncGeneratorBody }
+ AsyncGeneratorExpression : async function * BindingIdentifier ( FormalParameters ) { AsyncGeneratorBody }
+
+ - It is a Syntax Error if ContainsUseStrict of AsyncGeneratorBody is true and
+ IsSimpleParameterList of FormalParameters is false.
+
+ 14.7.1 Static Semantics: Early Errors
+
+ AsyncMethod : async PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody }
+
+ - It is a Syntax Error if ContainsUseStrict of AsyncFunctionBody is true and
+ IsSimpleParameterList of UniqueFormalParameters is false.
+
+ AsyncFunctionDeclaration : async function BindingIdentifier ( FormalParameters ) { AsyncFunctionBody }
+ AsyncFunctionDeclaration : async function ( FormalParameters ) { AsyncFunctionBody }
+ AsyncFunctionExpression : async function ( FormalParameters ) { AsyncFunctionBody }
+ AsyncFunctionExpression : async function BindingIdentifier ( FormalParameters ) { AsyncFunctionBody }
+
+ - It is a Syntax Error if ContainsUseStrict of AsyncFunctionBody is true and
+ IsSimpleParameterList of FormalParameters is false.
+
+ 14.8.1 Static Semantics: Early Errors
+
+ AsyncArrowFunction : CoverCallExpressionAndAsyncArrowHead => AsyncConciseBody
+
+ - It is a Syntax Error if ContainsUseStrict of AsyncConciseBody is true and
+ IsSimpleParameterList of CoverCallExpressionAndAsyncArrowHead is false.
+
+---*/
+$DONOTEVALUATE();
+
+
+async function f({property}) {
+ "use strict";
+}
diff --git a/js/src/tests/test262/language/statements/async-function/params-trailing-comma-multiple.js b/js/src/tests/test262/language/statements/async-function/params-trailing-comma-multiple.js
new file mode 100644
index 0000000000..6c9d696c32
--- /dev/null
+++ b/js/src/tests/test262/language/statements/async-function/params-trailing-comma-multiple.js
@@ -0,0 +1,38 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/function-forms/params-trailing-comma-multiple.case
+// - src/function-forms/default/async-func-decl.template
+/*---
+description: A trailing comma should not increase the respective length, using multiple parameters (async function declaration)
+esid: sec-async-function-definitions
+features: [async-functions]
+flags: [generated, async]
+info: |
+ 14.6 Async Function Definitions
+
+ AsyncFunctionDeclaration :
+ async function BindingIdentifier ( FormalParameters ) { AsyncFunctionBody }
+
+
+ Trailing comma in the parameters list
+
+ 14.1 Function Definitions
+
+ FormalParameters[Yield, Await] : FormalParameterList[?Yield, ?Await] ,
+---*/
+
+
+var callCount = 0;
+
+// Stores a reference `ref` for case evaluation
+async function ref(a, b,) {
+ assert.sameValue(a, 42);
+ assert.sameValue(b, 39);
+ callCount = callCount + 1;
+}
+
+ref(42, 39, 1).then(() => {
+ assert.sameValue(callCount, 1, 'function invoked exactly once');
+}).then($DONE, $DONE);
+
+assert.sameValue(ref.length, 2, 'length is properly set');
diff --git a/js/src/tests/test262/language/statements/async-function/params-trailing-comma-single.js b/js/src/tests/test262/language/statements/async-function/params-trailing-comma-single.js
new file mode 100644
index 0000000000..5f1b1ee69e
--- /dev/null
+++ b/js/src/tests/test262/language/statements/async-function/params-trailing-comma-single.js
@@ -0,0 +1,37 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/function-forms/params-trailing-comma-single.case
+// - src/function-forms/default/async-func-decl.template
+/*---
+description: A trailing comma should not increase the respective length, using a single parameter (async function declaration)
+esid: sec-async-function-definitions
+features: [async-functions]
+flags: [generated, async]
+info: |
+ 14.6 Async Function Definitions
+
+ AsyncFunctionDeclaration :
+ async function BindingIdentifier ( FormalParameters ) { AsyncFunctionBody }
+
+
+ Trailing comma in the parameters list
+
+ 14.1 Function Definitions
+
+ FormalParameters[Yield, Await] : FormalParameterList[?Yield, ?Await] ,
+---*/
+
+
+var callCount = 0;
+
+// Stores a reference `ref` for case evaluation
+async function ref(a,) {
+ assert.sameValue(a, 42);
+ callCount = callCount + 1;
+}
+
+ref(42, 39).then(() => {
+ assert.sameValue(callCount, 1, 'function invoked exactly once');
+}).then($DONE, $DONE);
+
+assert.sameValue(ref.length, 1, 'length is properly set');
diff --git a/js/src/tests/test262/language/statements/async-function/rest-param-strict-body.js b/js/src/tests/test262/language/statements/async-function/rest-param-strict-body.js
new file mode 100644
index 0000000000..b58daec03c
--- /dev/null
+++ b/js/src/tests/test262/language/statements/async-function/rest-param-strict-body.js
@@ -0,0 +1,110 @@
+// |reftest| error:SyntaxError
+// This file was procedurally generated from the following sources:
+// - src/function-forms/rest-param-strict-body.case
+// - src/function-forms/syntax/async-func-decl.template
+/*---
+description: RestParameter and Use Strict Directive are not allowed to coexist for the same function. (async function declaration)
+esid: sec-async-function-definitions
+features: [rest-parameters, async-functions]
+flags: [generated]
+negative:
+ phase: parse
+ type: SyntaxError
+info: |
+ 14.6 Async Function Definitions
+
+ AsyncFunctionDeclaration :
+ async function BindingIdentifier ( FormalParameters ) { AsyncFunctionBody }
+
+
+ 14.1.13 Static Semantics: IsSimpleParameterList
+
+ FormalParameters : FormalParameterList , FunctionRestParameter
+
+ 1. Return false.
+
+ 14.1.2 Static Semantics: Early Errors
+
+ FunctionDeclaration : function BindingIdentifier ( FormalParameters ) { FunctionBody }
+ FunctionDeclaration : function ( FormalParameters ) { FunctionBody }
+ FunctionExpression : function BindingIdentifier ( FormalParameters ) { FunctionBody }
+
+ - It is a Syntax Error if ContainsUseStrict of FunctionBody is true and
+ IsSimpleParameterList of FormalParameters is false.
+
+ 14.2.1 Static Semantics: Early Errors
+
+ ArrowFunction : ArrowParameters => ConciseBody
+
+ - It is a Syntax Error if ContainsUseStrict of ConciseBody is true and
+ IsSimpleParameterList of ArrowParameters is false.
+
+ 14.3.1 Static Semantics: Early Errors
+
+ MethodDefinition : PropertyName ( UniqueFormalParameters ) { FunctionBody }
+
+ - It is a Syntax Error if ContainsUseStrict of FunctionBody is true and
+ IsSimpleParameterList of UniqueFormalParameters is false.
+
+ MethodDefinition : set PropertyName ( PropertySetParameterList ) { FunctionBody }
+
+ - It is a Syntax Error if ContainsUseStrict of FunctionBody is true and
+ IsSimpleParameterList of PropertySetParameterList is false.
+
+ 14.4.1 Static Semantics: Early Errors
+
+ GeneratorMethod : * PropertyName ( UniqueFormalParameters ) { GeneratorBody }
+
+ - It is a Syntax Error if ContainsUseStrict of GeneratorBody is true and
+ IsSimpleParameterList of UniqueFormalParameters is false.
+
+ GeneratorDeclaration : function * BindingIdentifier ( FormalParameters ) { GeneratorBody }
+ GeneratorDeclaration : function * ( FormalParameters ) { GeneratorBody }
+ GeneratorExpression : function * BindingIdentifier ( FormalParameters ) { GeneratorBody }
+
+ - It is a Syntax Error if ContainsUseStrict of GeneratorBody is true and
+ IsSimpleParameterList of UniqueFormalParameters is false.
+
+ 14.5.1 Static Semantics: Early Errors
+
+ AsyncGeneratorMethod : async * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody }
+
+ - It is a Syntax Error if ContainsUseStrict of AsyncGeneratorBody is true and
+ IsSimpleParameterList of UniqueFormalParameters is false.
+
+ AsyncGeneratorDeclaration : async function * BindingIdentifier ( FormalParameters ) { AsyncGeneratorBody }
+ AsyncGeneratorDeclaration : async function * ( FormalParameters ) { AsyncGeneratorBody }
+ AsyncGeneratorExpression : async function * BindingIdentifier ( FormalParameters ) { AsyncGeneratorBody }
+
+ - It is a Syntax Error if ContainsUseStrict of AsyncGeneratorBody is true and
+ IsSimpleParameterList of FormalParameters is false.
+
+ 14.7.1 Static Semantics: Early Errors
+
+ AsyncMethod : async PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody }
+
+ - It is a Syntax Error if ContainsUseStrict of AsyncFunctionBody is true and
+ IsSimpleParameterList of UniqueFormalParameters is false.
+
+ AsyncFunctionDeclaration : async function BindingIdentifier ( FormalParameters ) { AsyncFunctionBody }
+ AsyncFunctionDeclaration : async function ( FormalParameters ) { AsyncFunctionBody }
+ AsyncFunctionExpression : async function ( FormalParameters ) { AsyncFunctionBody }
+ AsyncFunctionExpression : async function BindingIdentifier ( FormalParameters ) { AsyncFunctionBody }
+
+ - It is a Syntax Error if ContainsUseStrict of AsyncFunctionBody is true and
+ IsSimpleParameterList of FormalParameters is false.
+
+ 14.8.1 Static Semantics: Early Errors
+
+ AsyncArrowFunction : CoverCallExpressionAndAsyncArrowHead => AsyncConciseBody
+
+ - It is a Syntax Error if ContainsUseStrict of AsyncConciseBody is true and
+ IsSimpleParameterList of CoverCallExpressionAndAsyncArrowHead is false.
+
+---*/
+$DONOTEVALUATE();
+
+
+async function f(a,...rest) {
+ "use strict";
+}
diff --git a/js/src/tests/test262/language/statements/async-function/rest-params-trailing-comma-early-error.js b/js/src/tests/test262/language/statements/async-function/rest-params-trailing-comma-early-error.js
new file mode 100644
index 0000000000..a4e5b59135
--- /dev/null
+++ b/js/src/tests/test262/language/statements/async-function/rest-params-trailing-comma-early-error.js
@@ -0,0 +1,36 @@
+// |reftest| error:SyntaxError
+// This file was procedurally generated from the following sources:
+// - src/function-forms/rest-params-trailing-comma-early-error.case
+// - src/function-forms/syntax/async-func-decl.template
+/*---
+description: It's a syntax error if a FunctionRestParameter is followed by a trailing comma (async function declaration)
+esid: sec-async-function-definitions
+features: [async-functions]
+flags: [generated]
+negative:
+ phase: parse
+ type: SyntaxError
+info: |
+ 14.6 Async Function Definitions
+
+ AsyncFunctionDeclaration :
+ async function BindingIdentifier ( FormalParameters ) { AsyncFunctionBody }
+
+
+ Trailing comma in the parameters list
+
+ 14.1 Function Definitions
+
+ FormalParameters[Yield, Await] :
+ [empty]
+ FunctionRestParameter[?Yield, ?Await]
+ FormalParameterList[?Yield, ?Await]
+ FormalParameterList[?Yield, ?Await] ,
+ FormalParameterList[?Yield, ?Await] , FunctionRestParameter[?Yield, ?Await]
+---*/
+$DONOTEVALUATE();
+
+
+async function f(...a,) {
+
+}
diff --git a/js/src/tests/test262/language/statements/async-function/returns-async-arrow-returns-arguments-from-parent-function.js b/js/src/tests/test262/language/statements/async-function/returns-async-arrow-returns-arguments-from-parent-function.js
new file mode 100644
index 0000000000..2643fe8125
--- /dev/null
+++ b/js/src/tests/test262/language/statements/async-function/returns-async-arrow-returns-arguments-from-parent-function.js
@@ -0,0 +1,31 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/async-functions/returns-async-arrow-returns-arguments-from-parent-function.case
+// - src/async-functions/evaluation/async-declaration.template
+/*---
+description: Async function returns an async function. (Async function declaration)
+esid: prod-AsyncFunctionDeclaration
+features: [async-functions]
+flags: [generated, async]
+info: |
+ Async Function Definitions
+
+ AsyncFunctionDeclaration:
+ async [no LineTerminator here] function BindingIdentifier ( FormalParameters ) { AsyncFunctionBody }
+
+---*/
+let count = 0;
+
+
+async function asyncFn(x) {
+ let a = arguments;
+ return async () => a === arguments;
+}
+
+asyncFn().then(retFn => {
+ count++;
+ return retFn();
+}).then(result => {
+ assert.sameValue(result, true);
+ assert.sameValue(count, 1);
+}).then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/async-function/returns-async-arrow-returns-newtarget.js b/js/src/tests/test262/language/statements/async-function/returns-async-arrow-returns-newtarget.js
new file mode 100644
index 0000000000..9b9f18d211
--- /dev/null
+++ b/js/src/tests/test262/language/statements/async-function/returns-async-arrow-returns-newtarget.js
@@ -0,0 +1,30 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/async-functions/returns-async-arrow-returns-newtarget.case
+// - src/async-functions/evaluation/async-declaration.template
+/*---
+description: Async function returns an async function. (Async function declaration)
+esid: prod-AsyncFunctionDeclaration
+features: [async-functions]
+flags: [generated, async]
+info: |
+ Async Function Definitions
+
+ AsyncFunctionDeclaration:
+ async [no LineTerminator here] function BindingIdentifier ( FormalParameters ) { AsyncFunctionBody }
+
+---*/
+let count = 0;
+
+
+async function asyncFn(x) {
+ return async () => new.target;
+}
+
+asyncFn().then(retFn => {
+ count++;
+ return retFn();
+}).then(result => {
+ assert.sameValue(result, undefined);
+ assert.sameValue(count, 1);
+}).then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/async-function/returns-async-arrow.js b/js/src/tests/test262/language/statements/async-function/returns-async-arrow.js
new file mode 100644
index 0000000000..d611abfd48
--- /dev/null
+++ b/js/src/tests/test262/language/statements/async-function/returns-async-arrow.js
@@ -0,0 +1,30 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/async-functions/returns-async-arrow.case
+// - src/async-functions/evaluation/async-declaration.template
+/*---
+description: Async function returns an async function. (Async function declaration)
+esid: prod-AsyncFunctionDeclaration
+features: [async-functions]
+flags: [generated, async]
+info: |
+ Async Function Definitions
+
+ AsyncFunctionDeclaration:
+ async [no LineTerminator here] function BindingIdentifier ( FormalParameters ) { AsyncFunctionBody }
+
+---*/
+let count = 0;
+
+
+async function asyncFn(x) {
+ return async () => x;
+}
+
+asyncFn(1).then(retFn => {
+ count++;
+ return retFn();
+}).then(result => {
+ assert.sameValue(result, 1);
+ assert.sameValue(count, 1);
+}).then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/async-function/returns-async-function-returns-arguments-from-own-function.js b/js/src/tests/test262/language/statements/async-function/returns-async-function-returns-arguments-from-own-function.js
new file mode 100644
index 0000000000..ec3e021001
--- /dev/null
+++ b/js/src/tests/test262/language/statements/async-function/returns-async-function-returns-arguments-from-own-function.js
@@ -0,0 +1,31 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/async-functions/returns-async-function-returns-arguments-from-own-function.case
+// - src/async-functions/evaluation/async-declaration.template
+/*---
+description: Async function returns an async function. (Async function declaration)
+esid: prod-AsyncFunctionDeclaration
+features: [async-functions]
+flags: [generated, async]
+info: |
+ Async Function Definitions
+
+ AsyncFunctionDeclaration:
+ async [no LineTerminator here] function BindingIdentifier ( FormalParameters ) { AsyncFunctionBody }
+
+---*/
+let count = 0;
+
+
+async function asyncFn(x) {
+ let a = arguments;
+ return async function() { return a === arguments; };
+}
+
+asyncFn(1).then(retFn => {
+ count++;
+ return retFn();
+}).then(result => {
+ assert.sameValue(result, false);
+ assert.sameValue(count, 1);
+}).then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/async-function/returns-async-function-returns-newtarget.js b/js/src/tests/test262/language/statements/async-function/returns-async-function-returns-newtarget.js
new file mode 100644
index 0000000000..ebcbe36042
--- /dev/null
+++ b/js/src/tests/test262/language/statements/async-function/returns-async-function-returns-newtarget.js
@@ -0,0 +1,30 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/async-functions/returns-async-function-returns-newtarget.case
+// - src/async-functions/evaluation/async-declaration.template
+/*---
+description: Async function returns an async function. (Async function declaration)
+esid: prod-AsyncFunctionDeclaration
+features: [async-functions]
+flags: [generated, async]
+info: |
+ Async Function Definitions
+
+ AsyncFunctionDeclaration:
+ async [no LineTerminator here] function BindingIdentifier ( FormalParameters ) { AsyncFunctionBody }
+
+---*/
+let count = 0;
+
+
+async function asyncFn(x) {
+ return async function() { return new.target; };
+}
+
+asyncFn(1).then(retFn => {
+ count++;
+ return retFn();
+}).then(result => {
+ assert.sameValue(result, undefined);
+ assert.sameValue(count, 1);
+}).then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/async-function/returns-async-function.js b/js/src/tests/test262/language/statements/async-function/returns-async-function.js
new file mode 100644
index 0000000000..c3b973c6bb
--- /dev/null
+++ b/js/src/tests/test262/language/statements/async-function/returns-async-function.js
@@ -0,0 +1,30 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/async-functions/returns-async-function.case
+// - src/async-functions/evaluation/async-declaration.template
+/*---
+description: Async function returns an async function. (Async function declaration)
+esid: prod-AsyncFunctionDeclaration
+features: [async-functions]
+flags: [generated, async]
+info: |
+ Async Function Definitions
+
+ AsyncFunctionDeclaration:
+ async [no LineTerminator here] function BindingIdentifier ( FormalParameters ) { AsyncFunctionBody }
+
+---*/
+let count = 0;
+
+
+async function asyncFn(x) {
+ return async function() { return x; };
+}
+
+asyncFn(1).then(retFn => {
+ count++;
+ return retFn();
+}).then(result => {
+ assert.sameValue(result, 1);
+ assert.sameValue(count, 1);
+}).then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/async-function/shell.js b/js/src/tests/test262/language/statements/async-function/shell.js
new file mode 100644
index 0000000000..ae18ad584d
--- /dev/null
+++ b/js/src/tests/test262/language/statements/async-function/shell.js
@@ -0,0 +1,113 @@
+// GENERATED, DO NOT EDIT
+// file: asyncHelpers.js
+// Copyright (C) 2022 Igalia, S.L. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+/*---
+description: |
+ A collection of assertion and wrapper functions for testing asynchronous built-ins.
+defines: [asyncTest]
+---*/
+
+function asyncTest(testFunc) {
+ if (!Object.hasOwn(globalThis, "$DONE")) {
+ throw new Test262Error("asyncTest called without async flag");
+ }
+ if (typeof testFunc !== "function") {
+ $DONE(new Test262Error("asyncTest called with non-function argument"));
+ return;
+ }
+ try {
+ testFunc().then(
+ function () {
+ $DONE();
+ },
+ function (error) {
+ $DONE(error);
+ }
+ );
+ } catch (syncError) {
+ $DONE(syncError);
+ }
+}
+
+assert.throwsAsync = async function (expectedErrorConstructor, func, message) {
+ var innerThenable;
+ if (message === undefined) {
+ message = "";
+ } else {
+ message += " ";
+ }
+ if (typeof func === "function") {
+ try {
+ innerThenable = func();
+ if (
+ innerThenable === null ||
+ typeof innerThenable !== "object" ||
+ typeof innerThenable.then !== "function"
+ ) {
+ message +=
+ "Expected to obtain an inner promise that would reject with a" +
+ expectedErrorConstructor.name +
+ " but result was not a thenable";
+ throw new Test262Error(message);
+ }
+ } catch (thrown) {
+ message +=
+ "Expected a " +
+ expectedErrorConstructor.name +
+ " to be thrown asynchronously but an exception was thrown synchronously while obtaining the inner promise";
+ throw new Test262Error(message);
+ }
+ } else {
+ message +=
+ "assert.throwsAsync called with an argument that is not a function";
+ throw new Test262Error(message);
+ }
+
+ try {
+ return innerThenable.then(
+ function () {
+ message +=
+ "Expected a " +
+ expectedErrorConstructor.name +
+ " to be thrown asynchronously but no exception was thrown at all";
+ throw new Test262Error(message);
+ },
+ function (thrown) {
+ var expectedName, actualName;
+ if (typeof thrown !== "object" || thrown === null) {
+ message += "Thrown value was not an object!";
+ throw new Test262Error(message);
+ } else if (thrown.constructor !== expectedErrorConstructor) {
+ expectedName = expectedErrorConstructor.name;
+ actualName = thrown.constructor.name;
+ if (expectedName === actualName) {
+ message +=
+ "Expected a " +
+ expectedName +
+ " but got a different error constructor with the same name";
+ } else {
+ message +=
+ "Expected a " + expectedName + " but got a " + actualName;
+ }
+ throw new Test262Error(message);
+ }
+ }
+ );
+ } catch (thrown) {
+ if (typeof thrown !== "object" || thrown === null) {
+ message +=
+ "Expected a " +
+ expectedErrorConstructor.name +
+ " to be thrown asynchronously but innerThenable synchronously threw a value that was not an object ";
+ } else {
+ message +=
+ "Expected a " +
+ expectedErrorConstructor.name +
+ " to be thrown asynchronously but a " +
+ thrown.constructor.name +
+ " was thrown synchronously";
+ }
+ throw new Test262Error(message);
+ }
+};
diff --git a/js/src/tests/test262/language/statements/async-function/syntax-declaration-line-terminators-allowed.js b/js/src/tests/test262/language/statements/async-function/syntax-declaration-line-terminators-allowed.js
new file mode 100644
index 0000000000..6573d802e0
--- /dev/null
+++ b/js/src/tests/test262/language/statements/async-function/syntax-declaration-line-terminators-allowed.js
@@ -0,0 +1,19 @@
+// Copyright 2016 Microsoft, Inc. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+author: Brian Terlson <brian.terlson@microsoft.com>
+esid: pending
+description: >
+ Declarations allow line breaks after function and after arguments list
+---*/
+
+async function
+foo()
+{
+
+}
+
+assert(foo instanceof Function);
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/async-function/syntax-declaration-no-line-terminator.js b/js/src/tests/test262/language/statements/async-function/syntax-declaration-no-line-terminator.js
new file mode 100644
index 0000000000..586b181800
--- /dev/null
+++ b/js/src/tests/test262/language/statements/async-function/syntax-declaration-no-line-terminator.js
@@ -0,0 +1,15 @@
+// Copyright 2016 Microsoft, Inc. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+author: Brian Terlson <brian.terlson@microsoft.com>
+esid: pending
+description: Async function declarations cannot have a line break after `async`
+info: Reference error is thrown due to looking up async in strict mode
+---*/
+assert.throws(ReferenceError, function() {
+ async
+ function foo() {}
+});
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/language/statements/async-function/syntax-declaration.js b/js/src/tests/test262/language/statements/async-function/syntax-declaration.js
new file mode 100644
index 0000000000..7b409d3007
--- /dev/null
+++ b/js/src/tests/test262/language/statements/async-function/syntax-declaration.js
@@ -0,0 +1,16 @@
+// |reftest| async
+// Copyright 2016 Microsoft, Inc. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+author: Brian Terlson <brian.terlson@microsoft.com>
+esid: pending
+description: Async function declaration returns a promise
+flags: [async]
+---*/
+
+async function foo () { }
+
+foo().then(function() {
+ $DONE();
+})
diff --git a/js/src/tests/test262/language/statements/async-function/try-reject-finally-reject.js b/js/src/tests/test262/language/statements/async-function/try-reject-finally-reject.js
new file mode 100644
index 0000000000..14814d099b
--- /dev/null
+++ b/js/src/tests/test262/language/statements/async-function/try-reject-finally-reject.js
@@ -0,0 +1,28 @@
+// |reftest| async
+// Copyright 2017 Caitlin Potter. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+author: Caitlin Potter <caitp@igalia.com>
+esid: pending
+description: >
+ Implementations must defer rejecting an async function's Promise until after
+ all finally blocks have been evaluated.
+flags: [async]
+---*/
+
+async function f() {
+ try {
+ await new Promise(function(resolve, reject) {
+ reject("early-reject");
+ });
+ } finally {
+ await new Promise(function(resolve, reject) {
+ reject("override");
+ });
+ }
+}
+
+f().then($DONE, function(value) {
+ assert.sameValue(value, "override", "Awaited rejection in finally block");
+}).then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/async-function/try-reject-finally-return.js b/js/src/tests/test262/language/statements/async-function/try-reject-finally-return.js
new file mode 100644
index 0000000000..5bf93ea1cf
--- /dev/null
+++ b/js/src/tests/test262/language/statements/async-function/try-reject-finally-return.js
@@ -0,0 +1,26 @@
+// |reftest| async
+// Copyright 2017 Caitlin Potter. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+author: Caitlin Potter <caitp@igalia.com>
+esid: pending
+description: >
+ Implementations must defer rejecting an async function's Promise until after
+ all finally blocks have been evaluated.
+flags: [async]
+---*/
+
+async function f() {
+ try {
+ await new Promise(function(resolve, reject) {
+ reject("early-reject");
+ });
+ } finally {
+ return "override";
+ }
+}
+
+f().then(function(value) {
+ assert.sameValue(value, "override", "Return in finally block");
+}).then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/async-function/try-reject-finally-throw.js b/js/src/tests/test262/language/statements/async-function/try-reject-finally-throw.js
new file mode 100644
index 0000000000..8027488be6
--- /dev/null
+++ b/js/src/tests/test262/language/statements/async-function/try-reject-finally-throw.js
@@ -0,0 +1,26 @@
+// |reftest| async
+// Copyright 2017 Caitlin Potter. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+author: Caitlin Potter <caitp@igalia.com>
+esid: pending
+description: >
+ Implementations must defer rejecting an async function's Promise until after
+ all finally blocks have been evaluated.
+flags: [async]
+---*/
+
+async function f() {
+ try {
+ await new Promise(function(resolve, reject) {
+ reject("early-reject");
+ });
+ } finally {
+ throw "override";
+ }
+}
+
+f().then($DONE, function(value) {
+ assert.sameValue(value, "override", "Exception thrown in finally block");
+}).then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/async-function/try-return-finally-reject.js b/js/src/tests/test262/language/statements/async-function/try-return-finally-reject.js
new file mode 100644
index 0000000000..0455d3ad71
--- /dev/null
+++ b/js/src/tests/test262/language/statements/async-function/try-return-finally-reject.js
@@ -0,0 +1,26 @@
+// |reftest| async
+// Copyright 2017 Caitlin Potter. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+author: Caitlin Potter <caitp@igalia.com>
+esid: pending
+description: >
+ Implementations must defer resolving an async function's Promise until after
+ all finally blocks have been evaluated.
+flags: [async]
+---*/
+
+async function f() {
+ try {
+ return "early-return";
+ } finally {
+ await new Promise(function(resolve, reject) {
+ reject("override");
+ });
+ }
+}
+
+f().then($DONE, function(value) {
+ assert.sameValue(value, "override", "Awaited rejection in finally block");
+}).then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/async-function/try-return-finally-return.js b/js/src/tests/test262/language/statements/async-function/try-return-finally-return.js
new file mode 100644
index 0000000000..eed39ff17b
--- /dev/null
+++ b/js/src/tests/test262/language/statements/async-function/try-return-finally-return.js
@@ -0,0 +1,26 @@
+// |reftest| async
+// Copyright 2017 Caitlin Potter. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+author: Caitlin Potter <caitp@igalia.com>
+esid: pending
+description: >
+ Implementations must defer resolving an async function's Promise until after
+ all finally blocks have been evaluated.
+flags: [async]
+---*/
+
+async function f() {
+ try {
+ return "early-return";
+ } finally {
+ return await new Promise(function(resolve, reject) {
+ resolve("override");
+ });
+ }
+}
+
+f().then(function(value) {
+ assert.sameValue(value, "override", "Return in finally block");
+}).then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/async-function/try-return-finally-throw.js b/js/src/tests/test262/language/statements/async-function/try-return-finally-throw.js
new file mode 100644
index 0000000000..aba4c86fe6
--- /dev/null
+++ b/js/src/tests/test262/language/statements/async-function/try-return-finally-throw.js
@@ -0,0 +1,24 @@
+// |reftest| async
+// Copyright 2017 Caitlin Potter. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+author: Caitlin Potter <caitp@igalia.com>
+esid: pending
+description: >
+ Implementations must defer resolving an async function's Promise until after
+ all finally blocks have been evaluated.
+flags: [async]
+---*/
+
+async function f() {
+ try {
+ return "early-return";
+ } finally {
+ throw "override";
+ }
+}
+
+f().then($DONE, function(value) {
+ assert.sameValue(value, "override", "Exception thrown in finally block");
+}).then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/async-function/try-throw-finally-reject.js b/js/src/tests/test262/language/statements/async-function/try-throw-finally-reject.js
new file mode 100644
index 0000000000..be2d482b52
--- /dev/null
+++ b/js/src/tests/test262/language/statements/async-function/try-throw-finally-reject.js
@@ -0,0 +1,26 @@
+// |reftest| async
+// Copyright 2017 Caitlin Potter. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+author: Caitlin Potter <caitp@igalia.com>
+esid: pending
+description: >
+ Implementations must defer rejecting an async function's Promise until after
+ all finally blocks have been evaluated.
+flags: [async]
+---*/
+
+async function f() {
+ try {
+ throw "early-throw";
+ } finally {
+ await new Promise(function(resolve, reject) {
+ reject("override");
+ });
+ }
+}
+
+f().then($DONE, function(value) {
+ assert.sameValue(value, "override", "Awaited rejection in finally block");
+}).then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/async-function/try-throw-finally-return.js b/js/src/tests/test262/language/statements/async-function/try-throw-finally-return.js
new file mode 100644
index 0000000000..80a8d303db
--- /dev/null
+++ b/js/src/tests/test262/language/statements/async-function/try-throw-finally-return.js
@@ -0,0 +1,26 @@
+// |reftest| async
+// Copyright 2017 Caitlin Potter. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+author: Caitlin Potter <caitp@igalia.com>
+esid: pending
+description: >
+ Implementations must defer rejecting an async function's Promise until after
+ all finally blocks have been evaluated.
+flags: [async]
+---*/
+
+async function f() {
+ try {
+ throw "early-throw";
+ } finally {
+ return await new Promise(function(resolve, reject) {
+ resolve("override");
+ });
+ }
+}
+
+f().then(function(value) {
+ assert.sameValue(value, "override", "Return in finally block");
+}).then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/async-function/try-throw-finally-throw.js b/js/src/tests/test262/language/statements/async-function/try-throw-finally-throw.js
new file mode 100644
index 0000000000..0ccfe934a1
--- /dev/null
+++ b/js/src/tests/test262/language/statements/async-function/try-throw-finally-throw.js
@@ -0,0 +1,24 @@
+// |reftest| async
+// Copyright 2017 Caitlin Potter. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+author: Caitlin Potter <caitp@igalia.com>
+esid: pending
+description: >
+ Implementations must defer rejecting an async function's Promise until after
+ all finally blocks have been evaluated.
+flags: [async]
+---*/
+
+async function f() {
+ try {
+ throw "early-throw";
+ } finally {
+ throw "override";
+ }
+}
+
+f().then($DONE, function(value) {
+ assert.sameValue(value, "override", "Exception thrown in finally block");
+}).then($DONE, $DONE);
diff --git a/js/src/tests/test262/language/statements/async-function/unscopables-with-in-nested-fn.js b/js/src/tests/test262/language/statements/async-function/unscopables-with-in-nested-fn.js
new file mode 100644
index 0000000000..bcec8c672e
--- /dev/null
+++ b/js/src/tests/test262/language/statements/async-function/unscopables-with-in-nested-fn.js
@@ -0,0 +1,80 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/function-forms/unscopables-with-in-nested-fn.case
+// - src/function-forms/default/async-func-decl.template
+/*---
+description: Symbol.unscopables behavior across scope boundaries (async function declaration)
+esid: sec-async-function-definitions
+features: [globalThis, Symbol.unscopables, async-functions]
+flags: [generated, noStrict, async]
+info: |
+ 14.6 Async Function Definitions
+
+ AsyncFunctionDeclaration :
+ async function BindingIdentifier ( FormalParameters ) { AsyncFunctionBody }
+
+
+ ...
+ Let envRec be lex's EnvironmentRecord.
+ Let exists be ? envRec.HasBinding(name).
+
+ HasBinding
+
+ ...
+ If the withEnvironment flag of envRec is false, return true.
+ Let unscopables be ? Get(bindings, @@unscopables).
+ If Type(unscopables) is Object, then
+ Let blocked be ToBoolean(? Get(unscopables, N)).
+ If blocked is true, return false.
+
+ (The `with` Statement) Runtime Semantics: Evaluation
+
+ ...
+ Set the withEnvironment flag of newEnv’s EnvironmentRecord to true.
+ ...
+
+---*/
+let count = 0;
+var v = 1;
+globalThis[Symbol.unscopables] = {
+ v: true,
+};
+
+{
+ count++;
+
+
+var callCount = 0;
+
+// Stores a reference `ref` for case evaluation
+async function ref(x) {
+ (function() {
+ count++;
+ with (globalThis) {
+ count++;
+ assert.sameValue(v, 1, 'The value of `v` is 1');
+ }
+ })();
+ (function() {
+ count++;
+ var v = x;
+ with (globalThis) {
+ count++;
+ assert.sameValue(v, 10, 'The value of `v` is 10');
+ v = 20;
+ }
+ assert.sameValue(v, 20, 'The value of `v` is 20');
+ assert.sameValue(globalThis.v, 1, 'The value of globalThis.v is 1');
+ })();
+ assert.sameValue(v, 1, 'The value of `v` is 1');
+ assert.sameValue(globalThis.v, 1, 'The value of globalThis.v is 1');
+ callCount = callCount + 1;
+}
+
+ref(10).then(() => {
+ assert.sameValue(callCount, 1, 'function invoked exactly once');
+}).then($DONE, $DONE);
+
+ count++;
+}
+assert.sameValue(count, 6, 'The value of `count` is 6');
diff --git a/js/src/tests/test262/language/statements/async-function/unscopables-with.js b/js/src/tests/test262/language/statements/async-function/unscopables-with.js
new file mode 100644
index 0000000000..ecdf135c5f
--- /dev/null
+++ b/js/src/tests/test262/language/statements/async-function/unscopables-with.js
@@ -0,0 +1,74 @@
+// |reftest| async
+// This file was procedurally generated from the following sources:
+// - src/function-forms/unscopables-with.case
+// - src/function-forms/default/async-func-decl.template
+/*---
+description: Symbol.unscopables behavior across scope boundaries (async function declaration)
+esid: sec-async-function-definitions
+features: [globalThis, Symbol.unscopables, async-functions]
+flags: [generated, noStrict, async]
+info: |
+ 14.6 Async Function Definitions
+
+ AsyncFunctionDeclaration :
+ async function BindingIdentifier ( FormalParameters ) { AsyncFunctionBody }
+
+
+ ...
+ Let envRec be lex's EnvironmentRecord.
+ Let exists be ? envRec.HasBinding(name).
+
+ HasBinding
+
+ ...
+ If the withEnvironment flag of envRec is false, return true.
+ Let unscopables be ? Get(bindings, @@unscopables).
+ If Type(unscopables) is Object, then
+ Let blocked be ToBoolean(? Get(unscopables, N)).
+ If blocked is true, return false.
+
+ (The `with` Statement) Runtime Semantics: Evaluation
+
+ ...
+ Set the withEnvironment flag of newEnv’s EnvironmentRecord to true.
+ ...
+
+---*/
+let count = 0;
+var v = 1;
+globalThis[Symbol.unscopables] = {
+ v: true,
+};
+
+{
+ count++;
+
+
+var callCount = 0;
+
+// Stores a reference `ref` for case evaluation
+async function ref(x) {
+ count++;
+ with (globalThis) {
+ count++;
+ assert.sameValue(v, undefined, 'The value of `v` is expected to equal `undefined`');
+ }
+ count++;
+ var v = x;
+ with (globalThis) {
+ count++;
+ assert.sameValue(v, 10, 'The value of `v` is 10');
+ v = 20;
+ }
+ assert.sameValue(v, 20, 'The value of `v` is 20');
+ assert.sameValue(globalThis.v, 1, 'The value of globalThis.v is 1');
+ callCount = callCount + 1;
+}
+
+ref(10).then(() => {
+ assert.sameValue(callCount, 1, 'function invoked exactly once');
+}).then($DONE, $DONE);
+
+ count++;
+}
+assert.sameValue(count, 6, 'The value of `count` is 6');