Reviewers: Lasse Reichstein,

Description:
Add a test that r1383 failed (harmlessly).

Please review this at http://codereview.chromium.org/44002

SVN Base: http://v8.googlecode.com/svn/branches/bleeding_edge/

Affected files:
   M     test/mjsunit/regexp-static.js


Index: test/mjsunit/regexp-static.js
===================================================================
--- test/mjsunit/regexp-static.js       (revision 1481)
+++ test/mjsunit/regexp-static.js       (working copy)
@@ -132,3 +132,25 @@
  re = /(.)/g;
  function f() { return RegExp.$1; };
  assertEquals('abcd', 'abcd'.replace(re, f));
+
+// lastParen where the last parenthesis didn't match.
+assertEquals("foo,", /foo(?:a(x))?/.exec("foobx"), "lastParen setup");
+assertEquals("", RegExp.lastParen, "lastParen");
+
+// The same test for $1 to $9.
+for (var i = 1; i <= 9; i++) {
+  var haystack = "foo";
+  var re_text = "^foo";
+  for (var j = 0; j < i - 1; j++) {
+    haystack += "x";
+    re_text += "(x)";
+  }
+  re_text += "(?:a(x))?";
+  haystack += "bx";
+  var re = new RegExp(re_text);
+  assertTrue(re.test(haystack), "$" + i + " setup");
+  for (var j = 1; j < i - 1; j++) {
+    assertEquals("x", RegExp['$' + j], "$" + j + " in $" + i + " setup");
+  }
+  assertEquals("", RegExp['$' + (i)], "$" + i);
+}



--~--~---------~--~----~------------~-------~--~----~
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
-~----------~----~----~----~------~----~------~--~---

Reply via email to