| 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 'package:unittest/unittest.dart'; | 9 import 'package:unittest/unittest.dart'; |
| 10 | 10 |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 }), completes); | 196 }), completes); |
| 197 }); | 197 }); |
| 198 }); | 198 }); |
| 199 | 199 |
| 200 group('with a single stream', () { | 200 group('with a single stream', () { |
| 201 StreamController controller; | 201 StreamController controller; |
| 202 Stream stream; | 202 Stream stream; |
| 203 | 203 |
| 204 setUp(() { | 204 setUp(() { |
| 205 errorGroup = new ErrorGroup(); | 205 errorGroup = new ErrorGroup(); |
| 206 controller = new StreamController.broadcast(); | 206 controller = new StreamController(); |
| 207 stream = errorGroup.registerStream(controller.stream); | 207 stream = errorGroup.registerStream(controller.stream.asBroadcastStream()); |
| 208 }); | 208 }); |
| 209 | 209 |
| 210 test('should pass through values from the stream', () { | 210 test('should pass through values from the stream', () { |
| 211 expect(stream.elementAt(0), completion(equals(1))); | 211 expect(stream.elementAt(0), completion(equals(1))); |
| 212 expect(stream.elementAt(1), completion(equals(2))); | 212 expect(stream.elementAt(1), completion(equals(2))); |
| 213 expect(errorGroup.done, completes); | 213 expect(errorGroup.done, completes); |
| 214 | 214 |
| 215 controller..add(1)..add(2)..close(); | 215 controller..add(1)..add(2)..close(); |
| 216 }); | 216 }); |
| 217 | 217 |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 335 }); | 335 }); |
| 336 | 336 |
| 337 group('with multiple streams', () { | 337 group('with multiple streams', () { |
| 338 StreamController controller1; | 338 StreamController controller1; |
| 339 StreamController controller2; | 339 StreamController controller2; |
| 340 Stream stream1; | 340 Stream stream1; |
| 341 Stream stream2; | 341 Stream stream2; |
| 342 | 342 |
| 343 setUp(() { | 343 setUp(() { |
| 344 errorGroup = new ErrorGroup(); | 344 errorGroup = new ErrorGroup(); |
| 345 controller1 = new StreamController.broadcast(); | 345 controller1 = new StreamController(); |
| 346 controller2 = new StreamController.broadcast(); | 346 controller2 = new StreamController(); |
| 347 stream1 = errorGroup.registerStream(controller1.stream); | 347 stream1 = errorGroup.registerStream(controller1.stream.asBroadcastStream()
); |
| 348 stream2 = errorGroup.registerStream(controller2.stream); | 348 stream2 = errorGroup.registerStream(controller2.stream.asBroadcastStream()
); |
| 349 }); | 349 }); |
| 350 | 350 |
| 351 test("should pipe exceptions from one stream to the other and to .done", | 351 test("should pipe exceptions from one stream to the other and to .done", |
| 352 () { | 352 () { |
| 353 expect(stream1.first, throwsFormatException); | 353 expect(stream1.first, throwsFormatException); |
| 354 expect(stream2.first, throwsFormatException); | 354 expect(stream2.first, throwsFormatException); |
| 355 expect(errorGroup.done, throwsFormatException); | 355 expect(errorGroup.done, throwsFormatException); |
| 356 | 356 |
| 357 controller1.addError(new AsyncError(new FormatException())); | 357 controller1.addError(new AsyncError(new FormatException())); |
| 358 }); | 358 }); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 390 }); | 390 }); |
| 391 | 391 |
| 392 group('with a stream and a future', () { | 392 group('with a stream and a future', () { |
| 393 StreamController controller; | 393 StreamController controller; |
| 394 Stream stream; | 394 Stream stream; |
| 395 Completer completer; | 395 Completer completer; |
| 396 Future future; | 396 Future future; |
| 397 | 397 |
| 398 setUp(() { | 398 setUp(() { |
| 399 errorGroup = new ErrorGroup(); | 399 errorGroup = new ErrorGroup(); |
| 400 controller = new StreamController.broadcast(); | 400 controller = new StreamController(); |
| 401 stream = errorGroup.registerStream(controller.stream); | 401 stream = errorGroup.registerStream(controller.stream.asBroadcastStream()); |
| 402 completer = new Completer(); | 402 completer = new Completer(); |
| 403 future = errorGroup.registerFuture(completer.future); | 403 future = errorGroup.registerFuture(completer.future); |
| 404 }); | 404 }); |
| 405 | 405 |
| 406 test("should pipe exceptions from the stream to the future", () { | 406 test("should pipe exceptions from the stream to the future", () { |
| 407 expect(stream.first, throwsFormatException); | 407 expect(stream.first, throwsFormatException); |
| 408 expect(future, throwsFormatException); | 408 expect(future, throwsFormatException); |
| 409 expect(errorGroup.done, throwsFormatException); | 409 expect(errorGroup.done, throwsFormatException); |
| 410 | 410 |
| 411 controller.addError(new AsyncError(new FormatException())); | 411 controller.addError(new AsyncError(new FormatException())); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 445 expect(stream.toList(), completion(equals(['value1', 'value2']))); | 445 expect(stream.toList(), completion(equals(['value1', 'value2']))); |
| 446 controller..add('value1')..add('value2')..close(); | 446 controller..add('value1')..add('value2')..close(); |
| 447 | 447 |
| 448 expect(stream.toList().then((_) { | 448 expect(stream.toList().then((_) { |
| 449 // shouldn't cause a top-level exception | 449 // shouldn't cause a top-level exception |
| 450 completer.completeError(new FormatException()); | 450 completer.completeError(new FormatException()); |
| 451 }), completes); | 451 }), completes); |
| 452 }); | 452 }); |
| 453 }); | 453 }); |
| 454 } | 454 } |
| OLD | NEW |