Index: tests/lib/async/future_test.dart |
diff --git a/tests/lib/async/future_test.dart b/tests/lib/async/future_test.dart |
index 71c509b6fd3973e7790df4418d8b1e55dd7bcb72..5ce2be931eacee375ebd71201e59ae0d5493b022 100644 |
--- a/tests/lib/async/future_test.dart |
+++ b/tests/lib/async/future_test.dart |
@@ -879,7 +879,6 @@ void testWaitCleanUpError() { |
void testWaitSyncError() { |
var cms = const Duration(milliseconds: 100); |
var cleanups = new List.filled(3, false); |
- var uncaughts = new List.filled(3, false); |
asyncStart(); |
asyncStart(); |
runZoned(() { |
@@ -896,6 +895,43 @@ void testWaitSyncError() { |
}); |
} |
+void testWaitSyncError2() { |
+ asyncStart(); |
+ Future.wait([null]).catchError((e, st) { |
+ // Makes sure that the `catchError` is invoked. |
+ // Regression test: an earlier version of `Future.wait` would propagate |
+ // the error too soon for the code to install an error handler. |
+ // `testWaitSyncError` didn't show this problem, because the `runZoned` |
+ // was already installed. |
+ asyncEnd(); |
+ }); |
+} |
+ |
+// Future.wait transforms synchronous errors into asynchronous ones. |
+// This function tests that zones can intercept them. |
+void testWaitSyncError3() { |
+ var caughtError; |
+ var count = 0; |
+ |
+ AsyncError errorCallback( |
+ Zone self, ZoneDelegate parent, Zone zone, Object error, |
+ StackTrace stackTrace) { |
+ Expect.equals(0, count); |
+ count++; |
+ caughtError = error; |
+ return parent.errorCallback(zone, error, stackTrace); |
+ } |
+ |
+ asyncStart(); |
+ runZoned(() { |
+ Future.wait([null]).catchError((e, st) { |
+ Expect.identical(e, caughtError); |
+ Expect.equals(1, count); |
+ asyncEnd(); |
+ }); |
+ }, zoneSpecification: new ZoneSpecification(errorCallback: errorCallback)); |
+} |
+ |
void testBadFuture() { |
var bad = new BadFuture(); |
// Completing with bad future (then call throws) puts error in result. |
@@ -1096,6 +1132,8 @@ main() { |
testWaitCleanUp(); |
testWaitCleanUpError(); |
testWaitSyncError(); |
+ testWaitSyncError2(); |
+ testWaitSyncError3(); |
testBadFuture(); |