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

Unified Diff: tests/corelib/regexp/regexp_test.dart

Issue 2510783002: VM: Optimize RegExp.matchAsPrefix(...) by generating a sticky RegExp specialization. (Closed)
Patch Set: Done Created 4 years, 1 month 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 | « runtime/vm/regexp_assembler_ir.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/corelib/regexp/regexp_test.dart
diff --git a/tests/corelib/regexp/regexp_test.dart b/tests/corelib/regexp/regexp_test.dart
index 60483ba545934d06b0a84dd6c19aa45404d6bc38..3231f2a00681292113e5280235cd80a95c9484cf 100644
--- a/tests/corelib/regexp/regexp_test.dart
+++ b/tests/corelib/regexp/regexp_test.dart
@@ -591,4 +591,28 @@ void main() {
// Tests skipped from V8:
// Test that RegExp.prototype.toString() throws TypeError for
// incompatible receivers (ES5 section 15.10.6 and 15.10.6.4).
+
+ testSticky();
+}
+
+testSticky() {
+ var re = new RegExp(r"foo.bar");
+ Expect.isNotNull(re.matchAsPrefix("foo_bar", 0));
+ Expect.isNull(re.matchAsPrefix("..foo_bar", 0));
+ Expect.isNotNull(re.matchAsPrefix("..foo_bar", 2));
+
+ re = new RegExp(r"^foo");
+ Expect.isNotNull(re.matchAsPrefix("foobar", 0));
+ Expect.isNull(re.matchAsPrefix("..foo", 0));
+ Expect.isNull(re.matchAsPrefix("..foo", 2));
+
+ re = new RegExp(r"^foo", multiLine: true);
+ Expect.isNotNull(re.matchAsPrefix("foobar", 0));
+ Expect.isNull(re.matchAsPrefix("..\nfoo", 0));
+ Expect.isNotNull(re.matchAsPrefix("..\nfoo", 3));
+ Expect.isNull(re.matchAsPrefix("..\nfoofoo", 6));
+
+ re = new RegExp(r"bar$");
+ Expect.isNull(re.matchAsPrefix("foobar", 0));
+ Expect.isNotNull(re.matchAsPrefix("foobar", 3));
}
« no previous file with comments | « runtime/vm/regexp_assembler_ir.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698