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

Side by Side 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, 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_empty_description2_test.dart ('k') | tests/lib/async/zone_fork_test.dart » ('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 testForkedZone(Zone forked) {
10 var result;
11 result = forked.run(() {
12 Expect.identical(forked, Zone.current);
13 return 499;
14 });
15 Expect.equals(499, result);
16 Expect.identical(Zone.ROOT, Zone.current);
17
18 result = forked.runUnary((x) {
19 Expect.equals(42, x);
20 Expect.identical(forked, Zone.current);
21 return -499;
22 }, 42);
23 Expect.equals(-499, result);
24 Expect.identical(Zone.ROOT, Zone.current);
25
26 bool runGuardedDidRun = false;
27 forked.runGuarded(() {
28 runGuardedDidRun = true;
29 Expect.identical(forked, Zone.current);
30 });
31 Expect.identical(Zone.ROOT, Zone.current);
32 Expect.isTrue(runGuardedDidRun);
33
34 runGuardedDidRun = false;
35 forked.runUnaryGuarded((x) {
36 runGuardedDidRun = true;
37 Expect.equals(42, x);
38 Expect.identical(forked, Zone.current);
39 }, 42);
40 Expect.identical(Zone.ROOT, Zone.current);
41 Expect.isTrue(runGuardedDidRun);
42
43 var callback = () => 499;
44 Expect.identical(callback, forked.registerCallback(callback));
45 Expect.identical(Zone.ROOT, Zone.current);
46
47 var callback1 = (x) => 42 + x;
48 Expect.identical(callback1, forked.registerUnaryCallback(callback1));
49 Expect.identical(Zone.ROOT, Zone.current);
50
51 asyncStart();
52 bool asyncDidRun = false;
53 forked.scheduleMicrotask(() {
54 // The runAsync functions on the Zone don't bind the closures.
55 Expect.identical(Zone.ROOT, Zone.current);
56 asyncDidRun = true;
57 asyncEnd();
58 });
59 Expect.isFalse(asyncDidRun);
60 Expect.identical(Zone.ROOT, Zone.current);
61
62 asyncStart();
63 bool timerDidRun = false;
64 forked.createTimer(const Duration(milliseconds: 0), () {
65 // The createTimer functions on the Zone don't bind the closures.
66 Expect.identical(Zone.ROOT, Zone.current);
67 timerDidRun = true;
68 asyncEnd();
69 });
70 Expect.identical(Zone.ROOT, Zone.current);
71 }
72
73 main() {
74 Expect.identical(Zone.ROOT, Zone.current);
75 Zone forked = Zone.current.fork();
76 Expect.isFalse(identical(Zone.ROOT, forked));
77 testForkedZone(forked);
78 Zone forkedChild = forked.fork();
79 testForkedZone(forkedChild);
80 }
OLDNEW
« 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