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

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

Issue 23450047: Run runAsync callbacks of futures in their zone. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 3 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 | « sdk/lib/async/future_impl.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 'package:async_helper/async_helper.dart';
8
9 main() {
10 asyncStart();
11 Completer done = new Completer();
12
13 // Make sure that the zones use the runAsync of their zones.
14 int runAsyncCount = 0;
15 Completer completer;
16 Completer completer2;
17 Future future;
18 Future future2;
19 runZonedExperimental(() {
20 completer = new Completer();
21 completer.complete(499);
22 completer2 = new Completer.sync();
23 completer2.complete(-499);
24 future = new Future.value(42);
25 future2 = new Future.error(11);
26 }, onRunAsync: (f) {
27 runAsyncCount++;
28 runAsync(f);
29 });
30 int openCallbackCount = 0;
31
32 openCallbackCount++;
33 completer.future.then((x) {
34 Expect.equals(499, x);
35 openCallbackCount--;
36 if (openCallbackCount == 0) done.complete();
37 });
38
39 openCallbackCount++;
40 completer2.future.then((x) {
41 Expect.equals(-499, x);
42 openCallbackCount--;
43 if (openCallbackCount == 0) done.complete();
44 });
45
46 openCallbackCount++;
47 future.then((x) {
48 Expect.equals(42, x);
49 openCallbackCount--;
50 if (openCallbackCount == 0) done.complete();
51 });
52
53 openCallbackCount++;
54 future2.catchError((x) {
55 Expect.equals(11, x);
56 openCallbackCount--;
57 if (openCallbackCount == 0) done.complete();
58 });
59
60 done.future.whenComplete(() {
61 Expect.equals(4, runAsyncCount);
62 asyncEnd();
63 });
64 }
OLDNEW
« no previous file with comments | « sdk/lib/async/future_impl.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698