This repository was archived by the owner on Feb 22, 2018. It is now read-only.
File tree 2 files changed +19
-1
lines changed
2 files changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -156,6 +156,7 @@ class Logger implements List {
156
156
}
157
157
158
158
List <Function > _asyncQueue = [];
159
+ List _asyncErrors = [];
159
160
160
161
nextTurn ([bool runUntilEmpty = false ]) {
161
162
// copy the queue as it may change.
@@ -170,7 +171,15 @@ nextTurn([bool runUntilEmpty = false]) {
170
171
171
172
async (Function fn) =>
172
173
() {
173
- dartAsync.runZonedExperimental (fn, onRunAsync: (asyncFn) => _asyncQueue.add (asyncFn));
174
+ _asyncErrors = [];
175
+ dartAsync.runZonedExperimental (fn,
176
+ onRunAsync: (asyncFn) => _asyncQueue.add (asyncFn),
177
+ onError: (e) => _asyncErrors.add (e));
178
+
179
+ _asyncErrors.forEach ((e) {
180
+ throw "During runZoned: $e . Stack:\n ${dartAsync .getAttachedStackTrace (e )}" ;
181
+ });
182
+
174
183
expect (_asyncQueue.isEmpty).toBe (true );
175
184
};
176
185
Original file line number Diff line number Diff line change @@ -121,5 +121,14 @@ main() {
121
121
})();
122
122
}).toThrow ("blah" );
123
123
});
124
+
125
+
126
+ it ('should complain if the test throws an exception during async calls' , () {
127
+ var ran = false ;
128
+ expect (async (() {
129
+ new Future .value ('s' ).then ((_) { throw "blah then" ; });
130
+ nextTurn (true );
131
+ })).toThrow ("blah then" );
132
+ });
124
133
});
125
134
}
You can’t perform that action at this time.
0 commit comments