Fix orange from bug 630117. a=bustage

This commit is contained in:
Jonas Sicking 2011-02-01 16:19:22 -08:00
parent 64d3a59630
commit bf711df83f

View File

@ -318,12 +318,12 @@ function testSlice(type, name) {
running('test ' + name + ' Slice');
try {
var array = new type([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]);
var slice = array.slice(0, 5);
var slice = array.subset(0, 5);
assertEq('slice.length', 5, slice.length);
for (var i = 0; i < 5; i++) {
assertEq('Element ' + i, i, slice[i]);
}
slice = array.slice(4, 10);
slice = array.subset(4, 10);
assertEq('slice.length', 6, slice.length);
for (var i = 0; i < 6; i++) {
assertEq('Element ' + i, 4 + i, slice[i]);
@ -338,12 +338,12 @@ function negativeTestSlice(type, name) {
running('negativeTest ' + name + ' Slice');
try {
var array = new type([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]);
slice = array.slice(5, 11);
slice = array.subset(5, 11);
if (slice.length != 5) {
fail();
return;
}
slice = array.slice(10, 10);
slice = array.subset(10, 10);
if (slice.length != 0) {
fail();
return;
@ -487,13 +487,13 @@ function testSlicingWithOutOfRangeValues(type, name, sz) {
shouldBe("array.slice(4, 0x3FFFFFFF).length", "(32 / typeSize) - 4");
shouldBe("array.slice(4, -2147483648).length", "0");
// Test slice() against overflows.
array = array.slice(2);
array = array.subset(2);
if (sz > 1) {
// Full byte offset is +1 larger than the maximum unsigned long int.
// Make sure slice() still handles it correctly. Otherwise overflow would happen and
// Make sure subset() still handles it correctly. Otherwise overflow would happen and
// offset would be 0, and array.length array.length would incorrectly be 1.
var start = 4294967296 / sz - 2;
array = array.slice(start, start + 1);
array = array.subset(start, start + 1);
shouldBe("array.length", "0");
}
} catch (e) {
@ -512,10 +512,10 @@ function testSlicingWithDefaultValues(type, name, sz) {
typeSize = sz;
shouldBe("array.length", "32 / typeSize");
try {
shouldBe("array.slice(0).length", "(32 / typeSize)");
shouldBe("array.slice(2).length", "(32 / typeSize) - 2");
shouldBe("array.slice(-2).length", "2");
shouldBe("array.slice(-2147483648).length", "(32 / typeSize)");
shouldBe("array.subset(0).length", "(32 / typeSize)");
shouldBe("array.subset(2).length", "(32 / typeSize) - 2");
shouldBe("array.subset(-2).length", "2");
shouldBe("array.subset(-2147483648).length", "(32 / typeSize)");
} catch (e) {
testFailed("Slicing of " + name + " threw exception");
}