Index: tests/corelib/future_test.dart |
diff --git a/tests/corelib/future_test.dart b/tests/corelib/future_test.dart |
index 9ed1db54ed8a38e398b61fb2691a54d1067b8f12..1916dddfeddb9e0b68c331cf44b5835a13689713 100644 |
--- a/tests/corelib/future_test.dart |
+++ b/tests/corelib/future_test.dart |
@@ -565,6 +565,92 @@ testTransformExceptionReturnsAFuture() { |
Expect.equals("transformed value", transformedFuture.value); |
} |
+// Tests for branching exceptions |
+ |
+testExceptionTravelsAlongBothBranches() { |
+ var results = <int>[]; |
+ |
+ var completer = new Completer(); |
+ var branch1 = completer.future.transform((_) => null); |
+ var branch2 = completer.future.transform((_) => null); |
+ |
+ branch1.handleException((e) { |
+ results.add(1); |
+ return true; |
+ }); |
+ |
+ branch2.handleException((e) { |
+ results.add(2); |
+ return true; |
+ }); |
+ |
+ completer.completeException("error"); |
+ Expect.setEquals([1, 2], results); |
+} |
+ |
+testExceptionTravelsAlongBothBranchesAfterComplete() { |
+ var results = <int>[]; |
+ |
+ var completer = new Completer(); |
+ completer.completeException("error"); |
+ |
+ var branch1 = completer.future.transform((_) => null); |
+ var branch2 = completer.future.transform((_) => null); |
+ |
+ branch1.handleException((e) { |
+ results.add(1); |
+ return true; |
+ }); |
+ |
+ branch2.handleException((e) { |
+ results.add(2); |
+ return true; |
+ }); |
+ |
+ Expect.setEquals([1, 2], results); |
+} |
+ |
+testExceptionIsHandledInBaseAndBranch() { |
+ var results = <String>[]; |
+ |
+ var completer = new Completer(); |
+ var branch = completer.future.transform((_) => null); |
+ |
+ completer.future.handleException((e) { |
+ results.add("base"); |
+ return true; |
+ }); |
+ |
+ branch.handleException((e) { |
+ results.add("branch"); |
+ return true; |
+ }); |
+ |
+ completer.completeException("error"); |
+ Expect.setEquals(["base", "branch"], results); |
+} |
+ |
+testExceptionIsHandledInBaseAndBranchAfterComplete() { |
+ var results = <String>[]; |
+ |
+ var completer = new Completer(); |
+ completer.completeException("error"); |
+ |
+ var branch = completer.future.transform((_) => null); |
+ |
+ completer.future.handleException((e) { |
+ results.add("base"); |
+ return true; |
+ }); |
+ |
+ branch.handleException((e) { |
+ results.add("branch"); |
+ return true; |
+ }); |
+ |
+ Expect.setEquals(["base", "branch"], results); |
+} |
+ |
main() { |
testImmediate(); |
testNeverComplete(); |
@@ -605,4 +691,8 @@ main() { |
testTransformExceptionThrows(); |
testTransformExceptionReturns(); |
testTransformExceptionReturnsAFuture(); |
+ testExceptionTravelsAlongBothBranches(); |
+ testExceptionTravelsAlongBothBranchesAfterComplete(); |
+ testExceptionIsHandledInBaseAndBranch(); |
+ testExceptionIsHandledInBaseAndBranchAfterComplete(); |
} |