Chromium Code Reviews| 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 // VMOptions=--enable_async --optimization-counter-threshold=5 | |
| 6 | |
| 7 import 'package:expect/expect.dart'; | |
| 8 | |
| 9 import 'dart:async'; | |
| 10 | |
| 11 // It does not matter where a future is generated. | |
| 12 bar(p) async => p; | |
| 13 baz(p) => new Future(() => p); | |
| 14 | |
| 15 test0_1() async { | |
| 16 throw 1; | |
| 17 } | |
| 18 | |
| 19 test0() async { | |
| 20 try { | |
| 21 await test0_1(); | |
| 22 } catch (e) { | |
| 23 Expect.equals(1, e); | |
| 24 } | |
| 25 } | |
| 26 | |
| 27 test1_1() async { | |
| 28 throw 1; | |
| 29 } | |
| 30 | |
| 31 test1_2() async { | |
| 32 try { | |
| 33 await test1_1(); | |
| 34 } catch (e) { | |
| 35 throw e+1; | |
| 36 } | |
| 37 } | |
| 38 | |
| 39 test1() async { | |
| 40 try { | |
| 41 await test1_2(); | |
| 42 } catch (e) { | |
| 43 Expect.equals(2, e); | |
| 44 } | |
| 45 } | |
| 46 | |
| 47 test2() async { | |
| 48 var x; | |
| 49 var test2_1 = () async { | |
| 50 try { | |
| 51 throw 'a'; | |
| 52 } catch (e) { | |
| 53 throw e + 'b'; | |
| 54 } | |
| 55 }; | |
| 56 try { | |
| 57 try { | |
| 58 await test2_1(); | |
| 59 } catch (e) { | |
| 60 var y = await bar(e + 'c'); | |
| 61 throw y; | |
| 62 } | |
| 63 } catch (e) { | |
| 64 x = e + 'd'; | |
| 65 return '?'; | |
| 66 } finally { | |
| 67 print(x); | |
|
srdjan
2014/09/05 19:32:10
Why printing in test?
Michael Lippautz (Google)
2014/09/05 19:50:18
Left over. removed.
| |
| 68 return x; | |
| 69 } | |
| 70 return '!'; | |
| 71 } | |
| 72 | |
| 73 main() async { | |
| 74 var result; | |
| 75 for (int i = 0; i < 10; i++) { | |
| 76 await test0(); | |
| 77 await test1(); | |
| 78 result = await test2(); | |
| 79 Expect.equals('abcd', result); | |
| 80 } | |
| 81 } | |
| OLD | NEW |