| 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));
|
| +}
|
|
|