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

Side by Side Diff: pkg/scheduled_test/lib/scheduled_test.dart

Issue 12393017: Fix issue with async callbacks that get called synchronously while running test case function causi… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 9 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
« no previous file with comments | « no previous file | pkg/unittest/lib/src/expect.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) 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 // TODO(nweiz): Add support for calling [schedule] while the schedule is already 5 // TODO(nweiz): Add support for calling [schedule] while the schedule is already
6 // running. 6 // running.
7 // TODO(nweiz): Port the non-Pub-specific scheduled test libraries from Pub. 7 // TODO(nweiz): Port the non-Pub-specific scheduled test libraries from Pub.
8 /// A package for writing readable tests of asynchronous behavior. 8 /// A package for writing readable tests of asynchronous behavior.
9 /// 9 ///
10 /// This package works by building up a queue of asynchronous tasks called a 10 /// This package works by building up a queue of asynchronous tasks called a
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 309
310 unittest.tearDown(() { 310 unittest.tearDown(() {
311 _currentSchedule = null; 311 _currentSchedule = null;
312 }); 312 });
313 } 313 }
314 314
315 /// Ensures that the global configuration for `scheduled_test` has been 315 /// Ensures that the global configuration for `scheduled_test` has been
316 /// initialized. 316 /// initialized.
317 void _ensureInitialized() { 317 void _ensureInitialized() {
318 unittest.ensureInitialized(); 318 unittest.ensureInitialized();
319 unittest.wrapAsync = (f) { 319 unittest.wrapAsync = (f, [id = '']) {
320 if (currentSchedule == null) { 320 if (currentSchedule == null) {
321 throw new StateError("Unexpected call to wrapAsync with no current " 321 throw new StateError("Unexpected call to wrapAsync with no current "
322 "schedule."); 322 "schedule.");
323 } 323 }
324 324
325 return currentSchedule.wrapAsync(f); 325 return currentSchedule.wrapAsync(f);
326 }; 326 };
327 } 327 }
328 328
329 /// Like [wrapAsync], this ensures that the current task queue waits for 329 /// Like [wrapAsync], this ensures that the current task queue waits for
330 /// out-of-band asynchronous code, and that errors raised in that code are 330 /// out-of-band asynchronous code, and that errors raised in that code are
331 /// handled correctly. However, [wrapFuture] wraps a [Future] chain rather than 331 /// handled correctly. However, [wrapFuture] wraps a [Future] chain rather than
332 /// a single callback. 332 /// a single callback.
333 /// 333 ///
334 /// The returned [Future] completes to the same value or error as [future]. 334 /// The returned [Future] completes to the same value or error as [future].
335 Future wrapFuture(Future future) { 335 Future wrapFuture(Future future) {
336 if (currentSchedule == null) { 336 if (currentSchedule == null) {
337 throw new StateError("Unexpected call to wrapFuture with no current " 337 throw new StateError("Unexpected call to wrapFuture with no current "
338 "schedule."); 338 "schedule.");
339 } 339 }
340 340
341 return currentSchedule.wrapFuture(future); 341 return currentSchedule.wrapFuture(future);
342 } 342 }
OLDNEW
« no previous file with comments | « no previous file | pkg/unittest/lib/src/expect.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698