| Index: test/mjsunit/harmony/async-await-functions.js
|
| diff --git a/test/mjsunit/harmony/async-await-functions.js b/test/mjsunit/harmony/async-await-functions.js
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..20886b1a40a2fb3c60bf08d63a4e8ac6b774f0c0
|
| --- /dev/null
|
| +++ b/test/mjsunit/harmony/async-await-functions.js
|
| @@ -0,0 +1,81 @@
|
| +// Copyright 2015 the V8 project authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +// Flags: --harmony-async-await --allow-natives-syntax
|
| +
|
| +function TestAsyncFunctionParsing() {
|
| + async function a() {}
|
| + var b = async function() {};
|
| + var c = async function c() {};
|
| + function x() {
|
| + return async function() {};
|
| + }
|
| +
|
| + assertEquals(String(a), 'async function a() {}');
|
| + assertEquals(String(b), 'async function () {}');
|
| + assertEquals(String(c), 'async function c() {}');
|
| + assertEquals(String(x()), 'async function () {}');
|
| +
|
| + assertTrue(%FunctionIsAsync(a));
|
| + assertTrue(%FunctionIsAsync(b));
|
| + assertTrue(%FunctionIsAsync(c));
|
| + assertTrue(%FunctionIsAsync(x()));
|
| + assertFalse(%FunctionIsAsync(x));
|
| +}
|
| +TestAsyncFunctionParsing();
|
| +
|
| +
|
| +function TestAsyncGeneratorError() {
|
| + assertThrows("async function* foo() {}", SyntaxError);
|
| +}
|
| +TestAsyncGeneratorError();
|
| +
|
| +
|
| +function TestStrictModeAsyncFunctionParsing() {
|
| + 'use strict';
|
| +
|
| + async function a2() {}
|
| + var b2 = async function() {};
|
| +
|
| + assertTrue(%FunctionIsAsync(a2));
|
| + assertTrue(%FunctionIsAsync(b2));
|
| +}
|
| +TestStrictModeAsyncFunctionParsing();
|
| +
|
| +
|
| +function TestAsyncFunctionInFunction() {
|
| + function a() {
|
| + async function b() {}
|
| + async function c() {}
|
| + var d = async function() {}, e = async function() {};
|
| + return [a, b, async function() {}];
|
| + }
|
| +
|
| + function* b() {
|
| + yield async function a() {};
|
| + yield async function b() {};
|
| + return async function c() {};
|
| + }
|
| +
|
| + var g = b();
|
| + assertTrue(%FunctionIsAsync(g.next().value));
|
| + assertTrue(%FunctionIsAsync(g.next().value));
|
| + assertTrue(%FunctionIsAsync(g.next().value));
|
| +}
|
| +TestAsyncFunctionInFunction();
|
| +
|
| +
|
| +function TestAsyncKeywordLineTerminator() {
|
| + // async identifier followed by a function
|
| + // keyword on the next line
|
| + var async = 10;
|
| + var b = async
|
| + function foo() {
|
| + return 15;
|
| + }
|
| +
|
| + assertEquals(b, 10);
|
| + assertFalse(%FunctionIsAsync(foo));
|
| +}
|
| +TestAsyncKeywordLineTerminator();
|
|
|