OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 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. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 // Test async/await syntax. | 5 // Test async/await syntax. |
6 | 6 |
7 import 'dart:async' show Stream; | 7 import 'dart:async' show Stream; |
8 | 8 |
9 var yield = 0; | 9 var yield = 0; |
10 var await = 0; | 10 var await = 0; |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 a05h() async { // //# a05h: continued | 47 a05h() async { // //# a05h: continued |
48 yield* st; // //# a05h: compile-time error | 48 yield* st; // //# a05h: compile-time error |
49 } // //# a05h: continued | 49 } // //# a05h: continued |
50 a06a() async { await for (var o in st) {} } // //# a06a: ok | 50 a06a() async { await for (var o in st) {} } // //# a06a: ok |
51 a06b() sync* { await for (var o in st) {} } // //# a06b: compile-time error | 51 a06b() sync* { await for (var o in st) {} } // //# a06b: compile-time error |
52 a07a() sync* { yield 0; } // //# a07a: ok | 52 a07a() sync* { yield 0; } // //# a07a: ok |
53 a07b() sync { yield 0; } // //# a07b: compile-time error | 53 a07b() sync { yield 0; } // //# a07b: compile-time error |
54 a08a() sync* { yield* []; } // //# a08a: ok | 54 a08a() sync* { yield* []; } // //# a08a: ok |
55 a08b() sync { yield 0; } // //# a08b: compile-time error | 55 a08b() sync { yield 0; } // //# a08b: compile-time error |
56 a09a() async* { yield 0; } // //# a09a: ok | 56 a09a() async* { yield 0; } // //# a09a: ok |
57 a10a() async* { yield* []; } // //# a10a: static type warning | 57 a10a() async* { yield* []; } // //# a10a: compile-time error |
58 | 58 |
59 get sync sync {} // //# a11a: compile-time error | 59 get sync sync {} // //# a11a: compile-time error |
60 get sync sync* {} // //# a11b: ok | 60 get sync sync* {} // //# a11b: ok |
61 get async async {} // //# a11c: ok | 61 get async async {} // //# a11c: ok |
62 get async async* {} // //# a11d: ok | 62 get async async* {} // //# a11d: ok |
63 | 63 |
64 get sync {} // //# a12a: ok | 64 get sync {} // //# a12a: ok |
65 get sync* {} // //# a12b: compile-time error | 65 get sync* {} // //# a12b: compile-time error |
66 get async {} // //# a12c: ok | 66 get async {} // //# a12c: ok |
67 get async* {} // //# a12d: compile-time error | 67 get async* {} // //# a12d: compile-time error |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 b02a() async {} // //# b02a: ok | 115 b02a() async {} // //# b02a: ok |
116 b03a() async* {} // //# b03a: ok | 116 b03a() async* {} // //# b03a: ok |
117 b04a() sync* {} // //# b04a: ok | 117 b04a() sync* {} // //# b04a: ok |
118 b04b() sync {} // //# b04b: compile-time error | 118 b04b() sync {} // //# b04b: compile-time error |
119 b05a() async { await 0; } // //# b05a: ok | 119 b05a() async { await 0; } // //# b05a: ok |
120 b06a() async { await for (var o in st) {} } // //# b06a: ok | 120 b06a() async { await for (var o in st) {} } // //# b06a: ok |
121 b06b() async { await for ( ; ; ) {} } // //# b06b: compile-time error | 121 b06b() async { await for ( ; ; ) {} } // //# b06b: compile-time error |
122 b07a() sync* { yield 0; } // //# b07a: ok | 122 b07a() sync* { yield 0; } // //# b07a: ok |
123 b08a() sync* { yield* []; } // //# b08a: ok | 123 b08a() sync* { yield* []; } // //# b08a: ok |
124 b09a() async* { yield 0; } // //# b09a: ok | 124 b09a() async* { yield 0; } // //# b09a: ok |
125 b10a() async* { yield* []; } // //# b10a: static type warning | 125 b10a() async* { yield* []; } // //# b10a: compile-time error |
126 b10b() async { yield 0; } // //# b10b: compile-time error | 126 b10b() async { yield 0; } // //# b10b: compile-time error |
127 | 127 |
128 get sync sync {} // //# b11a: compile-time error | 128 get sync sync {} // //# b11a: compile-time error |
129 get sync sync* {} // //# b11b: ok | 129 get sync sync* {} // //# b11b: ok |
130 get async async {} // //# b11c: ok | 130 get async async {} // //# b11c: ok |
131 get async async* {} // //# b11d: ok | 131 get async async* {} // //# b11d: ok |
132 | 132 |
133 get sync {} // //# b12a: ok | 133 get sync {} // //# b12a: ok |
134 get sync* {} // //# b12b: compile-time error | 134 get sync* {} // //# b12b: compile-time error |
135 get async {} // //# b12c: ok | 135 get async {} // //# b12c: ok |
(...skipping 24 matching lines...) Expand all Loading... |
160 c01c() sync* => null; c01c(); // //# c01c: compile-time
error | 160 c01c() sync* => null; c01c(); // //# c01c: compile-time
error |
161 c02a() async {} c02a(); // //# c02a: ok | 161 c02a() async {} c02a(); // //# c02a: ok |
162 c03a() async* {} c03a(); // //# c03a: ok | 162 c03a() async* {} c03a(); // //# c03a: ok |
163 c04a() sync* {} c04a(); // //# c04a: ok | 163 c04a() sync* {} c04a(); // //# c04a: ok |
164 c04b() sync {} c04b(); // //# c04b: compile-time
error | 164 c04b() sync {} c04b(); // //# c04b: compile-time
error |
165 c05a() async { await 0; } c05a(); // //# c05a: ok | 165 c05a() async { await 0; } c05a(); // //# c05a: ok |
166 c06a() async { await for (var o in st) {} } c06a(); // //# c06a: ok | 166 c06a() async { await for (var o in st) {} } c06a(); // //# c06a: ok |
167 c07a() sync* { yield 0; } c07a(); // //# c07a: ok | 167 c07a() sync* { yield 0; } c07a(); // //# c07a: ok |
168 c08a() sync* { yield* []; } c08a(); // //# c08a: ok | 168 c08a() sync* { yield* []; } c08a(); // //# c08a: ok |
169 c09a() async* { yield 0; } c09a(); // //# c09a: ok | 169 c09a() async* { yield 0; } c09a(); // //# c09a: ok |
170 c10a() async* { yield* []; } c10a(); // //# c10a: static type w
arning | 170 c10a() async* { yield* []; } c10a(); // //# c10a: compile-time
error |
171 c11a() async { yield -5; } c11a(); // //# c11a: compile-time
error | 171 c11a() async { yield -5; } c11a(); // //# c11a: compile-time
error |
172 c11b() async { yield* st; } c11b(); // //# c11b: compile-time
error | 172 c11b() async { yield* st; } c11b(); // //# c11b: compile-time
error |
173 } | 173 } |
174 | 174 |
175 method2() { | 175 method2() { |
176 var d01a = () async => null; d01a(); // //# d01a: ok | 176 var d01a = () async => null; d01a(); // //# d01a: ok |
177 var d01b = () async* => null; d01b(); // //# d01b: compi
le-time error | 177 var d01b = () async* => null; d01b(); // //# d01b: compi
le-time error |
178 var d01c = () sync* => null; d01c(); // //# d01c: compi
le-time error | 178 var d01c = () sync* => null; d01c(); // //# d01c: compi
le-time error |
179 var d02a = () async {}; d02a(); // //# d02a: ok | 179 var d02a = () async {}; d02a(); // //# d02a: ok |
180 var d03a = () async* {}; d03a(); // //# d03a: ok | 180 var d03a = () async* {}; d03a(); // //# d03a: ok |
181 var d04a = () sync* {}; d04a(); // //# d04a: ok | 181 var d04a = () sync* {}; d04a(); // //# d04a: ok |
182 var d04b = () sync {}; d04b(); // //# d04b: compi
le-time error | 182 var d04b = () sync {}; d04b(); // //# d04b: compi
le-time error |
183 var d05a = () async { await 0; }; d05a(); // //# d05a: ok | 183 var d05a = () async { await 0; }; d05a(); // //# d05a: ok |
184 var d06a = () async { await for (var o in st) {} }; d06a(); // //# d06a: ok | 184 var d06a = () async { await for (var o in st) {} }; d06a(); // //# d06a: ok |
185 var d07a = () sync* { yield 0; }; d07a(); // //# d07a: ok | 185 var d07a = () sync* { yield 0; }; d07a(); // //# d07a: ok |
186 var d08a = () sync* { yield* []; }; d08a(); // //# d08a: ok | 186 var d08a = () sync* { yield* []; }; d08a(); // //# d08a: ok |
187 var d08b = () sync* { yield*0+1; }; d08b(); // //# d08b: stati
c type warning | 187 var d08b = () sync* { yield*0+1; }; d08b(); // //# d08b: compi
le-time error |
188 var d08c = () { yield*0+1; }; d08c(); // //# d08c: ok | 188 var d08c = () { yield*0+1; }; d08c(); // //# d08c: ok |
189 var d09a = () async* { yield 0; }; d09a(); // //# d09a: ok | 189 var d09a = () async* { yield 0; }; d09a(); // //# d09a: ok |
190 var d10a = () async* { yield* []; }; d10a(); // //# d10a: stati
c type warning | 190 var d10a = () async* { yield* []; }; d10a(); // //# d10a: compi
le-time error |
191 } | 191 } |
192 | 192 |
193 void main() { | 193 void main() { |
194 var a; | 194 var a; |
195 var c = new C(); | 195 var c = new C(); |
196 c = new C.e1(); //# e1: continued | 196 c = new C.e1(); //# e1: continued |
197 c = new C.e2(); //# e2: continued | 197 c = new C.e2(); //# e2: continued |
198 c = new C.e3(); //# e3: continued | 198 c = new C.e3(); //# e3: continued |
199 c = new C.e4(); //# e4: continued | 199 c = new C.e4(); //# e4: continued |
200 c = new C.e5(); //# e5: continued | 200 c = new C.e5(); //# e5: continued |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
292 a = c.async; // //# b14c: continued | 292 a = c.async; // //# b14c: continued |
293 a = c.async; // //# b14d: continued | 293 a = c.async; // //# b14d: continued |
294 c.sync(); // //# b15a: continued | 294 c.sync(); // //# b15a: continued |
295 c.sync(); // //# b15b: continued | 295 c.sync(); // //# b15b: continued |
296 c.async(); // //# b15c: continued | 296 c.async(); // //# b15c: continued |
297 c.async(); // //# b15d: continued | 297 c.async(); // //# b15d: continued |
298 | 298 |
299 method1(); | 299 method1(); |
300 method2(); | 300 method2(); |
301 } | 301 } |
OLD | NEW |