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

Unified Diff: tests/lib/async/future_test.dart

Issue 11826050: Consider a thrown AsyncError from a future/stream handler a rethrow. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comments. Add tests. Created 7 years, 11 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 | « sdk/lib/async/stream_controller.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/lib/async/future_test.dart
diff --git a/tests/lib/async/future_test.dart b/tests/lib/async/future_test.dart
index 4c578d7f92c147a7715dd046cf862714b28fca6c..83fda868599b6bffd7fe20a73b4f03376a5a0a37 100644
--- a/tests/lib/async/future_test.dart
+++ b/tests/lib/async/future_test.dart
@@ -443,7 +443,80 @@ testFutureWhenErrorFutureError() {
completer.completeError("Error");
}
+testFutureThenThrowsAsync() {
+ final completer = new Completer<int>();
+ final future = completer.future;
+ AsyncError error = new AsyncError(42, "st");
+
+ var port = new ReceivePort();
+ future.then((v) {
+ throw error;
+ }).catchError((AsyncError e) {
+ Expect.identical(error, e);
+ port.close();
+ });
+ completer.complete(0);
+}
+
+testFutureCatchThrowsAsync() {
+ final completer = new Completer<int>();
+ final future = completer.future;
+ AsyncError error = new AsyncError(42, "st");
+
+ var port = new ReceivePort();
+ future.catchError((AsyncError e) {
+ throw error;
+ }).catchError((AsyncError e) {
+ Expect.identical(error, e);
+ port.close();
+ });
+ completer.completeError(0);
+}
+
+testFutureCatchRethrowsAsync() {
+ final completer = new Completer<int>();
+ final future = completer.future;
+ AsyncError error;
+
+ var port = new ReceivePort();
+ future.catchError((AsyncError e) {
+ error = e;
+ throw e;
+ }).catchError((AsyncError e) {
+ Expect.identical(error, e);
+ port.close();
+ });
+ completer.completeError(0);
+}
+
+testFutureWhenThrowsAsync() {
+ final completer = new Completer<int>();
+ final future = completer.future;
+ AsyncError error = new AsyncError(42, "st");
+
+ var port = new ReceivePort();
+ future.whenComplete(() {
+ throw error;
+ }).catchError((AsyncError e) {
+ Expect.identical(error, e);
+ port.close();
+ });
+ completer.complete(0);
+}
+
+testCompleteWithAsyncError() {
+ final completer = new Completer<int>();
+ final future = completer.future;
+ AsyncError error = new AsyncError(42, "st");
+
+ var port = new ReceivePort();
+ future.catchError((AsyncError e) {
+ Expect.identical(error, e);
+ port.close();
+ });
+ completer.completeError(error);
+}
main() {
testImmediate();
@@ -453,6 +526,7 @@ main() {
testCompleteWithSuccessHandlerBeforeComplete();
testCompleteWithSuccessHandlerAfterComplete();
testCompleteManySuccessHandlers();
+ testCompleteWithAsyncError();
testException();
testExceptionHandler();
@@ -475,5 +549,10 @@ main() {
testFutureWhenErrorFutureValue();
testFutureWhenValueFutureError();
testFutureWhenErrorFutureError();
+
+ testFutureThenThrowsAsync();
+ testFutureCatchThrowsAsync();
+ testFutureWhenThrowsAsync();
+ testFutureCatchRethrowsAsync();
}
« no previous file with comments | « sdk/lib/async/stream_controller.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698