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

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

Issue 14886015: Use runAsync for Futures. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 7 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/test/unittest_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) 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 import 'package:stack_trace/stack_trace.dart'; 9 import 'package:stack_trace/stack_trace.dart';
10 10
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 lines = lines.skip(1).map((line) => '$prefix$line').toList(); 45 lines = lines.skip(1).map((line) => '$prefix$line').toList();
46 lines.insert(0, firstLine); 46 lines.insert(0, firstLine);
47 return lines.join('\n'); 47 return lines.join('\n');
48 } 48 }
49 49
50 /// Returns a [Future] that completes after pumping the event queue [times] 50 /// Returns a [Future] that completes after pumping the event queue [times]
51 /// times. By default, this should pump the event queue enough times to allow 51 /// times. By default, this should pump the event queue enough times to allow
52 /// any code to run, as long as it's not waiting on some external event. 52 /// any code to run, as long as it's not waiting on some external event.
53 Future pumpEventQueue([int times=20]) { 53 Future pumpEventQueue([int times=20]) {
54 if (times == 0) return new Future.value(); 54 if (times == 0) return new Future.value();
55 return new Future.value().then((_) => pumpEventQueue(times - 1)); 55 return new Future.delayed(Duration.ZERO, () => pumpEventQueue(times - 1));
nweiz 2013/05/10 23:49:43 It would be nice to add a comment here about which
floitsch 2013/05/13 10:52:48 Done.
56 } 56 }
57 57
58 /// Returns whether [iterable1] has the same elements in the same order as 58 /// Returns whether [iterable1] has the same elements in the same order as
59 /// [iterable2]. The elements are compared using `==`. 59 /// [iterable2]. The elements are compared using `==`.
60 bool orderedIterableEquals(Iterable iterable1, Iterable iterable2) { 60 bool orderedIterableEquals(Iterable iterable1, Iterable iterable2) {
61 var iter1 = iterable1.iterator; 61 var iter1 = iterable1.iterator;
62 var iter2 = iterable2.iterator; 62 var iter2 = iterable2.iterator;
63 63
64 while (true) { 64 while (true) {
65 var hasNext1 = iter1.moveNext(); 65 var hasNext1 = iter1.moveNext();
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 } 188 }
189 189
190 /// Returns a string representation of [trace] that has the core and test frames 190 /// Returns a string representation of [trace] that has the core and test frames
191 /// folded together. 191 /// folded together.
192 String terseTraceString(StackTrace trace) { 192 String terseTraceString(StackTrace trace) {
193 return new Trace.from(trace).terse.foldFrames((frame) { 193 return new Trace.from(trace).terse.foldFrames((frame) {
194 return frame.package == 'scheduled_test' || frame.package == 'unittest' || 194 return frame.package == 'scheduled_test' || frame.package == 'unittest' ||
195 frame.isCore; 195 frame.isCore;
196 }).toString().trim(); 196 }).toString().trim();
197 } 197 }
OLDNEW
« no previous file with comments | « no previous file | pkg/unittest/test/unittest_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698