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

Unified Diff: tests/language/reg_exp_test.dart

Issue 16206008: Fix-up RegExp implementations. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Renaming startIndex to index. Add comment. 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 | « tests/co19/co19-runtime.status ('k') | no next file » | 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 631cfda4f68b0355106979fe53f145ae765e8636..26826a906b956a5f31ee254124b268321faa5b3e 100644
--- a/tests/language/reg_exp_test.dart
+++ b/tests/language/reg_exp_test.dart
@@ -5,22 +5,24 @@
import "package:expect/expect.dart";
-class RegExpTest {
- static test1() {
- RegExp exp = new RegExp("(\\w+)");
- String str = "Parse my string";
- List<Match> matches = new List<Match>.from(exp.allMatches(str));
- Expect.equals(3, matches.length);
- Expect.equals("Parse", matches[0].group(0));
- Expect.equals("my", matches[1].group(0));
- Expect.equals("string", matches[2].group(0));
- }
+void main() {
+ RegExp exp = new RegExp(r"(\w+)");
+ String str = "Parse my string";
+ List<Match> matches = exp.allMatches(str).toList();
+ Expect.equals(3, matches.length);
+ Expect.equals("Parse", matches[0].group(0));
+ Expect.equals("my", matches[1].group(0));
+ Expect.equals("string", matches[2].group(0));
- static testMain() {
- test1();
- }
-}
+ // Check that allMatches progresses correctly for empty matches, and that
+ // it includes the empty match at the end position.
+ exp = new RegExp("a?");
+ str = "babba";
+ Expect.listEquals(["", "a", "", "", "a", ""],
+ exp.allMatches(str).map((x)=>x[0]).toList());
-main() {
- RegExpTest.testMain();
+ // Regression test for http://dartbug.com/2980
+ exp = new RegExp("^", multiLine: true); // Any zero-length match will work.
+ str = "foo\nbar\nbaz";
+ Expect.equals(" foo\n bar\n baz", str.replaceAll(exp, " "));
}
« no previous file with comments | « tests/co19/co19-runtime.status ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698