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

Side by Side Diff: tests/lib/async/zone_value_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/zone_run_unary_test.dart ('k') | tests/lib/lib.status » ('j') | 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 '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.
15
16 Expect.identical(Zone.ROOT, Zone.current);
17 Zone forked;
18 Map zoneValues = new Map();
19 var foo = const Symbol("foo");
20 var bar = const Symbol("bar");
21 zoneValues[foo] = 499;
22 zoneValues[bar] = [];
23 forked = Zone.current.fork(zoneValues: zoneValues);
24
25 Expect.identical(Zone.ROOT, Zone.current);
26 Expect.isNull(Zone.current[foo]);
27 Expect.isNull(Zone.current[bar]);
28
29 forked.run(() {
30 Expect.equals(499, Zone.current[foo]);
31 Expect.listEquals([], Zone.current[bar]);
32 Zone.current[bar].add(42);
33 });
34 Expect.identical(Zone.ROOT, Zone.current);
35 Expect.isNull(Zone.current[foo]);
36 Expect.isNull(Zone.current[bar]);
37
38 forked.run(() {
39 Expect.equals(499, Zone.current[foo]);
40 Expect.listEquals([42], Zone.current[bar]);
41 });
42
43 zoneValues = new Map();
44 var gee = const Symbol("gee");
45 zoneValues[gee] = 99;
46 zoneValues[foo] = -499;
47 Zone forkedChild = forked.fork(zoneValues: zoneValues);
48
49 forkedChild.run(() {
50 Expect.equals(-499, Zone.current[foo]);
51 Expect.listEquals([42], Zone.current[bar]);
52 Expect.equals(99, Zone.current[gee]);
53 });
54 }
OLDNEW
« no previous file with comments | « tests/lib/async/zone_run_unary_test.dart ('k') | tests/lib/lib.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698