| 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 error_group_test; | 5 library error_group_test; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 | 8 |
| 9 import '../../../pkg/unittest/lib/unittest.dart'; | 9 import '../../../pkg/unittest/lib/unittest.dart'; |
| 10 import '../../pub/error_group.dart'; | 10 import '../../pub/error_group.dart'; |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 }), completes); | 195 }), completes); |
| 196 }); | 196 }); |
| 197 }); | 197 }); |
| 198 | 198 |
| 199 group('with a single stream', () { | 199 group('with a single stream', () { |
| 200 StreamController controller; | 200 StreamController controller; |
| 201 Stream stream; | 201 Stream stream; |
| 202 | 202 |
| 203 setUp(() { | 203 setUp(() { |
| 204 errorGroup = new ErrorGroup(); | 204 errorGroup = new ErrorGroup(); |
| 205 controller = new StreamController.multiSubscription(); | 205 controller = new StreamController.broadcast(); |
| 206 stream = errorGroup.registerStream(controller.stream); | 206 stream = errorGroup.registerStream(controller.stream); |
| 207 }); | 207 }); |
| 208 | 208 |
| 209 test('should pass through values from the stream', () { | 209 test('should pass through values from the stream', () { |
| 210 expect(stream.elementAt(0), completion(equals(1))); | 210 expect(stream.elementAt(0), completion(equals(1))); |
| 211 expect(stream.elementAt(1), completion(equals(2))); | 211 expect(stream.elementAt(1), completion(equals(2))); |
| 212 expect(errorGroup.done, completes); | 212 expect(errorGroup.done, completes); |
| 213 | 213 |
| 214 controller..add(1)..add(2)..close(); | 214 controller..add(1)..add(2)..close(); |
| 215 }); | 215 }); |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 334 }); | 334 }); |
| 335 | 335 |
| 336 group('with multiple streams', () { | 336 group('with multiple streams', () { |
| 337 StreamController controller1; | 337 StreamController controller1; |
| 338 StreamController controller2; | 338 StreamController controller2; |
| 339 Stream stream1; | 339 Stream stream1; |
| 340 Stream stream2; | 340 Stream stream2; |
| 341 | 341 |
| 342 setUp(() { | 342 setUp(() { |
| 343 errorGroup = new ErrorGroup(); | 343 errorGroup = new ErrorGroup(); |
| 344 controller1 = new StreamController.multiSubscription(); | 344 controller1 = new StreamController.broadcast(); |
| 345 controller2 = new StreamController.multiSubscription(); | 345 controller2 = new StreamController.broadcast(); |
| 346 stream1 = errorGroup.registerStream(controller1.stream); | 346 stream1 = errorGroup.registerStream(controller1.stream); |
| 347 stream2 = errorGroup.registerStream(controller2.stream); | 347 stream2 = errorGroup.registerStream(controller2.stream); |
| 348 }); | 348 }); |
| 349 | 349 |
| 350 test("should pipe exceptions from one stream to the other and to .done", | 350 test("should pipe exceptions from one stream to the other and to .done", |
| 351 () { | 351 () { |
| 352 expect(stream1.first, throwsFormatException); | 352 expect(stream1.first, throwsFormatException); |
| 353 expect(stream2.first, throwsFormatException); | 353 expect(stream2.first, throwsFormatException); |
| 354 expect(errorGroup.done, throwsFormatException); | 354 expect(errorGroup.done, throwsFormatException); |
| 355 | 355 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 389 }); | 389 }); |
| 390 | 390 |
| 391 group('with a stream and a future', () { | 391 group('with a stream and a future', () { |
| 392 StreamController controller; | 392 StreamController controller; |
| 393 Stream stream; | 393 Stream stream; |
| 394 Completer completer; | 394 Completer completer; |
| 395 Future future; | 395 Future future; |
| 396 | 396 |
| 397 setUp(() { | 397 setUp(() { |
| 398 errorGroup = new ErrorGroup(); | 398 errorGroup = new ErrorGroup(); |
| 399 controller = new StreamController.multiSubscription(); | 399 controller = new StreamController.broadcast(); |
| 400 stream = errorGroup.registerStream(controller.stream); | 400 stream = errorGroup.registerStream(controller.stream); |
| 401 completer = new Completer(); | 401 completer = new Completer(); |
| 402 future = errorGroup.registerFuture(completer.future); | 402 future = errorGroup.registerFuture(completer.future); |
| 403 }); | 403 }); |
| 404 | 404 |
| 405 test("should pipe exceptions from the stream to the future", () { | 405 test("should pipe exceptions from the stream to the future", () { |
| 406 expect(stream.first, throwsFormatException); | 406 expect(stream.first, throwsFormatException); |
| 407 expect(future, throwsFormatException); | 407 expect(future, throwsFormatException); |
| 408 expect(errorGroup.done, throwsFormatException); | 408 expect(errorGroup.done, throwsFormatException); |
| 409 | 409 |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 457 const isStateError = const _StateError(); | 457 const isStateError = const _StateError(); |
| 458 | 458 |
| 459 /// A matcher for functions that throw StateError. | 459 /// A matcher for functions that throw StateError. |
| 460 const Matcher throwsStateError = | 460 const Matcher throwsStateError = |
| 461 const Throws(isStateError); | 461 const Throws(isStateError); |
| 462 | 462 |
| 463 class _StateError extends TypeMatcher { | 463 class _StateError extends TypeMatcher { |
| 464 const _StateError() : super("StateError"); | 464 const _StateError() : super("StateError"); |
| 465 bool matches(item, MatchState matchState) => item is StateError; | 465 bool matches(item, MatchState matchState) => item is StateError; |
| 466 } | 466 } |
| OLD | NEW |