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

Unified Diff: tests/language/reg_exp_test.dart

Issue 460613002: Add optional start index to Pattern.allMatches. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 4 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 | « tests/corelib/string_pattern_test.dart ('k') | third_party/pkg/route_hierarchical/lib/pattern.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/language/reg_exp_test.dart
diff --git a/tests/language/reg_exp_test.dart b/tests/language/reg_exp_test.dart
index c51663c3b63bb6224dc9c1b3305637ebc87529af..600b34435d443165a2bebc0951d9036547a3e24f 100644
--- a/tests/language/reg_exp_test.dart
+++ b/tests/language/reg_exp_test.dart
@@ -21,6 +21,23 @@ void main() {
Expect.listEquals(["", "a", "", "", "a", ""],
exp.allMatches(str).map((x)=>x[0]).toList());
+ // Check that allMatches works with optional start index.
Anders Johnsen 2014/08/11 11:57:01 Should the RegExp '.*' match regExp.allMatches
Lasse Reichstein Nielsen 2014/08/11 12:35:35 It should. I'll add a test for it.
+ exp = new RegExp("as{2}");
+ str = "assassin";
+ Expect.equals(2, exp.allMatches(str).length);
+ Expect.equals(2, exp.allMatches(str, 0).length);
+ Expect.equals(1, exp.allMatches(str, 1).length);
+ Expect.equals(0, exp.allMatches(str, 4).length);
+ Expect.equals(0, exp.allMatches(str, str.length).length);
+ Expect.throws(() => exp.allMatches(str, -1));
+ Expect.throws(() => exp.allMatches(str, str.length + 1));
+
+ // The "^" must only match at the beginning of the string.
+ // Using a start-index doesn't change where the string starts.
+ exp = new RegExp("^ass");
+ Expect.equals(1, exp.allMatches(str, 0).length);
+ Expect.equals(0, exp.allMatches(str, 3).length);
+
// Regression test for http://dartbug.com/2980
exp = new RegExp("^", multiLine: true); // Any zero-length match will work.
str = "foo\nbar\nbaz";
« no previous file with comments | « tests/corelib/string_pattern_test.dart ('k') | third_party/pkg/route_hierarchical/lib/pattern.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698