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 "package:expect/expect.dart"; | 6 import "package:expect/expect.dart"; |
6 import "package:async_helper/async_helper.dart"; | 7 import "package:async_helper/async_helper.dart"; |
7 | 8 |
8 foo() async { | 9 mkStream(int n) async* { |
Lasse Reichstein Nielsen
2015/08/06 12:38:41
I'd add "Stream" as return type.
Just because chec
| |
9 throw 42; | 10 for (int i = 0; i < n; i++) yield i; |
10 } | |
11 | |
12 test() async { | |
13 var exception; | |
14 try { | |
15 await foo(); | |
16 } catch (e) { | |
17 print(await(e)); | |
18 await (exception = await e); | |
19 } | |
20 Expect.equals(42, exception); | |
21 } | 11 } |
22 | 12 |
23 main() { | 13 main() { |
14 f(s) async { | |
15 var r = 0; | |
16 await for(var v in s.take(5)) r += v; | |
17 return r; | |
18 } | |
19 | |
24 asyncStart(); | 20 asyncStart(); |
25 test().then((_) => asyncEnd()); | 21 f(mkStream(10)).then((v) { |
22 Expect.equals(10, v); | |
23 asyncEnd(); | |
24 }); | |
26 } | 25 } |
26 | |
OLD | NEW |