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