Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(34)

Unified Diff: test/mjsunit/harmony/async-await-functions.js

Issue 1423663006: [es7] Implement async functions parsing Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/token.h ('k') | test/mjsunit/harmony/async-keyword.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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();
« no previous file with comments | « src/token.h ('k') | test/mjsunit/harmony/async-keyword.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698