1
0
mirror of https://github.com/robertkrimen/otto synced 2025-10-26 20:28:49 +08:00

Test for correct endIndex when submatching

This commit is contained in:
Robert Krimen
2012-11-11 16:20:38 -08:00
parent 1b39f1b6cc
commit bff799a0e1
2 changed files with 16 additions and 3 deletions

View File

@@ -1637,11 +1637,24 @@ func TestRegExp_exec(t *testing.T) {
abc = /./g;
def = '123456';
ghi = 0;
while (abc.exec(def) !== null) {
ghi += 1
while (ghi < 100 && abc.exec(def) !== null) {
ghi += 1;
}
[ ghi, def.length, ghi == def.length ];
`, "6,6,true")
test(`
abc = /[abc](\d)?/g;
def = 'a0 b c1 d3';
ghi = 0;
lastIndex = 0;
while (ghi < 100 && abc.exec(def) !== null) {
lastIndex = abc.lastIndex;
ghi += 1;
}
[ ghi, lastIndex ];
`, "3,7")
}
func TestNewFunction(t *testing.T) {