| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // BSD-style license that can be found in the LICENSE file. | |
| 4 | |
| 5 import 'package:async_helper/async_helper.dart'; | |
| 6 import "package:expect/expect.dart"; | |
| 7 import 'dart:async'; | |
| 8 import 'catch_errors.dart'; | |
| 9 | |
| 10 class A { | |
| 11 add(x) => print(x); | |
| 12 } | |
| 13 | |
| 14 var events = []; | |
| 15 | |
| 16 body() { | |
| 17 events.add("body entry"); | |
| 18 scheduleMicrotask(() { | |
| 19 events.add("run async body"); | |
| 20 throw "foo"; | |
| 21 }); | |
| 22 return 499; | |
| 23 } | |
| 24 | |
| 25 onAsyncHandler(fun) { | |
| 26 events.add("async handler"); | |
| 27 scheduleMicrotask(fun); | |
| 28 events.add("async handler done"); | |
| 29 } | |
| 30 | |
| 31 onErrorHandler(e) { | |
| 32 events.add("error: $e"); | |
| 33 } | |
| 34 | |
| 35 main() { | |
| 36 asyncStart(); | |
| 37 | |
| 38 // Test that runZonedScheduleMicrotask works when async, error and done | |
| 39 // are used. | |
| 40 var result = runZonedScheduleMicrotask(body, | |
| 41 onScheduleMicrotask: onAsyncHandler, onError: onErrorHandler); | |
| 42 events.add("after"); | |
| 43 Timer.run(() { | |
| 44 Expect.listEquals([ | |
| 45 "body entry", | |
| 46 "async handler", | |
| 47 "async handler done", | |
| 48 "after", | |
| 49 "run async body", | |
| 50 "error: foo" | |
| 51 ], events); | |
| 52 asyncEnd(); | |
| 53 }); | |
| 54 } | |
| OLD | NEW |