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

Unified Diff: tests/language/regex/assertion_test.dart

Issue 539153002: Port and integrate the irregexp engine from V8 (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressed Ivan's comments. Created 6 years, 2 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/language/regex/ascii-regexp-subject_test.dart ('k') | tests/language/regex/backreferences_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/language/regex/assertion_test.dart
diff --git a/tests/language/regex/assertion_test.dart b/tests/language/regex/assertion_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..ffabd585726ef82a40e1721d6846bd4e888c51a1
--- /dev/null
+++ b/tests/language/regex/assertion_test.dart
@@ -0,0 +1,95 @@
+// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+import 'util.dart';
+import 'package:expect/expect.dart';
+
+void main() {
+ description("This page tests handling of parenthetical assertions.");
+
+ var regex1 = new RegExp(r"(x)(?=\1)x");
+ shouldBe(regex1.firstMatch('xx'), ['xx','x']);
+
+ var regex2 = new RegExp(r"(.*?)a(?!(a+)b\2c)\2(.*)");
+ shouldBe(regex2.firstMatch('baaabaac'), ['baaabaac','ba',null,'abaac']);
+
+ var regex3 = new RegExp(r"(?=(a+?))(\1ab)");
+ shouldBe(regex3.firstMatch('aaab'), ['aab','a','aab']);
+
+ var regex4 = new RegExp(r"(?=(a+?))(\1ab)");
+ shouldBe(regex4.firstMatch('aaab'), ['aab','a','aab']);
+
+ var regex5 = new RegExp(r"^P([1-6])(?=\1)([1-6])$");
+ shouldBe(regex5.firstMatch('P11'), ['P11','1','1']);
+
+ var regex6 = new RegExp(r"(([a-c])b*?\2)*");
+ shouldBe(regex6.firstMatch('ababbbcbc'), ['ababb','bb','b']);
+
+ var regex7 = new RegExp(r"(x)(?=x)x");
+ shouldBe(regex7.firstMatch('xx'), ['xx','x']);
+
+ var regex8 = new RegExp(r"(x)(\1)");
+ shouldBe(regex8.firstMatch('xx'), ['xx','x','x']);
+
+ var regex9 = new RegExp(r"(x)(?=\1)x");
+ shouldBeNull(regex9.firstMatch('xy'));
+
+ var regex10 = new RegExp(r"(x)(?=x)x");
+ shouldBeNull(regex10.firstMatch('xy'));
+
+ var regex11 = new RegExp(r"(x)(\1)");
+ shouldBeNull(regex11.firstMatch('xy'));
+
+ var regex12 = new RegExp(r"(x)(?=\1)x");
+ shouldBeNull(regex12.firstMatch('x'));
+ shouldBe(regex12.firstMatch('xx'), ['xx','x']);
+ shouldBe(regex12.firstMatch('xxy'), ['xx','x']);
+
+ var regex13 = new RegExp(r"(x)zzz(?=\1)x");
+ shouldBe(regex13.firstMatch('xzzzx'), ['xzzzx','x']);
+ shouldBe(regex13.firstMatch('xzzzxy'), ['xzzzx','x']);
+
+ var regex14 = new RegExp(r"(a)\1(?=(b*c))bc");
+ shouldBe(regex14.firstMatch('aabc'), ['aabc','a','bc']);
+ shouldBe(regex14.firstMatch('aabcx'), ['aabc','a','bc']);
+
+ var regex15 = new RegExp(r"(a)a(?=(b*c))bc");
+ shouldBe(regex15.firstMatch('aabc'), ['aabc','a','bc']);
+ shouldBe(regex15.firstMatch('aabcx'), ['aabc','a','bc']);
+
+ var regex16 = new RegExp(r"a(?=(b*c))bc");
+ shouldBeNull(regex16.firstMatch('ab'));
+ shouldBe(regex16.firstMatch('abc'), ['abc','bc']);
+
+ var regex17 = new RegExp(r"(?=((?:ab)*))a");
+ shouldBe(regex17.firstMatch('ab'), ['a','ab']);
+ shouldBe(regex17.firstMatch('abc'), ['a','ab']);
+
+ var regex18 = new RegExp(r"(?=((?:xx)*))x");
+ shouldBe(regex18.firstMatch('x'), ['x','']);
+ shouldBe(regex18.firstMatch('xx'), ['x','xx']);
+ shouldBe(regex18.firstMatch('xxx'), ['x','xx']);
+
+ var regex19 = new RegExp(r"(?=((xx)*))x");
+ shouldBe(regex19.firstMatch('x'), ['x','',null]);
+ shouldBe(regex19.firstMatch('xx'), ['x','xx','xx']);
+ shouldBe(regex19.firstMatch('xxx'), ['x','xx','xx']);
+
+ var regex20 = new RegExp(r"(?=(xx))+x");
+ shouldBeNull(regex20.firstMatch('x'));
+ shouldBe(regex20.firstMatch('xx'), ['x','xx']);
+ shouldBe(regex20.firstMatch('xxx'), ['x','xx']);
+
+ var regex21 = new RegExp(r"(?=a+b)aab");
+ shouldBe(regex21.firstMatch('aab'), ['aab']);
+
+ var regex22 = new RegExp(r"(?!(u|m{0,}g+)u{1,}|2{2,}!1%n|(?!K|(?=y)|(?=ip))+?)(?=(?=(((?:7))*?)*?))p", multiLine: true);
+ shouldBeNull(regex22.firstMatch('55up'));
+
+ var regex23 = new RegExp(r"(?=(a)b|c?)()*d");
+ shouldBeNull(regex23.firstMatch('ax'));
+
+ var regex24 = new RegExp(r"(?=a|b?)c");
+ shouldBeNull(regex24.firstMatch('x'));
+}
« no previous file with comments | « tests/language/regex/ascii-regexp-subject_test.dart ('k') | tests/language/regex/backreferences_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698