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

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

Issue 23875032: Expose Zones. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Mark stack trace test as failing. 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
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 'package:async_helper/async_helper.dart';
7 import 'dart:async';
8
9 main() {
10 Completer done = new Completer();
11 List events = [];
12
13 // runGuarded calls run, captures the synchronous error (if any) and
14 // gives that one to handleUncaughtError.
Lasse Reichstein Nielsen 2013/09/23 14:24:12 Bad comment?
floitsch 2013/09/23 17:12:07 Done.
15
16 Expect.identical(Zone.ROOT, Zone.current);
17 Zone forked;
18 forked = Zone.current.fork(null, new ZoneDescription(
19 fork: (Zone self, ZoneDelegate parent, Zone origin,
20 Map mapValues, ZoneDescription zoneDescription) {
21 // The zone is still the same as when origin.run was invoked, which
22 // is the root zone. (The origin zone hasn't been set yet).
23 Expect.identical(Zone.ROOT, Zone.current);
24 events.add("forked.fork");
25 Function descriptionRun = zoneDescription.run;
26 ZoneDescription modified = new ZoneDescription.from(zoneDescription,
27 run: (self, parent, origin, f) {
28 events.add("wrapped run");
29 return descriptionRun(self, parent, origin, () {
30 events.add("wrapped f");
31 return f();
32 });
33 });
34 return parent.fork(origin, mapValues, modified);
35 }));
36
37 events.add("start");
38 Zone forkedChild = forked.fork(null, new ZoneDescription(
39 run: (Zone self, ZoneDelegate parent, Zone origin, f()) {
40 events.add("executing child run");
41 return parent.run(origin, f);
42 }));
43
44 events.add("after child fork");
45 Expect.identical(Zone.ROOT, Zone.current);
46
47 forkedChild.run(() {
48 events.add("child run");
49 });
50
51 events.add("after child run");
52
53 Expect.listEquals(
54 [ "start",
55 "forked.fork",
56 "after child fork",
57 "wrapped run", "executing child run", "wrapped f", "child run",
58 "after child run" ],
59 events);
60 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698