Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(392)

Unified Diff: tests/corelib/src/FutureTest.dart

Issue 9533014: futures: handle exceptions immediately if the future already completed. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « corelib/src/implementation/future_implementation.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/corelib/src/FutureTest.dart
diff --git a/tests/corelib/src/FutureTest.dart b/tests/corelib/src/FutureTest.dart
index 43c11ff7800cb0c5ad3b0c00fee145f5c4d79c3e..967abbbf6618f814ab744b748b976a85a8b8c205 100644
--- a/tests/corelib/src/FutureTest.dart
+++ b/tests/corelib/src/FutureTest.dart
@@ -166,6 +166,30 @@ testExceptionHandlerReturnsFalse2() {
Expect.isTrue(reached);
}
+testExceptionHandlerAfterCompleteThenNotCalled() {
+ final completer = new Completer<int>();
+ final future = completer.future;
+ final ex = new Exception();
+
+ var ex2;
+ completer.completeException(ex);
+ future.handleException((e) { ex2 = e; return true; });
+ future.then((e) { });
+ Expect.equals(ex, ex2);
+}
+
+testExceptionHandlerAfterCompleteReturnsFalseThenThrows() {
+ final completer = new Completer<int>();
+ final future = completer.future;
+ final ex = new Exception();
+
+ var ex2;
+ completer.completeException(ex);
+ future.handleException((e) { ex2 = e; return false; });
+ Expect.throws(() { future.then((e) { }); });
+ Expect.equals(ex, ex2);
+}
+
// Tests for Future.transform
testTransformSuccess() {
@@ -263,6 +287,8 @@ main() {
testExceptionHandlerReturnsTrue2();
testExceptionHandlerReturnsFalse();
testExceptionHandlerReturnsFalse2();
+ testExceptionHandlerAfterCompleteThenNotCalled();
+ testExceptionHandlerAfterCompleteReturnsFalseThenThrows();
testTransformSuccess();
testTransformFutureFails();
testTransformTransformerFails();
« no previous file with comments | « corelib/src/implementation/future_implementation.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698