2 "String.match(…) test"
5 // match with a global regexp should set lastIndex to zero; if read-only this should throw.
6 // If the regexp is not global, lastIndex is not modified.
8 function testMatch(_re
, readonly
)
13 re
= Object
.defineProperty(re
, 'lastIndex', {writable
:false});
14 return '0x1x2'.match(re
);
17 shouldBe("testMatch(/x/g, false)", '["x","x"]');
18 shouldThrow("testMatch(/x/g, true)");
19 shouldBe("testMatch(/x/, false)", '["x"]');
20 shouldBe("testMatch(/x/, true)", '["x"]');
21 shouldBe("testMatch(/x/g, false); re.lastIndex", '0');
22 shouldThrow("testMatch(/x/g, true); re.lastIndex");
23 shouldBe("testMatch(/x/, false); re.lastIndex", '3');
24 shouldBe("testMatch(/x/, true); re.lastIndex", '3');