OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 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 | 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 // VMOptions=--enable_async --optimization-counter-threshold=5 | 5 // VMOptions=--enable_async --optimization-counter-threshold=5 |
6 | 6 |
7 import 'package:expect/expect.dart'; | 7 import 'package:expect/expect.dart'; |
8 | 8 |
9 import 'dart:async'; | 9 import 'dart:async'; |
10 | 10 |
(...skipping 30 matching lines...) Expand all Loading... |
41 throw x; | 41 throw x; |
42 } catch (e1) { | 42 } catch (e1) { |
43 var y = await baz(e1 + 1); | 43 var y = await baz(e1 + 1); |
44 throw y; | 44 throw y; |
45 } | 45 } |
46 } catch (e2) { | 46 } catch (e2) { |
47 return e2; | 47 return e2; |
48 } | 48 } |
49 } | 49 } |
50 | 50 |
| 51 nesting() async { |
| 52 try { |
| 53 try { |
| 54 var x = 1; |
| 55 var y = () async { |
| 56 try { |
| 57 var z = (await bar(3)) + x; |
| 58 throw z; |
| 59 } catch (e1) { |
| 60 return e1; |
| 61 } |
| 62 }; |
| 63 var a = await y(); |
| 64 throw a; |
| 65 } catch (e2) { |
| 66 throw e2 + 1; |
| 67 } |
| 68 } catch (e3) { |
| 69 return e3; |
| 70 } |
| 71 } |
| 72 |
51 main() async { | 73 main() async { |
52 var result; | 74 var result; |
53 for (int i = 0; i < 10; i++) { | 75 for (int i = 0; i < 10; i++) { |
54 result = await foo(); | 76 result = await foo(); |
55 Expect.equals(result, 30); | 77 Expect.equals(result, 30); |
56 result = await quaz(17); | 78 result = await quaz(17); |
57 Expect.equals(result, 17); | 79 Expect.equals(result, 17); |
58 result = await quazz(); | 80 result = await quazz(); |
59 Expect.equals(result, 2); | 81 Expect.equals(result, 2); |
| 82 result = await nesting(); |
| 83 Expect.equals(result, 5); |
60 } | 84 } |
61 } | 85 } |
OLD | NEW |