From dbf251586e280cebc716b96f1a8a089ffa63a54f Mon Sep 17 00:00:00 2001 From: Brian Terlson <brian.terlson@microsoft.com> Date: Tue, 26 Jan 2016 14:31:32 -0800 Subject: [PATCH] Add tests for async functions Closes #479 --- .../AsyncFunction/AsyncFunction-construct.js | 31 +++++++++++++++++++ .../AsyncFunction-is-extensible.js | 13 ++++++++ .../AsyncFunction-is-subclass.js | 15 +++++++++ .../AsyncFunction/AsyncFunction-length.js | 16 ++++++++++ .../AsyncFunction/AsyncFunction-name.js | 16 ++++++++++ .../AsyncFunction/AsyncFunction-prototype.js | 14 +++++++++ test/built-ins/AsyncFunction/AsyncFunction.js | 12 +++++++ .../AsyncFunctionPrototype-is-extensible.js | 14 +++++++++ .../AsyncFunctionPrototype-prototype.js | 10 ++++++ .../AsyncFunctionPrototype-to-string.js | 17 ++++++++++ .../AsyncFunction/instance-construct.js | 16 ++++++++++ .../AsyncFunction/instance-has-name.js | 16 ++++++++++ .../AsyncFunction/instance-length.js | 22 +++++++++++++ .../instance-prototype-property.js | 12 +++++++ .../AsyncFunction/is-not-a-global.js | 13 ++++++++ .../prototype/toString/AsyncFunction.js | 15 +++++++++ .../toString/async-function-declaration.js | 13 ++++++++ .../toString/async-function-expression.js | 13 ++++++++ .../prototype/toString/async-method.js | 15 +++++++++ .../arrow-returns-promise.js | 17 ++++++++++ .../early-errors-arrow-NSPL-with-USD.js | 12 +++++++ ...rs-arrow-arguments-in-formal-parameters.js | 13 ++++++++ ...y-errors-arrow-await-in-formals-default.js | 10 ++++++ .../early-errors-arrow-await-in-formals.js | 10 ++++++ ...y-errors-arrow-body-contains-super-call.js | 11 +++++++ ...rors-arrow-body-contains-super-property.js | 11 +++++++ ...early-errors-arrow-duplicate-parameters.js | 13 ++++++++ ...-errors-arrow-eval-in-formal-parameters.js | 12 +++++++ ...rly-errors-arrow-formals-body-duplicate.js | 11 +++++++ ...rrors-arrow-formals-contains-super-call.js | 11 +++++++ ...s-arrow-formals-contains-super-property.js | 11 +++++++ .../early-errors-expression-NSPL-with-USD.js | 12 +++++++ ...expression-binding-identifier-arguments.js | 13 ++++++++ ...rors-expression-binding-identifier-eval.js | 12 +++++++ ...ors-expression-body-contains-super-call.js | 11 +++++++ ...expression-body-contains-super-property.js | 12 +++++++ ...rs-expression-eval-in-formal-parameters.js | 12 +++++++ ...rrors-expression-formals-body-duplicate.js | 11 +++++++ ...-expression-formals-contains-super-call.js | 11 +++++++ ...ression-formals-contains-super-property.js | 11 +++++++ ...expression-not-simple-assignment-target.js | 12 +++++++ .../expression-returns-promise.js | 12 +++++++ .../syntax-expression-is-PrimaryExpression.js | 11 +++++++ .../await-BindingIdentifier-in-global.js | 13 ++++++++ .../await/await-BindingIdentifier-nested.js | 15 +++++++++ .../await-awaits-thenable-not-callable.js | 20 ++++++++++++ .../await-awaits-thenables-that-throw.js | 31 +++++++++++++++++++ .../await/await-awaits-thenables.js | 21 +++++++++++++ .../expressions/await/await-in-function.js | 12 +++++++ .../expressions/await/await-in-generator.js | 12 +++++++ .../expressions/await/await-in-global.js | 12 +++++++ .../await/await-in-nested-function.js | 20 ++++++++++++ .../await/await-in-nested-generator.js | 20 ++++++++++++ .../await/await-throws-rejections.js | 23 ++++++++++++++ ...rors-await-not-simple-assignment-target.js | 14 +++++++++ test/language/expressions/await/no-operand.js | 14 +++++++++ ...xpression-with-MultiplicativeExpression.js | 17 ++++++++++ .../await/syntax-await-has-UnaryExpression.js | 18 +++++++++++ .../async-super-call-body.js | 26 ++++++++++++++++ .../async-super-call-param.js | 27 ++++++++++++++++ ...arly-errors-object-method-NSPL-with-USD.js | 13 ++++++++ ...t-method-arguments-in-formal-parameters.js | 13 ++++++++ ...-object-method-await-in-formals-default.js | 13 ++++++++ ...y-errors-object-method-await-in-formals.js | 12 +++++++ ...-object-method-body-contains-super-call.js | 12 +++++++ ...rors-object-method-duplicate-parameters.js | 13 ++++++++ ...object-method-eval-in-formal-parameters.js | 13 ++++++++ ...rs-object-method-formals-body-duplicate.js | 13 ++++++++ ...ject-method-formals-contains-super-call.js | 12 +++++++ .../object-method-returns-promise.js | 15 +++++++++ .../declaration-returns-promise.js | 13 ++++++++ .../early-errors-declaration-NSPL-with-USD.js | 12 +++++++ ...laration-arguments-in-formal-parameters.js | 13 ++++++++ ...rs-declaration-await-in-formals-default.js | 10 ++++++ ...rly-errors-declaration-await-in-formals.js | 10 ++++++ ...eclaration-binding-identifier-arguments.js | 13 ++++++++ ...ors-declaration-binding-identifier-eval.js | 12 +++++++ ...rs-declaration-body-contains-super-call.js | 11 +++++++ ...eclaration-body-contains-super-property.js | 11 +++++++ ...errors-declaration-duplicate-parameters.js | 13 ++++++++ ...s-declaration-eval-in-formal-parameters.js | 12 +++++++ ...rors-declaration-formals-body-duplicate.js | 11 +++++++ ...declaration-formals-contains-super-call.js | 11 +++++++ ...aration-formals-contains-super-property.js | 11 +++++++ .../early-errors-no-async-generator.js | 12 +++++++ ...valuation-body-that-returns-after-await.js | 21 +++++++++++++ .../evaluation-body-that-returns.js | 19 ++++++++++++ ...evaluation-body-that-throws-after-await.js | 24 ++++++++++++++ .../evaluation-body-that-throws.js | 22 +++++++++++++ .../async-function/evaluation-body.js | 18 +++++++++++ .../evaluation-default-that-throws.js | 20 ++++++++++++ .../evaluation-mapped-arguments.js | 22 +++++++++++++ .../evaluation-this-value-global.js | 17 ++++++++++ .../evaluation-this-value-passed.js | 18 +++++++++++ .../evaluation-unmapped-arguments.js | 23 ++++++++++++++ ...ax-declaration-line-terminators-allowed.js | 17 ++++++++++ .../syntax-declaration-no-line-terminator.js | 13 ++++++++ .../async-function/syntax-declaration.js | 15 +++++++++ .../class-method-returns-promise.js | 14 +++++++++ ...early-errors-class-method-NSPL-with-USD.js | 13 ++++++++ ...s-method-arguments-in-formal-parameters.js | 12 +++++++ ...s-class-method-await-in-formals-default.js | 13 ++++++++ ...ly-errors-class-method-await-in-formals.js | 12 +++++++ ...s-class-method-body-contains-super-call.js | 12 +++++++ ...rrors-class-method-duplicate-parameters.js | 14 +++++++++ ...-class-method-eval-in-formal-parameters.js | 12 +++++++ ...ors-class-method-formals-body-duplicate.js | 14 +++++++++ ...lass-method-formals-contains-super-call.js | 12 +++++++ .../methods-async-super-call-body.js | 25 +++++++++++++++ .../methods-async-super-call-param.js | 24 ++++++++++++++ 110 files changed, 1620 insertions(+) create mode 100644 test/built-ins/AsyncFunction/AsyncFunction-construct.js create mode 100644 test/built-ins/AsyncFunction/AsyncFunction-is-extensible.js create mode 100644 test/built-ins/AsyncFunction/AsyncFunction-is-subclass.js create mode 100644 test/built-ins/AsyncFunction/AsyncFunction-length.js create mode 100644 test/built-ins/AsyncFunction/AsyncFunction-name.js create mode 100644 test/built-ins/AsyncFunction/AsyncFunction-prototype.js create mode 100644 test/built-ins/AsyncFunction/AsyncFunction.js create mode 100644 test/built-ins/AsyncFunction/AsyncFunctionPrototype-is-extensible.js create mode 100644 test/built-ins/AsyncFunction/AsyncFunctionPrototype-prototype.js create mode 100644 test/built-ins/AsyncFunction/AsyncFunctionPrototype-to-string.js create mode 100644 test/built-ins/AsyncFunction/instance-construct.js create mode 100644 test/built-ins/AsyncFunction/instance-has-name.js create mode 100644 test/built-ins/AsyncFunction/instance-length.js create mode 100644 test/built-ins/AsyncFunction/instance-prototype-property.js create mode 100644 test/built-ins/AsyncFunction/is-not-a-global.js create mode 100644 test/built-ins/Function/prototype/toString/AsyncFunction.js create mode 100644 test/built-ins/Function/prototype/toString/async-function-declaration.js create mode 100644 test/built-ins/Function/prototype/toString/async-function-expression.js create mode 100644 test/built-ins/Function/prototype/toString/async-method.js create mode 100644 test/language/expressions/async-arrow-function/arrow-returns-promise.js create mode 100644 test/language/expressions/async-arrow-function/early-errors-arrow-NSPL-with-USD.js create mode 100644 test/language/expressions/async-arrow-function/early-errors-arrow-arguments-in-formal-parameters.js create mode 100644 test/language/expressions/async-arrow-function/early-errors-arrow-await-in-formals-default.js create mode 100644 test/language/expressions/async-arrow-function/early-errors-arrow-await-in-formals.js create mode 100644 test/language/expressions/async-arrow-function/early-errors-arrow-body-contains-super-call.js create mode 100644 test/language/expressions/async-arrow-function/early-errors-arrow-body-contains-super-property.js create mode 100644 test/language/expressions/async-arrow-function/early-errors-arrow-duplicate-parameters.js create mode 100644 test/language/expressions/async-arrow-function/early-errors-arrow-eval-in-formal-parameters.js create mode 100644 test/language/expressions/async-arrow-function/early-errors-arrow-formals-body-duplicate.js create mode 100644 test/language/expressions/async-arrow-function/early-errors-arrow-formals-contains-super-call.js create mode 100644 test/language/expressions/async-arrow-function/early-errors-arrow-formals-contains-super-property.js create mode 100644 test/language/expressions/async-function/early-errors-expression-NSPL-with-USD.js create mode 100644 test/language/expressions/async-function/early-errors-expression-binding-identifier-arguments.js create mode 100644 test/language/expressions/async-function/early-errors-expression-binding-identifier-eval.js create mode 100644 test/language/expressions/async-function/early-errors-expression-body-contains-super-call.js create mode 100644 test/language/expressions/async-function/early-errors-expression-body-contains-super-property.js create mode 100644 test/language/expressions/async-function/early-errors-expression-eval-in-formal-parameters.js create mode 100644 test/language/expressions/async-function/early-errors-expression-formals-body-duplicate.js create mode 100644 test/language/expressions/async-function/early-errors-expression-formals-contains-super-call.js create mode 100644 test/language/expressions/async-function/early-errors-expression-formals-contains-super-property.js create mode 100644 test/language/expressions/async-function/early-errors-expression-not-simple-assignment-target.js create mode 100644 test/language/expressions/async-function/expression-returns-promise.js create mode 100644 test/language/expressions/async-function/syntax-expression-is-PrimaryExpression.js create mode 100644 test/language/expressions/await/await-BindingIdentifier-in-global.js create mode 100644 test/language/expressions/await/await-BindingIdentifier-nested.js create mode 100644 test/language/expressions/await/await-awaits-thenable-not-callable.js create mode 100644 test/language/expressions/await/await-awaits-thenables-that-throw.js create mode 100644 test/language/expressions/await/await-awaits-thenables.js create mode 100644 test/language/expressions/await/await-in-function.js create mode 100644 test/language/expressions/await/await-in-generator.js create mode 100644 test/language/expressions/await/await-in-global.js create mode 100644 test/language/expressions/await/await-in-nested-function.js create mode 100644 test/language/expressions/await/await-in-nested-generator.js create mode 100644 test/language/expressions/await/await-throws-rejections.js create mode 100644 test/language/expressions/await/early-errors-await-not-simple-assignment-target.js create mode 100644 test/language/expressions/await/no-operand.js create mode 100644 test/language/expressions/await/syntax-await-has-UnaryExpression-with-MultiplicativeExpression.js create mode 100644 test/language/expressions/await/syntax-await-has-UnaryExpression.js create mode 100644 test/language/expressions/object/method-definition/async-super-call-body.js create mode 100644 test/language/expressions/object/method-definition/async-super-call-param.js create mode 100644 test/language/expressions/object/method-definition/early-errors-object-method-NSPL-with-USD.js create mode 100644 test/language/expressions/object/method-definition/early-errors-object-method-arguments-in-formal-parameters.js create mode 100644 test/language/expressions/object/method-definition/early-errors-object-method-await-in-formals-default.js create mode 100644 test/language/expressions/object/method-definition/early-errors-object-method-await-in-formals.js create mode 100644 test/language/expressions/object/method-definition/early-errors-object-method-body-contains-super-call.js create mode 100644 test/language/expressions/object/method-definition/early-errors-object-method-duplicate-parameters.js create mode 100644 test/language/expressions/object/method-definition/early-errors-object-method-eval-in-formal-parameters.js create mode 100644 test/language/expressions/object/method-definition/early-errors-object-method-formals-body-duplicate.js create mode 100644 test/language/expressions/object/method-definition/early-errors-object-method-formals-contains-super-call.js create mode 100644 test/language/expressions/object/method-definition/object-method-returns-promise.js create mode 100644 test/language/statements/async-function/declaration-returns-promise.js create mode 100644 test/language/statements/async-function/early-errors-declaration-NSPL-with-USD.js create mode 100644 test/language/statements/async-function/early-errors-declaration-arguments-in-formal-parameters.js create mode 100644 test/language/statements/async-function/early-errors-declaration-await-in-formals-default.js create mode 100644 test/language/statements/async-function/early-errors-declaration-await-in-formals.js create mode 100644 test/language/statements/async-function/early-errors-declaration-binding-identifier-arguments.js create mode 100644 test/language/statements/async-function/early-errors-declaration-binding-identifier-eval.js create mode 100644 test/language/statements/async-function/early-errors-declaration-body-contains-super-call.js create mode 100644 test/language/statements/async-function/early-errors-declaration-body-contains-super-property.js create mode 100644 test/language/statements/async-function/early-errors-declaration-duplicate-parameters.js create mode 100644 test/language/statements/async-function/early-errors-declaration-eval-in-formal-parameters.js create mode 100644 test/language/statements/async-function/early-errors-declaration-formals-body-duplicate.js create mode 100644 test/language/statements/async-function/early-errors-declaration-formals-contains-super-call.js create mode 100644 test/language/statements/async-function/early-errors-declaration-formals-contains-super-property.js create mode 100644 test/language/statements/async-function/early-errors-no-async-generator.js create mode 100644 test/language/statements/async-function/evaluation-body-that-returns-after-await.js create mode 100644 test/language/statements/async-function/evaluation-body-that-returns.js create mode 100644 test/language/statements/async-function/evaluation-body-that-throws-after-await.js create mode 100644 test/language/statements/async-function/evaluation-body-that-throws.js create mode 100644 test/language/statements/async-function/evaluation-body.js create mode 100644 test/language/statements/async-function/evaluation-default-that-throws.js create mode 100644 test/language/statements/async-function/evaluation-mapped-arguments.js create mode 100644 test/language/statements/async-function/evaluation-this-value-global.js create mode 100644 test/language/statements/async-function/evaluation-this-value-passed.js create mode 100644 test/language/statements/async-function/evaluation-unmapped-arguments.js create mode 100644 test/language/statements/async-function/syntax-declaration-line-terminators-allowed.js create mode 100644 test/language/statements/async-function/syntax-declaration-no-line-terminator.js create mode 100644 test/language/statements/async-function/syntax-declaration.js create mode 100644 test/language/statements/class/definition/class-method-returns-promise.js create mode 100644 test/language/statements/class/definition/early-errors-class-method-NSPL-with-USD.js create mode 100644 test/language/statements/class/definition/early-errors-class-method-arguments-in-formal-parameters.js create mode 100644 test/language/statements/class/definition/early-errors-class-method-await-in-formals-default.js create mode 100644 test/language/statements/class/definition/early-errors-class-method-await-in-formals.js create mode 100644 test/language/statements/class/definition/early-errors-class-method-body-contains-super-call.js create mode 100644 test/language/statements/class/definition/early-errors-class-method-duplicate-parameters.js create mode 100644 test/language/statements/class/definition/early-errors-class-method-eval-in-formal-parameters.js create mode 100644 test/language/statements/class/definition/early-errors-class-method-formals-body-duplicate.js create mode 100644 test/language/statements/class/definition/early-errors-class-method-formals-contains-super-call.js create mode 100644 test/language/statements/class/definition/methods-async-super-call-body.js create mode 100644 test/language/statements/class/definition/methods-async-super-call-param.js diff --git a/test/built-ins/AsyncFunction/AsyncFunction-construct.js b/test/built-ins/AsyncFunction/AsyncFunction-construct.js new file mode 100644 index 0000000000..e28ead10e7 --- /dev/null +++ b/test/built-ins/AsyncFunction/AsyncFunction-construct.js @@ -0,0 +1,31 @@ +// 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: > + %AsyncFunction% creates functions with or without new and handles arguments + similarly to functions. +---*/ + +var AsyncFunction = async function foo() { }.constructor; +var fn; + +fn = AsyncFunction("a", "await 1;"); +assert.sameValue(fn.length, 1, "length with 1 argument, call"); + +fn = AsyncFunction("a,b", "await 1;"); +assert.sameValue(fn.length, 2, "length with 2 arguments in one, call"); + +fn = AsyncFunction("a", "b", "await 1;"); +assert.sameValue(fn.length, 2, "length with 2 arguments, call"); + +fn = new AsyncFunction("a", "await 1;"); +assert.sameValue(fn.length, 1, "length with 1 argument, construct"); + +fn = new AsyncFunction("a,b", "await 1;"); +assert.sameValue(fn.length, 2, "length with 2 arguments in one, construct"); + +fn = new AsyncFunction("a", "b", "await 1;"); +assert.sameValue(fn.length, 2, "length with 2 arguments, construct"); diff --git a/test/built-ins/AsyncFunction/AsyncFunction-is-extensible.js b/test/built-ins/AsyncFunction/AsyncFunction-is-extensible.js new file mode 100644 index 0000000000..f1e790b2a0 --- /dev/null +++ b/test/built-ins/AsyncFunction/AsyncFunction-is-extensible.js @@ -0,0 +1,13 @@ +// 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: > + %AsyncFunction% is extensible +---*/ + +var AsyncFunction = async function() { }.constructor; +AsyncFunction.x = 1; +assert.sameValue(AsyncFunction.x, 1); diff --git a/test/built-ins/AsyncFunction/AsyncFunction-is-subclass.js b/test/built-ins/AsyncFunction/AsyncFunction-is-subclass.js new file mode 100644 index 0000000000..0237591d8b --- /dev/null +++ b/test/built-ins/AsyncFunction/AsyncFunction-is-subclass.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: > + %AsyncFunction% is a subclass of Function +---*/ +async function foo() { }; +var AsyncFunction = foo.constructor; +assert.sameValue(Object.getPrototypeOf(AsyncFunction), Function, "Prototype of constructor is Function"); +assert.sameValue(Object.getPrototypeOf(AsyncFunction.prototype), Function.prototype, "Prototype of constructor's prototype is Function.prototype"); +assert(foo instanceof Function, 'async function instance is instanceof Function'); + diff --git a/test/built-ins/AsyncFunction/AsyncFunction-length.js b/test/built-ins/AsyncFunction/AsyncFunction-length.js new file mode 100644 index 0000000000..3258fde567 --- /dev/null +++ b/test/built-ins/AsyncFunction/AsyncFunction-length.js @@ -0,0 +1,16 @@ +// 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: > + %AsyncFunction% has a length of 1 with writable false, enumerable false, configurable true. +includes: [propertyHelper.js] +---*/ + +var AsyncFunction = async function foo() { }.constructor; +assert.sameValue(AsyncFunction.length, 1); +verifyNotWritable(AsyncFunction, 'length'); +verifyNotEnumerable(AsyncFunction, 'length'); +verifyConfigurable(AsyncFunction, 'length'); diff --git a/test/built-ins/AsyncFunction/AsyncFunction-name.js b/test/built-ins/AsyncFunction/AsyncFunction-name.js new file mode 100644 index 0000000000..5b9b4a0d5f --- /dev/null +++ b/test/built-ins/AsyncFunction/AsyncFunction-name.js @@ -0,0 +1,16 @@ +// 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: > + %AsyncFunction% has a name of "AsyncFunction". +includes: [propertyHelper.js] +---*/ + +var AsyncFunction = async function foo() { }.constructor; +assert.sameValue(AsyncFunction.name, "AsyncFunction"); +verifyNotWritable(AsyncFunction, "name"); +verifyNotEnumerable(AsyncFunction, "name"); +verifyConfigurable(AsyncFunction, "name"); diff --git a/test/built-ins/AsyncFunction/AsyncFunction-prototype.js b/test/built-ins/AsyncFunction/AsyncFunction-prototype.js new file mode 100644 index 0000000000..91ce757884 --- /dev/null +++ b/test/built-ins/AsyncFunction/AsyncFunction-prototype.js @@ -0,0 +1,14 @@ +// 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: AsyncFunction has a prototype property with writable false, enumerable false, configurable false. +includes: [propertyHelper.js] +---*/ + +var AsyncFunction = async function foo() { }.constructor; +verifyNotConfigurable(AsyncFunction, 'prototype'); +verifyNotWritable(AsyncFunction, 'prototype'); +verifyNotEnumerable(AsyncFunction, 'prototype'); diff --git a/test/built-ins/AsyncFunction/AsyncFunction.js b/test/built-ins/AsyncFunction/AsyncFunction.js new file mode 100644 index 0000000000..358f3a706c --- /dev/null +++ b/test/built-ins/AsyncFunction/AsyncFunction.js @@ -0,0 +1,12 @@ +// 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: > + %AsyncFunction% exists and is a function +---*/ + +var AsyncFunction = async function foo() { }.constructor; +assert.sameValue(typeof AsyncFunction, "function"); diff --git a/test/built-ins/AsyncFunction/AsyncFunctionPrototype-is-extensible.js b/test/built-ins/AsyncFunction/AsyncFunctionPrototype-is-extensible.js new file mode 100644 index 0000000000..d2ddcc1ab4 --- /dev/null +++ b/test/built-ins/AsyncFunction/AsyncFunctionPrototype-is-extensible.js @@ -0,0 +1,14 @@ +// 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: > + %AsyncFunctionPrototype% has a [[Extensible]] of true +---*/ + +var AsyncFunction = async function foo() { }.constructor; +AsyncFunction.prototype.x = 1; +assert.sameValue(AsyncFunction.prototype.x, 1); + diff --git a/test/built-ins/AsyncFunction/AsyncFunctionPrototype-prototype.js b/test/built-ins/AsyncFunction/AsyncFunctionPrototype-prototype.js new file mode 100644 index 0000000000..f0d3086170 --- /dev/null +++ b/test/built-ins/AsyncFunction/AsyncFunctionPrototype-prototype.js @@ -0,0 +1,10 @@ +// 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: AsyncFunction.prototype has a [[prototype]] of Function.prototype +---*/ +var AsyncFunction = async function foo() { }.constructor; +assert.sameValue(Object.getPrototypeOf(AsyncFunction.prototype), Function.prototype); diff --git a/test/built-ins/AsyncFunction/AsyncFunctionPrototype-to-string.js b/test/built-ins/AsyncFunction/AsyncFunctionPrototype-to-string.js new file mode 100644 index 0000000000..eb3d468681 --- /dev/null +++ b/test/built-ins/AsyncFunction/AsyncFunctionPrototype-to-string.js @@ -0,0 +1,17 @@ +// 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: > + %AsyncFunctionPrototype% has a Symbol.toStringTag property of "AsyncFunction" +includes: [propertyHelper.js] +---*/ + +var AsyncFunction = async function foo() { }.constructor; +var AFP = AsyncFunction.prototype; +assert.sameValue(AFP[Symbol.toStringTag], "AsyncFunction", "toStringTag value"); +verifyNotWritable(AFP, Symbol.toStringTag); +verifyNotEnumerable(AFP, Symbol.toStringTag); +verifyConfigurable(AFP, Symbol.toStringTag); diff --git a/test/built-ins/AsyncFunction/instance-construct.js b/test/built-ins/AsyncFunction/instance-construct.js new file mode 100644 index 0000000000..00a9354ac5 --- /dev/null +++ b/test/built-ins/AsyncFunction/instance-construct.js @@ -0,0 +1,16 @@ +// 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 instances are not constructors and do not have a + [[Construct]] slot. +---*/ + +async function foo() { } +assert.throws(TypeError, function() { + new foo(); +}); + diff --git a/test/built-ins/AsyncFunction/instance-has-name.js b/test/built-ins/AsyncFunction/instance-has-name.js new file mode 100644 index 0000000000..ba35a8c5ba --- /dev/null +++ b/test/built-ins/AsyncFunction/instance-has-name.js @@ -0,0 +1,16 @@ +// 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 have a name property +includes: [propertyHelper.js] +---*/ + +async function foo () { }; + +assert.sameValue(foo.name, "foo"); +verifyNotWritable(foo, "name"); +verifyNotEnumerable(foo, "name"); +verifyConfigurable(foo, "name"); diff --git a/test/built-ins/AsyncFunction/instance-length.js b/test/built-ins/AsyncFunction/instance-length.js new file mode 100644 index 0000000000..9f636af05b --- /dev/null +++ b/test/built-ins/AsyncFunction/instance-length.js @@ -0,0 +1,22 @@ +// 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 have a length property that is the number of expected + arguments. +includes: [propertyHelper.js] +---*/ + +async function l0() { } +async function l1(a) { } +async function l2(a, b) { } +assert.sameValue(l0.length, 0); +assert.sameValue(l1.length, 1); +assert.sameValue(l2.length, 2) + +verifyNotWritable(l0, 'length'); +verifyNotEnumerable(l0, 'length'); +verifyConfigurable(l0, 'length'); diff --git a/test/built-ins/AsyncFunction/instance-prototype-property.js b/test/built-ins/AsyncFunction/instance-prototype-property.js new file mode 100644 index 0000000000..5be9a187e0 --- /dev/null +++ b/test/built-ins/AsyncFunction/instance-prototype-property.js @@ -0,0 +1,12 @@ +// 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 instances do not have a prototype property. +---*/ +async function foo() { }; +assert.sameValue(foo.prototype, undefined, 'foo.prototype should be undefined'); +assert(!foo.hasOwnProperty('prototype'), 'foo.prototype should not exist'); diff --git a/test/built-ins/AsyncFunction/is-not-a-global.js b/test/built-ins/AsyncFunction/is-not-a-global.js new file mode 100644 index 0000000000..22fdf20884 --- /dev/null +++ b/test/built-ins/AsyncFunction/is-not-a-global.js @@ -0,0 +1,13 @@ +// 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: > + %AsyncFunction% is not exposed as a global +---*/ + +assert.throws(ReferenceError, function () { + AsyncFunction +}, "AsyncFunction should not be present as a global"); diff --git a/test/built-ins/Function/prototype/toString/AsyncFunction.js b/test/built-ins/Function/prototype/toString/AsyncFunction.js new file mode 100644 index 0000000000..0ed8c301d1 --- /dev/null +++ b/test/built-ins/Function/prototype/toString/AsyncFunction.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: > + Function.prototype.toString on an async function created with the + AsyncFunction constructor. +features: [async-functions] +---*/ +async function f() {} +var AsyncFunction = f.constructor; +var g = /* before */AsyncFunction("a", " /* a */ b, c /* b */ //", "/* c */ ; /* d */ //")/* after */; +assert.sameValue(g.toString(), "async function anonymous(a, /* a */ b, c /* b */ //\n) {/* c */ ; /* d */ //\n}"); diff --git a/test/built-ins/Function/prototype/toString/async-function-declaration.js b/test/built-ins/Function/prototype/toString/async-function-declaration.js new file mode 100644 index 0000000000..4b909bbf7b --- /dev/null +++ b/test/built-ins/Function/prototype/toString/async-function-declaration.js @@ -0,0 +1,13 @@ +// 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: Function.prototype.toString on an async function declaration +features: [async-functions] +---*/ + +/* before */async function /* a */ f /* b */ ( /* c */ x /* d */ , /* e */ y /* f */ ) /* g */ { /* h */ ; /* i */ ; /* j */ }/* after */ + +assert.sameValue(f.toString(), "async function /* a */ f /* b */ ( /* c */ x /* d */ , /* e */ y /* f */ ) /* g */ { /* h */ ; /* i */ ; /* j */ }"); diff --git a/test/built-ins/Function/prototype/toString/async-function-expression.js b/test/built-ins/Function/prototype/toString/async-function-expression.js new file mode 100644 index 0000000000..8e7a8bf9ea --- /dev/null +++ b/test/built-ins/Function/prototype/toString/async-function-expression.js @@ -0,0 +1,13 @@ +// 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: Function.prototype.toString on an async function expression +features: [async-functions] +---*/ + +let f = /* before */async function /* a */ f /* b */ ( /* c */ x /* d */ , /* e */ y /* f */ ) /* g */ { /* h */ ; /* i */ ; /* j */ }/* after */; + +assert.sameValue(f.toString(), "async function /* a */ f /* b */ ( /* c */ x /* d */ , /* e */ y /* f */ ) /* g */ { /* h */ ; /* i */ ; /* j */ }"); diff --git a/test/built-ins/Function/prototype/toString/async-method.js b/test/built-ins/Function/prototype/toString/async-method.js new file mode 100644 index 0000000000..d711ec5bec --- /dev/null +++ b/test/built-ins/Function/prototype/toString/async-method.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: Function.prototype.toString on an async method +features: [async-functions] +---*/ + +let f = { /* before */async f /* a */ ( /* b */ ) /* c */ { /* d */ }/* after */ }.f; +let g = { /* before */async /* a */ [ /* b */ "g" /* c */ ] /* d */ ( /* e */ ) /* f */ { /* g */ }/* after */ }.g; + +assert.sameValue(f.toString(), "async f /* a */ ( /* b */ ) /* c */ { /* d */ }"); +assert.sameValue(g.toString(), "async /* a */ [ /* b */ \"g\" /* c */ ] /* d */ ( /* e */ ) /* f */ { /* g */ }"); diff --git a/test/language/expressions/async-arrow-function/arrow-returns-promise.js b/test/language/expressions/async-arrow-function/arrow-returns-promise.js new file mode 100644 index 0000000000..87827f5cc8 --- /dev/null +++ b/test/language/expressions/async-arrow-function/arrow-returns-promise.js @@ -0,0 +1,17 @@ +// 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 arrow functions return promises +flags: [async] +---*/ + +var p = (async () => await 1 + await 2)(); +assert(Object.getPrototypeOf(p) === Promise.prototype); +p.then(function (v) { + assert.sameValue(v, 3); + $DONE(); +}, $DONE); diff --git a/test/language/expressions/async-arrow-function/early-errors-arrow-NSPL-with-USD.js b/test/language/expressions/async-arrow-function/early-errors-arrow-NSPL-with-USD.js new file mode 100644 index 0000000000..c96c4c77a3 --- /dev/null +++ b/test/language/expressions/async-arrow-function/early-errors-arrow-NSPL-with-USD.js @@ -0,0 +1,12 @@ +// 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: SyntaxError +---*/ + +async (x = 1) => {"use strict"} diff --git a/test/language/expressions/async-arrow-function/early-errors-arrow-arguments-in-formal-parameters.js b/test/language/expressions/async-arrow-function/early-errors-arrow-arguments-in-formal-parameters.js new file mode 100644 index 0000000000..c3b0163991 --- /dev/null +++ b/test/language/expressions/async-arrow-function/early-errors-arrow-arguments-in-formal-parameters.js @@ -0,0 +1,13 @@ +// 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 +negative: SyntaxError +flags: [onlyStrict] +---*/ + +async(arguments) => { } + diff --git a/test/language/expressions/async-arrow-function/early-errors-arrow-await-in-formals-default.js b/test/language/expressions/async-arrow-function/early-errors-arrow-await-in-formals-default.js new file mode 100644 index 0000000000..b33839ad41 --- /dev/null +++ b/test/language/expressions/async-arrow-function/early-errors-arrow-await-in-formals-default.js @@ -0,0 +1,10 @@ +// 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: SyntaxError +---*/ +async(x = await) => { } diff --git a/test/language/expressions/async-arrow-function/early-errors-arrow-await-in-formals.js b/test/language/expressions/async-arrow-function/early-errors-arrow-await-in-formals.js new file mode 100644 index 0000000000..36ad10600f --- /dev/null +++ b/test/language/expressions/async-arrow-function/early-errors-arrow-await-in-formals.js @@ -0,0 +1,10 @@ +// 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: SyntaxError +---*/ +async(await) => { } diff --git a/test/language/expressions/async-arrow-function/early-errors-arrow-body-contains-super-call.js b/test/language/expressions/async-arrow-function/early-errors-arrow-body-contains-super-call.js new file mode 100644 index 0000000000..5c1fb0a8f5 --- /dev/null +++ b/test/language/expressions/async-arrow-function/early-errors-arrow-body-contains-super-call.js @@ -0,0 +1,11 @@ +// 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: SyntaxError +---*/ + +async(foo) => { super() }; diff --git a/test/language/expressions/async-arrow-function/early-errors-arrow-body-contains-super-property.js b/test/language/expressions/async-arrow-function/early-errors-arrow-body-contains-super-property.js new file mode 100644 index 0000000000..35e8eaad12 --- /dev/null +++ b/test/language/expressions/async-arrow-function/early-errors-arrow-body-contains-super-property.js @@ -0,0 +1,11 @@ +// 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: SyntaxError +---*/ + +async(foo) => { super.prop }; diff --git a/test/language/expressions/async-arrow-function/early-errors-arrow-duplicate-parameters.js b/test/language/expressions/async-arrow-function/early-errors-arrow-duplicate-parameters.js new file mode 100644 index 0000000000..280162b188 --- /dev/null +++ b/test/language/expressions/async-arrow-function/early-errors-arrow-duplicate-parameters.js @@ -0,0 +1,13 @@ +// 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: SyntaxError +flags: [onlyStrict] +---*/ + +async(a, a) => { } diff --git a/test/language/expressions/async-arrow-function/early-errors-arrow-eval-in-formal-parameters.js b/test/language/expressions/async-arrow-function/early-errors-arrow-eval-in-formal-parameters.js new file mode 100644 index 0000000000..595d3ee021 --- /dev/null +++ b/test/language/expressions/async-arrow-function/early-errors-arrow-eval-in-formal-parameters.js @@ -0,0 +1,12 @@ +// 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 +negative: SyntaxError +flags: [onlyStrict] +---*/ + +async(eval) => { } diff --git a/test/language/expressions/async-arrow-function/early-errors-arrow-formals-body-duplicate.js b/test/language/expressions/async-arrow-function/early-errors-arrow-formals-body-duplicate.js new file mode 100644 index 0000000000..97c6201d4f --- /dev/null +++ b/test/language/expressions/async-arrow-function/early-errors-arrow-formals-body-duplicate.js @@ -0,0 +1,11 @@ +// 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: SyntaxError +---*/ + +async(bar) => { let bar; } diff --git a/test/language/expressions/async-arrow-function/early-errors-arrow-formals-contains-super-call.js b/test/language/expressions/async-arrow-function/early-errors-arrow-formals-contains-super-call.js new file mode 100644 index 0000000000..73f67feb49 --- /dev/null +++ b/test/language/expressions/async-arrow-function/early-errors-arrow-formals-contains-super-call.js @@ -0,0 +1,11 @@ +// 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: SyntaxError +---*/ + +async(foo = super()) => {} diff --git a/test/language/expressions/async-arrow-function/early-errors-arrow-formals-contains-super-property.js b/test/language/expressions/async-arrow-function/early-errors-arrow-formals-contains-super-property.js new file mode 100644 index 0000000000..8e14b1e61b --- /dev/null +++ b/test/language/expressions/async-arrow-function/early-errors-arrow-formals-contains-super-property.js @@ -0,0 +1,11 @@ +// 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: SyntaxError +---*/ + +async (foo = super.foo) => { } diff --git a/test/language/expressions/async-function/early-errors-expression-NSPL-with-USD.js b/test/language/expressions/async-function/early-errors-expression-NSPL-with-USD.js new file mode 100644 index 0000000000..e52af62cf7 --- /dev/null +++ b/test/language/expressions/async-function/early-errors-expression-NSPL-with-USD.js @@ -0,0 +1,12 @@ +// 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: SyntaxError +---*/ + +(async function (x = 1) {"use strict"}) diff --git a/test/language/expressions/async-function/early-errors-expression-binding-identifier-arguments.js b/test/language/expressions/async-function/early-errors-expression-binding-identifier-arguments.js new file mode 100644 index 0000000000..87b3ba9f1d --- /dev/null +++ b/test/language/expressions/async-function/early-errors-expression-binding-identifier-arguments.js @@ -0,0 +1,13 @@ +// 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: SyntaxError +flags: [onlyStrict] +---*/ +(async function arguments () { }) + diff --git a/test/language/expressions/async-function/early-errors-expression-binding-identifier-eval.js b/test/language/expressions/async-function/early-errors-expression-binding-identifier-eval.js new file mode 100644 index 0000000000..16050d5b85 --- /dev/null +++ b/test/language/expressions/async-function/early-errors-expression-binding-identifier-eval.js @@ -0,0 +1,12 @@ +// 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: SyntaxError +flags: [onlyStrict] +---*/ +(async function eval () { }) diff --git a/test/language/expressions/async-function/early-errors-expression-body-contains-super-call.js b/test/language/expressions/async-function/early-errors-expression-body-contains-super-call.js new file mode 100644 index 0000000000..e27fb987b4 --- /dev/null +++ b/test/language/expressions/async-function/early-errors-expression-body-contains-super-call.js @@ -0,0 +1,11 @@ +// 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: SyntaxError +---*/ + +(async function foo (foo) { super() }) diff --git a/test/language/expressions/async-function/early-errors-expression-body-contains-super-property.js b/test/language/expressions/async-function/early-errors-expression-body-contains-super-property.js new file mode 100644 index 0000000000..3539109e20 --- /dev/null +++ b/test/language/expressions/async-function/early-errors-expression-body-contains-super-property.js @@ -0,0 +1,12 @@ +// 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: SyntaxError +---*/ + +(async function foo (foo) { super.prop }); + diff --git a/test/language/expressions/async-function/early-errors-expression-eval-in-formal-parameters.js b/test/language/expressions/async-function/early-errors-expression-eval-in-formal-parameters.js new file mode 100644 index 0000000000..972b30863f --- /dev/null +++ b/test/language/expressions/async-function/early-errors-expression-eval-in-formal-parameters.js @@ -0,0 +1,12 @@ +// 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: SyntaxError +flags: [onlyStrict] +---*/ + +(async function foo (eval) { }) diff --git a/test/language/expressions/async-function/early-errors-expression-formals-body-duplicate.js b/test/language/expressions/async-function/early-errors-expression-formals-body-duplicate.js new file mode 100644 index 0000000000..8414ce634f --- /dev/null +++ b/test/language/expressions/async-function/early-errors-expression-formals-body-duplicate.js @@ -0,0 +1,11 @@ +// 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: SyntaxError +---*/ + +(async function foo (bar) { let bar; }); diff --git a/test/language/expressions/async-function/early-errors-expression-formals-contains-super-call.js b/test/language/expressions/async-function/early-errors-expression-formals-contains-super-call.js new file mode 100644 index 0000000000..6997deb7d8 --- /dev/null +++ b/test/language/expressions/async-function/early-errors-expression-formals-contains-super-call.js @@ -0,0 +1,11 @@ +// 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: SyntaxError +---*/ + +(async function foo (foo = super()) { var bar; }); diff --git a/test/language/expressions/async-function/early-errors-expression-formals-contains-super-property.js b/test/language/expressions/async-function/early-errors-expression-formals-contains-super-property.js new file mode 100644 index 0000000000..04110a5aa4 --- /dev/null +++ b/test/language/expressions/async-function/early-errors-expression-formals-contains-super-property.js @@ -0,0 +1,11 @@ +// 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: SyntaxError +---*/ + +(async function foo (foo = super.foo) { var bar; }); diff --git a/test/language/expressions/async-function/early-errors-expression-not-simple-assignment-target.js b/test/language/expressions/async-function/early-errors-expression-not-simple-assignment-target.js new file mode 100644 index 0000000000..49555f399b --- /dev/null +++ b/test/language/expressions/async-function/early-errors-expression-not-simple-assignment-target.js @@ -0,0 +1,12 @@ +// 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 expressions are not a simple assignment target. +negative: ReferenceError +---*/ + +(async function foo() { } = 1) diff --git a/test/language/expressions/async-function/expression-returns-promise.js b/test/language/expressions/async-function/expression-returns-promise.js new file mode 100644 index 0000000000..3300674f4c --- /dev/null +++ b/test/language/expressions/async-function/expression-returns-promise.js @@ -0,0 +1,12 @@ +// 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 expressions return promises +---*/ + +var p = async function() { }(); +assert(p instanceof Promise, "async functions return promise instances"); diff --git a/test/language/expressions/async-function/syntax-expression-is-PrimaryExpression.js b/test/language/expressions/async-function/syntax-expression-is-PrimaryExpression.js new file mode 100644 index 0000000000..992c363850 --- /dev/null +++ b/test/language/expressions/async-function/syntax-expression-is-PrimaryExpression.js @@ -0,0 +1,11 @@ +// 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 expressions are PrimaryExpressions +---*/ + +(async function foo() { }.prototype) diff --git a/test/language/expressions/await/await-BindingIdentifier-in-global.js b/test/language/expressions/await/await-BindingIdentifier-in-global.js new file mode 100644 index 0000000000..1f03fb440b --- /dev/null +++ b/test/language/expressions/await/await-BindingIdentifier-in-global.js @@ -0,0 +1,13 @@ +// 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: > + Await is allowed as a binding identifier in global scope +---*/ + +async function await() { return 1 } +assert(await instanceof Function); + diff --git a/test/language/expressions/await/await-BindingIdentifier-nested.js b/test/language/expressions/await/await-BindingIdentifier-nested.js new file mode 100644 index 0000000000..a4813b607b --- /dev/null +++ b/test/language/expressions/await/await-BindingIdentifier-nested.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: > + Await is not allowed as an identifier in functions nested in async functions +negative: SyntaxError +---*/ + +async function foo() { + function await() { + } +} diff --git a/test/language/expressions/await/await-awaits-thenable-not-callable.js b/test/language/expressions/await/await-awaits-thenable-not-callable.js new file mode 100644 index 0000000000..1737c55c4d --- /dev/null +++ b/test/language/expressions/await/await-awaits-thenable-not-callable.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: > + Await can await any thenable. If the thenable's then is not callable, + await evaluates to the thenable +flags: [async] +---*/ + +async function foo() { + var thenable = { then: 42 }; + var res = await thenable; + assert.sameValue(res, thenable); +} + +foo().then($DONE, $DONE); + diff --git a/test/language/expressions/await/await-awaits-thenables-that-throw.js b/test/language/expressions/await/await-awaits-thenables-that-throw.js new file mode 100644 index 0000000000..f00302d7e0 --- /dev/null +++ b/test/language/expressions/await/await-awaits-thenables-that-throw.js @@ -0,0 +1,31 @@ +// 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: > + Await can await any thenable. +flags: [async] +---*/ + +var error = {}; +var thenable = { + then: function (resolve, reject) { + throw error; + } +} +async function foo() { + var caught = false; + try { + await thenable; + } catch(e) { + caught = true; + assert.sameValue(e, error); + } + + assert(caught); +} + +foo().then($DONE, $DONE); + diff --git a/test/language/expressions/await/await-awaits-thenables.js b/test/language/expressions/await/await-awaits-thenables.js new file mode 100644 index 0000000000..1f0aafa5ab --- /dev/null +++ b/test/language/expressions/await/await-awaits-thenables.js @@ -0,0 +1,21 @@ +// 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: > + Await can await any thenable. +flags: [async] +---*/ + +var thenable = { + then: function (resolve, reject) { + resolve(42); + } +} +async function foo() { + assert.sameValue(await thenable, 42); +} + +foo().then($DONE, $DONE); diff --git a/test/language/expressions/await/await-in-function.js b/test/language/expressions/await/await-in-function.js new file mode 100644 index 0000000000..91e0788e83 --- /dev/null +++ b/test/language/expressions/await/await-in-function.js @@ -0,0 +1,12 @@ +// 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: > + Await is an identifier in a function +---*/ + +function foo(await) { return await; } +assert.sameValue(foo(1), 1); diff --git a/test/language/expressions/await/await-in-generator.js b/test/language/expressions/await/await-in-generator.js new file mode 100644 index 0000000000..4fc9398cd9 --- /dev/null +++ b/test/language/expressions/await/await-in-generator.js @@ -0,0 +1,12 @@ +// 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: > + Await in a generator is an identifier +---*/ + +function* foo(await) { yield await; }; +assert.sameValue(foo(1).next().value, 1); diff --git a/test/language/expressions/await/await-in-global.js b/test/language/expressions/await/await-in-global.js new file mode 100644 index 0000000000..581cd3ec4f --- /dev/null +++ b/test/language/expressions/await/await-in-global.js @@ -0,0 +1,12 @@ +// 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: > + Await is an identifier in global scope +---*/ + +var await = 1; +assert.sameValue(await, 1); diff --git a/test/language/expressions/await/await-in-nested-function.js b/test/language/expressions/await/await-in-nested-function.js new file mode 100644 index 0000000000..370d1c39c7 --- /dev/null +++ b/test/language/expressions/await/await-in-nested-function.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: > + Await is allowed as an identifier in functions nested in async functions +---*/ + +var await; +async function foo() { + function bar() { + await = 1; + } + bar(); +} +foo(); + +assert.sameValue(await, 1); diff --git a/test/language/expressions/await/await-in-nested-generator.js b/test/language/expressions/await/await-in-nested-generator.js new file mode 100644 index 0000000000..4e9268745f --- /dev/null +++ b/test/language/expressions/await/await-in-nested-generator.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: > + Await is allowed as an identifier in generator functions nested in async functions +---*/ + +var await; +async function foo() { + function* bar() { + await = 1; + } + bar().next(); +} +foo(); + +assert.sameValue(await, 1); diff --git a/test/language/expressions/await/await-throws-rejections.js b/test/language/expressions/await/await-throws-rejections.js new file mode 100644 index 0000000000..1be6084076 --- /dev/null +++ b/test/language/expressions/await/await-throws-rejections.js @@ -0,0 +1,23 @@ +// 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: > + Await throws errors from rejected promises +---*/ + +async function foo() { + var err = {}; + var caught = false; + try { + await Promise.reject(err); + } catch(e) { + caught = true; + assert.sameValue(e, err); + } + + assert(caught); +} + diff --git a/test/language/expressions/await/early-errors-await-not-simple-assignment-target.js b/test/language/expressions/await/early-errors-await-not-simple-assignment-target.js new file mode 100644 index 0000000000..4560ff9665 --- /dev/null +++ b/test/language/expressions/await/early-errors-await-not-simple-assignment-target.js @@ -0,0 +1,14 @@ +// 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: > + await is not a simple assignment target and cannot be assigned to. +negative: ReferenceError +---*/ + +async function foo() { + (await 1) = 1; +} diff --git a/test/language/expressions/await/no-operand.js b/test/language/expressions/await/no-operand.js new file mode 100644 index 0000000000..88705df792 --- /dev/null +++ b/test/language/expressions/await/no-operand.js @@ -0,0 +1,14 @@ +// 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: > + await requries an operand. +negative: SyntaxError +---*/ + +async function foo() { + await; +} diff --git a/test/language/expressions/await/syntax-await-has-UnaryExpression-with-MultiplicativeExpression.js b/test/language/expressions/await/syntax-await-has-UnaryExpression-with-MultiplicativeExpression.js new file mode 100644 index 0000000000..27cbbe28b6 --- /dev/null +++ b/test/language/expressions/await/syntax-await-has-UnaryExpression-with-MultiplicativeExpression.js @@ -0,0 +1,17 @@ +// 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: > + Await's operand is a UnaryExpression +flags: [async] +---*/ + +async function foo() { + let x = 2; + let y = await Promise.resolve(2) * x + assert.sameValue(y, 4); +} +foo().then($DONE, $DONE); diff --git a/test/language/expressions/await/syntax-await-has-UnaryExpression.js b/test/language/expressions/await/syntax-await-has-UnaryExpression.js new file mode 100644 index 0000000000..688b28ec2e --- /dev/null +++ b/test/language/expressions/await/syntax-await-has-UnaryExpression.js @@ -0,0 +1,18 @@ +// 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: > + Await's operand is a UnaryExpression +flags: [async] +---*/ + +async function foo() { + let x = 1; + let y = await x++; + assert.sameValue(y, 1); + assert.sameValue(x, 2); +} +foo().then($DONE, $DONE); diff --git a/test/language/expressions/object/method-definition/async-super-call-body.js b/test/language/expressions/object/method-definition/async-super-call-body.js new file mode 100644 index 0000000000..40459314f6 --- /dev/null +++ b/test/language/expressions/object/method-definition/async-super-call-body.js @@ -0,0 +1,26 @@ +// 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: > + Super calls work in body of async methods +flags: [async] +---*/ + +var sup = { + method() { + return 'sup'; + } +} + +var child = { + __proto__: sup, + async method() { + var x = await super.method(); + assert.sameValue(x, 'sup'); + } +} + +child.method().then($DONE, $DONE); diff --git a/test/language/expressions/object/method-definition/async-super-call-param.js b/test/language/expressions/object/method-definition/async-super-call-param.js new file mode 100644 index 0000000000..5eb55b18cf --- /dev/null +++ b/test/language/expressions/object/method-definition/async-super-call-param.js @@ -0,0 +1,27 @@ +// 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: > + Super calls work in parameter list of async methods +flags: [async] +---*/ + +var sup = { + method() { + return 'sup'; + } +} + +var child = { + __proto__: sup, + async method(x = super.method()) { + var y = await x; + assert.sameValue(y, 'sup'); + } +} + +child.method().then($DONE, $DONE); + diff --git a/test/language/expressions/object/method-definition/early-errors-object-method-NSPL-with-USD.js b/test/language/expressions/object/method-definition/early-errors-object-method-NSPL-with-USD.js new file mode 100644 index 0000000000..1f88b5662c --- /dev/null +++ b/test/language/expressions/object/method-definition/early-errors-object-method-NSPL-with-USD.js @@ -0,0 +1,13 @@ +// 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: SyntaxError +---*/ +({ + foo(x = 1) {"use strict"} +}); diff --git a/test/language/expressions/object/method-definition/early-errors-object-method-arguments-in-formal-parameters.js b/test/language/expressions/object/method-definition/early-errors-object-method-arguments-in-formal-parameters.js new file mode 100644 index 0000000000..049113d84d --- /dev/null +++ b/test/language/expressions/object/method-definition/early-errors-object-method-arguments-in-formal-parameters.js @@ -0,0 +1,13 @@ +// 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 +negative: SyntaxError +flags: [onlyStrict] +---*/ +!{ + async foo (arguments) { } +} diff --git a/test/language/expressions/object/method-definition/early-errors-object-method-await-in-formals-default.js b/test/language/expressions/object/method-definition/early-errors-object-method-await-in-formals-default.js new file mode 100644 index 0000000000..68c37c0b02 --- /dev/null +++ b/test/language/expressions/object/method-definition/early-errors-object-method-await-in-formals-default.js @@ -0,0 +1,13 @@ +// 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: SyntaxError +---*/ +!{ + async foo (x = await) { } +} + diff --git a/test/language/expressions/object/method-definition/early-errors-object-method-await-in-formals.js b/test/language/expressions/object/method-definition/early-errors-object-method-await-in-formals.js new file mode 100644 index 0000000000..b390fd2a93 --- /dev/null +++ b/test/language/expressions/object/method-definition/early-errors-object-method-await-in-formals.js @@ -0,0 +1,12 @@ +// 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: SyntaxError +---*/ +!{ + async foo (await) { } +} diff --git a/test/language/expressions/object/method-definition/early-errors-object-method-body-contains-super-call.js b/test/language/expressions/object/method-definition/early-errors-object-method-body-contains-super-call.js new file mode 100644 index 0000000000..3eda771523 --- /dev/null +++ b/test/language/expressions/object/method-definition/early-errors-object-method-body-contains-super-call.js @@ -0,0 +1,12 @@ +// 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 AsyncFunctionBody contains SuperCall is true +negative: SyntaxError +---*/ +!{ + async foo () { super() } +} diff --git a/test/language/expressions/object/method-definition/early-errors-object-method-duplicate-parameters.js b/test/language/expressions/object/method-definition/early-errors-object-method-duplicate-parameters.js new file mode 100644 index 0000000000..9282c45e6a --- /dev/null +++ b/test/language/expressions/object/method-definition/early-errors-object-method-duplicate-parameters.js @@ -0,0 +1,13 @@ +// 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: > + Early error rules for StrictFormalParameters are applied +negative: SyntaxError +---*/ +!{ + async foo(a, a) { } +} diff --git a/test/language/expressions/object/method-definition/early-errors-object-method-eval-in-formal-parameters.js b/test/language/expressions/object/method-definition/early-errors-object-method-eval-in-formal-parameters.js new file mode 100644 index 0000000000..9eb6231406 --- /dev/null +++ b/test/language/expressions/object/method-definition/early-errors-object-method-eval-in-formal-parameters.js @@ -0,0 +1,13 @@ +// 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: SyntaxError +flags: [onlyStrict] +---*/ +!{ + async foo(eval) { } +} diff --git a/test/language/expressions/object/method-definition/early-errors-object-method-formals-body-duplicate.js b/test/language/expressions/object/method-definition/early-errors-object-method-formals-body-duplicate.js new file mode 100644 index 0000000000..d8697085fd --- /dev/null +++ b/test/language/expressions/object/method-definition/early-errors-object-method-formals-body-duplicate.js @@ -0,0 +1,13 @@ +// 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: SyntaxError +---*/ + +!{ + async function foo(bar) { let bar; } +} diff --git a/test/language/expressions/object/method-definition/early-errors-object-method-formals-contains-super-call.js b/test/language/expressions/object/method-definition/early-errors-object-method-formals-contains-super-call.js new file mode 100644 index 0000000000..b46d1ea4b5 --- /dev/null +++ b/test/language/expressions/object/method-definition/early-errors-object-method-formals-contains-super-call.js @@ -0,0 +1,12 @@ +// 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: SyntaxError +---*/ +!{ + async foo(foo = super()) { } +} diff --git a/test/language/expressions/object/method-definition/object-method-returns-promise.js b/test/language/expressions/object/method-definition/object-method-returns-promise.js new file mode 100644 index 0000000000..47bdc0e87a --- /dev/null +++ b/test/language/expressions/object/method-definition/object-method-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 function method definitions return promises +---*/ +var obj = { + async method() {} +} +var p = obj.method(); +assert(p instanceof Promise, "async functions return promise instances"); + diff --git a/test/language/statements/async-function/declaration-returns-promise.js b/test/language/statements/async-function/declaration-returns-promise.js new file mode 100644 index 0000000000..dcd41c83fa --- /dev/null +++ b/test/language/statements/async-function/declaration-returns-promise.js @@ -0,0 +1,13 @@ +// 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"); diff --git a/test/language/statements/async-function/early-errors-declaration-NSPL-with-USD.js b/test/language/statements/async-function/early-errors-declaration-NSPL-with-USD.js new file mode 100644 index 0000000000..2284554d85 --- /dev/null +++ b/test/language/statements/async-function/early-errors-declaration-NSPL-with-USD.js @@ -0,0 +1,12 @@ +// 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: SyntaxError +---*/ + +async function foo(x = 1){"use strict"} diff --git a/test/language/statements/async-function/early-errors-declaration-arguments-in-formal-parameters.js b/test/language/statements/async-function/early-errors-declaration-arguments-in-formal-parameters.js new file mode 100644 index 0000000000..6bfb5c8974 --- /dev/null +++ b/test/language/statements/async-function/early-errors-declaration-arguments-in-formal-parameters.js @@ -0,0 +1,13 @@ +// 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: SyntaxError +flags: [onlyStrict] +---*/ + +async function foo (arguments) { } + diff --git a/test/language/statements/async-function/early-errors-declaration-await-in-formals-default.js b/test/language/statements/async-function/early-errors-declaration-await-in-formals-default.js new file mode 100644 index 0000000000..aa3e5e5159 --- /dev/null +++ b/test/language/statements/async-function/early-errors-declaration-await-in-formals-default.js @@ -0,0 +1,10 @@ +// 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: SyntaxError +---*/ +async function foo (x = await) { } diff --git a/test/language/statements/async-function/early-errors-declaration-await-in-formals.js b/test/language/statements/async-function/early-errors-declaration-await-in-formals.js new file mode 100644 index 0000000000..ee57dcd19c --- /dev/null +++ b/test/language/statements/async-function/early-errors-declaration-await-in-formals.js @@ -0,0 +1,10 @@ +// 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: SyntaxError +---*/ +async function foo (await) { } diff --git a/test/language/statements/async-function/early-errors-declaration-binding-identifier-arguments.js b/test/language/statements/async-function/early-errors-declaration-binding-identifier-arguments.js new file mode 100644 index 0000000000..225e0085e3 --- /dev/null +++ b/test/language/statements/async-function/early-errors-declaration-binding-identifier-arguments.js @@ -0,0 +1,13 @@ +// 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: SyntaxError +flags: [onlyStrict] +---*/ +async function arguments () { } + diff --git a/test/language/statements/async-function/early-errors-declaration-binding-identifier-eval.js b/test/language/statements/async-function/early-errors-declaration-binding-identifier-eval.js new file mode 100644 index 0000000000..ea9a58e962 --- /dev/null +++ b/test/language/statements/async-function/early-errors-declaration-binding-identifier-eval.js @@ -0,0 +1,12 @@ +// 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: SyntaxError +flags: [onlyStrict] +---*/ +async function eval () { } diff --git a/test/language/statements/async-function/early-errors-declaration-body-contains-super-call.js b/test/language/statements/async-function/early-errors-declaration-body-contains-super-call.js new file mode 100644 index 0000000000..b4ad18cccc --- /dev/null +++ b/test/language/statements/async-function/early-errors-declaration-body-contains-super-call.js @@ -0,0 +1,11 @@ +// 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: SyntaxError +---*/ + +async function foo (foo) { super() }; diff --git a/test/language/statements/async-function/early-errors-declaration-body-contains-super-property.js b/test/language/statements/async-function/early-errors-declaration-body-contains-super-property.js new file mode 100644 index 0000000000..53fb87e10c --- /dev/null +++ b/test/language/statements/async-function/early-errors-declaration-body-contains-super-property.js @@ -0,0 +1,11 @@ +// 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: SyntaxError +---*/ + +async function foo (foo) { super.prop }; diff --git a/test/language/statements/async-function/early-errors-declaration-duplicate-parameters.js b/test/language/statements/async-function/early-errors-declaration-duplicate-parameters.js new file mode 100644 index 0000000000..f91c35c614 --- /dev/null +++ b/test/language/statements/async-function/early-errors-declaration-duplicate-parameters.js @@ -0,0 +1,13 @@ +// 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: SyntaxError +flags: [onlyStrict] +---*/ + +async function foo(a, a) { } diff --git a/test/language/statements/async-function/early-errors-declaration-eval-in-formal-parameters.js b/test/language/statements/async-function/early-errors-declaration-eval-in-formal-parameters.js new file mode 100644 index 0000000000..f2b24adaa7 --- /dev/null +++ b/test/language/statements/async-function/early-errors-declaration-eval-in-formal-parameters.js @@ -0,0 +1,12 @@ +// 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: SyntaxError +flags: [onlyStrict] +---*/ + +async function foo (eval) { } diff --git a/test/language/statements/async-function/early-errors-declaration-formals-body-duplicate.js b/test/language/statements/async-function/early-errors-declaration-formals-body-duplicate.js new file mode 100644 index 0000000000..1de28ba4f2 --- /dev/null +++ b/test/language/statements/async-function/early-errors-declaration-formals-body-duplicate.js @@ -0,0 +1,11 @@ +// 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: SyntaxError +---*/ + +async function foo (bar) { let bar; } diff --git a/test/language/statements/async-function/early-errors-declaration-formals-contains-super-call.js b/test/language/statements/async-function/early-errors-declaration-formals-contains-super-call.js new file mode 100644 index 0000000000..bdd6e2b55d --- /dev/null +++ b/test/language/statements/async-function/early-errors-declaration-formals-contains-super-call.js @@ -0,0 +1,11 @@ +// 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: SyntaxError +---*/ + +async function foo (foo = super()) { let bar; } diff --git a/test/language/statements/async-function/early-errors-declaration-formals-contains-super-property.js b/test/language/statements/async-function/early-errors-declaration-formals-contains-super-property.js new file mode 100644 index 0000000000..d68260db71 --- /dev/null +++ b/test/language/statements/async-function/early-errors-declaration-formals-contains-super-property.js @@ -0,0 +1,11 @@ +// 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: SyntaxError +---*/ + +async function foo (foo = super.foo) { let bar; } diff --git a/test/language/statements/async-function/early-errors-no-async-generator.js b/test/language/statements/async-function/early-errors-no-async-generator.js new file mode 100644 index 0000000000..4e4d2e44a7 --- /dev/null +++ b/test/language/statements/async-function/early-errors-no-async-generator.js @@ -0,0 +1,12 @@ +// 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 generators are not a thing (yet) +negative: SyntaxError +---*/ + +async function* foo() { } diff --git a/test/language/statements/async-function/evaluation-body-that-returns-after-await.js b/test/language/statements/async-function/evaluation-body-that-returns-after-await.js new file mode 100644 index 0000000000..7c5643aa60 --- /dev/null +++ b/test/language/statements/async-function/evaluation-body-that-returns-after-await.js @@ -0,0 +1,21 @@ +// 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/test/language/statements/async-function/evaluation-body-that-returns.js b/test/language/statements/async-function/evaluation-body-that-returns.js new file mode 100644 index 0000000000..9749621c20 --- /dev/null +++ b/test/language/statements/async-function/evaluation-body-that-returns.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: > + 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/test/language/statements/async-function/evaluation-body-that-throws-after-await.js b/test/language/statements/async-function/evaluation-body-that-throws-after-await.js new file mode 100644 index 0000000000..c8d2f22dab --- /dev/null +++ b/test/language/statements/async-function/evaluation-body-that-throws-after-await.js @@ -0,0 +1,24 @@ +// 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/test/language/statements/async-function/evaluation-body-that-throws.js b/test/language/statements/async-function/evaluation-body-that-throws.js new file mode 100644 index 0000000000..1f841cf135 --- /dev/null +++ b/test/language/statements/async-function/evaluation-body-that-throws.js @@ -0,0 +1,22 @@ +// 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/test/language/statements/async-function/evaluation-body.js b/test/language/statements/async-function/evaluation-body.js new file mode 100644 index 0000000000..e2d7c95ad4 --- /dev/null +++ b/test/language/statements/async-function/evaluation-body.js @@ -0,0 +1,18 @@ +// 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); diff --git a/test/language/statements/async-function/evaluation-default-that-throws.js b/test/language/statements/async-function/evaluation-default-that-throws.js new file mode 100644 index 0000000000..f4d07b1192 --- /dev/null +++ b/test/language/statements/async-function/evaluation-default-that-throws.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: > + 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/test/language/statements/async-function/evaluation-mapped-arguments.js b/test/language/statements/async-function/evaluation-mapped-arguments.js new file mode 100644 index 0000000000..b1b54f4b00 --- /dev/null +++ b/test/language/statements/async-function/evaluation-mapped-arguments.js @@ -0,0 +1,22 @@ +// 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/test/language/statements/async-function/evaluation-this-value-global.js b/test/language/statements/async-function/evaluation-this-value-global.js new file mode 100644 index 0000000000..7ba9e89350 --- /dev/null +++ b/test/language/statements/async-function/evaluation-this-value-global.js @@ -0,0 +1,17 @@ +// 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] +---*/ + +var glob = this; +async function foo() { + assert.sameValue(this, glob); +} + +foo().then($DONE, $DONE); diff --git a/test/language/statements/async-function/evaluation-this-value-passed.js b/test/language/statements/async-function/evaluation-this-value-passed.js new file mode 100644 index 0000000000..ee02978638 --- /dev/null +++ b/test/language/statements/async-function/evaluation-this-value-passed.js @@ -0,0 +1,18 @@ +// 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/test/language/statements/async-function/evaluation-unmapped-arguments.js b/test/language/statements/async-function/evaluation-unmapped-arguments.js new file mode 100644 index 0000000000..67b4b277a1 --- /dev/null +++ b/test/language/statements/async-function/evaluation-unmapped-arguments.js @@ -0,0 +1,23 @@ +// 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/test/language/statements/async-function/syntax-declaration-line-terminators-allowed.js b/test/language/statements/async-function/syntax-declaration-line-terminators-allowed.js new file mode 100644 index 0000000000..3709336741 --- /dev/null +++ b/test/language/statements/async-function/syntax-declaration-line-terminators-allowed.js @@ -0,0 +1,17 @@ +// 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); diff --git a/test/language/statements/async-function/syntax-declaration-no-line-terminator.js b/test/language/statements/async-function/syntax-declaration-no-line-terminator.js new file mode 100644 index 0000000000..f8c8262688 --- /dev/null +++ b/test/language/statements/async-function/syntax-declaration-no-line-terminator.js @@ -0,0 +1,13 @@ +// 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() {} +}); diff --git a/test/language/statements/async-function/syntax-declaration.js b/test/language/statements/async-function/syntax-declaration.js new file mode 100644 index 0000000000..23748008e3 --- /dev/null +++ b/test/language/statements/async-function/syntax-declaration.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 declaration returns a promise +flags: [async] +---*/ + +async function foo () { } + +foo().then(function() { + $DONE(); +}) diff --git a/test/language/statements/class/definition/class-method-returns-promise.js b/test/language/statements/class/definition/class-method-returns-promise.js new file mode 100644 index 0000000000..a0bc6064e7 --- /dev/null +++ b/test/language/statements/class/definition/class-method-returns-promise.js @@ -0,0 +1,14 @@ +// 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 expressions return promises +---*/ +class Foo { + async method() {}; +} +var p = new Foo().method(); +assert(p instanceof Promise, "async functions return promise instances"); diff --git a/test/language/statements/class/definition/early-errors-class-method-NSPL-with-USD.js b/test/language/statements/class/definition/early-errors-class-method-NSPL-with-USD.js new file mode 100644 index 0000000000..1df3a557dd --- /dev/null +++ b/test/language/statements/class/definition/early-errors-class-method-NSPL-with-USD.js @@ -0,0 +1,13 @@ +// 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: SyntaxError +---*/ +class Foo { + async bar(x = 1) {"use strict"} +} diff --git a/test/language/statements/class/definition/early-errors-class-method-arguments-in-formal-parameters.js b/test/language/statements/class/definition/early-errors-class-method-arguments-in-formal-parameters.js new file mode 100644 index 0000000000..e19517e009 --- /dev/null +++ b/test/language/statements/class/definition/early-errors-class-method-arguments-in-formal-parameters.js @@ -0,0 +1,12 @@ +// 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 +negative: SyntaxError +---*/ +class Foo { + async foo (arguments) { } +} diff --git a/test/language/statements/class/definition/early-errors-class-method-await-in-formals-default.js b/test/language/statements/class/definition/early-errors-class-method-await-in-formals-default.js new file mode 100644 index 0000000000..4575aa1d9e --- /dev/null +++ b/test/language/statements/class/definition/early-errors-class-method-await-in-formals-default.js @@ -0,0 +1,13 @@ +// 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: SyntaxError +---*/ +class Foo { + async foo (x = await) { } +} + diff --git a/test/language/statements/class/definition/early-errors-class-method-await-in-formals.js b/test/language/statements/class/definition/early-errors-class-method-await-in-formals.js new file mode 100644 index 0000000000..5a0512b3c8 --- /dev/null +++ b/test/language/statements/class/definition/early-errors-class-method-await-in-formals.js @@ -0,0 +1,12 @@ +// 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: SyntaxError +---*/ +class Foo { + async foo (await) { } +} diff --git a/test/language/statements/class/definition/early-errors-class-method-body-contains-super-call.js b/test/language/statements/class/definition/early-errors-class-method-body-contains-super-call.js new file mode 100644 index 0000000000..5e0814155c --- /dev/null +++ b/test/language/statements/class/definition/early-errors-class-method-body-contains-super-call.js @@ -0,0 +1,12 @@ +// 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 AsyncFunctionBody contains SuperCall is true +negative: SyntaxError +---*/ +class Foo { + async foo () { super() } +} diff --git a/test/language/statements/class/definition/early-errors-class-method-duplicate-parameters.js b/test/language/statements/class/definition/early-errors-class-method-duplicate-parameters.js new file mode 100644 index 0000000000..aaa491c938 --- /dev/null +++ b/test/language/statements/class/definition/early-errors-class-method-duplicate-parameters.js @@ -0,0 +1,14 @@ +// 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: > + Early error rules for StrictFormalParameters are applied +negative: SyntaxError +---*/ + +class Foo { + async foo(a, a) { } +} diff --git a/test/language/statements/class/definition/early-errors-class-method-eval-in-formal-parameters.js b/test/language/statements/class/definition/early-errors-class-method-eval-in-formal-parameters.js new file mode 100644 index 0000000000..2f4341fb55 --- /dev/null +++ b/test/language/statements/class/definition/early-errors-class-method-eval-in-formal-parameters.js @@ -0,0 +1,12 @@ +// 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: SyntaxError +---*/ +class Foo { + async foo(eval) { } +} diff --git a/test/language/statements/class/definition/early-errors-class-method-formals-body-duplicate.js b/test/language/statements/class/definition/early-errors-class-method-formals-body-duplicate.js new file mode 100644 index 0000000000..f7170dc9db --- /dev/null +++ b/test/language/statements/class/definition/early-errors-class-method-formals-body-duplicate.js @@ -0,0 +1,14 @@ +// 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: SyntaxError +---*/ + +class Foo { + async function foo(bar) { let bar; } +} diff --git a/test/language/statements/class/definition/early-errors-class-method-formals-contains-super-call.js b/test/language/statements/class/definition/early-errors-class-method-formals-contains-super-call.js new file mode 100644 index 0000000000..8103422068 --- /dev/null +++ b/test/language/statements/class/definition/early-errors-class-method-formals-contains-super-call.js @@ -0,0 +1,12 @@ +// 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: SyntaxError +---*/ +class Foo { + async foo(foo = super()) { } +} diff --git a/test/language/statements/class/definition/methods-async-super-call-body.js b/test/language/statements/class/definition/methods-async-super-call-body.js new file mode 100644 index 0000000000..5999137619 --- /dev/null +++ b/test/language/statements/class/definition/methods-async-super-call-body.js @@ -0,0 +1,25 @@ +// 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: > + Super calls work in body of async methods +flags: [async] +---*/ +class A { + async method() { + return 'sup'; + } +} + +class B extends A { + async method() { + var x = await super.method(); + assert.sameValue(x, 'sup'); + } +} +var child = new B(); +child.method().then($DONE, $DONE); + diff --git a/test/language/statements/class/definition/methods-async-super-call-param.js b/test/language/statements/class/definition/methods-async-super-call-param.js new file mode 100644 index 0000000000..4375b932f9 --- /dev/null +++ b/test/language/statements/class/definition/methods-async-super-call-param.js @@ -0,0 +1,24 @@ +// 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: > + Super calls work in the parameter list of async methods +flags: [async] +---*/ + +class A { + async method() { + return 'sup'; + } +} + +class B extends A { + async method(x = super.method()) { + assert.sameValue(await x, 'sup'); + } +} +var child = new B(); +child.method().then($DONE, $DONE); -- GitLab