| 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:async_helper/async_helper.dart'; | 5 import 'package:async_helper/async_helper.dart'; |
| 6 import "package:expect/expect.dart"; | 6 import "package:expect/expect.dart"; |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 | 8 |
| 9 var events = []; | 9 var events = []; |
| 10 | 10 |
| 11 body() { | 11 body() { |
| 12 events.add("body entry"); | 12 events.add("body entry"); |
| 13 runAsync(() { | 13 scheduleMicrotask(() { |
| 14 events.add("run async body"); | 14 events.add("run async body"); |
| 15 runAsync(() { | 15 scheduleMicrotask(() { |
| 16 events.add("run nested body"); | 16 events.add("run nested body"); |
| 17 }); | 17 }); |
| 18 }); | 18 }); |
| 19 return 499; | 19 return 499; |
| 20 } | 20 } |
| 21 | 21 |
| 22 handler(fun) { | 22 handler(fun) { |
| 23 events.add("handler"); | 23 events.add("handler"); |
| 24 runAsync(fun); | 24 scheduleMicrotask(fun); |
| 25 events.add("handler done"); | 25 events.add("handler done"); |
| 26 } | 26 } |
| 27 | 27 |
| 28 main() { | 28 main() { |
| 29 asyncStart(); | 29 asyncStart(); |
| 30 | 30 |
| 31 // Test that body of a runAsync goes to the zone it came from. | 31 // Test that body of a scheduleMicrotask goes to the zone it came from. |
| 32 var result = runZonedExperimental(body, onRunAsync: handler); | 32 var result = runZonedExperimental(body, onScheduleMicrotask: handler); |
| 33 events.add("after"); | 33 events.add("after"); |
| 34 runAsync(() { | 34 scheduleMicrotask(() { |
| 35 runAsync(() { | 35 scheduleMicrotask(() { |
| 36 Expect.listEquals( | 36 Expect.listEquals( |
| 37 ["body entry", | 37 ["body entry", |
| 38 "handler", "handler done", | 38 "handler", "handler done", |
| 39 "after", | 39 "after", |
| 40 "run async body", | 40 "run async body", |
| 41 "handler", "handler done", | 41 "handler", "handler done", |
| 42 "run nested body"], | 42 "run nested body"], |
| 43 events); | 43 events); |
| 44 asyncEnd(); | 44 asyncEnd(); |
| 45 }); | 45 }); |
| 46 }); | 46 }); |
| 47 } | 47 } |
| OLD | NEW |