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

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

Issue 12853005: Change the way Patterns work in scheduled_test/descriptor. (Closed) Base URL: https://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 side-by-side diff with in-line comments
Download patch
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}) {
+ 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);
+ 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;
+}

Powered by Google App Engine
This is Rietveld 408576698