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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: tests/lib/async/zone_fork_test.dart
diff --git a/tests/lib/async/zone_fork_test.dart b/tests/lib/async/zone_fork_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..b5ebc305e7d8eb3ef59955b2fedebd6a118eb8b8
--- /dev/null
+++ b/tests/lib/async/zone_fork_test.dart
@@ -0,0 +1,60 @@
+// 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.
Lasse Reichstein Nielsen 2013/09/23 14:24:12 Bad comment?
floitsch 2013/09/23 17:12:07 Done.
+
+ Expect.identical(Zone.ROOT, Zone.current);
+ Zone forked;
+ forked = Zone.current.fork(null, new ZoneDescription(
+ fork: (Zone self, ZoneDelegate parent, Zone origin,
+ Map mapValues, ZoneDescription zoneDescription) {
+ // The zone is still the same as when origin.run was invoked, which
+ // is the root zone. (The origin zone hasn't been set yet).
+ Expect.identical(Zone.ROOT, Zone.current);
+ events.add("forked.fork");
+ Function descriptionRun = zoneDescription.run;
+ ZoneDescription modified = new ZoneDescription.from(zoneDescription,
+ run: (self, parent, origin, f) {
+ events.add("wrapped run");
+ return descriptionRun(self, parent, origin, () {
+ events.add("wrapped f");
+ return f();
+ });
+ });
+ return parent.fork(origin, mapValues, modified);
+ }));
+
+ events.add("start");
+ Zone forkedChild = forked.fork(null, new ZoneDescription(
+ run: (Zone self, ZoneDelegate parent, Zone origin, f()) {
+ events.add("executing child run");
+ return parent.run(origin, f);
+ }));
+
+ events.add("after child fork");
+ Expect.identical(Zone.ROOT, Zone.current);
+
+ forkedChild.run(() {
+ events.add("child run");
+ });
+
+ events.add("after child run");
+
+ Expect.listEquals(
+ [ "start",
+ "forked.fork",
+ "after child fork",
+ "wrapped run", "executing child run", "wrapped f", "child run",
+ "after child run" ],
+ events);
+}

Powered by Google App Engine
This is Rietveld 408576698