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

Side by Side Diff: tests/lib/async/zone_create_timer2_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 unified diff | Download patch | Annotate | Revision Log
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.
Lasse Reichstein Nielsen 2013/09/23 14:24:12 Wrong comment.
floitsch 2013/09/23 17:12:07 Done.
15
16 Expect.identical(Zone.ROOT, Zone.current);
17 Zone forked;
18 forked = Zone.current.fork(null, new ZoneDescription(
19 createTimer: (Zone self, ZoneDelegate parent, Zone origin,
20 Duration duration, f()) {
21 events.add("forked.createTimer");
22 return parent.createTimer(origin, duration, () {
23 events.add("wrapped function ${duration.inMilliseconds}");
24 f();
25 });
26 }));
27
28 asyncStart();
29 forked.run(() {
30 Timer timer = new Timer(const Duration(milliseconds: 20), () {
31 events.add("createTimer");
32 Expect.identical(forked, Zone.current);
33 done.complete(true);
34 });
35 });
36
37 Expect.identical(Zone.ROOT, Zone.current);
38 events.add("after createTimer");
39
40 done.future.whenComplete(() {
41 Expect.listEquals(
42 [ "forked.createTimer", "after createTimer", "wrapped function 20",
43 "createTimer" ],
44 events);
45 asyncEnd();
46 });
47 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698