Bug 576828: Test self-referential backreference. (r=dmandelin)

--HG--
extra : rebase_source : 42b9319d8e9c5ae48a04e8f9e099ee2ea8d93294
This commit is contained in:
Chris Leary 2011-06-03 16:36:42 -07:00
parent afa776f327
commit 1385ee75b6
3 changed files with 30 additions and 0 deletions

View File

@ -5,5 +5,6 @@ script 15.10.7.5-01.js
script empty-lookahead.js
script exec.js
script exec-lastIndex-ToInteger.js
script regress-576828.js
skip-if(!xulRuntime.shell&&(Android||xulRuntime.OS=="WINNT")) script regress-617935.js
script instance-property-storage-introspection.js

View File

@ -0,0 +1,8 @@
var re = /(z\1){3}/;
var str = 'zzz';
var actual = re.exec(str);
var expected = makeExpectedMatch(['zzz', 'z'], 0, str);
checkRegExpMatch(actual, expected);
if (typeof reportCompare == 'function')
reportCompare(true, true);

View File

@ -0,0 +1,21 @@
function makeExpectedMatch(arr, index, input) {
var expectedMatch = {
index: index,
input: input,
length: arr.length,
};
for (var i = 0; i < arr.length; ++i)
expectedMatch[i] = arr[i];
return expectedMatch;
}
function checkRegExpMatch(actual, expected) {
assertEq(actual.length, expected.length);
for (var i = 0; i < actual.length; ++i)
assertEq(actual[i], expected[i]);
assertEq(actual.index, expected.index);
assertEq(actual.input, expected.input);
}