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

Side by Side 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, 1 month 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 unified diff | Download patch
« no previous file with comments | « src/token.h ('k') | test/mjsunit/harmony/async-keyword.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2015 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 // Flags: --harmony-async-await --allow-natives-syntax
6
7 function TestAsyncFunctionParsing() {
8 async function a() {}
9 var b = async function() {};
10 var c = async function c() {};
11 function x() {
12 return async function() {};
13 }
14
15 assertEquals(String(a), 'async function a() {}');
16 assertEquals(String(b), 'async function () {}');
17 assertEquals(String(c), 'async function c() {}');
18 assertEquals(String(x()), 'async function () {}');
19
20 assertTrue(%FunctionIsAsync(a));
21 assertTrue(%FunctionIsAsync(b));
22 assertTrue(%FunctionIsAsync(c));
23 assertTrue(%FunctionIsAsync(x()));
24 assertFalse(%FunctionIsAsync(x));
25 }
26 TestAsyncFunctionParsing();
27
28
29 function TestAsyncGeneratorError() {
30 assertThrows("async function* foo() {}", SyntaxError);
31 }
32 TestAsyncGeneratorError();
33
34
35 function TestStrictModeAsyncFunctionParsing() {
36 'use strict';
37
38 async function a2() {}
39 var b2 = async function() {};
40
41 assertTrue(%FunctionIsAsync(a2));
42 assertTrue(%FunctionIsAsync(b2));
43 }
44 TestStrictModeAsyncFunctionParsing();
45
46
47 function TestAsyncFunctionInFunction() {
48 function a() {
49 async function b() {}
50 async function c() {}
51 var d = async function() {}, e = async function() {};
52 return [a, b, async function() {}];
53 }
54
55 function* b() {
56 yield async function a() {};
57 yield async function b() {};
58 return async function c() {};
59 }
60
61 var g = b();
62 assertTrue(%FunctionIsAsync(g.next().value));
63 assertTrue(%FunctionIsAsync(g.next().value));
64 assertTrue(%FunctionIsAsync(g.next().value));
65 }
66 TestAsyncFunctionInFunction();
67
68
69 function TestAsyncKeywordLineTerminator() {
70 // async identifier followed by a function
71 // keyword on the next line
72 var async = 10;
73 var b = async
74 function foo() {
75 return 15;
76 }
77
78 assertEquals(b, 10);
79 assertFalse(%FunctionIsAsync(foo));
80 }
81 TestAsyncKeywordLineTerminator();
OLDNEW
« 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