| 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 library scheduled_test.stream_matcher_test; | 5 library scheduled_test.stream_matcher_test; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 | 8 |
| 9 import 'package:scheduled_test/scheduled_stream.dart'; | 9 import 'package:scheduled_test/scheduled_stream.dart'; |
| 10 import 'package:scheduled_test/scheduled_test.dart'; | 10 import 'package:scheduled_test/scheduled_test.dart'; |
| 11 import 'package:scheduled_test/src/utils.dart'; | 11 import 'package:scheduled_test/src/utils.dart'; |
| 12 | 12 |
| 13 import '../metatest.dart'; | 13 import 'package:metatest/metatest.dart'; |
| 14 import '../utils.dart'; | 14 import '../utils.dart'; |
| 15 | 15 |
| 16 /// Returns a [ScheduledStream] that asynchronously emits the numbers 1 through | 16 /// Returns a [ScheduledStream] that asynchronously emits the numbers 1 through |
| 17 /// 5 and then closes. | 17 /// 5 and then closes. |
| 18 ScheduledStream createStream() { | 18 ScheduledStream createStream() { |
| 19 var controller = new StreamController(); | 19 var controller = new StreamController(); |
| 20 var stream = new ScheduledStream(controller.stream); | 20 var stream = new ScheduledStream(controller.stream); |
| 21 | 21 |
| 22 var future = pumpEventQueue(); | 22 var future = pumpEventQueue(); |
| 23 for (var i = 1; i <= 5; i++) { | 23 for (var i = 1; i <= 5; i++) { |
| 24 future = future.then((_) { | 24 future = future.then((_) { |
| 25 controller.add(i); | 25 controller.add(i); |
| 26 return pumpEventQueue(); | 26 return pumpEventQueue(); |
| 27 }); | 27 }); |
| 28 } | 28 } |
| 29 future.then((_) => controller.close()); | 29 future.then((_) => controller.close()); |
| 30 | 30 |
| 31 return stream; | 31 return stream; |
| 32 } | 32 } |
| 33 | 33 |
| 34 void main(_, message) { | 34 void main() => initTests(_test); |
| 35 |
| 36 void _test(message) { |
| 35 initMetatest(message); | 37 initMetatest(message); |
| 36 | 38 |
| 37 setUpTimeout(); | 39 setUpTimeout(); |
| 38 | 40 |
| 39 expectTestPasses("expect() with matching values passes", () { | 41 expectTestPasses("expect() with matching values passes", () { |
| 40 var stream = createStream(); | 42 var stream = createStream(); |
| 41 stream.expect(1); | 43 stream.expect(1); |
| 42 stream.expect(2); | 44 stream.expect(2); |
| 43 stream.expect(3); | 45 stream.expect(3); |
| 44 stream.expect(4); | 46 stream.expect(4); |
| (...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 324 expect(errors.first.error.message, equals( | 326 expect(errors.first.error.message, equals( |
| 325 "Expected: is done\n" | 327 "Expected: is done\n" |
| 326 " Emitted: * 1\n" | 328 " Emitted: * 1\n" |
| 327 " * 2\n" | 329 " * 2\n" |
| 328 " * 3\n" | 330 " * 3\n" |
| 329 " * 4\n" | 331 " * 4\n" |
| 330 " * 5\n" | 332 " * 5\n" |
| 331 " Which: stream wasn't finished")); | 333 " Which: stream wasn't finished")); |
| 332 }); | 334 }); |
| 333 } | 335 } |
| OLD | NEW |