Bug 577757 - array[-1073741824] != array["-1073741824"]. r=igor

This commit is contained in:
Jeff Walden 2010-09-30 21:03:47 -07:00
Родитель 5742cdd087
Коммит 1d67cb8429
2 изменённых файлов: 19 добавлений и 8 удалений

Просмотреть файл

@ -4196,11 +4196,18 @@ js_CheckForStringIndex(jsid id)
if (cp != end || (negative && index == 0))
return id;
if (negative) {
if (oldIndex < -(JSID_INT_MIN / 10) ||
(oldIndex == -(JSID_INT_MIN / 10) && c <= (-JSID_INT_MIN % 10)))
{
id = INT_TO_JSID(jsint(-index));
}
} else {
if (oldIndex < JSID_INT_MAX / 10 ||
(oldIndex == JSID_INT_MAX / 10 && c <= (JSID_INT_MAX % 10))) {
if (negative)
index = 0 - index;
id = INT_TO_JSID((jsint)index);
(oldIndex == JSID_INT_MAX / 10 && c <= (JSID_INT_MAX % 10)))
{
id = INT_TO_JSID(jsint(index));
}
}
return id;

Просмотреть файл

@ -63,7 +63,8 @@ var status = ''; var actual = ''; var expect = ''; var value = '';
// various indices to try -
var index = Array(-5000, -507, -3, -2, -1, 0, 1, 2, 3);
var index =
[-1073741825, -1073741824, -1073741823, -5000, -507, -3, -2, -1, -0, 0, 1, 2, 3, 1073741823, 1073741824, 1073741825];
//-------------------------------------------------------------------------------------------------
@ -77,7 +78,7 @@ function test()
printBugNumber(BUGNUMBER);
printStatus (summary);
for (j in index) {testProperty(index[j]);}
for (var j in index) {testProperty(index[j]);}
exitFunc ('test');
}
@ -101,8 +102,11 @@ function testProperty(i)
reportCompare(expect, actual, status);
}
function positive(n) { return 1 / n > 0; }
function getStatus(i)
{
return (statprefix + i + statsuffix);
return statprefix +
(positive(i) ? i : "-" + -i) +
statsuffix;
}