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 import "dart:async"; | 5 import "dart:async"; |
6 import "package:expect/expect.dart"; | 6 import "package:expect/expect.dart"; |
7 import "package:async_helper/async_helper.dart"; | 7 import "package:async_helper/async_helper.dart"; |
8 | 8 |
9 class Tracer { | 9 class Tracer { |
10 final String expected; | 10 final String expected; |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 } | 79 } |
80 tracer.trace("f"); | 80 tracer.trace("f"); |
81 } | 81 } |
82 | 82 |
83 foo4(Tracer tracer) async { | 83 foo4(Tracer tracer) async { |
84 try { | 84 try { |
85 try { | 85 try { |
86 await new Future.value(3); //# forceAwait: continued | 86 await new Future.value(3); //# forceAwait: continued |
87 tracer.trace("a"); | 87 tracer.trace("a"); |
88 throw "Error"; | 88 throw "Error"; |
89 } catch (error) { | 89 } catch(error) { |
90 tracer.trace("b"); | 90 tracer.trace("b"); |
91 Expect.equals("Error", error); | 91 Expect.equals("Error", error); |
92 throw "Error2"; | 92 throw "Error2"; |
93 } | 93 } |
94 } catch (error) { | 94 } catch(error) { |
95 Expect.equals("Error2", error); | 95 Expect.equals("Error2", error); |
96 tracer.trace("c"); | 96 tracer.trace("c"); |
97 } | 97 } |
98 tracer.trace("d"); | 98 tracer.trace("d"); |
| 99 |
99 } | 100 } |
100 | 101 |
101 foo5(Tracer tracer) async { | 102 foo5(Tracer tracer) async { |
102 try { | 103 try { |
103 tracer.trace("a"); | 104 tracer.trace("a"); |
104 try { | 105 try { |
105 await new Future.value(3); //# forceAwait: continued | 106 await new Future.value(3); //# forceAwait: continued |
106 tracer.trace("b"); | 107 tracer.trace("b"); |
107 throw "Error"; | 108 throw "Error"; |
108 } catch (error) { | 109 } catch(error) { |
109 tracer.trace("c"); | 110 tracer.trace("c"); |
110 Expect.equals("Error", error); | 111 Expect.equals("Error", error); |
111 throw "Error2"; | 112 throw "Error2"; |
112 } | 113 } |
113 } finally { | 114 } finally { |
114 tracer.trace("d"); | 115 tracer.trace("d"); |
115 } | 116 } |
116 tracer.trace("e"); | 117 tracer.trace("e"); |
| 118 |
117 } | 119 } |
118 | 120 |
119 foo6(Tracer tracer) async { | 121 foo6(Tracer tracer) async { |
120 try { | 122 try { |
121 try { | 123 try { |
122 await new Future.value(3); //# forceAwait: continued | 124 await new Future.value(3); //# forceAwait: continued |
123 tracer.trace("a"); | 125 tracer.trace("a"); |
124 throw "Error"; | 126 throw "Error"; |
125 } catch (error) { | 127 } catch(error) { |
126 tracer.trace("b"); | 128 tracer.trace("b"); |
127 Expect.equals("Error", error); | 129 Expect.equals("Error", error); |
128 throw "Error2"; | 130 throw "Error2"; |
129 } finally { | 131 } finally { |
130 tracer.trace("c"); | 132 tracer.trace("c"); |
131 throw "Error3"; | 133 throw "Error3"; |
132 } | 134 } |
133 } catch (error) { | 135 } catch(error) { |
134 tracer.trace("d"); | 136 tracer.trace("d"); |
135 Expect.equals("Error3", error); | 137 Expect.equals("Error3", error); |
136 } | 138 } |
137 tracer.trace("e"); | 139 tracer.trace("e"); |
138 } | 140 } |
139 | 141 |
140 foo7(Tracer tracer) async { | 142 foo7(Tracer tracer) async { |
141 try { | 143 try { |
142 try { | 144 try { |
143 await new Future.value(3); //# forceAwait: continued | 145 await new Future.value(3); //# forceAwait: continued |
144 tracer.trace("a"); | 146 tracer.trace("a"); |
145 throw "Error"; | 147 throw "Error"; |
146 } catch (error) { | 148 } catch(error) { |
147 Expect.equals("Error", error); | 149 Expect.equals("Error", error); |
148 tracer.trace("b"); | 150 tracer.trace("b"); |
149 throw "Error2"; | 151 throw "Error2"; |
150 } finally { | 152 } finally { |
151 tracer.trace("c"); | 153 tracer.trace("c"); |
152 throw "Error3"; | 154 throw "Error3"; |
153 } | 155 } |
154 } finally { | 156 } finally { |
155 tracer.trace("d"); | 157 tracer.trace("d"); |
156 } | 158 } |
157 tracer.trace("e"); | 159 tracer.trace("e"); |
158 } | 160 } |
159 | 161 |
160 foo8(Tracer tracer) async { | 162 foo8(Tracer tracer) async { |
161 try { | 163 try { |
162 try { | 164 try { |
163 await new Future.value(3); //# forceAwait: continued | 165 await new Future.value(3); //# forceAwait: continued |
164 tracer.trace("a"); | 166 tracer.trace("a"); |
165 throw "Error"; | 167 throw "Error"; |
166 } catch (error) { | 168 } catch(error) { |
167 Expect.equals("Error", error); | 169 Expect.equals("Error", error); |
168 tracer.trace("b"); | 170 tracer.trace("b"); |
169 return; | 171 return; |
170 } finally { | 172 } finally { |
171 tracer.trace("c"); | 173 tracer.trace("c"); |
172 throw "Error3"; | 174 throw "Error3"; |
173 } | 175 } |
174 } finally { | 176 } finally { |
175 tracer.trace("d"); | 177 tracer.trace("d"); |
176 } | 178 } |
177 tracer.trace("e"); | 179 tracer.trace("e"); |
178 } | 180 } |
179 | 181 |
180 foo9(Tracer tracer) async { | 182 foo9(Tracer tracer) async { |
181 try { | 183 try { |
182 while (true) { | 184 while(true) { |
183 try { | 185 try { |
184 await new Future.value(3); //# forceAwait: continued | 186 await new Future.value(3); //# forceAwait: continued |
185 tracer.trace("a"); | 187 tracer.trace("a"); |
186 throw "Error"; | 188 throw "Error"; |
187 } catch (error) { | 189 } catch(error) { |
188 Expect.equals("Error", error); | 190 Expect.equals("Error", error); |
189 tracer.trace("b"); | 191 tracer.trace("b"); |
190 return; | 192 return; |
191 } finally { | 193 } finally { |
192 tracer.trace("c"); | 194 tracer.trace("c"); |
193 break; | 195 break; |
194 } | 196 } |
195 tracer.trace("d"); | 197 tracer.trace("d"); |
196 } | 198 } |
197 } finally { | 199 } finally { |
198 tracer.trace("e"); | 200 tracer.trace("e"); |
199 } | 201 } |
200 tracer.trace("f"); | 202 tracer.trace("f"); |
201 } | 203 } |
202 | 204 |
203 foo10(Tracer tracer) async { | 205 foo10(Tracer tracer) async { |
204 try { | 206 try { |
205 int i = 0; | 207 int i = 0; |
206 while (true) { | 208 while (true) { |
207 try { | 209 try { |
208 try { | 210 try { |
209 tracer.trace("a"); | 211 tracer.trace("a"); |
210 throw "Error"; | 212 throw "Error"; |
211 } catch (error) { | 213 } catch (error) { |
212 tracer.trace("b"); | 214 tracer.trace("b"); |
213 try { | 215 try { |
214 await new Future.value(3); // //# forceAwait: continued | 216 await new Future.value(3); // //# forceAwait: continued |
215 throw "Error2"; | 217 throw "Error2"; |
216 } catch (error) { | 218 } catch(error) { |
217 tracer.trace("c"); | 219 tracer.trace("c"); |
218 } finally { | 220 } finally { |
219 tracer.trace("d"); | 221 tracer.trace("d"); |
220 } | 222 } |
221 tracer.trace("e"); | 223 tracer.trace("e"); |
222 throw "Error3"; | 224 throw "Error3"; |
223 } finally { | 225 } finally { |
224 tracer.trace("f"); | 226 tracer.trace("f"); |
225 // Continue and breaks 'eats' Error3. | 227 // Continue and breaks 'eats' Error3. |
226 if (i == 0) continue; | 228 if (i == 0) continue; |
227 if (i == 1) break; | 229 if (i == 1) break; |
228 } | 230 } |
229 } finally { | 231 } finally { |
230 tracer.trace("g"); | 232 tracer.trace("g"); |
231 i++; | 233 i++; |
232 } | 234 } |
233 } | 235 } |
234 } finally { | 236 } finally { |
235 tracer.trace("h"); | 237 tracer.trace("h"); |
236 } | 238 } |
237 tracer.trace("i"); | 239 tracer.trace("i"); |
238 } | 240 } |
239 | 241 |
240 foo11(Tracer tracer) async { | 242 foo11(Tracer tracer) async { |
241 try { | 243 try { |
242 bool firstTime = true; | 244 bool firstTime = true; |
243 while (true) { | 245 while(true) { |
244 tracer.trace("a"); | 246 tracer.trace("a"); |
245 if (firstTime) { | 247 if (firstTime) { |
246 try { | 248 try { |
247 await new Future.value(3); //# forceAwait: continued | 249 await new Future.value(3); //# forceAwait: continued |
248 tracer.trace("b"); | 250 tracer.trace("b"); |
249 throw "Error"; | 251 throw "Error"; |
250 } catch (error) { | 252 } catch(error) { |
251 Expect.equals("Error", error); | 253 Expect.equals("Error", error); |
252 tracer.trace("c"); | 254 tracer.trace("c"); |
253 firstTime = false; | 255 firstTime = false; |
254 continue; | 256 continue; |
255 } finally { | 257 } finally { |
256 tracer.trace("d"); | 258 tracer.trace("d"); |
257 } | 259 } |
258 } else { | 260 } else { |
259 tracer.trace("e"); | 261 tracer.trace("e"); |
260 return; | 262 return; |
261 } | 263 } |
262 } | 264 } |
263 } finally { | 265 } finally { |
264 tracer.trace("f"); | 266 tracer.trace("f"); |
265 } | 267 } |
266 tracer.trace("g"); | 268 tracer.trace("g"); |
267 } | 269 } |
268 | 270 |
269 foo12(Tracer tracer) async { | 271 foo12(Tracer tracer) async { |
270 try { | 272 try { |
271 bool firstTime = true; | 273 bool firstTime = true; |
272 while (true) { | 274 while(true) { |
273 tracer.trace("a"); | 275 tracer.trace("a"); |
274 if (firstTime) { | 276 if (firstTime) { |
275 try { | 277 try { |
276 await new Future.value(3); //# forceAwait: continued | 278 await new Future.value(3); //# forceAwait: continued |
277 tracer.trace("b"); | 279 tracer.trace("b"); |
278 throw "Error"; | 280 throw "Error"; |
279 } catch (error) { | 281 } catch(error) { |
280 Expect.equals("Error", error); | 282 Expect.equals("Error", error); |
281 tracer.trace("c"); | 283 tracer.trace("c"); |
282 firstTime = false; | 284 firstTime = false; |
283 continue; | 285 continue; |
284 } finally { | 286 } finally { |
285 tracer.trace("d"); | 287 tracer.trace("d"); |
286 break; | 288 break; |
287 } | 289 } |
288 } else { | 290 } else { |
289 tracer.trace("e"); | 291 tracer.trace("e"); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
326 foo14(Tracer tracer) async { | 328 foo14(Tracer tracer) async { |
327 try { | 329 try { |
328 try { | 330 try { |
329 tracer.trace("a"); | 331 tracer.trace("a"); |
330 throw "Error"; | 332 throw "Error"; |
331 } catch (error) { | 333 } catch (error) { |
332 tracer.trace("b"); | 334 tracer.trace("b"); |
333 try { | 335 try { |
334 await new Future.value(3); // //# forceAwait: continued | 336 await new Future.value(3); // //# forceAwait: continued |
335 throw "Error2"; | 337 throw "Error2"; |
336 } catch (error) { | 338 } catch(error) { |
337 tracer.trace("c"); | 339 tracer.trace("c"); |
338 } finally { | 340 } finally { |
339 tracer.trace("d"); | 341 tracer.trace("d"); |
340 } | 342 } |
341 tracer.trace("e"); | 343 tracer.trace("e"); |
342 throw "Error3"; | 344 throw "Error3"; |
343 } finally { | 345 } finally { |
344 tracer.trace("f"); | 346 tracer.trace("f"); |
345 } | 347 } |
346 } finally { | 348 } finally { |
347 tracer.trace("g"); | 349 tracer.trace("g"); |
348 } | 350 } |
349 tracer.trace("h"); | 351 tracer.trace("h"); |
350 } | 352 } |
351 | 353 |
352 foo15(Tracer tracer) async { | 354 foo15(Tracer tracer) async { |
353 try { | 355 try { |
354 try { | 356 try { |
355 tracer.trace("a"); | 357 tracer.trace("a"); |
356 throw "Error"; | 358 throw "Error"; |
357 } catch (error) { | 359 } catch (error) { |
358 tracer.trace("b"); | 360 tracer.trace("b"); |
359 try { | 361 try { |
360 await new Future.value(3); // //# forceAwait: continued | 362 await new Future.value(3); // //# forceAwait: continued |
361 throw "Error2"; | 363 throw "Error2"; |
362 } catch (error) { | 364 } catch(error) { |
363 tracer.trace("c"); | 365 tracer.trace("c"); |
364 } finally { | 366 } finally { |
365 tracer.trace("d"); | 367 tracer.trace("d"); |
366 } | 368 } |
367 tracer.trace("e"); | 369 tracer.trace("e"); |
368 throw "Error3"; | 370 throw "Error3"; |
369 } finally { | 371 } finally { |
370 tracer.trace("f"); | 372 tracer.trace("f"); |
371 return; | 373 return; |
372 } | 374 } |
373 } finally { | 375 } finally { |
374 tracer.trace("g"); | 376 tracer.trace("g"); |
375 } | 377 } |
376 tracer.trace("h"); | 378 tracer.trace("h"); |
377 } | 379 } |
378 | 380 |
379 foo16(Tracer tracer) async { | 381 foo16(Tracer tracer) async { |
380 try { | 382 try { |
381 try { | 383 try { |
382 tracer.trace("a"); | 384 tracer.trace("a"); |
383 throw "Error"; | 385 throw "Error"; |
384 } catch (error) { | 386 } catch (error) { |
385 tracer.trace("b"); | 387 tracer.trace("b"); |
386 try { | 388 try { |
387 await new Future.value(3); // //# forceAwait: continued | 389 await new Future.value(3); // //# forceAwait: continued |
388 throw "Error2"; | 390 throw "Error2"; |
389 } catch (error) { | 391 } catch(error) { |
390 tracer.trace("c"); | 392 tracer.trace("c"); |
391 } finally { | 393 } finally { |
392 tracer.trace("d"); | 394 tracer.trace("d"); |
393 return; | 395 return; |
394 } | 396 } |
395 tracer.trace("e"); | 397 tracer.trace("e"); |
396 throw "Error3"; | 398 throw "Error3"; |
397 } finally { | 399 } finally { |
398 tracer.trace("f"); | 400 tracer.trace("f"); |
399 } | 401 } |
(...skipping 17 matching lines...) Expand all Loading... |
417 } finally { | 419 } finally { |
418 tracer.trace("d"); | 420 tracer.trace("d"); |
419 } | 421 } |
420 tracer.trace("e"); | 422 tracer.trace("e"); |
421 } | 423 } |
422 tracer.trace("f"); | 424 tracer.trace("f"); |
423 } | 425 } |
424 | 426 |
425 foo18(Tracer tracer) async { | 427 foo18(Tracer tracer) async { |
426 try { | 428 try { |
427 tracer.trace("a"); | 429 tracer.trace("a"); |
428 } finally { | 430 } finally { |
429 try { | 431 try { |
430 tracer.trace("b"); | 432 tracer.trace("b"); |
431 } finally { | 433 } finally { |
432 await new Future.value(3); // //# forceAwait: continued | 434 await new Future.value(3); // //# forceAwait: continued |
433 tracer.trace("c"); | 435 tracer.trace("c"); |
434 } | 436 } |
435 tracer.trace("d"); | 437 tracer.trace("d"); |
436 } | 438 } |
437 tracer.trace("e"); | 439 tracer.trace("e"); |
(...skipping 27 matching lines...) Expand all Loading... |
465 await runTest("abcdefgX", foo14, "Error3"); | 467 await runTest("abcdefgX", foo14, "Error3"); |
466 await runTest("abcdefgX", foo14, "Error3"); | 468 await runTest("abcdefgX", foo14, "Error3"); |
467 await runTest("abcdefg", foo15); | 469 await runTest("abcdefg", foo15); |
468 await runTest("abcdfg", foo16); | 470 await runTest("abcdfg", foo16); |
469 await runTest("abcdef", foo17); | 471 await runTest("abcdef", foo17); |
470 await runTest("abcde", foo18); | 472 await runTest("abcde", foo18); |
471 } | 473 } |
472 | 474 |
473 void main() { | 475 void main() { |
474 asyncTest(test); | 476 asyncTest(test); |
475 } | 477 } |
OLD | NEW |