OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 "dart:async"; |
6 | 6 |
7 import "package:async/async.dart"; | 7 import "package:async/async.dart"; |
8 import "package:test/test.dart"; | 8 import "package:test/test.dart"; |
9 | 9 |
10 /// Create an error with the same values as [base], except that it throwsA | 10 /// Create an error with the same values as [base], except that it throwsA |
(...skipping 18 matching lines...) Expand all Loading... |
29 } | 29 } |
30 }); | 30 }); |
31 return controller.stream; | 31 return controller.stream; |
32 } | 32 } |
33 | 33 |
34 /// Counter used to give varying delays for streams. | 34 /// Counter used to give varying delays for streams. |
35 int ctr = 0; | 35 int ctr = 0; |
36 | 36 |
37 main() { | 37 main() { |
38 // Test that zipping [streams] gives the results iterated by [expectedData]. | 38 // Test that zipping [streams] gives the results iterated by [expectedData]. |
39 testZip(Iterable streams, Iterable expectedData) { | 39 testZip(Iterable<Stream> streams, Iterable expectedData) { |
40 List data = []; | 40 List data = []; |
41 Stream zip = new StreamZip(streams); | 41 Stream zip = new StreamZip(streams); |
42 zip.listen(data.add, onDone: expectAsync(() { | 42 zip.listen(data.add, onDone: expectAsync(() { |
43 expect(data, equals(expectedData)); | 43 expect(data, equals(expectedData)); |
44 })); | 44 })); |
45 } | 45 } |
46 | 46 |
47 test("Basic", () { | 47 test("Basic", () { |
48 testZip([mks([1, 2, 3]), mks([4, 5, 6]), mks([7, 8, 9])], | 48 testZip([mks([1, 2, 3]), mks([4, 5, 6]), mks([7, 8, 9])], |
49 [[1, 4, 7], [2, 5, 8], [3, 6, 9]]); | 49 [[1, 4, 7], [2, 5, 8], [3, 6, 9]]); |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
227 } else if (ctr == 2) { | 227 } else if (ctr == 2) { |
228 sub.pause(); | 228 sub.pause(); |
229 new Future.delayed(const Duration(milliseconds: 25)).then((_) { | 229 new Future.delayed(const Duration(milliseconds: 25)).then((_) { |
230 sub.resume(); | 230 sub.resume(); |
231 }); | 231 }); |
232 } | 232 } |
233 ctr++; | 233 ctr++; |
234 }, count: 4)); | 234 }, count: 4)); |
235 }); | 235 }); |
236 } | 236 } |
OLD | NEW |