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

Unified Diff: tests/corelib/string_pattern_test.dart

Issue 15709018: Proof-of-concept matchPrefix on Pattern. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressed other comments. Created 7 years, 6 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
« no previous file with comments | « sdk/lib/core/pattern.dart ('k') | tests/language/reg_exp_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/corelib/string_pattern_test.dart
diff --git a/tests/corelib/string_pattern_test.dart b/tests/corelib/string_pattern_test.dart
index 46b4e75d59ed1a9e60376311c5a30d47ad675c18..25e12e795f9add7ed9f6d056c5a979fd93b10ab6 100644
--- a/tests/corelib/string_pattern_test.dart
+++ b/tests/corelib/string_pattern_test.dart
@@ -14,6 +14,7 @@ main() {
testEmptyPattern();
testEmptyString();
testEmptyPatternAndString();
+ testMatchAsPrefix();
}
testNoMatch() {
@@ -77,3 +78,22 @@ testEmptyPatternAndString() {
Iterable<Match> matches = pattern.allMatches(str);
Expect.isTrue(matches.iterator.moveNext());
}
+
+testMatchAsPrefix() {
+ String pattern = "an";
+ String str = "banana";
+ Expect.isNull(pattern.matchAsPrefix(str));
+ Expect.isNull(pattern.matchAsPrefix(str, 0));
+ var m = pattern.matchAsPrefix(str, 1);
+ Expect.equals("an", m[0]);
+ Expect.equals(1, m.start);
+ Expect.isNull(pattern.matchAsPrefix(str, 2));
+ m = pattern.matchAsPrefix(str, 3);
+ Expect.equals("an", m[0]);
+ Expect.equals(3, m.start);
+ Expect.isNull(pattern.matchAsPrefix(str, 4));
+ Expect.isNull(pattern.matchAsPrefix(str, 5));
+ Expect.isNull(pattern.matchAsPrefix(str, 6));
+ Expect.throws(() => pattern.matchAsPrefix(str, -1));
+ Expect.throws(() => pattern.matchAsPrefix(str, 7));
+}
« no previous file with comments | « sdk/lib/core/pattern.dart ('k') | tests/language/reg_exp_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698