@@ -24,18 +24,31 @@ void main() {
2424 /// [MultiFutureTracker.addFutureFromClosure] .
2525 test ('no deadlock when delayed exceptions fire in closures' , () async {
2626 var sharedTracker = MultiFutureTracker (2 );
27- var t =
28- Future .delayed (Duration (milliseconds: 10 ), () => throw Exception ());
29- await sharedTracker.addFutureFromClosure (() => t);
30- expect (t, throwsA (const TypeMatcher <Exception >()));
31- var u =
32- Future .delayed (Duration (milliseconds: 10 ), () => throw Exception ());
33- await sharedTracker.addFutureFromClosure (() => u);
34- expect (u, throwsA (const TypeMatcher <Exception >()));
35- var v =
36- Future .delayed (Duration (milliseconds: 10 ), () => throw Exception ());
37- await sharedTracker.addFutureFromClosure (() => v);
38- expect (v, throwsA (const TypeMatcher <Exception >()));
27+ expect (() async {
28+ var t =
29+ Future .delayed (Duration (milliseconds: 10 ), () => throw Exception ());
30+ await sharedTracker.addFutureFromClosure (() => t);
31+ return t;
32+ }, throwsA (const TypeMatcher <Exception >()));
33+ expect (() async {
34+ var t =
35+ Future .delayed (Duration (milliseconds: 10 ), () => throw Exception ());
36+ await sharedTracker.addFutureFromClosure (() => t);
37+ return t;
38+ }, throwsA (const TypeMatcher <Exception >()));
39+ expect (() async {
40+ var t =
41+ Future .delayed (Duration (milliseconds: 10 ), () => throw Exception ());
42+ // ignore: empty_catches
43+ await sharedTracker.addFutureFromClosure (() => t);
44+ return t;
45+ }, throwsA (const TypeMatcher <Exception >()));
46+ expect (() async {
47+ var t =
48+ Future .delayed (Duration (milliseconds: 10 ), () => throw Exception ());
49+ await sharedTracker.addFutureFromClosure (() => t);
50+ return t;
51+ }, throwsA (const TypeMatcher <Exception >()));
3952
4053 /// We deadlock here if the exception is not handled properly.
4154 await sharedTracker.wait ();
@@ -55,8 +68,12 @@ void main() {
5568 var completed = < int > {};
5669 var tracker = MultiFutureTracker (1 );
5770 await tracker.addFutureFromClosure (() async => completed.add (0 ));
58- await tracker.addFutureFromClosure (() async => throw Exception ());
59- await tracker.addFutureFromClosure (() async => throw Exception ());
71+ await tracker
72+ .addFutureFromClosure (() async => throw Exception ())
73+ .catchError ((e) {});
74+ await tracker
75+ .addFutureFromClosure (() async => throw Exception ())
76+ .catchError ((e) {});
6077 await tracker.addFutureFromClosure (() async => completed.add (3 ));
6178 await tracker.wait ();
6279 expect (completed.length, equals (2 ));
0 commit comments