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 main() { | 9 main() { |
10 Completer done = new Completer(); | 10 Completer done = new Completer(); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 Expect.listEquals( | 50 Expect.listEquals( |
51 [ "forked.run", "runGuarded 1", "after runGuarded 1", | 51 [ "forked.run", "runGuarded 1", "after runGuarded 1", |
52 "forked.run", "runGuarded 2", "forked.handleUncaught 42" ], | 52 "forked.run", "runGuarded 2", "forked.handleUncaught 42" ], |
53 events); | 53 events); |
54 | 54 |
55 events.clear(); | 55 events.clear(); |
56 asyncStart(); | 56 asyncStart(); |
57 result = forked.runGuarded(() { | 57 result = forked.runGuarded(() { |
58 Expect.identical(forked, Zone.current); | 58 Expect.identical(forked, Zone.current); |
59 events.add("run closure"); | 59 events.add("run closure"); |
60 runAsync(() { | 60 scheduleMicrotask(() { |
61 events.add("run closure 2"); | 61 events.add("run closure 2"); |
62 Expect.identical(forked, Zone.current); | 62 Expect.identical(forked, Zone.current); |
63 done.complete(true); | 63 done.complete(true); |
64 throw 88; | 64 throw 88; |
65 }); | 65 }); |
66 throw 1234; | 66 throw 1234; |
67 }); | 67 }); |
68 events.add("after nested runAsync"); | 68 events.add("after nested scheduleMicrotask"); |
69 Expect.equals(499, result); | 69 Expect.equals(499, result); |
70 | 70 |
71 done.future.whenComplete(() { | 71 done.future.whenComplete(() { |
72 Expect.listEquals( | 72 Expect.listEquals( |
73 ["forked.run", "run closure", "forked.handleUncaught 1234", | 73 ["forked.run", "run closure", "forked.handleUncaught 1234", |
74 "after nested runAsync", "forked.run", "run closure 2", | 74 "after nested scheduleMicrotask", "forked.run", "run closure 2", |
75 "forked.handleUncaught 88" ], | 75 "forked.handleUncaught 88" ], |
76 events); | 76 events); |
77 asyncEnd(); | 77 asyncEnd(); |
78 }); | 78 }); |
79 } | 79 } |
OLD | NEW |