summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/regexp/has-capture-groups-intrinsic.js
blob: 2dfb450ea97f2a86b6b0a92b9f24fe089ee277a1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
function test() {
    var RegExpHasCaptureGroups = getSelfHostedValue("RegExpHasCaptureGroups");
    var cases = [
        [/a.+/, false],
        [/abc/, false],
        [/\r\n?|\n/, false],
        [/(abc)/, true],
        [/a(.+)/, true],
        [/a(b)(c)(d)/, true],
        [/a(?:b)/, false],
        [/((?:a))/, true],
        [/(?<name>a)/, true],
    ];
    for (var i = 0; i < 10; i++) {
        for (var [re, expected] of cases) {
            assertEq(RegExpHasCaptureGroups(re, "abcdef"), expected);
        }
    }
}
test();