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

Unified Diff: test/mjsunit/regexp.js

Issue 3158020: Use Copy-on-write arrays for cached regexp results. (Closed)
Patch Set: Changed comments. Created 10 years, 4 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
« src/x64/codegen-x64.cc ('K') | « src/x64/full-codegen-x64.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 a8891969f4839db012459d9d273d384cce3ce201..db8b13388e4b9e75e13052546bcbe1821c305cbd 100644
--- a/test/mjsunit/regexp.js
+++ b/test/mjsunit/regexp.js
@@ -484,3 +484,21 @@ assertRegExpTest(/[,b]\b[,b]/, ",b", true);
assertRegExpTest(/[,b]\B[,b]/, ",b", false);
assertRegExpTest(/[,b]\b[,b]/, "b,", true);
assertRegExpTest(/[,b]\B[,b]/, "b,", false);
+
+// Test that caching of result doesn't share result objects.
+// More iterations increases the chance of hitting a GC.
+for (var i = 0; i < 100; i++) {
+ var re = /x(y)z/;
+ var res = re.exec("axyzb");
+ assertTrue(!!res);
+ assertEquals(2, res.length);
+ assertEquals("xyz", res[0]);
+ assertEquals("y", res[1]);
+ assertEquals(1, res.index);
+ assertEquals("axyzb", res.input);
+ assertEquals(undefined, res.foobar);
+
+ res.foobar = "Arglebargle";
+ res[3] = "Glopglyf";
+ assertEquals("Arglebargle", res.foobar);
+}
« src/x64/codegen-x64.cc ('K') | « src/x64/full-codegen-x64.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698