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 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
257 stream.expect(allow(inOrder([1, 2, 3]))); | 257 stream.expect(allow(inOrder([1, 2, 3]))); |
258 stream.expect(4); | 258 stream.expect(4); |
259 }); | 259 }); |
260 | 260 |
261 expectTestPasses("allow() consumes nothing if the matcher doesn't match", () { | 261 expectTestPasses("allow() consumes nothing if the matcher doesn't match", () { |
262 var stream = createStream(); | 262 var stream = createStream(); |
263 stream.expect(allow(inOrder([1, 2, 100]))); | 263 stream.expect(allow(inOrder([1, 2, 100]))); |
264 stream.expect(1); | 264 stream.expect(1); |
265 }); | 265 }); |
266 | 266 |
| 267 expectTestPasses("never() consumes everything if the matcher never matches", |
| 268 () { |
| 269 var stream = createStream(); |
| 270 stream.expect(never(inOrder([2, 1]))); |
| 271 }); |
| 272 |
| 273 expectTestFails("never() fails if the matcher matches", () { |
| 274 var stream = createStream(); |
| 275 stream.expect(never(inOrder([2, 3]))); |
| 276 }, (errors) { |
| 277 expect(errors, hasLength(1)); |
| 278 expect(errors.first.error.message, equals( |
| 279 "Expected: never\n" |
| 280 " | * <2>\n" |
| 281 " | * <3>\n" |
| 282 " Emitted: * 1\n" |
| 283 " * 2\n" |
| 284 " * 3\n" |
| 285 " Which: matched\n" |
| 286 " | * <2>\n" |
| 287 " | * <3>")); |
| 288 }); |
| 289 |
267 expectTestPasses("isDone succeeds at the end of the stream", () { | 290 expectTestPasses("isDone succeeds at the end of the stream", () { |
268 var stream = createStream(); | 291 var stream = createStream(); |
269 stream.expect(consumeThrough(5)); | 292 stream.expect(consumeThrough(5)); |
270 stream.expect(isDone); | 293 stream.expect(isDone); |
271 }); | 294 }); |
272 | 295 |
273 expectTestFails("isDone fails before the end of the stream", () { | 296 expectTestFails("isDone fails before the end of the stream", () { |
274 var stream = createStream(); | 297 var stream = createStream(); |
275 stream.expect(consumeThrough(4)); | 298 stream.expect(consumeThrough(4)); |
276 stream.expect(isDone); | 299 stream.expect(isDone); |
277 }, (errors) { | 300 }, (errors) { |
278 expect(errors, hasLength(1)); | 301 expect(errors, hasLength(1)); |
279 expect(errors.first.error.message, equals( | 302 expect(errors.first.error.message, equals( |
280 "Expected: is done\n" | 303 "Expected: is done\n" |
281 " Emitted: * 1\n" | 304 " Emitted: * 1\n" |
282 " * 2\n" | 305 " * 2\n" |
283 " * 3\n" | 306 " * 3\n" |
284 " * 4\n" | 307 " * 4\n" |
285 " * 5\n" | 308 " * 5\n" |
286 " Which: stream wasn't finished")); | 309 " Which: stream wasn't finished")); |
287 }); | 310 }); |
288 } | 311 } |
OLD | NEW |