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

Side by Side Diff: test/mjsunit/harmony/async-keyword.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 | « test/mjsunit/harmony/async-await-functions.js ('k') | no next file » | 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 2014 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-sloppy-let
6
7 // Make sure we parse async keyword correctly
8 // as an identifier (in both sloppy and strict mode)
9
10
11 function TestAsyncKeywordSloppyVar() {
12 var async = 10;
13 async = 20;
14 async = function() {};
15 async = function(async) { async: return async; };
16 async = async(30);
17 var t = async + async;
18 assertEquals(async, 30);
19 assertEquals(t, 60);
20 }
21 TestAsyncKeywordSloppyVar();
22
23
24 function TestAsyncKeywordSloppyLet() {
25 let async = 10;
26 async = 20;
27 async = function() {};
28 async = function(async) { async: return async; };
29 async = async(30);
30 var t = async + async;
31 assertEquals(async, 30);
32 assertEquals(t, 60);
33 }
34 TestAsyncKeywordSloppyLet();
35
36
37 function TestAsyncKeywordStrictVar() {
38 'use strict';
39 var async = 10;
40 async = 20;
41 async = function() {};
42 async = function(async) { async: return async; };
43 async = async(30);
44 var t = async + async;
45 assertEquals(async, 30);
46 assertEquals(t, 60);
47 }
48 TestAsyncKeywordStrictVar();
49
50
51 function TestAsyncKeywordStrictLet() {
52 'use strict';
53 let async = 10;
54 async = 20;
55 async = function() {};
56 async = function(async) { async: return async; };
57 async = async(30);
58 var t = async + async;
59 assertEquals(async, 30);
60 assertEquals(t, 60);
61 }
62 TestAsyncKeywordStrictLet();
63
64
65 function TestAsyncKeywordStrictConst() {
66 'use strict';
67 const async = function() { async: return 10; };
68 assertEquals(async(), 10);
69 }
70 TestAsyncKeywordStrictConst();
71
72
73 function TestAsyncClassNameOrObjectSloppy() {
74 class async {
75 async() { return 1; }
76 }
77
78 var c = new async();
79 assertEquals(c.async(), 1);
80
81 var obj = {
82 async: function() {
83 async: var async = 10;
84 return async;
85 }
86 };
87
88 assertEquals(obj.async(), 10);
89
90 var obj2 = {
91 get async() {
92 return 42;
93 }
94 };
95
96 assertEquals(obj2.async, 42);
97 }
98 TestAsyncClassNameOrObjectSloppy();
99
100
101 function TestAsyncClassNameOrObjectStrict() {
102 'use strict';
103 class async {
104 async() { return 1; }
105 }
106
107 var c = new async();
108 assertEquals(c.async(), 1);
109
110 var obj = {
111 async: function() {
112 async: var async = 10;
113 return async;
114 }
115 };
116
117 assertEquals(obj.async(), 10);
118
119 var obj2 = {
120 get async() {
121 return 42;
122 }
123 };
124
125 assertEquals(obj2.async, 42);
126 }
127 TestAsyncClassNameOrObjectStrict();
128
129
130 function TestAsyncGeneratorName() {
131 function* async() { async: yield 1; }
132 assertEquals(async().next().value, 1);
133 }
134 TestAsyncGeneratorName();
135
136
137 function TestAsyncKeywordLineTerminator() {
138 // async identifier followed by a function
139 // keyword on the next line
140 var async = 10;
141 var b = async
142 function foo() {
143 return 15;
144 }
145
146 assertEquals(b, 10);
147 assertEquals(foo(), 15);
148 }
149 TestAsyncKeywordLineTerminator();
OLDNEW
« no previous file with comments | « test/mjsunit/harmony/async-await-functions.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698