OLD | NEW |
| (Empty) |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | |
2 // for details. All rights reserved. Use of this source code is governed by a | |
3 // BSD-style license that can be found in the LICENSE file. | |
4 | |
5 // Test async/await syntax. | |
6 | |
7 var yield = 0; | |
8 var await = 0; | |
9 | |
10 a01a() async => null; /// a01a: ok | |
11 a01b() async* => null; /// a01b: compile-time error | |
12 a01c() sync* => null; /// a01c: compile-time error | |
13 a02a() async {} /// a02a: ok | |
14 a03a() async* {} /// a03a: ok | |
15 a03b() async * {} /// a03b: compile-time error | |
16 a04a() sync* {} /// a04a: ok | |
17 a04b() sync {} /// a04b: compile-time error | |
18 a04c() sync * {} /// a04c: compile-time error | |
19 a05a() async { await 0; } /// a05a: ok | |
20 a05b() async { /// a05b: ok | |
21 await(a) {}; /// a05b: continued | |
22 await(0); /// a05b: continued | |
23 } /// a05b: continued | |
24 a05c() { /// a05c: ok | |
25 await(a) {}; /// a05c: continued | |
26 await(0); /// a05c: continued | |
27 } /// a05c: continued | |
28 a05d() async { /// a05d: compile-time error | |
29 await(a) {} /// a05d: continued | |
30 await(0); /// a05d: continued | |
31 } /// a05d: continued | |
32 a05e() { /// a05e: ok | |
33 await(a) {} /// a05e: continued | |
34 await(0); /// a05e: continued | |
35 } /// a05e: continued | |
36 a05f() async { /// a05f: compile-time error | |
37 var await = (a) {}; /// a05f: continued | |
38 await(0); /// a05f: continued | |
39 } /// a05f: continued | |
40 a06a() async { await for (var o in []) {} } /// a06a: ok | |
41 a06b() sync* { await for (var o in []) {} } /// a06b: compile-time error | |
42 a07a() sync* { yield 0; } /// a07a: ok | |
43 a07b() sync { yield 0; } /// a07b: compile-time error | |
44 a08a() sync* { yield* []; } /// a08a: ok | |
45 a08b() sync { yield 0; } /// a08b: compile-time error | |
46 a09a() async* { yield 0; } /// a09a: ok | |
47 a10a() async* { yield* []; } /// a10a: ok | |
48 | |
49 get sync sync {} /// a11a: compile-time error | |
50 get sync sync* {} /// a11b: ok | |
51 get async async {} /// a11c: ok | |
52 get async async* {} /// a11d: ok | |
53 | |
54 get sync {} /// a12a: ok | |
55 get sync* {} /// a12b: compile-time error | |
56 get async {} /// a12c: ok | |
57 get async* {} /// a12d: compile-time error | |
58 | |
59 int sync; /// a13a: ok | |
60 int sync*; /// a13b: compile-time error | |
61 int async; /// a13c: ok | |
62 int async*; /// a13d: compile-time error | |
63 | |
64 var sync; /// a14a: ok | |
65 var sync*; /// a14b: compile-time error | |
66 var async; /// a14c: ok | |
67 var async*; /// a14d: compile-time error | |
68 | |
69 sync() {} /// a15a: ok | |
70 sync*() {} /// a15b: compile-time error | |
71 async() {} /// a15c: ok | |
72 async*() {} /// a15d: compile-time error | |
73 | |
74 abstract class B { | |
75 b00a() async; /// b00a: compile-time error | |
76 b00b() async*; /// b00b: compile-time error | |
77 b00c() sync*; /// b00c: compile-time error | |
78 b00d() sync; /// b00d: compile-time error | |
79 } | |
80 | |
81 class C extends B { | |
82 C(); | |
83 | |
84 factory C.e1() async { return null; } /// e1: compile-time error | |
85 factory C.e2() async* { return null; } /// e2: compile-time error | |
86 factory C.e3() sync* { return null; } /// e3: compile-time error | |
87 factory C.e4() async = C; /// e4: compile-time error | |
88 factory C.e5() async* = C; /// e5: compile-time error | |
89 factory C.e6() sync* = C; /// e6: compile-time error | |
90 C.e7() async {} /// e7: compile-time error | |
91 C.e8() async* {} /// e8: compile-time error | |
92 C.e9() sync* {} /// e9: compile-time error | |
93 | |
94 b00a() {} /// b00a: continued | |
95 b00b() {} /// b00b: continued | |
96 b00c() {} /// b00c: continued | |
97 b00d() {} /// b00d: continued | |
98 | |
99 b01a() async => null; /// b01a: ok | |
100 b01b() async* => null; /// b01b: compile-time error | |
101 b01c() sync* => null; /// b01c: compile-time error | |
102 b02a() async {} /// b02a: ok | |
103 b03a() async* {} /// b03a: ok | |
104 b04a() sync* {} /// b04a: ok | |
105 b04b() sync {} /// b04b: compile-time error | |
106 b05a() async { await 0; } /// b05a: ok | |
107 b06a() async { await for (var o in []) {} } /// b06a: ok | |
108 b06b() async { await for ( ; ; ) {} } /// b06b: compile-time error | |
109 b07a() sync* { yield 0; } /// b07a: ok | |
110 b08a() sync* { yield* []; } /// b08a: ok | |
111 b09a() async* { yield 0; } /// b09a: ok | |
112 b10a() async* { yield* []; } /// b10a: ok | |
113 | |
114 get sync sync {} /// b11a: compile-time error | |
115 get sync sync* {} /// b11b: ok | |
116 get async async {} /// b11c: ok | |
117 get async async* {} /// b11d: ok | |
118 | |
119 get sync {} /// b12a: ok | |
120 get sync* {} /// b12b: compile-time error | |
121 get async {} /// b12c: ok | |
122 get async* {} /// b12d: compile-time error | |
123 | |
124 int sync; /// b13a: ok | |
125 int sync*; /// b13b: compile-time error | |
126 int async; /// b13c: ok | |
127 int async*; /// b13d: compile-time error | |
128 | |
129 var sync; /// b14a: ok | |
130 var sync*; /// b14b: compile-time error | |
131 var async; /// b14c: ok | |
132 var async*; /// b14d: compile-time error | |
133 | |
134 sync() {} /// b15a: ok | |
135 sync*() {} /// b15b: compile-time error | |
136 async() {} /// b15c: ok | |
137 async*() {} /// b15d: compile-time error | |
138 } | |
139 | |
140 method1() { | |
141 c01a() async => null; c01a(); /// c01a: ok | |
142 c01b() async* => null; c01b(); /// c01b: compile-time er
ror | |
143 c01c() sync* => null; c01c(); /// c01c: compile-time er
ror | |
144 c02a() async {} c02a(); /// c02a: ok | |
145 c03a() async* {} c03a(); /// c03a: ok | |
146 c04a() sync* {} c04a(); /// c04a: ok | |
147 c04b() sync {} c04b(); /// c04b: compile-time er
ror | |
148 c05a() async { await 0; } c05a(); /// c05a: ok | |
149 c06a() async { await for (var o in []) {} } c06a(); /// c06a: ok | |
150 c07a() sync* { yield 0; } c07a(); /// c07a: ok | |
151 c08a() sync* { yield* []; } c08a(); /// c08a: ok | |
152 c09a() async* { yield 0; } c09a(); /// c09a: ok | |
153 c10a() async* { yield* []; } c10a(); /// c10a: ok | |
154 } | |
155 | |
156 method2() { | |
157 var d01a = () async => null; d01a(); /// d01a: ok | |
158 var d01b = () async* => null; d01b(); /// d01b: compile
-time error | |
159 var d01c = () sync* => null; d01c(); /// d01c: compile
-time error | |
160 var d02a = () async {}; d02a(); /// d02a: ok | |
161 var d03a = () async* {}; d03a(); /// d03a: ok | |
162 var d04a = () sync* {}; d04a(); /// d04a: ok | |
163 var d04b = () sync {}; d04b(); /// d04b: compile
-time error | |
164 var d05a = () async { await 0; }; d05a(); /// d05a: ok | |
165 var d06a = () async { await for (var o in []) {} }; d06a(); /// d06a: ok | |
166 var d07a = () sync* { yield 0; }; d07a(); /// d07a: ok | |
167 var d08a = () sync* { yield* []; }; d08a(); /// d08a: ok | |
168 var d08b = () sync* { yield*0+1; }; d08b(); /// d08b: ok | |
169 var d08c = () { yield*0+1; }; d08c(); /// d08c: ok | |
170 var d09a = () async* { yield 0; }; d09a(); /// d09a: ok | |
171 var d10a = () async* { yield* []; }; d10a(); /// d10a: ok | |
172 } | |
173 | |
174 | |
175 void main() { | |
176 var a; | |
177 var c = new C(); | |
178 c = new C.e1(); /// e1: continued | |
179 c = new C.e2(); /// e2: continued | |
180 c = new C.e3(); /// e3: continued | |
181 c = new C.e4(); /// e4: continued | |
182 c = new C.e5(); /// e5: continued | |
183 c = new C.e6(); /// e6: continued | |
184 c = new C.e7(); /// e7: continued | |
185 c = new C.e8(); /// e8: continued | |
186 c = new C.e9(); /// e9: continued | |
187 | |
188 a01a(); /// a01a: continued | |
189 a01b(); /// a01b: continued | |
190 a01c(); /// a01c: continued | |
191 a02a(); /// a02a: continued | |
192 a03a(); /// a03a: continued | |
193 a03b(); /// a03b: continued | |
194 a04a(); /// a04a: continued | |
195 a04b(); /// a04b: continued | |
196 a04c(); /// a04c: continued | |
197 a05a(); /// a05a: continued | |
198 a05b(); /// a05b: continued | |
199 a05c(); /// a05c: continued | |
200 a05d(); /// a05d: continued | |
201 a05e(); /// a05e: continued | |
202 a05f(); /// a05f: continued | |
203 a06a(); /// a06a: continued | |
204 a06b(); /// a06b: continued | |
205 a07a(); /// a07a: continued | |
206 a07b(); /// a07b: continued | |
207 a08a(); /// a08a: continued | |
208 a08b(); /// a08b: continued | |
209 a09a(); /// a09a: continued | |
210 a10a(); /// a10a: continued | |
211 a = sync; /// a11a: continued | |
212 a = sync; /// a11b: continued | |
213 a = async; /// a11c: continued | |
214 a = async; /// a11d: continued | |
215 a = sync; /// a12a: continued | |
216 a = sync; /// a12b: continued | |
217 a = async; /// a12c: continued | |
218 a = async; /// a12d: continued | |
219 a = sync; /// a13a: continued | |
220 a = sync; /// a13b: continued | |
221 a = async; /// a13c: continued | |
222 a = async; /// a13d: continued | |
223 a = sync; /// a14a: continued | |
224 a = sync; /// a14b: continued | |
225 a = async; /// a14c: continued | |
226 a = async; /// a14d: continued | |
227 sync(); /// a15a: continued | |
228 sync(); /// a15b: continued | |
229 async(); /// a15c: continued | |
230 async(); /// a15d: continued | |
231 | |
232 c.b00a(); /// b00a: continued | |
233 c.b00b(); /// b00b: continued | |
234 c.b00c(); /// b00c: continued | |
235 c.b00d(); /// b00d: continued | |
236 c.b01a(); /// b01a: continued | |
237 c.b01b(); /// b01b: continued | |
238 c.b01c(); /// b01c: continued | |
239 c.b02a(); /// b02a: continued | |
240 c.b03a(); /// b03a: continued | |
241 c.b04a(); /// b04a: continued | |
242 c.b04b(); /// b04b: continued | |
243 c.b05a(); /// b05a: continued | |
244 c.b06a(); /// b06a: continued | |
245 c.b06b(); /// b06b: continued | |
246 c.b07a(); /// b07a: continued | |
247 c.b08a(); /// b08a: continued | |
248 c.b09a(); /// b09a: continued | |
249 c.b10a(); /// b10a: continued | |
250 a = c.sync; /// b11a: continued | |
251 a = c.sync; /// b11b: continued | |
252 a = c.async; /// b11c: continued | |
253 a = c.async; /// b11d: continued | |
254 a = c.sync; /// b12a: continued | |
255 a = c.sync; /// b12b: continued | |
256 a = c.async; /// b12c: continued | |
257 a = c.async; /// b12d: continued | |
258 a = c.sync; /// b13a: continued | |
259 a = c.sync; /// b13b: continued | |
260 a = c.async; /// b13c: continued | |
261 a = c.async; /// b13d: continued | |
262 a = c.sync; /// b14a: continued | |
263 a = c.sync; /// b14b: continued | |
264 a = c.async; /// b14c: continued | |
265 a = c.async; /// b14d: continued | |
266 c.sync(); /// b15a: continued | |
267 c.sync(); /// b15b: continued | |
268 c.async(); /// b15c: continued | |
269 c.async(); /// b15d: continued | |
270 | |
271 method1(); | |
272 method2(); | |
273 } | |
OLD | NEW |