blob: 3794d20c2e8e021e6b80cc90398336c11e61453a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
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();
|