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

Unified Diff: test/mjsunit/regexp.js

Issue 12944: * Implemented case-insensitive back-reference matching in irregexp-ia32. (Closed)
Patch Set: Review comments addressed Created 12 years 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 | « test/cctest/test-regexp.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/regexp.js
diff --git a/test/mjsunit/regexp.js b/test/mjsunit/regexp.js
index 5c8088c6655a2676a087feaa8416bc21cf17a3e7..412432cf34fc7f02ae0fda48971bca0fdfb40be8 100644
--- a/test/mjsunit/regexp.js
+++ b/test/mjsunit/regexp.js
@@ -263,4 +263,43 @@ assertTrue(/foo$(?!bar)/.test("foo"), "football12");
assertFalse(/f(o)\b\1/.test('foo'));
assertTrue(/f(o)\B\1/.test('foo'));
+// Back-reference, ignore case:
+// ASCII
+assertEquals("xaAx,a", String(/x(a)\1x/i.exec("xaAx")), "\\1 ASCII");
+assertFalse(/x(...)\1/i.test("xaaaaa"), "\\1 ASCII, string short");
+assertTrue(/x((?:))\1\1x/i.test("xx"), "\\1 empty, ASCII");
+assertTrue(/x(?:...|(...))\1x/i.test("xabcx"), "\\1 uncaptured, ASCII");
+assertTrue(/x(?:...|(...))\1x/i.test("xabcABCx"), "\\1 backtrack, ASCII");
+assertEquals("xaBcAbCABCx,aBc",
+ String(/x(...)\1\1x/i.exec("xaBcAbCABCx")),
+ "\\1\\1 ASCII");
+
+for (var i = 0; i < 128; i++) {
+ var testName = "(.)\\1 ~ " + i + "," + (i^0x20);
+ var test = /^(.)\1$/i.test(String.fromCharCode(i, i ^ 0x20))
+ var c = String.fromCharCode(i);
+ if (('A' <= c && c <= 'Z') || ('a' <= c && c <= 'z')) {
+ assertTrue(test, testName);
+ } else {
+ assertFalse(test, testName);
+ }
+}
+
+// UC16
+// Characters used:
+// "\u03a3\u03c2\u03c3\u039b\u03bb" - Sigma, final sigma, sigma, Lambda, lamda
+assertEquals("x\u03a3\u03c3x,\u03a3",
+ String(/x(.)\1x/i.exec("x\u03a3\u03c3x")), "\\1 UC16");
+assertFalse(/x(...)\1/i.test("x\u03a3\u03c2\u03c3\u03c2\u03c3"),
+ "\\1 ASCII, string short");
+assertTrue(/\u03a3((?:))\1\1x/i.test("\u03c2x"), "\\1 empty, UC16");
+assertTrue(/x(?:...|(...))\1x/i.test("x\u03a3\u03c2\u03c3x"),
+ "\\1 uncaptured, UC16");
+assertTrue(/x(?:...|(...))\1x/i.test("x\u03c2\u03c3\u039b\u03a3\u03c2\u03bbx"),
+ "\\1 backtrack, UC16");
+var longUC16String = "x\u03a3\u03c2\u039b\u03c2\u03c3\u03bb\u03c3\u03a3\u03bb";
+assertEquals(longUC16String + "," + longUC16String.substring(1,4),
+ String(/x(...)\1\1/i.exec(longUC16String)),
+ "\\1\\1 UC16");
+
assertFalse(/f(o)$\1/.test('foo'), "backref detects at_end");
« no previous file with comments | « test/cctest/test-regexp.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698