Chromium Code Reviews| 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:expect/expect.dart"; | |
| 6 import 'dart:async'; | |
| 7 import 'dart:isolate'; | |
| 8 | |
| 9 main() { | |
| 10 // We keep a ReceivePort open until all tests are done. This way the VM will | |
| 11 // time out if the callbacks are not invoked. | |
| 12 var port = new ReceivePort(); | |
| 13 var events = []; | |
| 14 // Work around bug that makes runAsync use Timers. Not sure it is still | |
| 15 // necessary, but it definitely doesn't hurt. | |
|
Lasse Reichstein Nielsen
2013/05/29 08:04:59
A "not sure" in a unit test is worrying.
Can we fi
floitsch
2013/05/29 15:21:29
Changed comment.
Still necessary, since we still u
| |
| 16 runAsync(() { }); | |
| 17 | |
| 18 // Test that errors are caught by nested `catchErrors`. Also uses `runAsync` | |
| 19 // in the body of a Timer. | |
| 20 catchErrors(() { | |
| 21 events.add("catch error entry"); | |
| 22 catchErrors(() { | |
| 23 events.add("catch error entry2"); | |
| 24 Timer.run(() { throw "timer error"; }); | |
| 25 new Timer(const Duration(milliseconds: 50), | |
| 26 () { | |
| 27 runAsync(() { throw "runAsync"; }); | |
| 28 throw "delayed error"; | |
| 29 }); | |
| 30 }).listen((x) { events.add(x); }) | |
| 31 .asFuture() | |
| 32 .then((_) => events.add("inner done")) | |
| 33 .then((_) { throw "inner done throw"; }); | |
| 34 events.add("after inner"); | |
| 35 Timer.run(() { throw "timer outer"; }); | |
| 36 throw "inner throw"; | |
| 37 }).listen((x) { | |
| 38 events.add(x); | |
| 39 }, | |
| 40 onDone: () { | |
| 41 Expect.listEquals([ | |
| 42 "catch error entry", | |
| 43 "catch error entry2", | |
| 44 "after inner", | |
| 45 "main exit", | |
| 46 "inner throw", | |
| 47 "timer error", | |
| 48 "timer outer", | |
| 49 "delayed error", | |
| 50 "runAsync", | |
| 51 "inner done", | |
| 52 "inner done throw" | |
| 53 ], | |
| 54 events); | |
| 55 port.close(); | |
| 56 }); | |
| 57 events.add("main exit"); | |
| 58 } | |
| OLD | NEW |