OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 import 'package:expect/expect.dart'; | 5 import 'package:expect/expect.dart'; |
6 import 'package:async_helper/async_helper.dart'; | 6 import 'package:async_helper/async_helper.dart'; |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 | 8 |
9 import 'dart:collection'; | 9 import 'dart:collection'; |
10 | 10 |
11 /** | 11 /** |
12 * We represent the current stack trace by an integer. From time to time we | 12 * We represent the current stack trace by an integer. From time to time we |
13 * increment the variable. This corresponds to a new stack trace. | 13 * increment the variable. This corresponds to a new stack trace. |
14 */ | 14 */ |
15 int stackTrace = 0; | 15 int stackTrace = 0; |
16 List restoredStackTrace = []; | 16 List restoredStackTrace = []; |
17 | 17 |
18 List events = []; | 18 List events = []; |
19 | 19 |
20 debugZoneRegisterCallback(Zone self, ZoneDelegate parent, Zone origin, f()) { | 20 debugZoneRegisterCallback(Zone self, ZoneDelegate parent, Zone origin, f()) { |
21 List savedTrace = [stackTrace]..addAll(restoredStackTrace); | 21 List savedTrace = [stackTrace]..addAll(restoredStackTrace); |
22 return parent.registerCallback(origin, () { | 22 return parent.registerCallback(origin, () { |
23 restoredStackTrace = savedTrace; | 23 restoredStackTrace = savedTrace; |
24 return f(); | 24 return f(); |
25 }); | 25 }); |
26 } | 26 } |
27 | 27 |
28 debugZoneRegisterUnaryCallback(Zone self, ZoneDelegate parent, Zone origin, | 28 debugZoneRegisterUnaryCallback( |
29 f(arg)) { | 29 Zone self, ZoneDelegate parent, Zone origin, f(arg)) { |
30 List savedTrace = [stackTrace]..addAll(restoredStackTrace); | 30 List savedTrace = [stackTrace]..addAll(restoredStackTrace); |
31 return parent.registerUnaryCallback(origin, (arg) { | 31 return parent.registerUnaryCallback(origin, (arg) { |
32 restoredStackTrace = savedTrace; | 32 restoredStackTrace = savedTrace; |
33 return f(arg); | 33 return f(arg); |
34 }); | 34 }); |
35 } | 35 } |
36 | 36 |
37 debugZoneRun(Zone self, ZoneDelegate parent, Zone origin, f()) { | 37 debugZoneRun(Zone self, ZoneDelegate parent, Zone origin, f()) { |
38 stackTrace++; | 38 stackTrace++; |
39 restoredStackTrace = []; | 39 restoredStackTrace = []; |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 }); | 118 }); |
119 }, runGuarded: false); | 119 }, runGuarded: false); |
120 }, runGuarded: false); | 120 }, runGuarded: false); |
121 openTests++; | 121 openTests++; |
122 f(); | 122 f(); |
123 f2(); | 123 f2(); |
124 | 124 |
125 done.future.whenComplete(() { | 125 done.future.whenComplete(() { |
126 // We don't really care for the order. | 126 // We don't really care for the order. |
127 events.sort(); | 127 events.sort(); |
128 Expect.listEquals([ "handling uncaught error bar", | 128 Expect.listEquals([ |
129 "handling uncaught error foo", | 129 "handling uncaught error bar", |
130 "handling uncaught error gee"], | 130 "handling uncaught error foo", |
131 events); | 131 "handling uncaught error gee" |
| 132 ], events); |
132 asyncEnd(); | 133 asyncEnd(); |
133 }); | 134 }); |
134 } | 135 } |
OLD | NEW |