| 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 'dart:async'; | 6 import 'dart:async'; |
| 7 | 7 |
| 8 var events = []; | 8 var events = []; |
| 9 | 9 |
| 10 body() { | 10 body() { |
| 11 events.add("body entry"); | 11 events.add("body entry"); |
| 12 runAsync(() { | 12 scheduleMicrotask(() { |
| 13 events.add("run async body"); | 13 events.add("run async body"); |
| 14 }); | 14 }); |
| 15 return 499; | 15 return 499; |
| 16 } | 16 } |
| 17 | 17 |
| 18 handler(fun) { | 18 handler(fun) { |
| 19 events.add("handler"); | 19 events.add("handler"); |
| 20 fun(); | 20 fun(); |
| 21 events.add("handler done"); | 21 events.add("handler done"); |
| 22 } | 22 } |
| 23 | 23 |
| 24 main() { | 24 main() { |
| 25 // Test that runAsync interception works. | 25 // Test that scheduleMicrotask interception works. |
| 26 var result = runZonedExperimental(body, onRunAsync: handler); | 26 var result = runZonedExperimental(body, onScheduleMicrotask: handler); |
| 27 // No need for a ReceivePort: If the runZonedExperimental disbehaved we | 27 // No need for a ReceivePort: If the runZonedExperimental disbehaved we |
| 28 // would have an [events] list that is different from what we expect. | 28 // would have an [events] list that is different from what we expect. |
| 29 Expect.listEquals(["body entry", "handler", "run async body", "handler done"], | 29 Expect.listEquals(["body entry", "handler", "run async body", "handler done"], |
| 30 events); | 30 events); |
| 31 } | 31 } |
| OLD | NEW |