diff --git a/test/built-ins/AsyncFunction/AsyncFunction-construct.js b/test/built-ins/AsyncFunction/AsyncFunction-construct.js new file mode 100644 index 0000000000000000000000000000000000000000..e28ead10e72fde52fe4e1808573acaee8c4084b6 --- /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 0000000000000000000000000000000000000000..f1e790b2a04e29c9c83b38530e0a912a752dbee3 --- /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 0000000000000000000000000000000000000000..0237591d8bfe3d683cb796ce99a42d4c4df833f8 --- /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 0000000000000000000000000000000000000000..3258fde5679e13805ddb8fb6766eddfc728665a5 --- /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 0000000000000000000000000000000000000000..5b9b4a0d5f41efbe9d8ad5d8f27299c4d7c3b197 --- /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 0000000000000000000000000000000000000000..91ce757884c24be700222ace4f320e93190b2458 --- /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 0000000000000000000000000000000000000000..358f3a706c636f0b60dbd6e437a7560331816aae --- /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 0000000000000000000000000000000000000000..d2ddcc1ab4482610807a2da7ad142fa738d1b02d --- /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 0000000000000000000000000000000000000000..f0d30861702ea0055fde0361a092a1955a7c1af3 --- /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 0000000000000000000000000000000000000000..eb3d468681570f68fd3774337279ec8ffa39eb60 --- /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 0000000000000000000000000000000000000000..00a9354ac50f416f4133c148e6401c1054168560 --- /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 0000000000000000000000000000000000000000..ba35a8c5ba1fcab94dd595ae713326dda6f443d8 --- /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 0000000000000000000000000000000000000000..9f636af05b3ae7d08395b0d0c30737d314fbf318 --- /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 0000000000000000000000000000000000000000..5be9a187e09259e48f64a3716f52789154eaddc0 --- /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 0000000000000000000000000000000000000000..22fdf2088412be6733b114a364736558dc11625b --- /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 0000000000000000000000000000000000000000..0ed8c301d158e0cc086b79d7941b443c05379bb5 --- /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 0000000000000000000000000000000000000000..4b909bbf7bd56023bbdc027720b929cb4e3df660 --- /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 0000000000000000000000000000000000000000..8e7a8bf9eaddaced20bf4b495539a203a63d75bd --- /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 0000000000000000000000000000000000000000..d711ec5bec5d9afd0c7afbf51fd9d62fec84999d --- /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 0000000000000000000000000000000000000000..87827f5cc818b74050ba4d4c29f1ac365f98412d --- /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 0000000000000000000000000000000000000000..c96c4c77a3deb4f97097aecb5531d283666ee967 --- /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 0000000000000000000000000000000000000000..c3b0163991088f815896dde0da9a93a7107df213 --- /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 0000000000000000000000000000000000000000..b33839ad419e0087a0d5cf51b1aa1513e59ccf93 --- /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 0000000000000000000000000000000000000000..36ad10600fd6038b27b58d2bf7d112d87f800376 --- /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 0000000000000000000000000000000000000000..5c1fb0a8f5eacd70dbba4af71c76b8b2a2a2b870 --- /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 0000000000000000000000000000000000000000..35e8eaad12c05e13db05d87b449eb8d05d4a5b22 --- /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 0000000000000000000000000000000000000000..280162b188ca3f946e1ca5d874f4c7b645eca174 --- /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 0000000000000000000000000000000000000000..595d3ee0210aa33dd2185f01f0632a2821b4f4da --- /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 0000000000000000000000000000000000000000..97c6201d4fcb98448d5cc0e159670c796a92f4eb --- /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 0000000000000000000000000000000000000000..73f67feb499e76c60137eef753c2a357f87ee0ba --- /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 0000000000000000000000000000000000000000..8e14b1e61b461053d372aab53900420ca761c931 --- /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 0000000000000000000000000000000000000000..e52af62cf7475fe18a35a2f41e8b1e2ac21cff2a --- /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 0000000000000000000000000000000000000000..87b3ba9f1d070fe4bacc36ff307b8b3c22c419a0 --- /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 0000000000000000000000000000000000000000..16050d5b85eb0946317dde890f1cffdd84da09e2 --- /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 0000000000000000000000000000000000000000..e27fb987b48d6079eb694c52b9785281026e29ba --- /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 0000000000000000000000000000000000000000..3539109e20e38582d97f4f8d682405bc4570766d --- /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 0000000000000000000000000000000000000000..972b30863f757dd35fb3b5dce65964d744cbd707 --- /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 0000000000000000000000000000000000000000..8414ce634ff56701771b7776a731aa5ca2bd42d6 --- /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 0000000000000000000000000000000000000000..6997deb7d8e360b9f59161c9a0cbb8b6938ccdfb --- /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 0000000000000000000000000000000000000000..04110a5aa46fc7177bb411ddfec80b709049e59a --- /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 0000000000000000000000000000000000000000..49555f399b5db4fd364fbdbcbb966b03bb2a5bf9 --- /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 0000000000000000000000000000000000000000..3300674f4c0043ab6270cec70b8b6e9b7780d083 --- /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 0000000000000000000000000000000000000000..992c363850d0858de15209a392db5df8264790b0 --- /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 0000000000000000000000000000000000000000..1f03fb440b77b0f5d2725f8a21e6dd58b44c1a77 --- /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 0000000000000000000000000000000000000000..a4813b607b0882b5a6b1f602558a3c90d41269ad --- /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 0000000000000000000000000000000000000000..1737c55c4ded45d532ae40f85a0de09df7673208 --- /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 0000000000000000000000000000000000000000..f00302d7e096e807a2f57c77aee46ffc318a6158 --- /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 0000000000000000000000000000000000000000..1f0aafa5ab68b1cec73242c9c7e8f201306d7c52 --- /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 0000000000000000000000000000000000000000..91e0788e833a75d078ac4157121a73d5411f4689 --- /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 0000000000000000000000000000000000000000..4fc9398cd959106d3040fcc984bfa852186ab9a7 --- /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 0000000000000000000000000000000000000000..581cd3ec4f26f7290c690f325a196418a5d1e98f --- /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 0000000000000000000000000000000000000000..370d1c39c7093c7a1c40fdcb091ac68c726b9652 --- /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 0000000000000000000000000000000000000000..4e9268745f0cb655487bcf11486f83e5727ac4d3 --- /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 0000000000000000000000000000000000000000..1be6084076c118d7a39aba7b1b4275a47b0e7ce5 --- /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 0000000000000000000000000000000000000000..4560ff966574e0c75c6fd2c03c367c40f8b7489d --- /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 0000000000000000000000000000000000000000..88705df7927cd69f14143e471498b06f06b9e950 --- /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 0000000000000000000000000000000000000000..27cbbe28b61150be6e7c3c90affb1d48a988e7e7 --- /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 0000000000000000000000000000000000000000..688b28ec2e3e646c0e6c42db6f6fd54298b9708e --- /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 0000000000000000000000000000000000000000..40459314f634c57995d16049198818173dbd4f7b --- /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 0000000000000000000000000000000000000000..5eb55b18cf4fbf0c3b38cf1e550bcfe222d9cfc0 --- /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 0000000000000000000000000000000000000000..1f88b5662cbb307eae039b9a75f7ff4e02ad649d --- /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 0000000000000000000000000000000000000000..049113d84d5402a3bbd9297a8bb4a2e197da25b9 --- /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 0000000000000000000000000000000000000000..68c37c0b028f646c58283dea37cc5683ea248e54 --- /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 0000000000000000000000000000000000000000..b390fd2a93646dcb6e744843e877045821acc597 --- /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 0000000000000000000000000000000000000000..3eda7715238f572e0c27f774abce351bca425f12 --- /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 0000000000000000000000000000000000000000..9282c45e6aff39742d581c11928d666a2e8a2386 --- /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 0000000000000000000000000000000000000000..9eb6231406fd426f552fcc582ea666414778fa92 --- /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 0000000000000000000000000000000000000000..d8697085fd2bc8c1b591dd6f6c98241d3975221b --- /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 0000000000000000000000000000000000000000..b46d1ea4b5a2013f497f1875aa6084192fd47930 --- /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 0000000000000000000000000000000000000000..47bdc0e87a39bfe84c091f866e72a25745112875 --- /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 0000000000000000000000000000000000000000..dcd41c83fa86e7728d8e69398163dfe78393b6da --- /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 0000000000000000000000000000000000000000..2284554d858d867ac57b9c66554e73493fcb2c78 --- /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 0000000000000000000000000000000000000000..6bfb5c8974635bba8865817838d1c0e7550d70e9 --- /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 0000000000000000000000000000000000000000..aa3e5e51598c44bc19c02883b337071bc2c12d89 --- /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 0000000000000000000000000000000000000000..ee57dcd19c440d0d1a7d082228c76865495dda96 --- /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 0000000000000000000000000000000000000000..225e0085e3bf15acc77db01931cb7e3b93704a3a --- /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 0000000000000000000000000000000000000000..ea9a58e962218f51b67e68ce727bb8d305ad7864 --- /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 0000000000000000000000000000000000000000..b4ad18cccccd5f1ab0e4a840be6f03e7ceb706f4 --- /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 0000000000000000000000000000000000000000..53fb87e10c99bc80f6e06ba7119f455b9a06336d --- /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 0000000000000000000000000000000000000000..f91c35c61492ce2003d46a23170940f0f908399c --- /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 0000000000000000000000000000000000000000..f2b24adaa7b2eea940fab2e550c325b421d8681b --- /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 0000000000000000000000000000000000000000..1de28ba4f2da3f8b344d1a361f8e76c649cebf81 --- /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 0000000000000000000000000000000000000000..bdd6e2b55d17753801278170664167a7696a34fe --- /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 0000000000000000000000000000000000000000..d68260db71a596b021fc65e367ac9f36c4559176 --- /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 0000000000000000000000000000000000000000..4e4d2e44a7e7056a3d8c6b04fa672b109070dfce --- /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 0000000000000000000000000000000000000000..7c5643aa60a924cf33611f3499cf8647aa8c2eb2 --- /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 0000000000000000000000000000000000000000..9749621c201e9c2569b60fa862a09125fa06c085 --- /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 0000000000000000000000000000000000000000..c8d2f22dabf6b1f3e57f05c4e56ee5c793e4114f --- /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 0000000000000000000000000000000000000000..1f841cf135829b6c7a9e7c875433dd6c6e947fc6 --- /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 0000000000000000000000000000000000000000..e2d7c95ad48a6aaaebf86564a6c5b3f9a700ca5f --- /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 0000000000000000000000000000000000000000..f4d07b119267fe110aa4669e5c8b064909d92ada --- /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 0000000000000000000000000000000000000000..b1b54f4b00ad014675897b0a1b81fede064b256c --- /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 0000000000000000000000000000000000000000..7ba9e893502cf6dfe696908bdb0c071e85450d0d --- /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 0000000000000000000000000000000000000000..ee0297863823c72e20c6ea11da13f9911acf6a41 --- /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 0000000000000000000000000000000000000000..67b4b277a1c2621313087b16c16ca3b68fc77ff4 --- /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 0000000000000000000000000000000000000000..37093367418b273ccbb3572580db3fe6705620c7 --- /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 0000000000000000000000000000000000000000..f8c82626885bd44383290b0bec2901aa865e8ee4 --- /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 0000000000000000000000000000000000000000..23748008e3b9c763fbd7dbee04d432838b65ecf5 --- /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 0000000000000000000000000000000000000000..a0bc6064e783514865c1b961a9b3742320495f19 --- /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 0000000000000000000000000000000000000000..1df3a557dd95cbc1b79a68fc68f2823241e1044a --- /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 0000000000000000000000000000000000000000..e19517e0091647b42b70c79ba1671ce46e81b8e8 --- /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 0000000000000000000000000000000000000000..4575aa1d9e392f62239b26c6b3ba4b177548dfdc --- /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 0000000000000000000000000000000000000000..5a0512b3c833f3ded744a6d49ff131ab76c2ef1c --- /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 0000000000000000000000000000000000000000..5e0814155c5196f997cad90a7fc86f2a4a51c913 --- /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 0000000000000000000000000000000000000000..aaa491c938850aec121ab1a0474c96ab66637826 --- /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 0000000000000000000000000000000000000000..2f4341fb55503f20223bccf559695047e21b5632 --- /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 0000000000000000000000000000000000000000..f7170dc9db32a0372147a21fa38c0fd20d966e3e --- /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 0000000000000000000000000000000000000000..8103422068888ff02d26038df94b45570aeb3555 --- /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 0000000000000000000000000000000000000000..5999137619dbc283765c817db761ab55bfdec9ee --- /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 0000000000000000000000000000000000000000..4375b932f907b23b2f22739d201559be62faaf05 --- /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);