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

Unified Diff: test/mjsunit/regexp-static.js

Issue 44002: Add a test that r1383 failed (harmlessly). (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 11 years, 9 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
+}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698