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

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

Issue 136113014: Introduce and use Zone:_enter and Zone:_leave, in Future. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Make futures faster and add a simple test. Created 6 years, 10 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
« sdk/lib/async/future_impl.dart ('K') | « sdk/lib/async/zone.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
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 'package:async_helper/async_helper.dart'; 6 import 'package:async_helper/async_helper.dart';
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 main() { 9 main() {
10 Completer done = new Completer(); 10 Completer done = new Completer();
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 Expect.equals(1234, result); 55 Expect.equals(1234, result);
56 56
57 done.future.whenComplete(() { 57 done.future.whenComplete(() {
58 Expect.listEquals( 58 Expect.listEquals(
59 ["zone forked", "forked.run", "run closure", "executed run", 59 ["zone forked", "forked.run", "run closure", "executed run",
60 "forked.run", "executed run2", "forked.run", "run closure 2", 60 "forked.run", "executed run2", "forked.run", "run closure 2",
61 "after nested scheduleMicrotask", "forked.run", "run closure 3"], 61 "after nested scheduleMicrotask", "forked.run", "run closure 3"],
62 events); 62 events);
63 asyncEnd(); 63 asyncEnd();
64 }); 64 });
65
66 var zone1 = Zone.ROOT.fork();
67 var zone2 = Zone.ROOT.fork();
68 var zone3 = Zone.ROOT.fork();
69 asyncStart();
70 asyncStart();
71 zone1.run(() {
72 var future = new Future.value();
73 zone2.run(() {
74 future.then((_) {
75 Expect.identical(zone2, Zone.current);
76 asyncEnd();
77 });
78 });
79 zone3.run(() {
80 future.then((_) {
81 Expect.identical(zone3, Zone.current);
82 asyncEnd();
83 });
84 });
85 });
65 } 86 }
OLDNEW
« sdk/lib/async/future_impl.dart ('K') | « sdk/lib/async/zone.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698