summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/regexp/lastIndex-negative.js
blob: 536b3d2233ded869146339a367945a53fa767db3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
// A negative lastIndex value must be treated as 0.
function test() {
    var re = /abc.+de/g;
    for (var i = 0; i < 100; i++) {
        re.lastIndex = (i > 60) ? -1 : 0;
        assertEq(typeof re.exec("abcXdef"), "object");
        assertEq(re.lastIndex, 6);

        re.lastIndex = (i > 60) ? -1 : 0;
        assertEq(re.test("abcXdef"), true);
        assertEq(re.lastIndex, 6);
    }
}
test();