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

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

Issue 12251012: Add built-in timeouts to scheduled_test. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Code review changes Created 7 years, 10 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
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 library utils; 5 library utils;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 /// Configures [future] so that its result (success or exception) is passed on 9 /// Configures [future] so that its result (success or exception) is passed on
10 /// to [completer]. 10 /// to [completer].
11 void chainToCompleter(Future future, Completer completer) { 11 void chainToCompleter(Future future, Completer completer) {
12 future.then((value) => completer.complete(value), 12 future.then((value) => completer.complete(value),
13 onError: (e) => completer.completeError(e.error, e.stackTrace)); 13 onError: (e) => completer.completeError(e.error, e.stackTrace));
14 } 14 }
15 15
16 /// Prepends each line in [text] with [prefix]. 16 /// Prepends each line in [text] with [prefix].
17 String prefixLines(String text, {String prefix: '| '}) => 17 String prefixLines(String text, {String prefix: '| '}) =>
18 text.split('\n').map((line) => '$prefix$line').join('\n'); 18 text.split('\n').map((line) => '$prefix$line').join('\n');
19
20 /// Returns a [Future] that completes after pumping the event queue [times]
21 /// times. By default, this should pump the event queue enough times to allow
22 /// any code to run, as long as it's not waiting on some external event.
23 Future pumpEventQueue([int times=200]) {
24 if (times == 0) return new Future.immediate(null);
25 return new Future.immediate(null).then((_) => pumpEventQueue(times - 1));
26 }
OLDNEW
« no previous file with comments | « pkg/scheduled_test/lib/src/substitute_future.dart ('k') | pkg/scheduled_test/test/metatest.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698