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'; |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 expect(errors.first.error.message, equals( | 201 expect(errors.first.error.message, equals( |
202 "Expected: values followed by <100>\n" | 202 "Expected: values followed by <100>\n" |
203 " Emitted: * 1\n" | 203 " Emitted: * 1\n" |
204 " * 2\n" | 204 " * 2\n" |
205 " * 3\n" | 205 " * 3\n" |
206 " * 4\n" | 206 " * 4\n" |
207 " * 5\n" | 207 " * 5\n" |
208 " Which: unexpected end of stream")); | 208 " Which: unexpected end of stream")); |
209 }); | 209 }); |
210 | 210 |
| 211 expectTestPasses("consumeWhile() consumes values while the given matcher " |
| 212 "matches", () { |
| 213 var stream = createStream(); |
| 214 stream.expect(consumeWhile(lessThan(4))); |
| 215 stream.expect(4); |
| 216 }); |
| 217 |
| 218 expectTestPasses("consumeWhile() will stop if the first value doesn't match", |
| 219 () { |
| 220 var stream = createStream(); |
| 221 stream.expect(consumeWhile(2)); |
| 222 stream.expect(1); |
| 223 }); |
| 224 |
211 expectTestPasses("either() will match if the first branch matches", () { | 225 expectTestPasses("either() will match if the first branch matches", () { |
212 createStream().expect(either(1, 100)); | 226 createStream().expect(either(1, 100)); |
213 }); | 227 }); |
214 | 228 |
215 expectTestPasses("either() will match if the second branch matches", () { | 229 expectTestPasses("either() will match if the second branch matches", () { |
216 createStream().expect(either(100, 1)); | 230 createStream().expect(either(100, 1)); |
217 }); | 231 }); |
218 | 232 |
219 expectTestPasses("either() will consume the maximal number of values if both " | 233 expectTestPasses("either() will consume the maximal number of values if both " |
220 "branches match", () { | 234 "branches match", () { |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
302 expect(errors.first.error.message, equals( | 316 expect(errors.first.error.message, equals( |
303 "Expected: is done\n" | 317 "Expected: is done\n" |
304 " Emitted: * 1\n" | 318 " Emitted: * 1\n" |
305 " * 2\n" | 319 " * 2\n" |
306 " * 3\n" | 320 " * 3\n" |
307 " * 4\n" | 321 " * 4\n" |
308 " * 5\n" | 322 " * 5\n" |
309 " Which: stream wasn't finished")); | 323 " Which: stream wasn't finished")); |
310 }); | 324 }); |
311 } | 325 } |
OLD | NEW |