OLD | NEW |
(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 |
| 12 Expect.identical(Zone.ROOT, Zone.current); |
| 13 // New zone, does nothing by itself. |
| 14 Zone forked = Zone.current.fork(specification: new ZoneSpecification()); |
| 15 |
| 16 int ctr = 0; |
| 17 void expectZone([timer]) { |
| 18 Expect.identical(forked, Zone.current); |
| 19 if (timer != null) timer.cancel(); |
| 20 if (++ctr == 3) { |
| 21 asyncEnd(); |
| 22 } |
| 23 } |
| 24 |
| 25 asyncStart(); |
| 26 Duration now = const Duration(seconds: 0); |
| 27 // Check that the callback is bound to the zone. |
| 28 forked.scheduleMicrotask(expectZone); |
| 29 forked.createTimer(now, expectZone); |
| 30 forked.createPeriodicTimer(now, expectZone); |
| 31 } |
OLD | NEW |