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 var events = []; |
| 14 |
| 15 body() { |
| 16 events.add("body entry"); |
| 17 scheduleMicrotask(() { |
| 18 events.add("run async body"); |
| 19 throw "foo"; |
| 20 }); |
| 21 return 499; |
| 22 } |
| 23 |
| 24 onAsyncHandler(fun) { |
| 25 events.add("async handler"); |
| 26 scheduleMicrotask(fun); |
| 27 events.add("async handler done"); |
| 28 } |
| 29 |
| 30 onErrorHandler(e) { |
| 31 events.add("error: $e"); |
| 32 } |
| 33 |
| 34 main() { |
| 35 asyncStart(); |
| 36 |
| 37 // Test that runZonedScheduleMicrotask works when async, error and done |
| 38 // are used. |
| 39 var result = runZonedScheduleMicrotask( |
| 40 body, |
| 41 onScheduleMicrotask: onAsyncHandler, |
| 42 onError: onErrorHandler); |
| 43 events.add("after"); |
| 44 Timer.run(() { |
| 45 Expect.listEquals( |
| 46 ["body entry", |
| 47 "async handler", "async handler done", |
| 48 "after", |
| 49 "run async body", |
| 50 "error: foo"], |
| 51 events); |
| 52 asyncEnd(); |
| 53 }); |
| 54 } |
OLD | NEW |