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

Unified Diff: pkg/scheduled_test/lib/src/utils.dart

Issue 93143002: Make pkg/stack_trace use stack chains. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/scheduled_test/lib/src/task.dart ('k') | pkg/scheduled_test/test/metatest.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/scheduled_test/lib/src/utils.dart
diff --git a/pkg/scheduled_test/lib/src/utils.dart b/pkg/scheduled_test/lib/src/utils.dart
index 7daac77553b13dea55e76cf04318a1fafeb0c29f..9cba0447190a1b440d4f9af8dd721abad11f1229 100644
--- a/pkg/scheduled_test/lib/src/utils.dart
+++ b/pkg/scheduled_test/lib/src/utils.dart
@@ -31,6 +31,9 @@ void chainToCompleter(Future future, Completer completer) {
future.then(completer.complete, onError: completer.completeError);
}
+/// Like [Future.sync], but wraps the Future in [Chain.track] as well.
+Future syncFuture(callback()) => Chain.track(new Future.sync(callback));
+
/// Prepends each line in [text] with [prefix]. If [firstPrefix] is passed, the
/// first line is prefixed with that instead.
String prefixLines(String text, {String prefix: '| ', String firstPrefix}) {
@@ -72,10 +75,6 @@ bool orderedIterableEquals(Iterable iterable1, Iterable iterable2) {
}
}
-// TODO(nweiz): remove this when issue 8731 is fixed.
-/// Returns a [Stream] that will immediately emit [error] and then close.
-Stream errorStream(error) => new Future.error(error).asStream();
-
/// Returns a buffered stream that will emit the same values as the stream
/// returned by [future] once [future] completes.
///
@@ -127,12 +126,11 @@ Stream futureStream(Future<Stream> future, {bool broadcast: false}) {
///
/// If the [StreamIterator] has no elements, the result is a state error.
Future<String> streamIteratorFirst(StreamIterator<String> streamIterator) {
- StackTrace stackTrace = new Trace.current();
return streamIterator.moveNext().then((hasNext) {
if (hasNext) {
return streamIterator.current;
} else {
- return new Future.error(new StateError("No elements"), stackTrace);
+ throw new StateError("No elements");
}
});
}
@@ -233,8 +231,12 @@ bool fullMatch(String string, Pattern pattern) {
/// Returns a string representation of [trace] that has the core and test frames
/// folded together.
String terseTraceString(StackTrace trace) {
- return new Trace.from(trace).terse.foldFrames((frame) {
- return frame.package == 'scheduled_test' || frame.package == 'unittest' ||
- frame.isCore;
- }).toString().trim();
+ return new Chain(new Chain.forTrace(trace).traces.map((trace) {
+ return trace.foldFrames((frame) {
+ return frame.package == 'scheduled_test' ||
+ frame.package == 'unittest' ||
+ frame.package == 'stack_trace' ||
+ frame.isCore;
+ });
+ })).terse.toString().trim();
}
« no previous file with comments | « pkg/scheduled_test/lib/src/task.dart ('k') | pkg/scheduled_test/test/metatest.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698