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

Side by Side Diff: tests/language_strong/async_throw_in_catch_test.dart

Issue 2765693002: Update all tests (Closed)
Patch Set: Created 3 years, 9 months 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
OLDNEW
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 14 matching lines...) Expand all
25 void done() { 25 void done() {
26 Expect.equals(expected.length, counter, "Received too few traces"); 26 Expect.equals(expected.length, counter, "Received too few traces");
27 } 27 }
28 } 28 }
29 29
30 foo1(Tracer tracer) async { 30 foo1(Tracer tracer) async {
31 try { 31 try {
32 tracer.trace("a"); 32 tracer.trace("a");
33 // This await forces dart2js to rewrite the try into a state machine 33 // This await forces dart2js to rewrite the try into a state machine
34 // instead of relying on the existing structure. 34 // instead of relying on the existing structure.
35 await new Future.value(3); /// forceAwait: ok 35 await new Future.value(3); //# forceAwait: ok
36 tracer.trace("b"); 36 tracer.trace("b");
37 throw "Error"; 37 throw "Error";
38 } catch (error) { 38 } catch (error) {
39 tracer.trace("c"); 39 tracer.trace("c");
40 Expect.equals("Error", error); 40 Expect.equals("Error", error);
41 throw "Error2"; 41 throw "Error2";
42 tracer.trace("d"); 42 tracer.trace("d");
43 } finally { 43 } finally {
44 tracer.trace("e"); 44 tracer.trace("e");
45 } 45 }
46 tracer.trace("f"); 46 tracer.trace("f");
47 } 47 }
48 48
49 foo2(Tracer tracer) async { 49 foo2(Tracer tracer) async {
50 try { 50 try {
51 tracer.trace("a"); 51 tracer.trace("a");
52 await new Future.value(3); /// forceAwait: continued 52 await new Future.value(3); //# forceAwait: continued
53 tracer.trace("b"); 53 tracer.trace("b");
54 throw "Error"; 54 throw "Error";
55 tracer.trace("c"); 55 tracer.trace("c");
56 } catch (error) { 56 } catch (error) {
57 tracer.trace("d"); 57 tracer.trace("d");
58 Expect.equals("Error", error); 58 Expect.equals("Error", error);
59 await new Future.error("Error2"); 59 await new Future.error("Error2");
60 } finally { 60 } finally {
61 tracer.trace("e"); 61 tracer.trace("e");
62 } 62 }
63 tracer.trace("f"); 63 tracer.trace("f");
64 } 64 }
65 65
66 foo3(Tracer tracer) async { 66 foo3(Tracer tracer) async {
67 try { 67 try {
68 tracer.trace("a"); 68 tracer.trace("a");
69 await new Future.value(3); /// forceAwait: continued 69 await new Future.value(3); //# forceAwait: continued
70 tracer.trace("b"); 70 tracer.trace("b");
71 throw "Error"; 71 throw "Error";
72 tracer.trace("c"); 72 tracer.trace("c");
73 } catch (error) { 73 } catch (error) {
74 Expect.equals("Error", error); 74 Expect.equals("Error", error);
75 tracer.trace("d"); 75 tracer.trace("d");
76 return; 76 return;
77 } finally { 77 } finally {
78 tracer.trace("e"); 78 tracer.trace("e");
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
102 foo5(Tracer tracer) async { 102 foo5(Tracer tracer) async {
103 try { 103 try {
104 tracer.trace("a"); 104 tracer.trace("a");
105 try { 105 try {
106 await new Future.value(3); /// forceAwait: continued 106 await new Future.value(3); //# forceAwait: continued
107 tracer.trace("b"); 107 tracer.trace("b");
108 throw "Error"; 108 throw "Error";
109 } catch(error) { 109 } catch(error) {
110 tracer.trace("c"); 110 tracer.trace("c");
111 Expect.equals("Error", error); 111 Expect.equals("Error", error);
112 throw "Error2"; 112 throw "Error2";
113 } 113 }
114 } finally { 114 } finally {
115 tracer.trace("d"); 115 tracer.trace("d");
116 } 116 }
117 tracer.trace("e"); 117 tracer.trace("e");
118 118
119 } 119 }
120 120
121 foo6(Tracer tracer) async { 121 foo6(Tracer tracer) async {
122 try { 122 try {
123 try { 123 try {
124 await new Future.value(3); /// forceAwait: continued 124 await new Future.value(3); //# forceAwait: continued
125 tracer.trace("a"); 125 tracer.trace("a");
126 throw "Error"; 126 throw "Error";
127 } catch(error) { 127 } catch(error) {
128 tracer.trace("b"); 128 tracer.trace("b");
129 Expect.equals("Error", error); 129 Expect.equals("Error", error);
130 throw "Error2"; 130 throw "Error2";
131 } finally { 131 } finally {
132 tracer.trace("c"); 132 tracer.trace("c");
133 throw "Error3"; 133 throw "Error3";
134 } 134 }
135 } catch(error) { 135 } catch(error) {
136 tracer.trace("d"); 136 tracer.trace("d");
137 Expect.equals("Error3", error); 137 Expect.equals("Error3", error);
138 } 138 }
139 tracer.trace("e"); 139 tracer.trace("e");
140 } 140 }
141 141
142 foo7(Tracer tracer) async { 142 foo7(Tracer tracer) async {
143 try { 143 try {
144 try { 144 try {
145 await new Future.value(3); /// forceAwait: continued 145 await new Future.value(3); //# forceAwait: continued
146 tracer.trace("a"); 146 tracer.trace("a");
147 throw "Error"; 147 throw "Error";
148 } catch(error) { 148 } catch(error) {
149 Expect.equals("Error", error); 149 Expect.equals("Error", error);
150 tracer.trace("b"); 150 tracer.trace("b");
151 throw "Error2"; 151 throw "Error2";
152 } finally { 152 } finally {
153 tracer.trace("c"); 153 tracer.trace("c");
154 throw "Error3"; 154 throw "Error3";
155 } 155 }
156 } finally { 156 } finally {
157 tracer.trace("d"); 157 tracer.trace("d");
158 } 158 }
159 tracer.trace("e"); 159 tracer.trace("e");
160 } 160 }
161 161
162 foo8(Tracer tracer) async { 162 foo8(Tracer tracer) async {
163 try { 163 try {
164 try { 164 try {
165 await new Future.value(3); /// forceAwait: continued 165 await new Future.value(3); //# forceAwait: continued
166 tracer.trace("a"); 166 tracer.trace("a");
167 throw "Error"; 167 throw "Error";
168 } catch(error) { 168 } catch(error) {
169 Expect.equals("Error", error); 169 Expect.equals("Error", error);
170 tracer.trace("b"); 170 tracer.trace("b");
171 return; 171 return;
172 } finally { 172 } finally {
173 tracer.trace("c"); 173 tracer.trace("c");
174 throw "Error3"; 174 throw "Error3";
175 } 175 }
176 } finally { 176 } finally {
177 tracer.trace("d"); 177 tracer.trace("d");
178 } 178 }
179 tracer.trace("e"); 179 tracer.trace("e");
180 } 180 }
181 181
182 foo9(Tracer tracer) async { 182 foo9(Tracer tracer) async {
183 try { 183 try {
184 while(true) { 184 while(true) {
185 try { 185 try {
186 await new Future.value(3); /// forceAwait: continued 186 await new Future.value(3); //# forceAwait: continued
187 tracer.trace("a"); 187 tracer.trace("a");
188 throw "Error"; 188 throw "Error";
189 } catch(error) { 189 } catch(error) {
190 Expect.equals("Error", error); 190 Expect.equals("Error", error);
191 tracer.trace("b"); 191 tracer.trace("b");
192 return; 192 return;
193 } finally { 193 } finally {
194 tracer.trace("c"); 194 tracer.trace("c");
195 break; 195 break;
196 } 196 }
197 tracer.trace("d"); 197 tracer.trace("d");
198 } 198 }
199 } finally { 199 } finally {
200 tracer.trace("e"); 200 tracer.trace("e");
201 } 201 }
202 tracer.trace("f"); 202 tracer.trace("f");
203 } 203 }
204 204
205 foo10(Tracer tracer) async { 205 foo10(Tracer tracer) async {
206 try { 206 try {
207 int i = 0; 207 int i = 0;
208 while (true) { 208 while (true) {
209 try { 209 try {
210 try { 210 try {
211 tracer.trace("a"); 211 tracer.trace("a");
212 throw "Error"; 212 throw "Error";
213 } catch (error) { 213 } catch (error) {
214 tracer.trace("b"); 214 tracer.trace("b");
215 try { 215 try {
216 await new Future.value(3); /// forceAwait: continued 216 await new Future.value(3); //# forceAwait: continued
217 throw "Error2"; 217 throw "Error2";
218 } catch(error) { 218 } catch(error) {
219 tracer.trace("c"); 219 tracer.trace("c");
220 } finally { 220 } finally {
221 tracer.trace("d"); 221 tracer.trace("d");
222 } 222 }
223 tracer.trace("e"); 223 tracer.trace("e");
224 throw "Error3"; 224 throw "Error3";
225 } finally { 225 } finally {
226 tracer.trace("f"); 226 tracer.trace("f");
(...skipping 12 matching lines...) Expand all
239 tracer.trace("i"); 239 tracer.trace("i");
240 } 240 }
241 241
242 foo11(Tracer tracer) async { 242 foo11(Tracer tracer) async {
243 try { 243 try {
244 bool firstTime = true; 244 bool firstTime = true;
245 while(true) { 245 while(true) {
246 tracer.trace("a"); 246 tracer.trace("a");
247 if (firstTime) { 247 if (firstTime) {
248 try { 248 try {
249 await new Future.value(3); /// forceAwait: continued 249 await new Future.value(3); //# forceAwait: continued
250 tracer.trace("b"); 250 tracer.trace("b");
251 throw "Error"; 251 throw "Error";
252 } catch(error) { 252 } catch(error) {
253 Expect.equals("Error", error); 253 Expect.equals("Error", error);
254 tracer.trace("c"); 254 tracer.trace("c");
255 firstTime = false; 255 firstTime = false;
256 continue; 256 continue;
257 } finally { 257 } finally {
258 tracer.trace("d"); 258 tracer.trace("d");
259 } 259 }
260 } else { 260 } else {
261 tracer.trace("e"); 261 tracer.trace("e");
262 return; 262 return;
263 } 263 }
264 } 264 }
265 } finally { 265 } finally {
266 tracer.trace("f"); 266 tracer.trace("f");
267 } 267 }
268 tracer.trace("g"); 268 tracer.trace("g");
269 } 269 }
270 270
271 foo12(Tracer tracer) async { 271 foo12(Tracer tracer) async {
272 try { 272 try {
273 bool firstTime = true; 273 bool firstTime = true;
274 while(true) { 274 while(true) {
275 tracer.trace("a"); 275 tracer.trace("a");
276 if (firstTime) { 276 if (firstTime) {
277 try { 277 try {
278 await new Future.value(3); /// forceAwait: continued 278 await new Future.value(3); //# forceAwait: continued
279 tracer.trace("b"); 279 tracer.trace("b");
280 throw "Error"; 280 throw "Error";
281 } catch(error) { 281 } catch(error) {
282 Expect.equals("Error", error); 282 Expect.equals("Error", error);
283 tracer.trace("c"); 283 tracer.trace("c");
284 firstTime = false; 284 firstTime = false;
285 continue; 285 continue;
286 } finally { 286 } finally {
287 tracer.trace("d"); 287 tracer.trace("d");
288 break; 288 break;
(...skipping 13 matching lines...) Expand all
302 try { 302 try {
303 try { 303 try {
304 tracer.trace("a"); 304 tracer.trace("a");
305 return; 305 return;
306 } catch (error) { 306 } catch (error) {
307 tracer.trace("b"); 307 tracer.trace("b");
308 } finally { 308 } finally {
309 tracer.trace("c"); 309 tracer.trace("c");
310 try { 310 try {
311 try { 311 try {
312 await new Future.value(3); /// forceAwait: continued 312 await new Future.value(3); //# forceAwait: continued
313 tracer.trace("d"); 313 tracer.trace("d");
314 throw "Error"; 314 throw "Error";
315 } finally { 315 } finally {
316 tracer.trace("e"); 316 tracer.trace("e");
317 } 317 }
318 } finally { 318 } finally {
319 tracer.trace("f"); 319 tracer.trace("f");
320 } 320 }
321 } 321 }
322 } finally { 322 } finally {
323 tracer.trace("g"); 323 tracer.trace("g");
324 } 324 }
325 tracer.trace("h"); 325 tracer.trace("h");
326 } 326 }
327 327
328 foo14(Tracer tracer) async { 328 foo14(Tracer tracer) async {
329 try { 329 try {
330 try { 330 try {
331 tracer.trace("a"); 331 tracer.trace("a");
332 throw "Error"; 332 throw "Error";
333 } catch (error) { 333 } catch (error) {
334 tracer.trace("b"); 334 tracer.trace("b");
335 try { 335 try {
336 await new Future.value(3); /// forceAwait: continued 336 await new Future.value(3); //# forceAwait: continued
337 throw "Error2"; 337 throw "Error2";
338 } catch(error) { 338 } catch(error) {
339 tracer.trace("c"); 339 tracer.trace("c");
340 } finally { 340 } finally {
341 tracer.trace("d"); 341 tracer.trace("d");
342 } 342 }
343 tracer.trace("e"); 343 tracer.trace("e");
344 throw "Error3"; 344 throw "Error3";
345 } finally { 345 } finally {
346 tracer.trace("f"); 346 tracer.trace("f");
347 } 347 }
348 } finally { 348 } finally {
349 tracer.trace("g"); 349 tracer.trace("g");
350 } 350 }
351 tracer.trace("h"); 351 tracer.trace("h");
352 } 352 }
353 353
354 foo15(Tracer tracer) async { 354 foo15(Tracer tracer) async {
355 try { 355 try {
356 try { 356 try {
357 tracer.trace("a"); 357 tracer.trace("a");
358 throw "Error"; 358 throw "Error";
359 } catch (error) { 359 } catch (error) {
360 tracer.trace("b"); 360 tracer.trace("b");
361 try { 361 try {
362 await new Future.value(3); /// forceAwait: continued 362 await new Future.value(3); //# forceAwait: continued
363 throw "Error2"; 363 throw "Error2";
364 } catch(error) { 364 } catch(error) {
365 tracer.trace("c"); 365 tracer.trace("c");
366 } finally { 366 } finally {
367 tracer.trace("d"); 367 tracer.trace("d");
368 } 368 }
369 tracer.trace("e"); 369 tracer.trace("e");
370 throw "Error3"; 370 throw "Error3";
371 } finally { 371 } finally {
372 tracer.trace("f"); 372 tracer.trace("f");
373 return; 373 return;
374 } 374 }
375 } finally { 375 } finally {
376 tracer.trace("g"); 376 tracer.trace("g");
377 } 377 }
378 tracer.trace("h"); 378 tracer.trace("h");
379 } 379 }
380 380
381 foo16(Tracer tracer) async { 381 foo16(Tracer tracer) async {
382 try { 382 try {
383 try { 383 try {
384 tracer.trace("a"); 384 tracer.trace("a");
385 throw "Error"; 385 throw "Error";
386 } catch (error) { 386 } catch (error) {
387 tracer.trace("b"); 387 tracer.trace("b");
388 try { 388 try {
389 await new Future.value(3); /// forceAwait: continued 389 await new Future.value(3); //# forceAwait: continued
390 throw "Error2"; 390 throw "Error2";
391 } catch(error) { 391 } catch(error) {
392 tracer.trace("c"); 392 tracer.trace("c");
393 } finally { 393 } finally {
394 tracer.trace("d"); 394 tracer.trace("d");
395 return; 395 return;
396 } 396 }
397 tracer.trace("e"); 397 tracer.trace("e");
398 throw "Error3"; 398 throw "Error3";
399 } finally { 399 } finally {
400 tracer.trace("f"); 400 tracer.trace("f");
401 } 401 }
402 } finally { 402 } finally {
403 tracer.trace("g"); 403 tracer.trace("g");
404 } 404 }
405 tracer.trace("h"); 405 tracer.trace("h");
406 } 406 }
407 407
408 foo17(Tracer tracer) async { 408 foo17(Tracer tracer) async {
409 try { 409 try {
410 tracer.trace("a"); 410 tracer.trace("a");
411 } finally { 411 } finally {
412 try { 412 try {
413 tracer.trace("b"); 413 tracer.trace("b");
414 throw "Error"; 414 throw "Error";
415 } catch (error) { 415 } catch (error) {
416 await new Future.value(3); /// forceAwait: continued 416 await new Future.value(3); //# forceAwait: continued
417 Expect.equals("Error", error); 417 Expect.equals("Error", error);
418 tracer.trace("c"); 418 tracer.trace("c");
419 } finally { 419 } finally {
420 tracer.trace("d"); 420 tracer.trace("d");
421 } 421 }
422 tracer.trace("e"); 422 tracer.trace("e");
423 } 423 }
424 tracer.trace("f"); 424 tracer.trace("f");
425 } 425 }
426 426
427 foo18(Tracer tracer) async { 427 foo18(Tracer tracer) async {
428 try { 428 try {
429 tracer.trace("a"); 429 tracer.trace("a");
430 } finally { 430 } finally {
431 try { 431 try {
432 tracer.trace("b"); 432 tracer.trace("b");
433 } finally { 433 } finally {
434 await new Future.value(3); /// forceAwait: continued 434 await new Future.value(3); //# forceAwait: continued
435 tracer.trace("c"); 435 tracer.trace("c");
436 } 436 }
437 tracer.trace("d"); 437 tracer.trace("d");
438 } 438 }
439 tracer.trace("e"); 439 tracer.trace("e");
440 } 440 }
441 441
442 runTest(expectedTrace, fun, [expectedError]) async { 442 runTest(expectedTrace, fun, [expectedError]) async {
443 Tracer tracer = new Tracer(expectedTrace, expectedTrace); 443 Tracer tracer = new Tracer(expectedTrace, expectedTrace);
444 try { 444 try {
(...skipping 23 matching lines...) Expand all
468 await runTest("abcdefgX", foo14, "Error3"); 468 await runTest("abcdefgX", foo14, "Error3");
469 await runTest("abcdefg", foo15); 469 await runTest("abcdefg", foo15);
470 await runTest("abcdfg", foo16); 470 await runTest("abcdfg", foo16);
471 await runTest("abcdef", foo17); 471 await runTest("abcdef", foo17);
472 await runTest("abcde", foo18); 472 await runTest("abcde", foo18);
473 } 473 }
474 474
475 void main() { 475 void main() {
476 asyncTest(test); 476 asyncTest(test);
477 } 477 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698