Test TypedArrays with excess bytes in their underlying buffers

This commit is contained in:
Richard Gibson 2024-08-15 20:16:40 -04:00 committed by Philip Chimento
parent 1a0aa3b866
commit 585d7ac2b3
62 changed files with 96 additions and 56 deletions

View File

@ -40,7 +40,7 @@ testWithBigIntTypedArrayConstructors(TA => {
var expectedError;
try {
ab.resize(BPE * 2);
ab.resize(BPE * 3 - 1);
// If the preceding "resize" operation is successful, the typed array will
// be out out of bounds, so the subsequent prototype method should produce
// a TypeError due to the semantics of ValidateTypedArray.

View File

@ -40,7 +40,7 @@ testWithTypedArrayConstructors(TA => {
var expectedError;
try {
ab.resize(BPE * 2);
ab.resize(BPE * 3 - 1);
// If the preceding "resize" operation is successful, the typed array will
// be out out of bounds, so the subsequent prototype method should produce
// a TypeError due to the semantics of ValidateTypedArray.

View File

@ -37,6 +37,13 @@ testWithBigIntTypedArrayConstructors(function(TA) {
assert.sameValue(array.byteLength, expected, "following shrink (within bounds)");
try {
ab.resize(BPE * 3 - 1);
expected = BPE;
} catch (_) {}
assert.sameValue(array.byteLength, expected, "following shrink (partial element)");
try {
ab.resize(BPE);
expected = 0;

View File

@ -36,7 +36,7 @@ testWithBigIntTypedArrayConstructors(function(TA) {
var expected;
try {
ab.resize(BPE * 2);
ab.resize(BPE * 3 - 1);
expected = 0;
} catch (_) {
expected = BPE * 2;

View File

@ -37,6 +37,13 @@ testWithTypedArrayConstructors(function(TA) {
assert.sameValue(array.byteLength, expected, "following shrink (within bounds)");
try {
ab.resize(BPE * 3 - 1);
expected = BPE;
} catch (_) {}
assert.sameValue(array.byteLength, expected, "following shrink (partial element)");
try {
ab.resize(BPE);
expected = 0;

View File

@ -36,7 +36,7 @@ testWithTypedArrayConstructors(function(TA) {
var expected;
try {
ab.resize(BPE * 2);
ab.resize(BPE * 3 - 1);
expected = 0;
} catch (_) {
expected = BPE * 2;

View File

@ -34,6 +34,12 @@ testWithBigIntTypedArrayConstructors(function(TA) {
assert.sameValue(array.byteOffset, BPE, "following shrink (within bounds)");
try {
ab.resize(BPE * 3 - 1);
} catch (_) {}
assert.sameValue(array.byteOffset, BPE, "following shrink (partial element)");
try {
ab.resize(BPE);
} catch (_) {}

View File

@ -36,7 +36,7 @@ testWithBigIntTypedArrayConstructors(function(TA) {
var expected;
try {
ab.resize(BPE * 2);
ab.resize(BPE * 3 - 1);
expected = 0;
} catch (_) {
expected = BPE;

View File

@ -34,6 +34,12 @@ testWithTypedArrayConstructors(function(TA) {
assert.sameValue(array.byteOffset, BPE, "following shrink (within bounds)");
try {
ab.resize(BPE * 3 - 1);
} catch (_) {}
assert.sameValue(array.byteOffset, BPE, "following shrink (partial element)");
try {
ab.resize(BPE);
} catch (_) {}

View File

@ -36,7 +36,7 @@ testWithTypedArrayConstructors(function(TA) {
var expected;
try {
ab.resize(BPE * 2);
ab.resize(BPE * 3 - 1);
expected = 0;
} catch (_) {
expected = BPE;

View File

@ -40,7 +40,7 @@ testWithBigIntTypedArrayConstructors(TA => {
var expectedError;
try {
ab.resize(BPE * 2);
ab.resize(BPE * 3 - 1);
// If the preceding "resize" operation is successful, the typed array will
// be out out of bounds, so the subsequent prototype method should produce
// a TypeError due to the semantics of ValidateTypedArray.

View File

@ -40,7 +40,7 @@ testWithTypedArrayConstructors(TA => {
var expectedError;
try {
ab.resize(BPE * 2);
ab.resize(BPE * 3 - 1);
// If the preceding "resize" operation is successful, the typed array will
// be out out of bounds, so the subsequent prototype method should produce
// a TypeError due to the semantics of ValidateTypedArray.

View File

@ -40,7 +40,7 @@ testWithBigIntTypedArrayConstructors(TA => {
var expectedError;
try {
ab.resize(BPE * 2);
ab.resize(BPE * 3 - 1);
// If the preceding "resize" operation is successful, the typed array will
// be out out of bounds, so the subsequent prototype method should produce
// a TypeError due to the semantics of ValidateTypedArray.

View File

@ -40,7 +40,7 @@ testWithTypedArrayConstructors(TA => {
var expectedError;
try {
ab.resize(BPE * 2);
ab.resize(BPE * 3 - 1);
// If the preceding "resize" operation is successful, the typed array will
// be out out of bounds, so the subsequent prototype method should produce
// a TypeError due to the semantics of ValidateTypedArray.

View File

@ -40,7 +40,7 @@ testWithBigIntTypedArrayConstructors(TA => {
var expectedError;
try {
ab.resize(BPE * 2);
ab.resize(BPE * 3 - 1);
// If the preceding "resize" operation is successful, the typed array will
// be out out of bounds, so the subsequent prototype method should produce
// a TypeError due to the semantics of ValidateTypedArray.

View File

@ -40,7 +40,7 @@ testWithTypedArrayConstructors(TA => {
var expectedError;
try {
ab.resize(BPE * 2);
ab.resize(BPE * 3 - 1);
// If the preceding "resize" operation is successful, the typed array will
// be out out of bounds, so the subsequent prototype method should produce
// a TypeError due to the semantics of ValidateTypedArray.

View File

@ -40,7 +40,7 @@ testWithBigIntTypedArrayConstructors(TA => {
var expectedError;
try {
ab.resize(BPE * 2);
ab.resize(BPE * 3 - 1);
// If the preceding "resize" operation is successful, the typed array will
// be out out of bounds, so the subsequent prototype method should produce
// a TypeError due to the semantics of ValidateTypedArray.

View File

@ -40,7 +40,7 @@ testWithTypedArrayConstructors(TA => {
var expectedError;
try {
ab.resize(BPE * 2);
ab.resize(BPE * 3 - 1);
// If the preceding "resize" operation is successful, the typed array will
// be out out of bounds, so the subsequent prototype method should produce
// a TypeError due to the semantics of ValidateTypedArray.

View File

@ -40,7 +40,7 @@ testWithBigIntTypedArrayConstructors(TA => {
var expectedError;
try {
ab.resize(BPE * 2);
ab.resize(BPE * 3 - 1);
// If the preceding "resize" operation is successful, the typed array will
// be out out of bounds, so the subsequent prototype method should produce
// a TypeError due to the semantics of ValidateTypedArray.

View File

@ -40,7 +40,7 @@ testWithTypedArrayConstructors(TA => {
var expectedError;
try {
ab.resize(BPE * 2);
ab.resize(BPE * 3 - 1);
// If the preceding "resize" operation is successful, the typed array will
// be out out of bounds, so the subsequent prototype method should produce
// a TypeError due to the semantics of ValidateTypedArray.

View File

@ -40,7 +40,7 @@ testWithBigIntTypedArrayConstructors(TA => {
var expectedError;
try {
ab.resize(BPE * 2);
ab.resize(BPE * 3 - 1);
// If the preceding "resize" operation is successful, the typed array will
// be out out of bounds, so the subsequent prototype method should produce
// a TypeError due to the semantics of ValidateTypedArray.

View File

@ -40,7 +40,7 @@ testWithTypedArrayConstructors(TA => {
var expectedError;
try {
ab.resize(BPE * 2);
ab.resize(BPE * 3 - 1);
// If the preceding "resize" operation is successful, the typed array will
// be out out of bounds, so the subsequent prototype method should produce
// a TypeError due to the semantics of ValidateTypedArray.

View File

@ -40,7 +40,7 @@ testWithBigIntTypedArrayConstructors(TA => {
var expectedError;
try {
ab.resize(BPE * 2);
ab.resize(BPE * 3 - 1);
// If the preceding "resize" operation is successful, the typed array will
// be out out of bounds, so the subsequent prototype method should produce
// a TypeError due to the semantics of ValidateTypedArray.

View File

@ -40,7 +40,7 @@ testWithTypedArrayConstructors(TA => {
var expectedError;
try {
ab.resize(BPE * 2);
ab.resize(BPE * 3 - 1);
// If the preceding "resize" operation is successful, the typed array will
// be out out of bounds, so the subsequent prototype method should produce
// a TypeError due to the semantics of ValidateTypedArray.

View File

@ -40,7 +40,7 @@ testWithBigIntTypedArrayConstructors(TA => {
var expectedError;
try {
ab.resize(BPE * 2);
ab.resize(BPE * 3 - 1);
// If the preceding "resize" operation is successful, the typed array will
// be out out of bounds, so the subsequent prototype method should produce
// a TypeError due to the semantics of ValidateTypedArray.

View File

@ -40,7 +40,7 @@ testWithTypedArrayConstructors(TA => {
var expectedError;
try {
ab.resize(BPE * 2);
ab.resize(BPE * 3 - 1);
// If the preceding "resize" operation is successful, the typed array will
// be out out of bounds, so the subsequent prototype method should produce
// a TypeError due to the semantics of ValidateTypedArray.

View File

@ -40,7 +40,7 @@ testWithBigIntTypedArrayConstructors(TA => {
var expectedError;
try {
ab.resize(BPE * 2);
ab.resize(BPE * 3 - 1);
// If the preceding "resize" operation is successful, the typed array will
// be out out of bounds, so the subsequent prototype method should produce
// a TypeError due to the semantics of ValidateTypedArray.

View File

@ -40,7 +40,7 @@ testWithTypedArrayConstructors(TA => {
var expectedError;
try {
ab.resize(BPE * 2);
ab.resize(BPE * 3 - 1);
// If the preceding "resize" operation is successful, the typed array will
// be out out of bounds, so the subsequent prototype method should produce
// a TypeError due to the semantics of ValidateTypedArray.

View File

@ -40,7 +40,7 @@ testWithBigIntTypedArrayConstructors(TA => {
var expectedError;
try {
ab.resize(BPE * 2);
ab.resize(BPE * 3 - 1);
// If the preceding "resize" operation is successful, the typed array will
// be out out of bounds, so the subsequent prototype method should produce
// a TypeError due to the semantics of ValidateTypedArray.

View File

@ -40,7 +40,7 @@ testWithTypedArrayConstructors(TA => {
var expectedError;
try {
ab.resize(BPE * 2);
ab.resize(BPE * 3 - 1);
// If the preceding "resize" operation is successful, the typed array will
// be out out of bounds, so the subsequent prototype method should produce
// a TypeError due to the semantics of ValidateTypedArray.

View File

@ -40,7 +40,7 @@ testWithBigIntTypedArrayConstructors(TA => {
var expectedError;
try {
ab.resize(BPE * 2);
ab.resize(BPE * 3 - 1);
// If the preceding "resize" operation is successful, the typed array will
// be out out of bounds, so the subsequent prototype method should produce
// a TypeError due to the semantics of ValidateTypedArray.

View File

@ -40,7 +40,7 @@ testWithTypedArrayConstructors(TA => {
var expectedError;
try {
ab.resize(BPE * 2);
ab.resize(BPE * 3 - 1);
// If the preceding "resize" operation is successful, the typed array will
// be out out of bounds, so the subsequent prototype method should produce
// a TypeError due to the semantics of ValidateTypedArray.

View File

@ -40,7 +40,7 @@ testWithBigIntTypedArrayConstructors(TA => {
var expectedError;
try {
ab.resize(BPE * 2);
ab.resize(BPE * 3 - 1);
// If the preceding "resize" operation is successful, the typed array will
// be out out of bounds, so the subsequent prototype method should produce
// a TypeError due to the semantics of ValidateTypedArray.

View File

@ -40,7 +40,7 @@ testWithTypedArrayConstructors(TA => {
var expectedError;
try {
ab.resize(BPE * 2);
ab.resize(BPE * 3 - 1);
// If the preceding "resize" operation is successful, the typed array will
// be out out of bounds, so the subsequent prototype method should produce
// a TypeError due to the semantics of ValidateTypedArray.

View File

@ -40,7 +40,7 @@ testWithBigIntTypedArrayConstructors(TA => {
var expectedError;
try {
ab.resize(BPE * 2);
ab.resize(BPE * 3 - 1);
// If the preceding "resize" operation is successful, the typed array will
// be out out of bounds, so the subsequent prototype method should produce
// a TypeError due to the semantics of ValidateTypedArray.

View File

@ -40,7 +40,7 @@ testWithTypedArrayConstructors(TA => {
var expectedError;
try {
ab.resize(BPE * 2);
ab.resize(BPE * 3 - 1);
// If the preceding "resize" operation is successful, the typed array will
// be out out of bounds, so the subsequent prototype method should produce
// a TypeError due to the semantics of ValidateTypedArray.

View File

@ -40,7 +40,7 @@ testWithBigIntTypedArrayConstructors(TA => {
var expectedError;
try {
ab.resize(BPE * 2);
ab.resize(BPE * 3 - 1);
// If the preceding "resize" operation is successful, the typed array will
// be out out of bounds, so the subsequent prototype method should produce
// a TypeError due to the semantics of ValidateTypedArray.

View File

@ -40,7 +40,7 @@ testWithTypedArrayConstructors(TA => {
var expectedError;
try {
ab.resize(BPE * 2);
ab.resize(BPE * 3 - 1);
// If the preceding "resize" operation is successful, the typed array will
// be out out of bounds, so the subsequent prototype method should produce
// a TypeError due to the semantics of ValidateTypedArray.

View File

@ -40,7 +40,7 @@ testWithBigIntTypedArrayConstructors(TA => {
var expectedError;
try {
ab.resize(BPE * 2);
ab.resize(BPE * 3 - 1);
// If the preceding "resize" operation is successful, the typed array will
// be out out of bounds, so the subsequent prototype method should produce
// a TypeError due to the semantics of ValidateTypedArray.

View File

@ -40,7 +40,7 @@ testWithTypedArrayConstructors(TA => {
var expectedError;
try {
ab.resize(BPE * 2);
ab.resize(BPE * 3 - 1);
// If the preceding "resize" operation is successful, the typed array will
// be out out of bounds, so the subsequent prototype method should produce
// a TypeError due to the semantics of ValidateTypedArray.

View File

@ -37,6 +37,13 @@ testWithBigIntTypedArrayConstructors(function(TA) {
assert.sameValue(array.length, expected, "following shrink (within bounds)");
try {
ab.resize(BPE * 3 - 1);
expected = 1;
} catch (_) {}
assert.sameValue(array.length, expected, "following shrink (partial element)");
try {
ab.resize(BPE);
expected = 0;

View File

@ -36,7 +36,7 @@ testWithBigIntTypedArrayConstructors(function(TA) {
var expected;
try {
ab.resize(BPE * 2);
ab.resize(BPE * 3 - 1);
expected = 0;
} catch (_) {
expected = 2;

View File

@ -37,6 +37,13 @@ testWithTypedArrayConstructors(function(TA) {
assert.sameValue(array.length, expected, "following shrink (within bounds)");
try {
ab.resize(BPE * 3 - 1);
expected = 1;
} catch (_) {}
assert.sameValue(array.length, expected, "following shrink (partial element)");
try {
ab.resize(BPE);
expected = 0;

View File

@ -36,7 +36,7 @@ testWithTypedArrayConstructors(function(TA) {
var expected;
try {
ab.resize(BPE * 2);
ab.resize(BPE * 3 - 1);
expected = 0;
} catch (_) {
expected = 2;

View File

@ -40,7 +40,7 @@ testWithBigIntTypedArrayConstructors(TA => {
var expectedError;
try {
ab.resize(BPE * 2);
ab.resize(BPE * 3 - 1);
// If the preceding "resize" operation is successful, the typed array will
// be out out of bounds, so the subsequent prototype method should produce
// a TypeError due to the semantics of ValidateTypedArray.

View File

@ -40,7 +40,7 @@ testWithTypedArrayConstructors(TA => {
var expectedError;
try {
ab.resize(BPE * 2);
ab.resize(BPE * 3 - 1);
// If the preceding "resize" operation is successful, the typed array will
// be out out of bounds, so the subsequent prototype method should produce
// a TypeError due to the semantics of ValidateTypedArray.

View File

@ -40,7 +40,7 @@ testWithBigIntTypedArrayConstructors(TA => {
var expectedError;
try {
ab.resize(BPE * 2);
ab.resize(BPE * 3 - 1);
// If the preceding "resize" operation is successful, the typed array will
// be out out of bounds, so the subsequent prototype method should produce
// a TypeError due to the semantics of ValidateTypedArray.

View File

@ -40,7 +40,7 @@ testWithTypedArrayConstructors(TA => {
var expectedError;
try {
ab.resize(BPE * 2);
ab.resize(BPE * 3 - 1);
// If the preceding "resize" operation is successful, the typed array will
// be out out of bounds, so the subsequent prototype method should produce
// a TypeError due to the semantics of ValidateTypedArray.

View File

@ -40,7 +40,7 @@ testWithBigIntTypedArrayConstructors(TA => {
var expectedError;
try {
ab.resize(BPE * 2);
ab.resize(BPE * 3 - 1);
// If the preceding "resize" operation is successful, the typed array will
// be out out of bounds, so the subsequent prototype method should produce
// a TypeError due to the semantics of ValidateTypedArray.

View File

@ -40,7 +40,7 @@ testWithTypedArrayConstructors(TA => {
var expectedError;
try {
ab.resize(BPE * 2);
ab.resize(BPE * 3 - 1);
// If the preceding "resize" operation is successful, the typed array will
// be out out of bounds, so the subsequent prototype method should produce
// a TypeError due to the semantics of ValidateTypedArray.

View File

@ -40,7 +40,7 @@ testWithBigIntTypedArrayConstructors(TA => {
var expectedError;
try {
ab.resize(BPE * 2);
ab.resize(BPE * 3 - 1);
// If the preceding "resize" operation is successful, the typed array will
// be out out of bounds, so the subsequent prototype method should produce
// a TypeError due to the semantics of ValidateTypedArray.

View File

@ -40,7 +40,7 @@ testWithTypedArrayConstructors(TA => {
var expectedError;
try {
ab.resize(BPE * 2);
ab.resize(BPE * 3 - 1);
// If the preceding "resize" operation is successful, the typed array will
// be out out of bounds, so the subsequent prototype method should produce
// a TypeError due to the semantics of ValidateTypedArray.

View File

@ -40,7 +40,7 @@ testWithBigIntTypedArrayConstructors(TA => {
var expectedError;
try {
ab.resize(BPE * 2);
ab.resize(BPE * 3 - 1);
// If the preceding "resize" operation is successful, the typed array will
// be out out of bounds, so the subsequent prototype method should produce
// a TypeError due to the semantics of ValidateTypedArray.

View File

@ -40,7 +40,7 @@ testWithTypedArrayConstructors(TA => {
var expectedError;
try {
ab.resize(BPE * 2);
ab.resize(BPE * 3 - 1);
// If the preceding "resize" operation is successful, the typed array will
// be out out of bounds, so the subsequent prototype method should produce
// a TypeError due to the semantics of ValidateTypedArray.

View File

@ -40,7 +40,7 @@ testWithBigIntTypedArrayConstructors(TA => {
var expectedError;
try {
ab.resize(BPE * 2);
ab.resize(BPE * 3 - 1);
// If the preceding "resize" operation is successful, the typed array will
// be out out of bounds, so the subsequent prototype method should produce
// a TypeError due to the semantics of ValidateTypedArray.

View File

@ -40,7 +40,7 @@ testWithTypedArrayConstructors(TA => {
var expectedError;
try {
ab.resize(BPE * 2);
ab.resize(BPE * 3 - 1);
// If the preceding "resize" operation is successful, the typed array will
// be out out of bounds, so the subsequent prototype method should produce
// a TypeError due to the semantics of ValidateTypedArray.

View File

@ -40,7 +40,7 @@ testWithBigIntTypedArrayConstructors(TA => {
var expectedError;
try {
ab.resize(BPE * 2);
ab.resize(BPE * 3 - 1);
// If the preceding "resize" operation is successful, the typed array will
// be out out of bounds, so the subsequent prototype method should produce
// a TypeError due to the semantics of ValidateTypedArray.

View File

@ -40,7 +40,7 @@ testWithTypedArrayConstructors(TA => {
var expectedError;
try {
ab.resize(BPE * 2);
ab.resize(BPE * 3 - 1);
// If the preceding "resize" operation is successful, the typed array will
// be out out of bounds, so the subsequent prototype method should produce
// a TypeError due to the semantics of ValidateTypedArray.

View File

@ -40,7 +40,7 @@ testWithBigIntTypedArrayConstructors(TA => {
var expectedError;
try {
ab.resize(BPE * 2);
ab.resize(BPE * 3 - 1);
// If the preceding "resize" operation is successful, the typed array will
// be out out of bounds, so the subsequent prototype method should produce
// a TypeError due to the semantics of ValidateTypedArray.

View File

@ -40,7 +40,7 @@ testWithTypedArrayConstructors(TA => {
var expectedError;
try {
ab.resize(BPE * 2);
ab.resize(BPE * 3 - 1);
// If the preceding "resize" operation is successful, the typed array will
// be out out of bounds, so the subsequent prototype method should produce
// a TypeError due to the semantics of ValidateTypedArray.

View File

@ -40,7 +40,7 @@ testWithBigIntTypedArrayConstructors(TA => {
var expectedError;
try {
ab.resize(BPE * 2);
ab.resize(BPE * 3 - 1);
// If the preceding "resize" operation is successful, the typed array will
// be out out of bounds, so the subsequent prototype method should produce
// a TypeError due to the semantics of ValidateTypedArray.

View File

@ -40,7 +40,7 @@ testWithTypedArrayConstructors(TA => {
var expectedError;
try {
ab.resize(BPE * 2);
ab.resize(BPE * 3 - 1);
// If the preceding "resize" operation is successful, the typed array will
// be out out of bounds, so the subsequent prototype method should produce
// a TypeError due to the semantics of ValidateTypedArray.