OLD | NEW |
1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2017, 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 'package:unittest/unittest.dart'; | 5 import 'package:unittest/unittest.dart'; |
6 | 6 |
7 thrower() async { | 7 thrower() async { |
8 throw 'oops'; | 8 throw 'oops'; |
9 } | 9 } |
10 | 10 |
11 number() async { | 11 number() async { |
12 return 4; | 12 return 4; |
13 } | 13 } |
14 | 14 |
15 generator() async* { | 15 generator() async* { |
16 yield await number(); | 16 yield await number(); |
17 yield await thrower(); | 17 yield await thrower(); |
18 } | 18 } |
19 | 19 |
20 foo() async { | 20 foo() async { |
21 await for (var i in generator()) { | 21 await for (var i in generator()) { |
22 print(i); | 22 print(i); |
23 } | 23 } |
24 } | 24 } |
25 | 25 |
26 main() async { | 26 main() async { |
27 // Test async and async*. | 27 // Test async and async*. |
28 try { | 28 try { |
29 await foo(); | 29 await foo(); |
| 30 fail("Did not throw"); |
30 } catch (e, st) { | 31 } catch (e, st) { |
31 expect(st.toString(), stringContainsInOrder([ | 32 expect(st.toString(), stringContainsInOrder([ |
32 'thrower', '.dart:8', | 33 'thrower', '.dart:8', |
33 '<asynchronous suspension>', | 34 '<asynchronous suspension>', |
34 'generator', '.dart:17', | 35 'generator', '.dart:17', |
35 '<asynchronous suspension>', | 36 '<asynchronous suspension>', |
36 'foo', '.dart:21', | 37 'foo', '.dart:21', |
37 '<asynchronous suspension>', | 38 '<asynchronous suspension>', |
38 'main', | 39 'main', |
39 ])); | 40 ])); |
(...skipping 25 matching lines...) Expand all Loading... |
65 // Test for correct linkage. | 66 // Test for correct linkage. |
66 try { | 67 try { |
67 await thrower(); | 68 await thrower(); |
68 } catch(e, st) { | 69 } catch(e, st) { |
69 expect(st.toString(), stringContainsInOrder([ | 70 expect(st.toString(), stringContainsInOrder([ |
70 'thrower', '.dart:8', | 71 'thrower', '.dart:8', |
71 '<asynchronous suspension>', | 72 '<asynchronous suspension>', |
72 'main', '.dart:67', | 73 'main', '.dart:67', |
73 ])); | 74 ])); |
74 } | 75 } |
75 } | 76 } |
OLD | NEW |