| 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 import 'catch_errors.dart'; |
| 9 |
| 10 main() { |
| 11 // We keep a ReceivePort open until all tests are done. This way the VM will |
| 12 // hang if the callbacks are not invoked and the test will time out. |
| 13 var port = new ReceivePort(); |
| 14 var events = []; |
| 15 // Test that the outer `catchErrors` waits for the nested `catchErrors` stream |
| 16 // to be done. |
| 17 catchErrors(() { |
| 18 events.add("catch error entry"); |
| 19 catchErrors(() { |
| 20 events.add("catch error entry2"); |
| 21 new Future.error("future error"); |
| 22 new Future.error("future error2"); |
| 23 new Future.value(499).then((x) => throw x); |
| 24 new Future.delayed(const Duration(milliseconds: 50), () { |
| 25 throw "delayed error"; |
| 26 }); |
| 27 throw "catch error"; |
| 28 }).listen((x) { events.add("i $x"); }, |
| 29 onDone: () => events.add("inner done")); |
| 30 events.add("after inner"); |
| 31 throw "inner throw"; |
| 32 }).listen((x) { |
| 33 events.add("o $x"); |
| 34 }, |
| 35 onDone: () { |
| 36 Expect.listEquals(["catch error entry", |
| 37 "catch error entry2", |
| 38 "after inner", |
| 39 "main exit", |
| 40 "i catch error", |
| 41 "o inner throw", |
| 42 "i future error", |
| 43 "i future error2", |
| 44 "i 499", |
| 45 "i delayed error", |
| 46 "inner done", |
| 47 ], |
| 48 events); |
| 49 port.close(); |
| 50 }); |
| 51 events.add("main exit"); |
| 52 } |
| OLD | NEW |