| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 library future_timeout_test; | 5 library future_timeout_test; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'package:unittest/unittest.dart'; | 8 import 'package:unittest/unittest.dart'; |
| 9 | 9 |
| 10 main() { | 10 main() { |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 Zone forked; | 148 Zone forked; |
| 149 int registerCallDelta = 0; | 149 int registerCallDelta = 0; |
| 150 bool callbackCalled = false; | 150 bool callbackCalled = false; |
| 151 Function callback = () { | 151 Function callback = () { |
| 152 expect(callbackCalled, false); | 152 expect(callbackCalled, false); |
| 153 callbackCalled = true; | 153 callbackCalled = true; |
| 154 expect(Zone.current, forked); | 154 expect(Zone.current, forked); |
| 155 return 42; | 155 return 42; |
| 156 }; | 156 }; |
| 157 forked = Zone.current.fork(specification: new ZoneSpecification( | 157 forked = Zone.current.fork(specification: new ZoneSpecification( |
| 158 registerCallback: (Zone self, ZoneDelegate parent, Zone origin, f()) { | 158 registerCallback: |
| 159 <R>(Zone self, ZoneDelegate parent, Zone origin, R f()) { |
| 159 if (!identical(f, callback)) return f; | 160 if (!identical(f, callback)) return f; |
| 160 registerCallDelta++; // Increment calls to register. | 161 registerCallDelta++; // Increment calls to register. |
| 161 expect(origin, forked); | 162 expect(origin, forked); |
| 162 expect(self, forked); | 163 expect(self, forked); |
| 163 return expectAsync(() { | 164 return expectAsync(() { |
| 164 registerCallDelta--; | 165 registerCallDelta--; |
| 165 return f(); | 166 return f(); |
| 166 }); | 167 }); |
| 167 })); | 168 })); |
| 168 Completer completer = new Completer(); | 169 Completer completer = new Completer(); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 191 | 192 |
| 192 test("timeoutType", () { | 193 test("timeoutType", () { |
| 193 Completer completer = new Completer<int>(); | 194 Completer completer = new Completer<int>(); |
| 194 Future timedOut = completer.future.timeout(const Duration(milliseconds: 5)); | 195 Future timedOut = completer.future.timeout(const Duration(milliseconds: 5)); |
| 195 expect(timedOut, new isInstanceOf<Future<int>>()); | 196 expect(timedOut, new isInstanceOf<Future<int>>()); |
| 196 expect(timedOut, isNot(new isInstanceOf<Future<String>>())); | 197 expect(timedOut, isNot(new isInstanceOf<Future<String>>())); |
| 197 timedOut.catchError((_) {}); | 198 timedOut.catchError((_) {}); |
| 198 completer.complete(499); | 199 completer.complete(499); |
| 199 }); | 200 }); |
| 200 } | 201 } |
| OLD | NEW |