Chromium Code Reviews| 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 import 'dart:isolate'; | 7 import 'dart:isolate'; |
| 8 | 8 |
| 9 main() { | 9 main() { |
| 10 // We keep a ReceivePort open until all tests are done. This way the VM will | 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. | 11 // time out if the callbacks are not invoked. |
| 12 var port = new ReceivePort(); | 12 var port = new ReceivePort(); |
| 13 var events = []; | 13 var events = []; |
| 14 // Test nested `catchErrors`. | 14 // Test that the outer `catchErrors` waits for the nested `catchErrors` stream |
| 15 // The nested `catchErrors` throws all kinds of different errors (synchronous | 15 // to be done. |
| 16 // and asynchronous). The body of the outer `catchErrors` furthermore has a | |
| 17 // synchronous `throw`. | |
| 18 catchErrors(() { | 16 catchErrors(() { |
| 19 events.add("catch error entry"); | 17 events.add("catch error entry"); |
| 20 catchErrors(() { | 18 catchErrors(() { |
| 21 events.add("catch error entry2"); | 19 events.add("catch error entry2"); |
| 22 new Future.error("future error"); | 20 new Future.error("future error"); |
| 23 new Future.error("future error2"); | 21 new Future.error("future error2"); |
| 24 new Future.value(499).then((x) => throw x); | 22 new Future.value(499).then((x) => throw x); |
| 25 new Future.delayed(const Duration(milliseconds: 50), () { | 23 new Future.delayed(const Duration(milliseconds: 50), () { |
| 26 throw "delayed error"; | 24 throw "delayed error"; |
| 27 }); | 25 }); |
| 28 throw "catch error"; | 26 throw "catch error"; |
| 29 }).listen((x) { events.add(x); }) | 27 }).listen((x) { events.add(x); }, |
| 30 .asFuture() | 28 onDone: () => events.add("inner done")); |
|
Lasse Reichstein Nielsen
2013/05/29 08:32:26
Indent to '(' - i.e., 5 more.
floitsch
2013/05/29 15:48:56
Done.
| |
| 31 .then((_) => events.add("inner done")) | |
| 32 .then((_) { throw "inner done throw"; }); | |
| 33 events.add("after inner"); | 29 events.add("after inner"); |
| 34 throw "inner throw"; | 30 throw "inner throw"; |
| 35 }).listen((x) { | 31 }).listen((x) { |
| 36 events.add(x); | 32 events.add(x); |
| 37 }, | 33 }, |
| 38 onDone: () { | 34 onDone: () { |
| 39 Expect.listEquals([ | 35 Expect.listEquals([ |
| 40 "catch error entry", | 36 "catch error entry", |
| 41 "catch error entry2", | 37 "catch error entry2", |
| 42 "after inner", | 38 "after inner", |
| 43 "main exit", | 39 "main exit", |
| 44 "catch error", | 40 "catch error", |
| 45 "inner throw", | 41 "inner throw", |
| 46 "future error", | 42 "future error", |
| 47 "future error2", | 43 "future error2", |
| 48 499, | 44 499, |
| 49 "delayed error", | 45 "delayed error", |
| 50 "inner done", | 46 "inner done", |
| 51 "inner done throw" | |
| 52 ], | 47 ], |
| 53 events); | 48 events); |
| 54 port.close(); | 49 port.close(); |
| 55 }); | 50 }); |
| 56 events.add("main exit"); | 51 events.add("main exit"); |
| 57 } | 52 } |
| OLD | NEW |