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

Unified Diff: tests/lib/async/zone_empty_description_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_empty_description2_test.dart ('k') | tests/lib/async/zone_fork_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/lib/async/zone_empty_description_test.dart
diff --git a/tests/lib/async/zone_empty_description_test.dart b/tests/lib/async/zone_empty_description_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..81ddedca46dd8fa308765d330b12cb223bcbffef
--- /dev/null
+++ b/tests/lib/async/zone_empty_description_test.dart
@@ -0,0 +1,80 @@
+// 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';
+
+testForkedZone(Zone forked) {
+ var result;
+ result = forked.run(() {
+ Expect.identical(forked, Zone.current);
+ return 499;
+ });
+ Expect.equals(499, result);
+ Expect.identical(Zone.ROOT, Zone.current);
+
+ result = forked.runUnary((x) {
+ Expect.equals(42, x);
+ Expect.identical(forked, Zone.current);
+ return -499;
+ }, 42);
+ Expect.equals(-499, result);
+ Expect.identical(Zone.ROOT, Zone.current);
+
+ bool runGuardedDidRun = false;
+ forked.runGuarded(() {
+ runGuardedDidRun = true;
+ Expect.identical(forked, Zone.current);
+ });
+ Expect.identical(Zone.ROOT, Zone.current);
+ Expect.isTrue(runGuardedDidRun);
+
+ runGuardedDidRun = false;
+ forked.runUnaryGuarded((x) {
+ runGuardedDidRun = true;
+ Expect.equals(42, x);
+ Expect.identical(forked, Zone.current);
+ }, 42);
+ Expect.identical(Zone.ROOT, Zone.current);
+ Expect.isTrue(runGuardedDidRun);
+
+ var callback = () => 499;
+ Expect.identical(callback, forked.registerCallback(callback));
+ Expect.identical(Zone.ROOT, Zone.current);
+
+ var callback1 = (x) => 42 + x;
+ Expect.identical(callback1, forked.registerUnaryCallback(callback1));
+ Expect.identical(Zone.ROOT, Zone.current);
+
+ asyncStart();
+ bool asyncDidRun = false;
+ forked.scheduleMicrotask(() {
+ // The runAsync functions on the Zone don't bind the closures.
+ Expect.identical(Zone.ROOT, Zone.current);
+ asyncDidRun = true;
+ asyncEnd();
+ });
+ Expect.isFalse(asyncDidRun);
+ Expect.identical(Zone.ROOT, Zone.current);
+
+ asyncStart();
+ bool timerDidRun = false;
+ forked.createTimer(const Duration(milliseconds: 0), () {
+ // The createTimer functions on the Zone don't bind the closures.
+ Expect.identical(Zone.ROOT, Zone.current);
+ timerDidRun = true;
+ asyncEnd();
+ });
+ Expect.identical(Zone.ROOT, Zone.current);
+}
+
+main() {
+ Expect.identical(Zone.ROOT, Zone.current);
+ Zone forked = Zone.current.fork();
+ Expect.isFalse(identical(Zone.ROOT, forked));
+ testForkedZone(forked);
+ Zone forkedChild = forked.fork();
+ testForkedZone(forkedChild);
+}
« no previous file with comments | « tests/lib/async/zone_empty_description2_test.dart ('k') | tests/lib/async/zone_fork_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698