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

Unified 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, 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tests/lib/async/zone_run_unary_test.dart ('k') | tests/lib/lib.status » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/lib/async/zone_value_test.dart
diff --git a/tests/lib/async/zone_value_test.dart b/tests/lib/async/zone_value_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..8aa7c852a2d1b0a09d95f6bf268ceafb36b8b913
--- /dev/null
+++ b/tests/lib/async/zone_value_test.dart
@@ -0,0 +1,54 @@
+// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+import 'package:expect/expect.dart';
+import 'package:async_helper/async_helper.dart';
+import 'dart:async';
+
+main() {
+ Completer done = new Completer();
+ List events = [];
+
+ // runGuarded calls run, captures the synchronous error (if any) and
+ // gives that one to handleUncaughtError.
+
+ Expect.identical(Zone.ROOT, Zone.current);
+ Zone forked;
+ Map zoneValues = new Map();
+ var foo = const Symbol("foo");
+ var bar = const Symbol("bar");
+ zoneValues[foo] = 499;
+ zoneValues[bar] = [];
+ forked = Zone.current.fork(zoneValues: zoneValues);
+
+ Expect.identical(Zone.ROOT, Zone.current);
+ Expect.isNull(Zone.current[foo]);
+ Expect.isNull(Zone.current[bar]);
+
+ forked.run(() {
+ Expect.equals(499, Zone.current[foo]);
+ Expect.listEquals([], Zone.current[bar]);
+ Zone.current[bar].add(42);
+ });
+ Expect.identical(Zone.ROOT, Zone.current);
+ Expect.isNull(Zone.current[foo]);
+ Expect.isNull(Zone.current[bar]);
+
+ forked.run(() {
+ Expect.equals(499, Zone.current[foo]);
+ Expect.listEquals([42], Zone.current[bar]);
+ });
+
+ zoneValues = new Map();
+ var gee = const Symbol("gee");
+ zoneValues[gee] = 99;
+ zoneValues[foo] = -499;
+ Zone forkedChild = forked.fork(zoneValues: zoneValues);
+
+ forkedChild.run(() {
+ Expect.equals(-499, Zone.current[foo]);
+ Expect.listEquals([42], Zone.current[bar]);
+ Expect.equals(99, Zone.current[gee]);
+ });
+}
« 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