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

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

Issue 2311923002: Don't propagate synchronous Future.wait errors immediately. (Closed)
Patch Set: Add test. Created 4 years, 3 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
« sdk/lib/async/future.dart ('K') | « sdk/lib/async/future.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 71c509b6fd3973e7790df4418d8b1e55dd7bcb72..ef879670847ce71cf5edc1a73382c5ad37e760a9 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,40 @@ 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();
+ });
+}
+
+void testWaitSyncError3() {
Lasse Reichstein Nielsen 2016/09/06 09:53:27 Add comment saying what you are testing: That zone
floitsch 2016/09/06 09:57:15 Done.
+ 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.isNotNull(caughtError);
Lasse Reichstein Nielsen 2016/09/06 09:53:27 Check that caughtError is identical to e.
floitsch 2016/09/06 09:57:16 Done.
+ 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 +1129,8 @@ main() {
testWaitCleanUp();
testWaitCleanUpError();
testWaitSyncError();
+ testWaitSyncError2();
+ testWaitSyncError3();
testBadFuture();
« sdk/lib/async/future.dart ('K') | « sdk/lib/async/future.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698