Move function MayNeedBigInt to RAB helper file and inline WriteToTypedArray. (#4211)

This commit is contained in:
Ioanna M Dimitriou H 2024-09-03 16:23:23 +02:00 committed by GitHub
parent d012a4d0ef
commit fc49c9ce16
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
89 changed files with 182 additions and 333 deletions

View File

@ -9,7 +9,7 @@ defines:
- ctors
- MyBigInt64Array
- CreateResizableArrayBuffer
- WriteToTypedArray
- MayNeedBigInt
- Convert
- ToNumbers
- CreateRabForTest
@ -74,14 +74,6 @@ function CreateResizableArrayBuffer(byteLength, maxByteLength) {
return new ArrayBuffer(byteLength, { maxByteLength: maxByteLength });
}
function WriteToTypedArray(array, index, value) {
if (array instanceof BigInt64Array || array instanceof BigUint64Array) {
array[index] = BigInt(value);
} else {
array[index] = value;
}
}
function Convert(item) {
if (typeof item == 'bigint') {
return Number(item);
@ -98,12 +90,21 @@ function ToNumbers(array) {
return result;
}
function MayNeedBigInt(ta, n) {
assert.sameValue(typeof n, 'number');
if ((BigInt64Array !== 'undefined' && ta instanceof BigInt64Array)
|| (BigUint64Array !== 'undefined' && ta instanceof BigUint64Array)) {
return BigInt(n);
}
return n;
}
function CreateRabForTest(ctor) {
const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT);
// Write some data into the array.
const taWrite = new ctor(rab);
for (let i = 0; i < 4; ++i) {
WriteToTypedArray(taWrite, i, 2 * i);
taWrite[i] = MayNeedBigInt(taWrite, 2 * i);
}
return rab;
}

View File

@ -24,7 +24,7 @@ for (let ctor of ctors) {
// Write some data into the array.
let ta_write = new ctor(rab);
for (let i = 0; i < 4; ++i) {
WriteToTypedArray(ta_write, i, i);
ta_write[i] = MayNeedBigInt(ta_write, i);
}
assert.sameValue(ArrayAtHelper(fixedLength, -1), 3);
assert.sameValue(ArrayAtHelper(lengthTracking, -1), 3);

View File

@ -24,7 +24,7 @@ for (let ctor of ctors) {
// Write some data into the array.
const taWrite = new ctor(rab);
for (let i = 0; i < 4; ++i) {
WriteToTypedArray(taWrite, i, i);
taWrite[i] = MayNeedBigInt(taWrite, i);
}
// Orig. array: [0, 1, 2, 3]
@ -41,7 +41,7 @@ for (let ctor of ctors) {
3
]);
for (let i = 0; i < 4; ++i) {
WriteToTypedArray(taWrite, i, i);
taWrite[i] = MayNeedBigInt(taWrite, i);
}
ArrayCopyWithinHelper(fixedLengthWithOffset, 0, 1);
assert.compareArray(ToNumbers(fixedLengthWithOffset), [
@ -49,7 +49,7 @@ for (let ctor of ctors) {
3
]);
for (let i = 0; i < 4; ++i) {
WriteToTypedArray(taWrite, i, i);
taWrite[i] = MayNeedBigInt(taWrite, i);
}
ArrayCopyWithinHelper(lengthTracking, 0, 2);
assert.compareArray(ToNumbers(lengthTracking), [
@ -67,7 +67,7 @@ for (let ctor of ctors) {
// Shrink so that fixed length TAs go out of bounds.
rab.resize(3 * ctor.BYTES_PER_ELEMENT);
for (let i = 0; i < 3; ++i) {
WriteToTypedArray(taWrite, i, i);
taWrite[i] = MayNeedBigInt(taWrite, i);
}
// Orig. array: [0, 1, 2]
@ -99,7 +99,7 @@ for (let ctor of ctors) {
// Shrink so that the TAs with offset go out of bounds.
rab.resize(1 * ctor.BYTES_PER_ELEMENT);
WriteToTypedArray(taWrite, 0, 0);
taWrite[0] = MayNeedBigInt(taWrite, 0);
ArrayCopyWithinHelper(fixedLength, 0, 1, 1);
ArrayCopyWithinHelper(fixedLengthWithOffset, 0, 1, 1);
ArrayCopyWithinHelper(lengthTrackingWithOffset, 0, 1, 1);
@ -121,7 +121,7 @@ for (let ctor of ctors) {
// Grow so that all TAs are back in-bounds.
rab.resize(6 * ctor.BYTES_PER_ELEMENT);
for (let i = 0; i < 6; ++i) {
WriteToTypedArray(taWrite, i, i);
taWrite[i] = MayNeedBigInt(taWrite, i);
}
// Orig. array: [0, 1, 2, 3, 4, 5]
@ -138,7 +138,7 @@ for (let ctor of ctors) {
3
]);
for (let i = 0; i < 6; ++i) {
WriteToTypedArray(taWrite, i, i);
taWrite[i] = MayNeedBigInt(taWrite, i);
}
ArrayCopyWithinHelper(fixedLengthWithOffset, 0, 1);
assert.compareArray(ToNumbers(fixedLengthWithOffset), [
@ -146,7 +146,7 @@ for (let ctor of ctors) {
3
]);
for (let i = 0; i < 6; ++i) {
WriteToTypedArray(taWrite, i, i);
taWrite[i] = MayNeedBigInt(taWrite, i);
}
// [0, 1, 2, 3, 4, 5, ...] << lengthTracking
@ -161,7 +161,7 @@ for (let ctor of ctors) {
5
]);
for (let i = 0; i < 6; ++i) {
WriteToTypedArray(taWrite, i, i);
taWrite[i] = MayNeedBigInt(taWrite, i);
}
// [2, 3, 4, 5, ...] << lengthTrackingWithOffset

View File

@ -35,7 +35,7 @@ for (let ctor of ctors) {
// Write some data into the array.
const taWrite = new ctor(rab);
for (let i = 0; i < 4; ++i) {
WriteToTypedArray(taWrite, i, 2 * i);
taWrite[i] = MayNeedBigInt(taWrite, 2 * i);
}
// Orig. array: [0, 2, 4, 6]
@ -128,7 +128,7 @@ for (let ctor of ctors) {
// Grow so that all TAs are back in-bounds.
rab.resize(6 * ctor.BYTES_PER_ELEMENT);
for (let i = 0; i < 6; ++i) {
WriteToTypedArray(taWrite, i, 2 * i);
taWrite[i] = MayNeedBigInt(taWrite, 2 * i);
}
// Orig. array: [0, 2, 4, 6, 8, 10]

View File

@ -20,7 +20,7 @@ for (let ctor of ctors) {
// Write some data into the array.
const taWrite = new ctor(rab);
for (let i = 0; i < 4; ++i) {
WriteToTypedArray(taWrite, i, 2 * i);
taWrite[i] = MayNeedBigInt(taWrite, 2 * i);
}
// Orig. array: [0, 2, 4, 6]
@ -86,7 +86,7 @@ for (let ctor of ctors) {
// Grow so that all TAs are back in-bounds.
rab.resize(6 * ctor.BYTES_PER_ELEMENT);
for (let i = 0; i < 6; ++i) {
WriteToTypedArray(taWrite, i, 2 * i);
taWrite[i] = MayNeedBigInt(taWrite, 2 * i);
}
// Orig. array: [0, 2, 4, 6, 8, 10]

View File

@ -19,7 +19,7 @@ for (let ctor of ctors) {
// Write some data into the array.
const taWrite = new ctor(rab);
for (let i = 0; i < 4; ++i) {
WriteToTypedArray(taWrite, i, i);
taWrite[i] = MayNeedBigInt(taWrite, i);
}
// Orig. array: [0, 1, 2, 3]
@ -77,7 +77,7 @@ for (let ctor of ctors) {
// Grow so that all TAs are back in-bounds.
rab.resize(6 * ctor.BYTES_PER_ELEMENT);
for (let i = 0; i < 6; ++i) {
WriteToTypedArray(taWrite, i, i);
taWrite[i] = MayNeedBigInt(taWrite, i);
}
// Orig. array: [0, 1, 2, 3, 4, 5]

View File

@ -20,7 +20,7 @@ for (let ctor of ctors) {
// Write some data into the array.
const taWrite = new ctor(rab);
for (let i = 0; i < 4; ++i) {
WriteToTypedArray(taWrite, i, 2 * i);
taWrite[i] = MayNeedBigInt(taWrite, 2 * i);
}
// Orig. array: [0, 2, 4, 6]
@ -69,10 +69,10 @@ for (let ctor of ctors) {
// Grow so that all TAs are back in-bounds.
rab.resize(6 * ctor.BYTES_PER_ELEMENT);
for (let i = 0; i < 4; ++i) {
WriteToTypedArray(taWrite, i, 0);
taWrite[i] = MayNeedBigInt(taWrite, 0);
}
WriteToTypedArray(taWrite, 4, 2);
WriteToTypedArray(taWrite, 5, 4);
taWrite[4] = MayNeedBigInt(taWrite, 2);
taWrite[5] = MayNeedBigInt(taWrite, 4);
// Orig. array: [0, 0, 0, 0, 2, 4]
// [0, 0, 0, 0] << fixedLength

View File

@ -20,7 +20,7 @@ for (let ctor of ctors) {
// Write some data into the array.
const taWrite = new ctor(rab);
for (let i = 0; i < 4; ++i) {
WriteToTypedArray(taWrite, i, 2 * i);
taWrite[i] = MayNeedBigInt(taWrite, 2 * i);
}
// Orig. array: [0, 2, 4, 6]
@ -69,10 +69,10 @@ for (let ctor of ctors) {
// Grow so that all TAs are back in-bounds.
rab.resize(6 * ctor.BYTES_PER_ELEMENT);
for (let i = 0; i < 4; ++i) {
WriteToTypedArray(taWrite, i, 0);
taWrite[i] = MayNeedBigInt(taWrite, 0);
}
WriteToTypedArray(taWrite, 4, 2);
WriteToTypedArray(taWrite, 5, 4);
taWrite[4] = MayNeedBigInt(taWrite, 2);
taWrite[5] = MayNeedBigInt(taWrite, 4);
// Orig. array: [0, 0, 0, 0, 2, 4]
// [0, 0, 0, 0] << fixedLength

View File

@ -20,7 +20,7 @@ for (let ctor of ctors) {
// Write some data into the array.
const taWrite = new ctor(rab);
for (let i = 0; i < 4; ++i) {
WriteToTypedArray(taWrite, i, 2 * i);
taWrite[i] = MayNeedBigInt(taWrite, 2 * i);
}
// Orig. array: [0, 2, 4, 6]
@ -69,10 +69,10 @@ for (let ctor of ctors) {
// Grow so that all TAs are back in-bounds.
rab.resize(6 * ctor.BYTES_PER_ELEMENT);
for (let i = 0; i < 4; ++i) {
WriteToTypedArray(taWrite, i, 0);
taWrite[i] = MayNeedBigInt(taWrite, 0);
}
WriteToTypedArray(taWrite, 4, 2);
WriteToTypedArray(taWrite, 5, 4);
taWrite[4] = MayNeedBigInt(taWrite, 2);
taWrite[5] = MayNeedBigInt(taWrite, 4);
// Orig. array: [0, 0, 0, 0, 2, 4]
// [0, 0, 0, 0] << fixedLength

View File

@ -20,7 +20,7 @@ for (let ctor of ctors) {
// Write some data into the array.
const taWrite = new ctor(rab);
for (let i = 0; i < 4; ++i) {
WriteToTypedArray(taWrite, i, 2 * i);
taWrite[i] = MayNeedBigInt(taWrite, 2 * i);
}
// Orig. array: [0, 2, 4, 6]
@ -69,10 +69,10 @@ for (let ctor of ctors) {
// Grow so that all TAs are back in-bounds.
rab.resize(6 * ctor.BYTES_PER_ELEMENT);
for (let i = 0; i < 4; ++i) {
WriteToTypedArray(taWrite, i, 0);
taWrite[i] = MayNeedBigInt(taWrite, 0);
}
WriteToTypedArray(taWrite, 4, 2);
WriteToTypedArray(taWrite, 5, 4);
taWrite[4] = MayNeedBigInt(taWrite, 2);
taWrite[5] = MayNeedBigInt(taWrite, 4);
// Orig. array: [0, 0, 0, 0, 2, 4]
// [0, 0, 0, 0] << fixedLength

View File

@ -19,7 +19,7 @@ for (let ctor of ctors) {
// Write some data into the array.
const taWrite = new ctor(rab);
for (let i = 0; i < 4; ++i) {
WriteToTypedArray(taWrite, i, 2 * i);
taWrite[i] = MayNeedBigInt(taWrite, 2 * i);
}
// Orig. array: [0, 2, 4, 6]
@ -91,7 +91,7 @@ for (let ctor of ctors) {
// Grow so that all TAs are back in-bounds.
rab.resize(6 * ctor.BYTES_PER_ELEMENT);
for (let i = 0; i < 6; ++i) {
WriteToTypedArray(taWrite, i, 2 * i);
taWrite[i] = MayNeedBigInt(taWrite, 2 * i);
}
// Orig. array: [0, 2, 4, 6, 8, 10]

View File

@ -10,13 +10,6 @@ includes: [resizableArrayBufferUtils.js]
features: [resizable-arraybuffer, Array.prototype.includes]
---*/
function MayNeedBigInt(ta, n) {
if (typeof n == 'number' && (ta instanceof BigInt64Array || ta instanceof BigUint64Array)) {
return BigInt(n);
}
return n;
}
for (let ctor of ctors) {
const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT);
const fixedLength = new ctor(rab, 0, 4);
@ -61,7 +54,7 @@ for (let ctor of ctors) {
const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT);
const lengthTracking = new ctor(rab);
for (let i = 0; i < 4; ++i) {
WriteToTypedArray(lengthTracking, i, 1);
lengthTracking[i] = MayNeedBigInt(lengthTracking, 1);
}
let evil = {
valueOf: () => {
@ -77,7 +70,7 @@ for (let ctor of ctors) {
for (let ctor of ctors) {
const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT);
const lengthTracking = new ctor(rab);
WriteToTypedArray(lengthTracking, 0, 1);
lengthTracking[0] = MayNeedBigInt(lengthTracking, 1);
let evil = {
valueOf: () => {
rab.resize(6 * ctor.BYTES_PER_ELEMENT);

View File

@ -9,13 +9,6 @@ includes: [resizableArrayBufferUtils.js]
features: [resizable-arraybuffer, Array.prototype.includes]
---*/
function MayNeedBigInt(ta, n) {
if (typeof n == 'number' && (ta instanceof BigInt64Array || ta instanceof BigUint64Array)) {
return BigInt(n);
}
return n;
}
for (let ctor of ctors) {
const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT);
const fixedLength = new ctor(rab, 0, 4);
@ -26,7 +19,7 @@ for (let ctor of ctors) {
// Write some data into the array.
const taWrite = new ctor(rab);
for (let i = 0; i < 4; ++i) {
WriteToTypedArray(taWrite, i, 2 * i);
taWrite[i] = MayNeedBigInt(taWrite, 2 * i);
}
// Orig. array: [0, 2, 4, 6]
@ -100,7 +93,7 @@ for (let ctor of ctors) {
// Grow so that all TAs are back in-bounds.
rab.resize(6 * ctor.BYTES_PER_ELEMENT);
for (let i = 0; i < 6; ++i) {
WriteToTypedArray(taWrite, i, 2 * i);
taWrite[i] = MayNeedBigInt(taWrite, 2 * i);
}
// Orig. array: [0, 2, 4, 6, 8, 10]

View File

@ -10,19 +10,12 @@ includes: [resizableArrayBufferUtils.js]
features: [resizable-arraybuffer]
---*/
function MayNeedBigInt(ta, n) {
if (typeof n == 'number' && (ta instanceof BigInt64Array || ta instanceof BigUint64Array)) {
return BigInt(n);
}
return n;
}
// Growing + length-tracking TA.
for (let ctor of ctors) {
const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT);
const lengthTracking = new ctor(rab);
for (let i = 0; i < 4; ++i) {
WriteToTypedArray(lengthTracking, i, 1);
lengthTracking[i] = MayNeedBigInt(lengthTracking, 1);
}
let evil = {
valueOf: () => {
@ -40,7 +33,7 @@ for (let ctor of ctors) {
for (let ctor of ctors) {
const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT);
const lengthTracking = new ctor(rab);
WriteToTypedArray(lengthTracking, 0, 1);
lengthTracking[0] = MayNeedBigInt(lengthTracking, 1);
let evil = {
valueOf: () => {
rab.resize(6 * ctor.BYTES_PER_ELEMENT);

View File

@ -10,13 +10,6 @@ includes: [resizableArrayBufferUtils.js]
features: [resizable-arraybuffer]
---*/
function MayNeedBigInt(ta, n) {
if (typeof n == 'number' && (ta instanceof BigInt64Array || ta instanceof BigUint64Array)) {
return BigInt(n);
}
return n;
}
// Shrinking + fixed-length TA.
for (let ctor of ctors) {
const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT);
@ -52,7 +45,7 @@ for (let ctor of ctors) {
const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT);
const lengthTracking = new ctor(rab);
for (let i = 0; i < 4; ++i) {
WriteToTypedArray(lengthTracking, i, i);
lengthTracking[i] = MayNeedBigInt(lengthTracking, i);
}
let evil = {
valueOf: () => {

View File

@ -9,13 +9,6 @@ includes: [resizableArrayBufferUtils.js]
features: [resizable-arraybuffer]
---*/
function MayNeedBigInt(ta, n) {
if (typeof n == 'number' && (ta instanceof BigInt64Array || ta instanceof BigUint64Array)) {
return BigInt(n);
}
return n;
}
for (let ctor of ctors) {
const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT);
const fixedLength = new ctor(rab, 0, 4);
@ -26,7 +19,7 @@ for (let ctor of ctors) {
// Write some data into the array.
const taWrite = new ctor(rab);
for (let i = 0; i < 4; ++i) {
WriteToTypedArray(taWrite, i, Math.floor(i / 2));
taWrite[i] = MayNeedBigInt(taWrite, Math.floor(i / 2));
}
// Orig. array: [0, 0, 1, 1]
@ -98,7 +91,7 @@ for (let ctor of ctors) {
// Grow so that all TAs are back in-bounds.
rab.resize(6 * ctor.BYTES_PER_ELEMENT);
for (let i = 0; i < 6; ++i) {
WriteToTypedArray(taWrite, i, Math.floor(i / 2));
taWrite[i] = MayNeedBigInt(taWrite, Math.floor(i / 2));
}
// Orig. array: [0, 0, 1, 1, 2, 2]

View File

@ -20,7 +20,7 @@ for (let ctor of ctors) {
// Write some data into the array.
for (let i = 0; i < 4; ++i) {
WriteToTypedArray(taWrite, i, 2 * i);
taWrite[i] = MayNeedBigInt(taWrite, 2 * i);
}
// Orig. array: [0, 2, 4, 6]
@ -66,7 +66,7 @@ for (let ctor of ctors) {
// Grow so that all TAs are back in-bounds.
rab.resize(6 * ctor.BYTES_PER_ELEMENT);
for (let i = 0; i < 6; ++i) {
WriteToTypedArray(taWrite, i, 2 * i);
taWrite[i] = MayNeedBigInt(taWrite, 2 * i);
}
// Orig. array: [0, 2, 4, 6, 8, 10]

View File

@ -20,7 +20,7 @@ for (let ctor of ctors) {
// Write some data into the array.
const taWrite = new ctor(rab);
for (let i = 0; i < 4; ++i) {
WriteToTypedArray(taWrite, i, 2 * i);
taWrite[i] = MayNeedBigInt(taWrite, 2 * i);
}
assert.compareArray(Array.from(Array.prototype.keys.call(fixedLength)), [
@ -106,7 +106,7 @@ for (let ctor of ctors) {
// Grow so that all TAs are back in-bounds.
rab.resize(6 * ctor.BYTES_PER_ELEMENT);
for (let i = 0; i < 6; ++i) {
WriteToTypedArray(taWrite, i, 2 * i);
taWrite[i] = MayNeedBigInt(taWrite, 2 * i);
}
// Orig. array: [0, 2, 4, 6, 8, 10]

View File

@ -10,19 +10,12 @@ includes: [resizableArrayBufferUtils.js]
features: [resizable-arraybuffer]
---*/
function MayNeedBigInt(ta, n) {
if (typeof n == 'number' && (ta instanceof BigInt64Array || ta instanceof BigUint64Array)) {
return BigInt(n);
}
return n;
}
// Growing + length-tracking TA.
for (let ctor of ctors) {
const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT);
const lengthTracking = new ctor(rab);
for (let i = 0; i < 4; ++i) {
WriteToTypedArray(lengthTracking, i, 1);
lengthTracking[i] = MayNeedBigInt(lengthTracking, 1);
}
let evil = {
valueOf: () => {

View File

@ -10,13 +10,6 @@ includes: [resizableArrayBufferUtils.js]
features: [resizable-arraybuffer]
---*/
function MayNeedBigInt(ta, n) {
if (typeof n == 'number' && (ta instanceof BigInt64Array || ta instanceof BigUint64Array)) {
return BigInt(n);
}
return n;
}
// Shrinking + fixed-length TA.
for (let ctor of ctors) {
const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT);
@ -51,7 +44,7 @@ for (let ctor of ctors) {
const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT);
const lengthTracking = new ctor(rab);
for (let i = 0; i < 4; ++i) {
WriteToTypedArray(lengthTracking, i, i);
lengthTracking[i] = MayNeedBigInt(lengthTracking, i);
}
let evil = {
valueOf: () => {

View File

@ -10,13 +10,6 @@ includes: [resizableArrayBufferUtils.js]
features: [resizable-arraybuffer]
---*/
function MayNeedBigInt(ta, n) {
if (typeof n == 'number' && (ta instanceof BigInt64Array || ta instanceof BigUint64Array)) {
return BigInt(n);
}
return n;
}
for (let ctor of ctors) {
const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT);
const fixedLength = new ctor(rab, 0, 4);
@ -27,7 +20,7 @@ for (let ctor of ctors) {
// Write some data into the array.
const taWrite = new ctor(rab);
for (let i = 0; i < 4; ++i) {
WriteToTypedArray(taWrite, i, Math.floor(i / 2));
taWrite[i] = MayNeedBigInt(taWrite, Math.floor(i / 2));
}
// Orig. array: [0, 0, 1, 1]
@ -104,7 +97,7 @@ for (let ctor of ctors) {
// Grow so that all TAs are back in-bounds.
rab.resize(6 * ctor.BYTES_PER_ELEMENT);
for (let i = 0; i < 6; ++i) {
WriteToTypedArray(taWrite, i, Math.floor(i / 2));
taWrite[i] = MayNeedBigInt(taWrite, Math.floor(i / 2));
}
// Orig. array: [0, 0, 1, 1, 2, 2]

View File

@ -19,7 +19,7 @@ for (let ctor of ctors) {
// Write some data into the array.
const taWrite = new ctor(rab);
for (let i = 0; i < taWrite.length; ++i) {
WriteToTypedArray(taWrite, i, 2 * i);
taWrite[i] = MayNeedBigInt(taWrite, 2 * i);
}
// Orig. array: [0, 2, 4, 6]
@ -105,7 +105,7 @@ for (let ctor of ctors) {
// Grow so that all TAs are back in-bounds.
rab.resize(6 * ctor.BYTES_PER_ELEMENT);
for (let i = 0; i < 6; ++i) {
WriteToTypedArray(taWrite, i, 2 * i);
taWrite[i] = MayNeedBigInt(taWrite, 2 * i);
}
// Orig. array: [0, 2, 4, 6, 8, 10]

View File

@ -19,7 +19,7 @@ for (let ctor of ctors) {
// Write some data into the array.
const taWrite = new ctor(rab);
for (let i = 0; i < 4; ++i) {
WriteToTypedArray(taWrite, i, 2 * i);
taWrite[i] = MayNeedBigInt(taWrite, 2 * i);
}
// Orig. array: [0, 2, 4, 6]
@ -90,7 +90,7 @@ for (let ctor of ctors) {
// Grow so that all TAs are back in-bounds.
rab.resize(6 * ctor.BYTES_PER_ELEMENT);
for (let i = 0; i < 6; ++i) {
WriteToTypedArray(taWrite, i, 2 * i);
taWrite[i] = MayNeedBigInt(taWrite, 2 * i);
}
// Orig. array: [0, 2, 4, 6, 8, 10]

View File

@ -20,7 +20,7 @@ for (let ctor of ctors) {
// Write some data into the array.
const taWrite = new ctor(rab);
for (let i = 0; i < 4; ++i) {
WriteToTypedArray(taWrite, i, 2 * i);
taWrite[i] = MayNeedBigInt(taWrite, 2 * i);
}
// Orig. array: [0, 2, 4, 6]
@ -93,7 +93,7 @@ for (let ctor of ctors) {
// Grow so that all TAs are back in-bounds.
rab.resize(6 * ctor.BYTES_PER_ELEMENT);
for (let i = 0; i < 6; ++i) {
WriteToTypedArray(taWrite, i, 2 * i);
taWrite[i] = MayNeedBigInt(taWrite, 2 * i);
}
// Orig. array: [0, 2, 4, 6, 8, 10]

View File

@ -19,7 +19,7 @@ for (let ctor of ctors) {
function WriteData() {
// Write some data into the array.
for (let i = 0; i < wholeArrayView.length; ++i) {
WriteToTypedArray(wholeArrayView, i, 2 * i);
wholeArrayView[i] = MayNeedBigInt(wholeArrayView, 2 * i);
}
}
WriteData();

View File

@ -15,7 +15,7 @@ for (let ctor of ctors) {
const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT);
const lengthTracking = new ctor(rab);
for (let i = 0; i < 4; ++i) {
WriteToTypedArray(lengthTracking, i, i + 1);
lengthTracking[i] = MayNeedBigInt(lengthTracking, i + 1);
}
const evil = {
valueOf: () => {
@ -37,7 +37,7 @@ for (let ctor of ctors) {
const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT);
const lengthTracking = new ctor(rab);
for (let i = 0; i < 4; ++i) {
WriteToTypedArray(lengthTracking, i, i + 1);
lengthTracking[i] = MayNeedBigInt(lengthTracking, i + 1);
}
const evil = {

View File

@ -34,7 +34,7 @@ for (let ctor of ctors) {
const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT);
const lengthTracking = new ctor(rab);
for (let i = 0; i < 4; ++i) {
WriteToTypedArray(lengthTracking, i, i + 1);
lengthTracking[i] = MayNeedBigInt(lengthTracking, i + 1);
}
const evil = {
valueOf: () => {
@ -76,7 +76,7 @@ for (let ctor of ctors) {
const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT);
const lengthTracking = new ctor(rab);
for (let i = 0; i < 4; ++i) {
WriteToTypedArray(lengthTracking, i, i + 1);
lengthTracking[i] = MayNeedBigInt(lengthTracking, i + 1);
}
const evil = {
valueOf: () => {

View File

@ -19,7 +19,7 @@ for (let ctor of ctors) {
// Write some data into the array.
const taWrite = new ctor(rab);
for (let i = 0; i < 4; ++i) {
WriteToTypedArray(taWrite, i, i);
taWrite[i] = MayNeedBigInt(taWrite, i);
}
const fixedLengthSlice = Array.prototype.slice.call(fixedLength);
assert.compareArray(ToNumbers(fixedLengthSlice), [

View File

@ -19,7 +19,7 @@ for (let ctor of ctors) {
// Write some data into the array.
const taWrite = new ctor(rab);
for (let i = 0; i < 4; ++i) {
WriteToTypedArray(taWrite, i, 2 * i);
taWrite[i] = MayNeedBigInt(taWrite, 2 * i);
}
// Orig. array: [0, 2, 4, 6]
@ -79,7 +79,7 @@ for (let ctor of ctors) {
// Grow so that all TAs are back in-bounds.
rab.resize(6 * ctor.BYTES_PER_ELEMENT);
for (let i = 0; i < 6; ++i) {
WriteToTypedArray(taWrite, i, 2 * i);
taWrite[i] = MayNeedBigInt(taWrite, 2 * i);
}
// Orig. array: [0, 2, 4, 6, 8, 10]

View File

@ -25,7 +25,7 @@ function ResizeAndCompare(rab, resizeTo) {
function WriteUnsortedData(taFull) {
for (let i = 0; i < taFull.length; ++i) {
WriteToTypedArray(taFull, i, 10 - i);
taFull[i] = MayNeedBigInt(taFull, 10 - i);
}
}

View File

@ -20,7 +20,7 @@ for (let ctor of ctors) {
function WriteUnsortedData() {
// Write some data into the array.
for (let i = 0; i < taFull.length; ++i) {
WriteToTypedArray(taFull, i, 10 - i);
taFull[i] = MayNeedBigInt(taFull, 10 - i);
}
}
function OddBeforeEvenComparison(a, b) {

View File

@ -25,7 +25,7 @@ function ResizeAndCompare(rab, resizeTo) {
function WriteUnsortedData(taFull) {
for (let i = 0; i < taFull.length; ++i) {
WriteToTypedArray(taFull, i, 10 - i);
taFull[i] = MayNeedBigInt(taFull, 10 - i);
}
}

View File

@ -22,7 +22,7 @@ for (let ctor of ctors) {
function WriteUnsortedData() {
// Write some data into the array.
for (let i = 0; i < taFull.length; ++i) {
WriteToTypedArray(taFull, i, 10 - 2 * i);
taFull[i] = MayNeedBigInt(taFull, 10 - 2 * i);
}
}
// Orig. array: [10, 8, 6, 4]

View File

@ -26,7 +26,7 @@ for (let ctor of ctors) {
// Write some data into the array.
for (let i = 0; i < 4; ++i) {
WriteToTypedArray(taWrite, i, 2 * i);
taWrite[i] = MayNeedBigInt(taWrite, 2 * i);
}
// Orig. array: [0, 2, 4, 6]
@ -72,7 +72,7 @@ for (let ctor of ctors) {
// Grow so that all TAs are back in-bounds.
rab.resize(6 * ctor.BYTES_PER_ELEMENT);
for (let i = 0; i < 6; ++i) {
WriteToTypedArray(taWrite, i, 2 * i);
taWrite[i] = MayNeedBigInt(taWrite, 2 * i);
}
// Orig. array: [0, 2, 4, 6, 8, 10]

View File

@ -27,7 +27,7 @@ for (let ctor of ctors) {
// Write some data into the array.
const taWrite = new ctor(rab);
for (let i = 0; i < 4; ++i) {
WriteToTypedArray(taWrite, i, 2 * i);
taWrite[i] = MayNeedBigInt(taWrite, 2 * i);
}
// Orig. array: [0, 2, 4, 6]
@ -120,7 +120,7 @@ for (let ctor of ctors) {
// Grow so that all TAs are back in-bounds.
rab.resize(6 * ctor.BYTES_PER_ELEMENT);
for (let i = 0; i < 6; ++i) {
WriteToTypedArray(taWrite, i, 2 * i);
taWrite[i] = MayNeedBigInt(taWrite, 2 * i);
}
// Orig. array: [0, 2, 4, 6, 8, 10]

View File

@ -19,7 +19,7 @@ for (let ctor of ctors) {
const lengthTrackingWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT);
const taWrite = new ctor(rab);
for (let i = 0; i < 4; ++i) {
WriteToTypedArray(taWrite, i, i);
taWrite[i] = MayNeedBigInt(taWrite, i);
}
function func(...args) {
return [...args];

View File

@ -10,14 +10,6 @@ includes: [compareArray.js, resizableArrayBufferUtils.js]
features: [resizable-arraybuffer]
---*/
function MayNeedBigInt(ta, value) {
if (ta instanceof BigInt64Array || ta instanceof BigUint64Array) {
return BigInt(value);
} else {
return value;
}
}
function DefinePropertiesMayNeedBigInt(ta, index, value) {
const values = {};
values[index] = { value: MayNeedBigInt(ta, value) };

View File

@ -11,14 +11,6 @@ includes: [compareArray.js, resizableArrayBufferUtils.js]
features: [resizable-arraybuffer]
---*/
function MayNeedBigInt(ta, value) {
if (ta instanceof BigInt64Array || ta instanceof BigUint64Array) {
return BigInt(value);
} else {
return value;
}
}
// Fixed length.
for (let ctor of ctors) {
const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT);

View File

@ -11,14 +11,6 @@ includes: [compareArray.js, resizableArrayBufferUtils.js]
features: [resizable-arraybuffer]
---*/
function MayNeedBigInt(ta, value) {
if (ta instanceof BigInt64Array || ta instanceof BigUint64Array) {
return BigInt(value);
} else {
return value;
}
}
// Fixed length.
for (let ctor of ctors) {
const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT);

View File

@ -10,14 +10,6 @@ includes: [compareArray.js, resizableArrayBufferUtils.js]
features: [resizable-arraybuffer]
---*/
function MayNeedBigInt(ta, value) {
if (ta instanceof BigInt64Array || ta instanceof BigUint64Array) {
return BigInt(value);
} else {
return value;
}
}
function DefinePropertyMayNeedBigInt(ta, index, value) {
Object.defineProperty(ta, index, { value: MayNeedBigInt(ta, value) });
}

View File

@ -10,14 +10,6 @@ includes: [resizableArrayBufferUtils.js]
features: [resizable-arraybuffer]
---*/
function MayNeedBigInt(ta, num) {
if (ta instanceof BigInt64Array || ta instanceof BigUint64Array) {
return BigInt(num);
} else {
return num;
}
}
for (let ctor of ctors) {
const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 40 * ctor.BYTES_PER_ELEMENT);
const array = new ctor(rab, 0, 4);

View File

@ -24,7 +24,7 @@ for (let ctor of ctors) {
// Write some data into the array.
let ta_write = new ctor(rab);
for (let i = 0; i < 4; ++i) {
WriteToTypedArray(ta_write, i, i);
ta_write[i] = MayNeedBigInt(ta_write, i);
}
assert.sameValue(TypedArrayAtHelper(fixedLength, -1), 3);
assert.sameValue(TypedArrayAtHelper(lengthTracking, -1), 3);

View File

@ -34,7 +34,7 @@ for (let ctor of ctors) {
const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT);
const lengthTracking = new ctor(rab);
for (let i = 0; i < 4; ++i) {
WriteToTypedArray(lengthTracking, i, i);
lengthTracking[i] = MayNeedBigInt(lengthTracking, i);
}
// [0, 1, 2, 3]
// ^
@ -58,7 +58,7 @@ for (let ctor of ctors) {
const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT);
const lengthTracking = new ctor(rab);
for (let i = 0; i < 4; ++i) {
WriteToTypedArray(lengthTracking, i, i);
lengthTracking[i] = MayNeedBigInt(lengthTracking, i);
}
// [0, 1, 2, 3]
// ^

View File

@ -13,13 +13,13 @@ for (let ctor of ctors) {
const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT);
const lengthTracking = new ctor(rab);
for (let i = 0; i < 4; ++i) {
WriteToTypedArray(lengthTracking, i, i);
lengthTracking[i] = MayNeedBigInt(lengthTracking, i);
}
const evil = {
valueOf: () => {
rab.resize(6 * ctor.BYTES_PER_ELEMENT);
WriteToTypedArray(lengthTracking, 4, 4);
WriteToTypedArray(lengthTracking, 5, 5);
lengthTracking[4] = MayNeedBigInt(lengthTracking, 4);
lengthTracking[5] = MayNeedBigInt(lengthTracking, 5);
return 0;
}
};
@ -37,7 +37,7 @@ for (let ctor of ctors) {
]);
rab.resize(4 * ctor.BYTES_PER_ELEMENT);
for (let i = 0; i < 4; ++i) {
WriteToTypedArray(lengthTracking, i, i);
lengthTracking[i] = MayNeedBigInt(lengthTracking, i);
}
// Orig. array: [0, 1, 2, 3] [4, 5]

View File

@ -20,7 +20,7 @@ for (let ctor of ctors) {
// Write some data into the array.
const taWrite = new ctor(rab);
for (let i = 0; i < 4; ++i) {
WriteToTypedArray(taWrite, i, i);
taWrite[i] = MayNeedBigInt(taWrite, i);
}
// Orig. array: [0, 1, 2, 3]
@ -37,7 +37,7 @@ for (let ctor of ctors) {
3
]);
for (let i = 0; i < 4; ++i) {
WriteToTypedArray(taWrite, i, i);
taWrite[i] = MayNeedBigInt(taWrite, i);
}
fixedLengthWithOffset.copyWithin(0, 1);
assert.compareArray(ToNumbers(fixedLengthWithOffset), [
@ -45,7 +45,7 @@ for (let ctor of ctors) {
3
]);
for (let i = 0; i < 4; ++i) {
WriteToTypedArray(taWrite, i, i);
taWrite[i] = MayNeedBigInt(taWrite, i);
}
lengthTracking.copyWithin(0, 2);
assert.compareArray(ToNumbers(lengthTracking), [
@ -63,7 +63,7 @@ for (let ctor of ctors) {
// Shrink so that fixed length TAs go out of bounds.
rab.resize(3 * ctor.BYTES_PER_ELEMENT);
for (let i = 0; i < 3; ++i) {
WriteToTypedArray(taWrite, i, i);
taWrite[i] = MayNeedBigInt(taWrite, i);
}
// Orig. array: [0, 1, 2]
@ -92,7 +92,7 @@ for (let ctor of ctors) {
// Shrink so that the TAs with offset go out of bounds.
rab.resize(1 * ctor.BYTES_PER_ELEMENT);
WriteToTypedArray(taWrite, 0, 0);
taWrite[0] = MayNeedBigInt(taWrite, 0);
assert.throws(TypeError, () => {
fixedLength.copyWithin(0, 1, 1);
});
@ -124,7 +124,7 @@ for (let ctor of ctors) {
// Grow so that all TAs are back in-bounds.
rab.resize(6 * ctor.BYTES_PER_ELEMENT);
for (let i = 0; i < 6; ++i) {
WriteToTypedArray(taWrite, i, i);
taWrite[i] = MayNeedBigInt(taWrite, i);
}
// Orig. array: [0, 1, 2, 3, 4, 5]
@ -141,7 +141,7 @@ for (let ctor of ctors) {
3
]);
for (let i = 0; i < 6; ++i) {
WriteToTypedArray(taWrite, i, i);
taWrite[i] = MayNeedBigInt(taWrite, i);
}
fixedLengthWithOffset.copyWithin(0, 1);
assert.compareArray(ToNumbers(fixedLengthWithOffset), [
@ -149,7 +149,7 @@ for (let ctor of ctors) {
3
]);
for (let i = 0; i < 6; ++i) {
WriteToTypedArray(taWrite, i, i);
taWrite[i] = MayNeedBigInt(taWrite, i);
}
// [0, 1, 2, 3, 4, 5, ...] << lengthTracking
@ -164,7 +164,7 @@ for (let ctor of ctors) {
5
]);
for (let i = 0; i < 6; ++i) {
WriteToTypedArray(taWrite, i, i);
taWrite[i] = MayNeedBigInt(taWrite, i);
}
// [2, 3, 4, 5, ...] << lengthTrackingWithOffset

View File

@ -31,7 +31,7 @@ for (let ctor of ctors) {
// Write some data into the array.
const taWrite = new ctor(rab);
for (let i = 0; i < 4; ++i) {
WriteToTypedArray(taWrite, i, 2 * i);
taWrite[i] = MayNeedBigInt(taWrite, 2 * i);
}
// Orig. array: [0, 2, 4, 6]
@ -140,7 +140,7 @@ for (let ctor of ctors) {
// Grow so that all TAs are back in-bounds.
rab.resize(6 * ctor.BYTES_PER_ELEMENT);
for (let i = 0; i < 6; ++i) {
WriteToTypedArray(taWrite, i, 2 * i);
taWrite[i] = MayNeedBigInt(taWrite, 2 * i);
}
// Orig. array: [0, 2, 4, 6, 8, 10]

View File

@ -20,7 +20,7 @@ for (let ctor of ctors) {
// Write some data into the array.
const taWrite = new ctor(rab);
for (let i = 0; i < 4; ++i) {
WriteToTypedArray(taWrite, i, 2 * i);
taWrite[i] = MayNeedBigInt(taWrite, 2 * i);
}
// Orig. array: [0, 2, 4, 6]
@ -102,7 +102,7 @@ for (let ctor of ctors) {
// Grow so that all TAs are back in-bounds.
rab.resize(6 * ctor.BYTES_PER_ELEMENT);
for (let i = 0; i < 6; ++i) {
WriteToTypedArray(taWrite, i, 2 * i);
taWrite[i] = MayNeedBigInt(taWrite, 2 * i);
}
// Orig. array: [0, 2, 4, 6, 8, 10]

View File

@ -20,7 +20,7 @@ for (let ctor of ctors) {
// Write some data into the array.
const taWrite = new ctor(rab);
for (let i = 0; i < 4; ++i) {
WriteToTypedArray(taWrite, i, i);
taWrite[i] = MayNeedBigInt(taWrite, i);
}
// Orig. array: [0, 1, 2, 3]
@ -94,7 +94,7 @@ for (let ctor of ctors) {
// Grow so that all TAs are back in-bounds.
rab.resize(6 * ctor.BYTES_PER_ELEMENT);
for (let i = 0; i < 6; ++i) {
WriteToTypedArray(taWrite, i, i);
taWrite[i] = MayNeedBigInt(taWrite, i);
}
// Orig. array: [0, 1, 2, 3, 4, 5]

View File

@ -20,7 +20,7 @@ for (let ctor of ctors) {
// Write some data into the array.
const taWrite = new ctor(rab);
for (let i = 0; i < 4; ++i) {
WriteToTypedArray(taWrite, i, 2 * i);
taWrite[i] = MayNeedBigInt(taWrite, 2 * i);
}
// Orig. array: [0, 2, 4, 6]
@ -85,10 +85,10 @@ for (let ctor of ctors) {
// Grow so that all TAs are back in-bounds.
rab.resize(6 * ctor.BYTES_PER_ELEMENT);
for (let i = 0; i < 4; ++i) {
WriteToTypedArray(taWrite, i, 0);
taWrite[i] = MayNeedBigInt(taWrite, 0);
}
WriteToTypedArray(taWrite, 4, 2);
WriteToTypedArray(taWrite, 5, 4);
taWrite[4] = MayNeedBigInt(taWrite, 2);
taWrite[5] = MayNeedBigInt(taWrite, 4);
// Orig. array: [0, 0, 0, 0, 2, 4]
// [0, 0, 0, 0] << fixedLength

View File

@ -20,7 +20,7 @@ for (let ctor of ctors) {
// Write some data into the array.
const taWrite = new ctor(rab);
for (let i = 0; i < 4; ++i) {
WriteToTypedArray(taWrite, i, 2 * i);
taWrite[i] = MayNeedBigInt(taWrite, 2 * i);
}
// Orig. array: [0, 2, 4, 6]
@ -84,10 +84,10 @@ for (let ctor of ctors) {
// Grow so that all TAs are back in-bounds.
rab.resize(6 * ctor.BYTES_PER_ELEMENT);
for (let i = 0; i < 4; ++i) {
WriteToTypedArray(taWrite, i, 0);
taWrite[i] = MayNeedBigInt(taWrite, 0);
}
WriteToTypedArray(taWrite, 4, 2);
WriteToTypedArray(taWrite, 5, 4);
taWrite[4] = MayNeedBigInt(taWrite, 2);
taWrite[5] = MayNeedBigInt(taWrite, 4);
// Orig. array: [0, 0, 0, 0, 2, 4]
// [0, 0, 0, 0] << fixedLength

View File

@ -20,7 +20,7 @@ for (let ctor of ctors) {
// Write some data into the array.
const taWrite = new ctor(rab);
for (let i = 0; i < 4; ++i) {
WriteToTypedArray(taWrite, i, 2 * i);
taWrite[i] = MayNeedBigInt(taWrite, 2 * i);
}
// Orig. array: [0, 2, 4, 6]
@ -85,10 +85,10 @@ for (let ctor of ctors) {
// Grow so that all TAs are back in-bounds.
rab.resize(6 * ctor.BYTES_PER_ELEMENT);
for (let i = 0; i < 4; ++i) {
WriteToTypedArray(taWrite, i, 0);
taWrite[i] = MayNeedBigInt(taWrite, 0);
}
WriteToTypedArray(taWrite, 4, 2);
WriteToTypedArray(taWrite, 5, 4);
taWrite[4] = MayNeedBigInt(taWrite, 2);
taWrite[5] = MayNeedBigInt(taWrite, 4);
// Orig. array: [0, 0, 0, 0, 2, 4]
// [0, 0, 0, 0] << fixedLength

View File

@ -20,7 +20,7 @@ for (let ctor of ctors) {
// Write some data into the array.
const taWrite = new ctor(rab);
for (let i = 0; i < 4; ++i) {
WriteToTypedArray(taWrite, i, 2 * i);
taWrite[i] = MayNeedBigInt(taWrite, 2 * i);
}
// Orig. array: [0, 2, 4, 6]
@ -84,10 +84,10 @@ for (let ctor of ctors) {
// Grow so that all TAs are back in-bounds.
rab.resize(6 * ctor.BYTES_PER_ELEMENT);
for (let i = 0; i < 4; ++i) {
WriteToTypedArray(taWrite, i, 0);
taWrite[i] = MayNeedBigInt(taWrite, 0);
}
WriteToTypedArray(taWrite, 4, 2);
WriteToTypedArray(taWrite, 5, 4);
taWrite[4] = MayNeedBigInt(taWrite, 2);
taWrite[5] = MayNeedBigInt(taWrite, 4);
// Orig. array: [0, 0, 0, 0, 2, 4]
// [0, 0, 0, 0] << fixedLength

View File

@ -20,7 +20,7 @@ for (let ctor of ctors) {
// Write some data into the array.
const taWrite = new ctor(rab);
for (let i = 0; i < 4; ++i) {
WriteToTypedArray(taWrite, i, 2 * i);
taWrite[i] = MayNeedBigInt(taWrite, 2 * i);
}
// Orig. array: [0, 2, 4, 6]
@ -109,7 +109,7 @@ for (let ctor of ctors) {
// Grow so that all TAs are back in-bounds.
rab.resize(6 * ctor.BYTES_PER_ELEMENT);
for (let i = 0; i < 6; ++i) {
WriteToTypedArray(taWrite, i, 2 * i);
taWrite[i] = MayNeedBigInt(taWrite, 2 * i);
}
// Orig. array: [0, 2, 4, 6, 8, 10]

View File

@ -10,13 +10,6 @@ includes: [resizableArrayBufferUtils.js]
features: [resizable-arraybuffer, Array.prototype.includes]
---*/
function MayNeedBigInt(ta, n) {
if (typeof n == 'number' && (ta instanceof BigInt64Array || ta instanceof BigUint64Array)) {
return BigInt(n);
}
return n;
}
for (let ctor of ctors) {
const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT);
const fixedLength = new ctor(rab, 0, 4);
@ -61,7 +54,7 @@ for (let ctor of ctors) {
const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT);
const lengthTracking = new ctor(rab);
for (let i = 0; i < 4; ++i) {
WriteToTypedArray(lengthTracking, i, 1);
lengthTracking[i] = MayNeedBigInt(lengthTracking, 1);
}
let evil = {
valueOf: () => {
@ -77,7 +70,7 @@ for (let ctor of ctors) {
for (let ctor of ctors) {
const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT);
const lengthTracking = new ctor(rab);
WriteToTypedArray(lengthTracking, 0, 1);
lengthTracking[0] = MayNeedBigInt(lengthTracking, 1);
let evil = {
valueOf: () => {
rab.resize(6 * ctor.BYTES_PER_ELEMENT);

View File

@ -10,13 +10,6 @@ includes: [resizableArrayBufferUtils.js]
features: [resizable-arraybuffer, Array.prototype.includes]
---*/
function MayNeedBigInt(ta, n) {
if (typeof n == 'number' && (ta instanceof BigInt64Array || ta instanceof BigUint64Array)) {
return BigInt(n);
}
return n;
}
for (let ctor of ctors) {
const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT);
const fixedLength = new ctor(rab, 0, 4);
@ -27,7 +20,7 @@ for (let ctor of ctors) {
// Write some data into the array.
const taWrite = new ctor(rab);
for (let i = 0; i < 4; ++i) {
WriteToTypedArray(taWrite, i, 2 * i);
taWrite[i] = MayNeedBigInt(taWrite, 2 * i);
}
// Orig. array: [0, 2, 4, 6]
@ -116,7 +109,7 @@ for (let ctor of ctors) {
// Grow so that all TAs are back in-bounds.
rab.resize(6 * ctor.BYTES_PER_ELEMENT);
for (let i = 0; i < 6; ++i) {
WriteToTypedArray(taWrite, i, 2 * i);
taWrite[i] = MayNeedBigInt(taWrite, 2 * i);
}
// Orig. array: [0, 2, 4, 6, 8, 10]

View File

@ -10,19 +10,12 @@ includes: [resizableArrayBufferUtils.js]
features: [resizable-arraybuffer]
---*/
function MayNeedBigInt(ta, n) {
if (typeof n == 'number' && (ta instanceof BigInt64Array || ta instanceof BigUint64Array)) {
return BigInt(n);
}
return n;
}
// Growing + length-tracking TA.
for (let ctor of ctors) {
const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT);
const lengthTracking = new ctor(rab);
for (let i = 0; i < 4; ++i) {
WriteToTypedArray(lengthTracking, i, 1);
lengthTracking[i] = MayNeedBigInt(lengthTracking, 1);
}
let evil = {
valueOf: () => {
@ -40,7 +33,7 @@ for (let ctor of ctors) {
for (let ctor of ctors) {
const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT);
const lengthTracking = new ctor(rab);
WriteToTypedArray(lengthTracking, 0, 1);
lengthTracking[0] = MayNeedBigInt(lengthTracking, 1);
let evil = {
valueOf: () => {
rab.resize(6 * ctor.BYTES_PER_ELEMENT);

View File

@ -10,13 +10,6 @@ includes: [resizableArrayBufferUtils.js]
features: [resizable-arraybuffer]
---*/
function MayNeedBigInt(ta, n) {
if (typeof n == 'number' && (ta instanceof BigInt64Array || ta instanceof BigUint64Array)) {
return BigInt(n);
}
return n;
}
// Shrinking + fixed-length TA.
for (let ctor of ctors) {
const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT);
@ -52,7 +45,7 @@ for (let ctor of ctors) {
const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT);
const lengthTracking = new ctor(rab);
for (let i = 0; i < 4; ++i) {
WriteToTypedArray(lengthTracking, i, i);
lengthTracking[i] = MayNeedBigInt(lengthTracking, i);
}
let evil = {
valueOf: () => {

View File

@ -10,13 +10,6 @@ includes: [resizableArrayBufferUtils.js]
features: [resizable-arraybuffer]
---*/
function MayNeedBigInt(ta, n) {
if (typeof n == 'number' && (ta instanceof BigInt64Array || ta instanceof BigUint64Array)) {
return BigInt(n);
}
return n;
}
for (let ctor of ctors) {
const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT);
const fixedLength = new ctor(rab, 0, 4);
@ -27,7 +20,7 @@ for (let ctor of ctors) {
// Write some data into the array.
const taWrite = new ctor(rab);
for (let i = 0; i < 4; ++i) {
WriteToTypedArray(taWrite, i, Math.floor(i / 2));
taWrite[i] = MayNeedBigInt(taWrite, Math.floor(i / 2));
}
// Orig. array: [0, 0, 1, 1]
@ -116,7 +109,7 @@ for (let ctor of ctors) {
// Grow so that all TAs are back in-bounds.
rab.resize(6 * ctor.BYTES_PER_ELEMENT);
for (let i = 0; i < 6; ++i) {
WriteToTypedArray(taWrite, i, Math.floor(i / 2));
taWrite[i] = MayNeedBigInt(taWrite, Math.floor(i / 2));
}
// Orig. array: [0, 0, 1, 1, 2, 2]

View File

@ -20,7 +20,7 @@ for (let ctor of ctors) {
// Write some data into the array.
for (let i = 0; i < 4; ++i) {
WriteToTypedArray(taWrite, i, 2 * i);
taWrite[i] = MayNeedBigInt(taWrite, 2 * i);
}
// Orig. array: [0, 2, 4, 6]
@ -82,7 +82,7 @@ for (let ctor of ctors) {
// Grow so that all TAs are back in-bounds.
rab.resize(6 * ctor.BYTES_PER_ELEMENT);
for (let i = 0; i < 6; ++i) {
WriteToTypedArray(taWrite, i, 2 * i);
taWrite[i] = MayNeedBigInt(taWrite, 2 * i);
}
// Orig. array: [0, 2, 4, 6, 8, 10]

View File

@ -20,7 +20,7 @@ for (let ctor of ctors) {
// Write some data into the array.
const taWrite = new ctor(rab);
for (let i = 0; i < 4; ++i) {
WriteToTypedArray(taWrite, i, 2 * i);
taWrite[i] = MayNeedBigInt(taWrite, 2 * i);
}
// Orig. array: [0, 2, 4, 6]
@ -105,7 +105,7 @@ for (let ctor of ctors) {
// Grow so that all TAs are back in-bounds.
rab.resize(6 * ctor.BYTES_PER_ELEMENT);
for (let i = 0; i < 6; ++i) {
WriteToTypedArray(taWrite, i, 2 * i);
taWrite[i] = MayNeedBigInt(taWrite, 2 * i);
}
// Orig. array: [0, 2, 4, 6, 8, 10]

View File

@ -10,19 +10,12 @@ includes: [resizableArrayBufferUtils.js]
features: [resizable-arraybuffer]
---*/
function MayNeedBigInt(ta, n) {
if (typeof n == 'number' && (ta instanceof BigInt64Array || ta instanceof BigUint64Array)) {
return BigInt(n);
}
return n;
}
// Growing + length-tracking TA.
for (let ctor of ctors) {
const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT);
const lengthTracking = new ctor(rab);
for (let i = 0; i < 4; ++i) {
WriteToTypedArray(lengthTracking, i, 1);
lengthTracking[i] = MayNeedBigInt(lengthTracking, 1);
}
let evil = {
valueOf: () => {

View File

@ -10,13 +10,6 @@ includes: [resizableArrayBufferUtils.js]
features: [resizable-arraybuffer]
---*/
function MayNeedBigInt(ta, n) {
if (typeof n == 'number' && (ta instanceof BigInt64Array || ta instanceof BigUint64Array)) {
return BigInt(n);
}
return n;
}
// Shrinking + fixed-length TA.
for (let ctor of ctors) {
const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT);
@ -52,7 +45,7 @@ for (let ctor of ctors) {
const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT);
const lengthTracking = new ctor(rab);
for (let i = 0; i < 4; ++i) {
WriteToTypedArray(lengthTracking, i, i);
lengthTracking[i] = MayNeedBigInt(lengthTracking, i);
}
let evil = {
valueOf: () => {

View File

@ -10,13 +10,6 @@ includes: [resizableArrayBufferUtils.js]
features: [resizable-arraybuffer]
---*/
function MayNeedBigInt(ta, n) {
if (typeof n == 'number' && (ta instanceof BigInt64Array || ta instanceof BigUint64Array)) {
return BigInt(n);
}
return n;
}
for (let ctor of ctors) {
const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT);
const fixedLength = new ctor(rab, 0, 4);
@ -27,7 +20,7 @@ for (let ctor of ctors) {
// Write some data into the array.
const taWrite = new ctor(rab);
for (let i = 0; i < 4; ++i) {
WriteToTypedArray(taWrite, i, Math.floor(i / 2));
taWrite[i] = MayNeedBigInt(taWrite, Math.floor(i / 2));
}
// Orig. array: [0, 0, 1, 1]
@ -120,7 +113,7 @@ for (let ctor of ctors) {
// Grow so that all TAs are back in-bounds.
rab.resize(6 * ctor.BYTES_PER_ELEMENT);
for (let i = 0; i < 6; ++i) {
WriteToTypedArray(taWrite, i, Math.floor(i / 2));
taWrite[i] = MayNeedBigInt(taWrite, Math.floor(i / 2));
}
// Orig. array: [0, 0, 1, 1, 2, 2]

View File

@ -20,7 +20,7 @@ for (let ctor of ctors) {
// Write some data into the array.
const taWrite = new ctor(rab);
for (let i = 0; i < taWrite.length; ++i) {
WriteToTypedArray(taWrite, i, 2 * i);
taWrite[i] = MayNeedBigInt(taWrite, 2 * i);
}
// Orig. array: [0, 2, 4, 6]
@ -122,7 +122,7 @@ for (let ctor of ctors) {
// Grow so that all TAs are back in-bounds.
rab.resize(6 * ctor.BYTES_PER_ELEMENT);
for (let i = 0; i < 6; ++i) {
WriteToTypedArray(taWrite, i, 2 * i);
taWrite[i] = MayNeedBigInt(taWrite, 2 * i);
}
// Orig. array: [0, 2, 4, 6, 8, 10]

View File

@ -32,7 +32,7 @@ for (let ctor of ctors) {
const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT);
const taWrite = new ctor(rab);
for (let i = 0; i < 4; ++i) {
WriteToTypedArray(taWrite, i, i);
taWrite[i] = MayNeedBigInt(taWrite, i);
}
let resizeWhenConstructorCalled = false;
class MyArray extends ctor {
@ -59,7 +59,7 @@ for (let ctor of ctors) {
const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT);
const taWrite = new ctor(rab);
for (let i = 0; i < 4; ++i) {
WriteToTypedArray(taWrite, i, i);
taWrite[i] = MayNeedBigInt(taWrite, i);
}
let resizeWhenConstructorCalled = false;
class MyArray extends ctor {

View File

@ -56,7 +56,7 @@ for (let ctor of ctors) {
const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT);
const taWrite = new ctor(rab);
for (let i = 0; i < 4; ++i) {
WriteToTypedArray(taWrite, i, i);
taWrite[i] = MayNeedBigInt(taWrite, i);
}
let resizeWhenConstructorCalled = false;
class MyArray extends ctor {

View File

@ -20,7 +20,7 @@ for (let ctor of ctors) {
// Write some data into the array.
const taWrite = new ctor(rab);
for (let i = 0; i < 4; ++i) {
WriteToTypedArray(taWrite, i, 2 * i);
taWrite[i] = MayNeedBigInt(taWrite, 2 * i);
}
// Orig. array: [0, 2, 4, 6]
@ -109,7 +109,7 @@ for (let ctor of ctors) {
// Grow so that all TAs are back in-bounds.
rab.resize(6 * ctor.BYTES_PER_ELEMENT);
for (let i = 0; i < 6; ++i) {
WriteToTypedArray(taWrite, i, 2 * i);
taWrite[i] = MayNeedBigInt(taWrite, 2 * i);
}
// Orig. array: [0, 2, 4, 6, 8, 10]

View File

@ -20,7 +20,7 @@ for (let ctor of ctors) {
// Write some data into the array.
const taWrite = new ctor(rab);
for (let i = 0; i < 4; ++i) {
WriteToTypedArray(taWrite, i, 2 * i);
taWrite[i] = MayNeedBigInt(taWrite, 2 * i);
}
// Orig. array: [0, 2, 4, 6]
@ -110,7 +110,7 @@ for (let ctor of ctors) {
// Grow so that all TAs are back in-bounds.
rab.resize(6 * ctor.BYTES_PER_ELEMENT);
for (let i = 0; i < 6; ++i) {
WriteToTypedArray(taWrite, i, 2 * i);
taWrite[i] = MayNeedBigInt(taWrite, 2 * i);
}
// Orig. array: [0, 2, 4, 6, 8, 10]

View File

@ -20,7 +20,7 @@ for (let ctor of ctors) {
function WriteData() {
// Write some data into the array.
for (let i = 0; i < wholeArrayView.length; ++i) {
WriteToTypedArray(wholeArrayView, i, 2 * i);
wholeArrayView[i] = MayNeedBigInt(wholeArrayView, 2 * i);
}
}
WriteData();

View File

@ -42,7 +42,7 @@ for (let targetIsResizable of [
// Write some data into the array.
const taFull = new sourceCtor(rab);
for (let i = 0; i < 4; ++i) {
WriteToTypedArray(taFull, i, i + 1);
taFull[i] = MayNeedBigInt(taFull, i + 1);
}
// Orig. array: [1, 2, 3, 4]
@ -179,7 +179,7 @@ for (let targetIsResizable of [
// Grow so that all TAs are back in-bounds.
rab.resize(6 * sourceCtor.BYTES_PER_ELEMENT);
for (let i = 0; i < 6; ++i) {
WriteToTypedArray(taFull, i, i + 1);
taFull[i] = MayNeedBigInt(taFull, i + 1);
}
// Orig. array: [1, 2, 3, 4, 5, 6]

View File

@ -15,7 +15,7 @@ for (let ctor of ctors) {
const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT);
const lengthTracking = new ctor(rab);
for (let i = 0; i < 4; ++i) {
WriteToTypedArray(lengthTracking, i, i + 1);
lengthTracking[i] = MayNeedBigInt(lengthTracking, i + 1);
}
const evil = {
valueOf: () => {
@ -37,7 +37,7 @@ for (let ctor of ctors) {
const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT);
const lengthTracking = new ctor(rab);
for (let i = 0; i < 4; ++i) {
WriteToTypedArray(lengthTracking, i, i + 1);
lengthTracking[i] = MayNeedBigInt(lengthTracking, i + 1);
}
const evil = {
valueOf: () => {

View File

@ -29,7 +29,7 @@ for (let ctor of ctors) {
const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT);
const lengthTracking = new ctor(rab);
for (let i = 0; i < 4; ++i) {
WriteToTypedArray(lengthTracking, i, i + 1);
lengthTracking[i] = MayNeedBigInt(lengthTracking, i + 1);
}
const evil = {
valueOf: () => {
@ -69,7 +69,7 @@ for (let ctor of ctors) {
const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT);
const lengthTracking = new ctor(rab);
for (let i = 0; i < 4; ++i) {
WriteToTypedArray(lengthTracking, i, i + 1);
lengthTracking[i] = MayNeedBigInt(lengthTracking, i + 1);
}
const evil = {
valueOf: () => {

View File

@ -20,7 +20,7 @@ for (let ctor of ctors) {
// Write some data into the array.
const taWrite = new ctor(rab);
for (let i = 0; i < 4; ++i) {
WriteToTypedArray(taWrite, i, i);
taWrite[i] = MayNeedBigInt(taWrite, i);
}
const fixedLengthSlice = fixedLength.slice();
assert.compareArray(ToNumbers(fixedLengthSlice), [

View File

@ -36,7 +36,7 @@ for (let ctor of ctors) {
const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT);
const taWrite = new ctor(rab);
for (let i = 0; i < 4; ++i) {
WriteToTypedArray(taWrite, i, 1);
taWrite[i] = MayNeedBigInt(taWrite, 1);
}
let resizeWhenConstructorCalled = false;
class MyArray extends ctor {
@ -69,7 +69,7 @@ for (let ctor of ctors) {
const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT);
const taWrite = new ctor(rab);
for (let i = 0; i < 4; ++i) {
WriteToTypedArray(taWrite, i, 1);
taWrite[i] = MayNeedBigInt(taWrite, 1);
}
let resizeWhenConstructorCalled = false;
class MyArray extends ctor {
@ -99,7 +99,7 @@ for (let ctor of ctors) {
const rab = CreateResizableArrayBuffer(8, 16);
const taWrite = new Uint8Array(rab);
for (let i = 0; i < 8; ++i) {
WriteToTypedArray(taWrite, i, 255);
taWrite[i] = MayNeedBigInt(taWrite, 255);
}
let resizeWhenConstructorCalled = false;
class MyArray extends Uint16Array {

View File

@ -19,7 +19,7 @@ for (let ctor of ctors) {
// Write some data into the array.
const taWrite = new ctor(rab);
for (let i = 0; i < 4; ++i) {
WriteToTypedArray(taWrite, i, 2 * i);
taWrite[i] = MayNeedBigInt(taWrite, 2 * i);
}
// Orig. array: [0, 2, 4, 6]
@ -95,7 +95,7 @@ for (let ctor of ctors) {
// Grow so that all TAs are back in-bounds.
rab.resize(6 * ctor.BYTES_PER_ELEMENT);
for (let i = 0; i < 6; ++i) {
WriteToTypedArray(taWrite, i, 2 * i);
taWrite[i] = MayNeedBigInt(taWrite, 2 * i);
}
// Orig. array: [0, 2, 4, 6, 8, 10]

View File

@ -27,7 +27,7 @@ function ResizeAndCompare(rab, resizeTo) {
function WriteUnsortedData(taFull) {
for (let i = 0; i < taFull.length; ++i) {
WriteToTypedArray(taFull, i, 10 - i);
taFull[i] = MayNeedBigInt(taFull, 10 - i);
}
}

View File

@ -20,7 +20,7 @@ for (let ctor of ctors) {
function WriteUnsortedData() {
// Write some data into the array.
for (let i = 0; i < taFull.length; ++i) {
WriteToTypedArray(taFull, i, 10 - i);
taFull[i] = MayNeedBigInt(taFull, 10 - i);
}
}
function OddBeforeEvenComparison(a, b) {

View File

@ -27,7 +27,7 @@ function ResizeAndCompare(rab, resizeTo) {
function WriteUnsortedData(taFull) {
for (let i = 0; i < taFull.length; ++i) {
WriteToTypedArray(taFull, i, 10 - i);
taFull[i] = MayNeedBigInt(taFull, 10 - i);
}
}

View File

@ -22,7 +22,7 @@ for (let ctor of ctors) {
function WriteUnsortedData() {
// Write some data into the array.
for (let i = 0; i < taFull.length; ++i) {
WriteToTypedArray(taFull, i, 10 - 2 * i);
taFull[i] = MayNeedBigInt(taFull, 10 - 2 * i);
}
}
// Orig. array: [10, 8, 6, 4]

View File

@ -19,7 +19,7 @@ for (let ctor of ctors) {
// Write some data into the array.
const taWrite = new ctor(rab);
for (let i = 0; i < 4; ++i) {
WriteToTypedArray(taWrite, i, 2 * i);
taWrite[i] = MayNeedBigInt(taWrite, 2 * i);
}
// Orig. array: [0, 2, 4, 6]
@ -129,7 +129,7 @@ for (let ctor of ctors) {
// Grow so that all TAs are back in-bounds.
rab.resize(6 * ctor.BYTES_PER_ELEMENT);
for (let i = 0; i < 6; ++i) {
WriteToTypedArray(taWrite, i, 2 * i);
taWrite[i] = MayNeedBigInt(taWrite, 2 * i);
}
// Orig. array: [0, 2, 4, 6, 8, 10]

View File

@ -36,7 +36,7 @@ for (let ctor of ctors) {
// Write some data into the array.
for (let i = 0; i < 4; ++i) {
WriteToTypedArray(taWrite, i, 2 * i);
taWrite[i] = MayNeedBigInt(taWrite, 2 * i);
}
// Orig. array: [0, 2, 4, 6]
@ -98,7 +98,7 @@ for (let ctor of ctors) {
// Grow so that all TAs are back in-bounds.
rab.resize(6 * ctor.BYTES_PER_ELEMENT);
for (let i = 0; i < 6; ++i) {
WriteToTypedArray(taWrite, i, 2 * i);
taWrite[i] = MayNeedBigInt(taWrite, 2 * i);
}
// Orig. array: [0, 2, 4, 6, 8, 10]

View File

@ -28,7 +28,7 @@ for (let ctor of ctors) {
// Write some data into the array.
const taWrite = new ctor(rab);
for (let i = 0; i < 4; ++i) {
WriteToTypedArray(taWrite, i, 2 * i);
taWrite[i] = MayNeedBigInt(taWrite, 2 * i);
}
// Orig. array: [0, 2, 4, 6]
@ -113,7 +113,7 @@ for (let ctor of ctors) {
// Grow so that all TAs are back in-bounds.
rab.resize(6 * ctor.BYTES_PER_ELEMENT);
for (let i = 0; i < 6; ++i) {
WriteToTypedArray(taWrite, i, 2 * i);
taWrite[i] = MayNeedBigInt(taWrite, 2 * i);
}
// Orig. array: [0, 2, 4, 6, 8, 10]

View File

@ -35,7 +35,7 @@ AllBigIntMatchedCtorCombinations((targetCtor, sourceCtor) => {
// Write some data into the array.
const taFull = new sourceCtor(rab);
for (let i = 0; i < 4; ++i) {
WriteToTypedArray(taFull, i, i + 1);
taFull[i] = MayNeedBigInt(taFull, i + 1);
}
// Orig. array: [1, 2, 3, 4]
@ -114,7 +114,7 @@ AllBigIntMatchedCtorCombinations((targetCtor, sourceCtor) => {
// Grow so that all TAs are back in-bounds.
rab.resize(6 * sourceCtor.BYTES_PER_ELEMENT);
for (let i = 0; i < 6; ++i) {
WriteToTypedArray(taFull, i, i + 1);
taFull[i] = MayNeedBigInt(taFull, i + 1);
}
// Orig. array: [1, 2, 3, 4, 5, 6]

View File

@ -19,7 +19,7 @@ for (let ctor of ctors) {
// Write some data into the array.
let ta_write = new ctor(rab);
for (let i = 0; i < 4; ++i) {
WriteToTypedArray(ta_write, i, i);
ta_write[i] = MayNeedBigInt(ta_write, i);
}
{
let [a, b, c, d, e] = fixedLength;

View File

@ -14,7 +14,7 @@ function CreateRab(buffer_byte_length, ctor) {
const rab = CreateResizableArrayBuffer(buffer_byte_length, 2 * buffer_byte_length);
let ta_write = new ctor(rab);
for (let i = 0; i < buffer_byte_length / ctor.BYTES_PER_ELEMENT; ++i) {
WriteToTypedArray(ta_write, i, i % 128);
ta_write[i] = MayNeedBigInt(ta_write, i % 128);
}
return rab;
}

View File

@ -14,7 +14,7 @@ function CreateRab(buffer_byte_length, ctor) {
const rab = CreateResizableArrayBuffer(buffer_byte_length, 2 * buffer_byte_length);
let ta_write = new ctor(rab);
for (let i = 0; i < buffer_byte_length / ctor.BYTES_PER_ELEMENT; ++i) {
WriteToTypedArray(ta_write, i, i % 128);
ta_write[i] = MayNeedBigInt(ta_write, i % 128);
}
return rab;
}

View File

@ -14,7 +14,7 @@ function CreateRab(buffer_byte_length, ctor) {
const rab = CreateResizableArrayBuffer(buffer_byte_length, 2 * buffer_byte_length);
let ta_write = new ctor(rab);
for (let i = 0; i < buffer_byte_length / ctor.BYTES_PER_ELEMENT; ++i) {
WriteToTypedArray(ta_write, i, i % 128);
ta_write[i] = MayNeedBigInt(ta_write, i % 128);
}
return rab;
}

View File

@ -14,7 +14,7 @@ function CreateRab(buffer_byte_length, ctor) {
const rab = CreateResizableArrayBuffer(buffer_byte_length, 2 * buffer_byte_length);
let ta_write = new ctor(rab);
for (let i = 0; i < buffer_byte_length / ctor.BYTES_PER_ELEMENT; ++i) {
WriteToTypedArray(ta_write, i, i % 128);
ta_write[i] = MayNeedBigInt(ta_write, i % 128);
}
return rab;
}

View File

@ -28,7 +28,7 @@ for (let ctor of ctors) {
// Write some data into the array.
let ta_write = new ctor(rab);
for (let i = 0; i < no_elements; ++i) {
WriteToTypedArray(ta_write, i, i % 128);
ta_write[i] = MayNeedBigInt(ta_write, i % 128);
}
// Create various different styles of TypedArrays with the RAB as the