Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(238)

Side by Side Diff: tests/lib/async/catch_errors8_test.dart

Issue 23875032: Expose Zones. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: rebase Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « tests/lib/async/catch_errors7_test.dart ('k') | tests/lib/async/catch_errors9_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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:async_helper/async_helper.dart'; 5 import 'package:async_helper/async_helper.dart';
6 import "package:expect/expect.dart"; 6 import "package:expect/expect.dart";
7 import 'dart:async'; 7 import 'dart:async';
8 import 'catch_errors.dart'; 8 import 'catch_errors.dart';
9 9
10 main() { 10 main() {
11 asyncStart(); 11 asyncStart();
12 Completer done = new Completer();
13
12 var events = []; 14 var events = [];
13 // Test nested `catchErrors`. 15 // Test nested `catchErrors`.
14 // The nested `catchErrors` throws all kinds of different errors (synchronous 16 // The nested `catchErrors` throws all kinds of different errors (synchronous
15 // and asynchronous). The body of the outer `catchErrors` furthermore has a 17 // and asynchronous). The body of the outer `catchErrors` furthermore has a
16 // synchronous `throw`. 18 // synchronous `throw`.
17 catchErrors(() { 19 catchErrors(() {
18 events.add("catch error entry"); 20 events.add("catch error entry");
19 catchErrors(() { 21 catchErrors(() {
20 events.add("catch error entry2"); 22 events.add("catch error entry2");
21 new Future.error("future error"); 23 new Future.error("future error");
22 new Future.error("future error2"); 24 new Future.error("future error2");
23 new Future.value(499).then((x) => throw x); 25 new Future.value(499).then((x) => throw x);
24 new Future.delayed(const Duration(milliseconds: 50), () { 26 new Future.delayed(const Duration(milliseconds: 50), () {
25 throw "delayed error"; 27 throw "delayed error";
26 }); 28 });
27 throw "catch error"; 29 throw "catch error";
28 }).listen((x) { events.add(x); }) 30 }).listen((x) {
29 .asFuture() 31 events.add(x);
30 .then((_) => events.add("inner done")) 32 if (x == "delayed error") {
31 .then((_) { throw "inner done throw"; }); 33 throw "inner done throw";
34 }
35 });
32 events.add("after inner"); 36 events.add("after inner");
33 throw "inner throw"; 37 throw "inner throw";
34 }).listen((x) { 38 }).listen((x) {
35 events.add(x); 39 events.add(x);
40 if (x == "inner done throw") {
41 done.complete(true);
42 }
36 }, 43 },
37 onDone: () { 44 onDone: () { Expect.fail("Unexpected callback"); });
38 Expect.listEquals(["catch error entry", 45
39 "catch error entry2", 46 done.future.whenComplete(() {
40 "after inner", 47 Expect.listEquals(["catch error entry",
41 "main exit", 48 "catch error entry2",
42 "catch error", 49 "after inner",
43 "inner throw", 50 "main exit",
44 "future error", 51 "catch error",
45 "future error2", 52 "inner throw",
46 499, 53 "future error",
47 "delayed error", 54 "future error2",
48 "inner done", 55 499,
49 "inner done throw" 56 "delayed error",
50 ], 57 "inner done throw"
51 events); 58 ],
52 asyncEnd(); 59 events);
53 }); 60 asyncEnd();
61 });
54 events.add("main exit"); 62 events.add("main exit");
55 } 63 }
OLDNEW
« no previous file with comments | « tests/lib/async/catch_errors7_test.dart ('k') | tests/lib/async/catch_errors9_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698