summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/regexp/lastIndex-valueOf.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/src/jit-test/tests/regexp/lastIndex-valueOf.js')
-rw-r--r--js/src/jit-test/tests/regexp/lastIndex-valueOf.js16
1 files changed, 16 insertions, 0 deletions
diff --git a/js/src/jit-test/tests/regexp/lastIndex-valueOf.js b/js/src/jit-test/tests/regexp/lastIndex-valueOf.js
new file mode 100644
index 0000000000..3794d20c2e
--- /dev/null
+++ b/js/src/jit-test/tests/regexp/lastIndex-valueOf.js
@@ -0,0 +1,16 @@
+function test() {
+ var re = /abc.+de/g;
+ var c = 0;
+ var weird = {valueOf() { c++; return 0; }};
+ for (var i = 0; i < 100; i++) {
+ re.lastIndex = (i > 60) ? weird : 0;
+ assertEq(typeof re.exec("abcXdef"), "object");
+ assertEq(re.lastIndex, 6);
+
+ re.lastIndex = (i > 60) ? weird : 0;
+ assertEq(re.test("abcXdef"), true);
+ assertEq(re.lastIndex, 6);
+ }
+ assertEq(c, 78);
+}
+test();