Chromium Code Reviews| 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 898b72e31e0d6c0b4461b7476bb4136b72e1e788..93398b06f4a061ca35305cfe28bebfdf7015459c 100644 |
| --- a/pkg/scheduled_test/lib/src/utils.dart |
| +++ b/pkg/scheduled_test/lib/src/utils.dart |
| @@ -30,9 +30,19 @@ void chainToCompleter(Future future, Completer completer) { |
| onError: (e) => completer.completeError(e)); |
| } |
| -/// Prepends each line in [text] with [prefix]. |
| -String prefixLines(String text, {String prefix: '| '}) => |
| - text.split('\n').map((line) => '$prefix$line').join('\n'); |
| +/// 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}) { |
|
Bob Nystrom
2013/03/15 21:58:46
This feels like ab arbitrary default prefix. At th
nweiz
2013/03/15 23:17:21
I think of this as a utility method for visually s
Bob Nystrom
2013/03/18 21:06:34
SGTM. I don't have a better name either.
|
| + var lines = text.split('\n'); |
| + if (firstPrefix == null) { |
| + return lines.map((line) => '$prefix$line').join('\n'); |
| + } |
| + |
| + var firstLine = "$firstPrefix${lines.first}"; |
| + lines = lines.skip(1).map((line) => '$prefix$line').toList(); |
| + lines.insertRange(0, 1, firstLine); |
|
Bob Nystrom
2013/03/15 21:58:46
insert(0, firstLine)
nweiz
2013/03/15 23:17:21
Woah, we have insert() now?
Bob Nystrom
2013/03/18 21:06:34
http://api.dartlang.org/docs/bleeding_edge/dart_co
|
| + return lines.join('\n'); |
| +} |
| /// Returns a [Future] that completes after pumping the event queue [times] |
| /// times. By default, this should pump the event queue enough times to allow |
| @@ -167,3 +177,10 @@ Future awaitObject(object) { |
| return map; |
| }); |
| } |
| + |
| +/// Returns whether [pattern] matches all of [string]. |
| +bool fullMatch(String string, Pattern pattern) { |
| + var matches = pattern.allMatches(string); |
| + if (matches.isEmpty) return false; |
| + return matches.first.start == 0 && matches.first.end == string.length; |
| +} |