| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // BSD-style license that can be found in the LICENSE file. | |
| 4 | |
| 5 import "dart:async"; | |
| 6 import "package:expect/expect.dart"; | |
| 7 import "package:async_helper/async_helper.dart"; | |
| 8 | |
| 9 expectList(stream, list) { | |
| 10 return stream.toList().then((v) { | |
| 11 Expect.listEquals(v, list); | |
| 12 }); | |
| 13 } | |
| 14 | |
| 15 Stream makeStream(int n) async* { | |
| 16 for (int i = 0; i < n; i++) yield i; | |
| 17 } | |
| 18 | |
| 19 main() { | |
| 20 fivePartialSums(Stream s) async* { | |
| 21 var r = 0; | |
| 22 await for (var v in s.take(5)) yield r += v; | |
| 23 } | |
| 24 | |
| 25 asyncStart(); | |
| 26 expectList(fivePartialSums(makeStream(10)), [0, 1, 3, 6, 10]) | |
| 27 .then(asyncSuccess); | |
| 28 } | |
| OLD | NEW |