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 26 matching lines...) Expand all Loading... |
37 Expect.fail("should not be invoked"); | 37 Expect.fail("should not be invoked"); |
38 }, 99); | 38 }, 99); |
39 Expect.equals(42, result); | 39 Expect.equals(42, result); |
40 events.add("executed run2"); | 40 events.add("executed run2"); |
41 | 41 |
42 asyncStart(); | 42 asyncStart(); |
43 shouldForward = true; | 43 shouldForward = true; |
44 result = forked.runUnary((arg) { | 44 result = forked.runUnary((arg) { |
45 Expect.identical(forked, Zone.current); | 45 Expect.identical(forked, Zone.current); |
46 events.add("run closure 2"); | 46 events.add("run closure 2"); |
47 runAsync(() { | 47 scheduleMicrotask(() { |
48 events.add("run closure 3"); | 48 events.add("run closure 3"); |
49 Expect.identical(forked, Zone.current); | 49 Expect.identical(forked, Zone.current); |
50 done.complete(true); | 50 done.complete(true); |
51 }); | 51 }); |
52 return -arg - 8; | 52 return -arg - 8; |
53 }, 490); | 53 }, 490); |
54 events.add("after nested runAsync"); | 54 events.add("after nested scheduleMicrotask"); |
55 Expect.equals(-499, result); | 55 Expect.equals(-499, result); |
56 | 56 |
57 done.future.whenComplete(() { | 57 done.future.whenComplete(() { |
58 Expect.listEquals( | 58 Expect.listEquals( |
59 ["zone forked", "forked.run1", "run closure", "executed run", | 59 ["zone forked", "forked.run1", "run closure", "executed run", |
60 "forked.run1", "executed run2", "forked.run1", "run closure 2", | 60 "forked.run1", "executed run2", "forked.run1", "run closure 2", |
61 "after nested runAsync", "run closure 3"], | 61 "after nested scheduleMicrotask", "run closure 3"], |
62 events); | 62 events); |
63 asyncEnd(); | 63 asyncEnd(); |
64 }); | 64 }); |
65 } | 65 } |
OLD | NEW |