| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 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 | 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. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 import 'package:expect/expect.dart'; | 5 import 'package:expect/expect.dart'; |
| 6 import 'package:async_helper/async_helper.dart'; | 6 import 'package:async_helper/async_helper.dart'; |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 | 8 |
| 9 testForkedZone(Zone forked) { | 9 testForkedZone(Zone forked) { |
| 10 var result; | 10 var result; |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 Expect.identical(callback, forked.registerCallback(callback)); | 44 Expect.identical(callback, forked.registerCallback(callback)); |
| 45 Expect.identical(Zone.ROOT, Zone.current); | 45 Expect.identical(Zone.ROOT, Zone.current); |
| 46 | 46 |
| 47 var callback1 = (x) => 42 + x; | 47 var callback1 = (x) => 42 + x; |
| 48 Expect.identical(callback1, forked.registerUnaryCallback(callback1)); | 48 Expect.identical(callback1, forked.registerUnaryCallback(callback1)); |
| 49 Expect.identical(Zone.ROOT, Zone.current); | 49 Expect.identical(Zone.ROOT, Zone.current); |
| 50 | 50 |
| 51 asyncStart(); | 51 asyncStart(); |
| 52 bool asyncDidRun = false; | 52 bool asyncDidRun = false; |
| 53 forked.scheduleMicrotask(() { | 53 forked.scheduleMicrotask(() { |
| 54 // The runAsync functions on the Zone don't bind the closures. | 54 // The scheduleMicrotask functions on the Zone don't bind the closures. |
| 55 Expect.identical(Zone.ROOT, Zone.current); | 55 Expect.identical(Zone.ROOT, Zone.current); |
| 56 asyncDidRun = true; | 56 asyncDidRun = true; |
| 57 asyncEnd(); | 57 asyncEnd(); |
| 58 }); | 58 }); |
| 59 Expect.isFalse(asyncDidRun); | 59 Expect.isFalse(asyncDidRun); |
| 60 Expect.identical(Zone.ROOT, Zone.current); | 60 Expect.identical(Zone.ROOT, Zone.current); |
| 61 | 61 |
| 62 asyncStart(); | 62 asyncStart(); |
| 63 bool timerDidRun = false; | 63 bool timerDidRun = false; |
| 64 forked.createTimer(const Duration(milliseconds: 0), () { | 64 forked.createTimer(const Duration(milliseconds: 0), () { |
| 65 // The createTimer functions on the Zone don't bind the closures. | 65 // The createTimer functions on the Zone don't bind the closures. |
| 66 Expect.identical(Zone.ROOT, Zone.current); | 66 Expect.identical(Zone.ROOT, Zone.current); |
| 67 timerDidRun = true; | 67 timerDidRun = true; |
| 68 asyncEnd(); | 68 asyncEnd(); |
| 69 }); | 69 }); |
| 70 Expect.identical(Zone.ROOT, Zone.current); | 70 Expect.identical(Zone.ROOT, Zone.current); |
| 71 } | 71 } |
| 72 | 72 |
| 73 main() { | 73 main() { |
| 74 Expect.identical(Zone.ROOT, Zone.current); | 74 Expect.identical(Zone.ROOT, Zone.current); |
| 75 Zone forked = Zone.current.fork(); | 75 Zone forked = Zone.current.fork(); |
| 76 Expect.isFalse(identical(Zone.ROOT, forked)); | 76 Expect.isFalse(identical(Zone.ROOT, forked)); |
| 77 testForkedZone(forked); | 77 testForkedZone(forked); |
| 78 Zone forkedChild = forked.fork(); | 78 Zone forkedChild = forked.fork(); |
| 79 testForkedZone(forkedChild); | 79 testForkedZone(forkedChild); |
| 80 } | 80 } |
| OLD | NEW |