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

Side by Side Diff: tests/lib/async/future_timeout_test.dart

Issue 3014593002: Use generic functions in zones. (Closed)
Patch Set: Added changes missing from patch set #2 Created 3 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
« no previous file with comments | « tests/lib/async/async_await_zones_test.dart ('k') | tests/lib/async/run_zoned6_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
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
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
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 }
OLDNEW
« no previous file with comments | « tests/lib/async/async_await_zones_test.dart ('k') | tests/lib/async/run_zoned6_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698