| 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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 test('should pass through a value from the future', () { | 57 test('should pass through a value from the future', () { |
| 58 expect(future, completion(equals('value'))); | 58 expect(future, completion(equals('value'))); |
| 59 expect(errorGroup.done, completes); | 59 expect(errorGroup.done, completes); |
| 60 completer.complete('value'); | 60 completer.complete('value'); |
| 61 }); | 61 }); |
| 62 | 62 |
| 63 test("shouldn't allow additional futures or streams once .done has " | 63 test("shouldn't allow additional futures or streams once .done has " |
| 64 "been called", () { | 64 "been called", () { |
| 65 completer.complete('value'); | 65 completer.complete('value'); |
| 66 | 66 |
| 67 completer.future.then(expectAsync1((_) { | 67 expect(completer.future |
| 68 expect(() => errorGroup.registerFuture(new Future.value()), | 68 .then((_) => errorGroup.registerFuture(new Future.value())), |
| 69 throwsStateError); |
| 70 expect(completer.future |
| 71 .then((_) => errorGroup.registerStream( |
| 72 new StreamController(sync: true).stream)), |
| 69 throwsStateError); | 73 throwsStateError); |
| 70 expect(() => errorGroup.registerStream( | |
| 71 new StreamController(sync: true).stream), | |
| 72 throwsStateError); | |
| 73 })); | |
| 74 }); | 74 }); |
| 75 | 75 |
| 76 test('should pass through an exception from the future if it has a ' | 76 test('should pass through an exception from the future if it has a ' |
| 77 'listener', () { | 77 'listener', () { |
| 78 expect(future, throwsFormatException); | 78 expect(future, throwsFormatException); |
| 79 // errorGroup shouldn't top-level the exception | 79 // errorGroup shouldn't top-level the exception |
| 80 completer.completeError(new FormatException()); | 80 completer.completeError(new FormatException()); |
| 81 }); | 81 }); |
| 82 | 82 |
| 83 test('should notify the error group of an exception from the future even ' | 83 test('should notify the error group of an exception from the future even ' |
| (...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 437 completion(equals(['value1', 'value2']))); | 437 completion(equals(['value1', 'value2']))); |
| 438 controller..add('value1')..add('value2')..close(); | 438 controller..add('value1')..add('value2')..close(); |
| 439 | 439 |
| 440 expect(signal.future.then((_) { | 440 expect(signal.future.then((_) { |
| 441 // shouldn't cause a top-level exception | 441 // shouldn't cause a top-level exception |
| 442 completer.completeError(new FormatException()); | 442 completer.completeError(new FormatException()); |
| 443 }), completes); | 443 }), completes); |
| 444 }); | 444 }); |
| 445 }); | 445 }); |
| 446 } | 446 } |
| OLD | NEW |