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

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

Issue 17672002: Add runAsync interceptor. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comments. Created 7 years, 6 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/intercept_run_async5_test.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 class A {
10 add(x) => print(x);
11 }
12 var events = [];
13
14 body() {
15 events.add("body entry");
16 runAsync(() {
17 events.add("run async body");
18 throw "foo";
19 });
20 return 499;
21 }
22
23 onAsyncHandler(fun) {
24 events.add("async handler");
25 runAsync(fun);
26 events.add("async handler done");
27 }
28
29 onErrorHandler(e) {
30 events.add("error: $e");
31 }
32
33 onDoneHandler() {
34 events.add("done");
35 }
36
37 main() {
38 // We keep a ReceivePort open until all tests are done. This way the VM will
39 // hang if the callbacks are not invoked and the test will time out.
40 var port = new ReceivePort();
41
42 // Test that runZonedExperimental works when async, error and done are used.
43 var result = runZonedExperimental(
44 body,
45 onRunAsync: onAsyncHandler,
46 onError: onErrorHandler,
47 onDone: onDoneHandler);
48 events.add("after");
49 Timer.run(() {
50 Expect.listEquals(
51 ["body entry",
52 "async handler", "async handler done",
53 "after",
54 "run async body",
55 "error: foo",
56 "done"],
57 events);
58 port.close();
59 });
60 }
OLDNEW
« no previous file with comments | « tests/lib/async/intercept_run_async5_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698