[rab/gsab] Tests for Array.p methods, part 2
In this part: find, findIndex, findLast, findLastIndex Drive-by: add missing tests for A.p.fill + detaching. Bug: v8:11111 Change-Id: I7583ccce16bf294cc5ab6adbb7ce1f019a11ad18 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3721315 Reviewed-by: Shu-yu Guo <syg@chromium.org> Auto-Submit: Marja Hölttä <marja@chromium.org> Commit-Queue: Shu-yu Guo <syg@chromium.org> Cr-Commit-Position: refs/heads/main@{#81366}
This commit is contained in:
parent
89189d1aca
commit
d86959d0ca
@ -776,7 +776,7 @@ function TestFill(helper) {
|
||||
assertEquals([15, 19, 19, 20, 16, 16], ReadDataFromBuffer(gsab, ctor));
|
||||
}
|
||||
}
|
||||
TestFill(FillHelper);
|
||||
TestFill(TypedArrayFillHelper);
|
||||
TestFill(ArrayFillHelper);
|
||||
|
||||
(function At() {
|
||||
@ -1467,7 +1467,8 @@ CopyWithinParameterConversionGrows(ArrayCopyWithinHelper);
|
||||
}
|
||||
})();
|
||||
|
||||
(function FindFindIndexFindLastFindLastIndex() {
|
||||
function FindFindIndexFindLastFindLastIndex(
|
||||
findHelper, findIndexHelper, findLastHelper, findLastIndexHelper) {
|
||||
for (let ctor of ctors) {
|
||||
const gsab = CreateGrowableSharedArrayBuffer(4 * ctor.BYTES_PER_ELEMENT,
|
||||
8 * ctor.BYTES_PER_ELEMENT);
|
||||
@ -1492,25 +1493,26 @@ CopyWithinParameterConversionGrows(ArrayCopyWithinHelper);
|
||||
return n == 2 || n == 4;
|
||||
}
|
||||
|
||||
assertEquals(2, Number(fixedLength.find(isTwoOrFour)));
|
||||
assertEquals(4, Number(fixedLengthWithOffset.find(isTwoOrFour)));
|
||||
assertEquals(2, Number(lengthTracking.find(isTwoOrFour)));
|
||||
assertEquals(4, Number(lengthTrackingWithOffset.find(isTwoOrFour)));
|
||||
assertEquals(2, Number(findHelper(fixedLength, isTwoOrFour)));
|
||||
assertEquals(4, Number(findHelper(fixedLengthWithOffset, isTwoOrFour)));
|
||||
assertEquals(2, Number(findHelper(lengthTracking, isTwoOrFour)));
|
||||
assertEquals(4, Number(findHelper(lengthTrackingWithOffset, isTwoOrFour)));
|
||||
|
||||
assertEquals(1, fixedLength.findIndex(isTwoOrFour));
|
||||
assertEquals(0, fixedLengthWithOffset.findIndex(isTwoOrFour));
|
||||
assertEquals(1, lengthTracking.findIndex(isTwoOrFour));
|
||||
assertEquals(0, lengthTrackingWithOffset.findIndex(isTwoOrFour));
|
||||
assertEquals(1, findIndexHelper(fixedLength, isTwoOrFour));
|
||||
assertEquals(0, findIndexHelper(fixedLengthWithOffset, isTwoOrFour));
|
||||
assertEquals(1, findIndexHelper(lengthTracking, isTwoOrFour));
|
||||
assertEquals(0, findIndexHelper(lengthTrackingWithOffset, isTwoOrFour));
|
||||
|
||||
assertEquals(4, Number(fixedLength.findLast(isTwoOrFour)));
|
||||
assertEquals(4, Number(fixedLengthWithOffset.findLast(isTwoOrFour)));
|
||||
assertEquals(4, Number(lengthTracking.findLast(isTwoOrFour)));
|
||||
assertEquals(4, Number(lengthTrackingWithOffset.findLast(isTwoOrFour)));
|
||||
assertEquals(4, Number(findLastHelper(fixedLength, isTwoOrFour)));
|
||||
assertEquals(4, Number(findLastHelper(fixedLengthWithOffset, isTwoOrFour)));
|
||||
assertEquals(4, Number(findLastHelper(lengthTracking, isTwoOrFour)));
|
||||
assertEquals(4,
|
||||
Number(findLastHelper(lengthTrackingWithOffset, isTwoOrFour)));
|
||||
|
||||
assertEquals(2, fixedLength.findLastIndex(isTwoOrFour));
|
||||
assertEquals(0, fixedLengthWithOffset.findLastIndex(isTwoOrFour));
|
||||
assertEquals(2, lengthTracking.findLastIndex(isTwoOrFour));
|
||||
assertEquals(0, lengthTrackingWithOffset.findLastIndex(isTwoOrFour));
|
||||
assertEquals(2, findLastIndexHelper(fixedLength, isTwoOrFour));
|
||||
assertEquals(0, findLastIndexHelper(fixedLengthWithOffset, isTwoOrFour));
|
||||
assertEquals(2, findLastIndexHelper(lengthTracking, isTwoOrFour));
|
||||
assertEquals(0, findLastIndexHelper(lengthTrackingWithOffset, isTwoOrFour));
|
||||
|
||||
// Grow.
|
||||
gsab.grow(6 * ctor.BYTES_PER_ELEMENT);
|
||||
@ -1526,29 +1528,36 @@ CopyWithinParameterConversionGrows(ArrayCopyWithinHelper);
|
||||
// [0, 0, 0, 0, 2, 4, ...] << lengthTracking
|
||||
// [0, 0, 2, 4, ...] << lengthTrackingWithOffset
|
||||
|
||||
assertEquals(undefined, fixedLength.find(isTwoOrFour));
|
||||
assertEquals(undefined, fixedLengthWithOffset.find(isTwoOrFour));
|
||||
assertEquals(2, Number(lengthTracking.find(isTwoOrFour)));
|
||||
assertEquals(2, Number(lengthTrackingWithOffset.find(isTwoOrFour)));
|
||||
assertEquals(undefined, findHelper(fixedLength, isTwoOrFour));
|
||||
assertEquals(undefined, findHelper(fixedLengthWithOffset, isTwoOrFour));
|
||||
assertEquals(2, Number(findHelper(lengthTracking, isTwoOrFour)));
|
||||
assertEquals(2, Number(findHelper(lengthTrackingWithOffset, isTwoOrFour)));
|
||||
|
||||
assertEquals(-1, fixedLength.findIndex(isTwoOrFour));
|
||||
assertEquals(-1, fixedLengthWithOffset.findIndex(isTwoOrFour));
|
||||
assertEquals(4, lengthTracking.findIndex(isTwoOrFour));
|
||||
assertEquals(2, lengthTrackingWithOffset.findIndex(isTwoOrFour));
|
||||
assertEquals(-1, findIndexHelper(fixedLength, isTwoOrFour));
|
||||
assertEquals(-1, findIndexHelper(fixedLengthWithOffset, isTwoOrFour));
|
||||
assertEquals(4, findIndexHelper(lengthTracking, isTwoOrFour));
|
||||
assertEquals(2, findIndexHelper(lengthTrackingWithOffset, isTwoOrFour));
|
||||
|
||||
assertEquals(undefined, fixedLength.findLast(isTwoOrFour));
|
||||
assertEquals(undefined, fixedLengthWithOffset.findLast(isTwoOrFour));
|
||||
assertEquals(4, Number(lengthTracking.findLast(isTwoOrFour)));
|
||||
assertEquals(4, Number(lengthTrackingWithOffset.findLast(isTwoOrFour)));
|
||||
assertEquals(undefined, findLastHelper(fixedLength, isTwoOrFour));
|
||||
assertEquals(undefined, findLastHelper(fixedLengthWithOffset, isTwoOrFour));
|
||||
assertEquals(4, Number(findLastHelper(lengthTracking, isTwoOrFour)));
|
||||
assertEquals(4,
|
||||
Number(findLastHelper(lengthTrackingWithOffset, isTwoOrFour)));
|
||||
|
||||
assertEquals(-1, fixedLength.findLastIndex(isTwoOrFour));
|
||||
assertEquals(-1, fixedLengthWithOffset.findLastIndex(isTwoOrFour));
|
||||
assertEquals(5, lengthTracking.findLastIndex(isTwoOrFour));
|
||||
assertEquals(3, lengthTrackingWithOffset.findLastIndex(isTwoOrFour));
|
||||
assertEquals(-1, findLastIndexHelper(fixedLength, isTwoOrFour));
|
||||
assertEquals(-1, findLastIndexHelper(fixedLengthWithOffset, isTwoOrFour));
|
||||
assertEquals(5, findLastIndexHelper(lengthTracking, isTwoOrFour));
|
||||
assertEquals(3, findLastIndexHelper(lengthTrackingWithOffset, isTwoOrFour));
|
||||
}
|
||||
})();
|
||||
}
|
||||
FindFindIndexFindLastFindLastIndex(
|
||||
TypedArrayFindHelper, TypedArrayFindIndexHelper, TypedArrayFindLastHelper,
|
||||
TypedArrayFindLastIndexHelper);
|
||||
FindFindIndexFindLastFindLastIndex(
|
||||
ArrayFindHelper, ArrayFindIndexHelper, ArrayFindLastHelper,
|
||||
ArrayFindLastIndexHelper);
|
||||
|
||||
(function FindGrowMidIteration() {
|
||||
function FindGrowMidIteration(findHelper) {
|
||||
// Orig. array: [0, 2, 4, 6]
|
||||
// [0, 2, 4, 6] << fixedLength
|
||||
// [4, 6] << fixedLengthWithOffset
|
||||
@ -1587,7 +1596,7 @@ CopyWithinParameterConversionGrows(ArrayCopyWithinHelper);
|
||||
values = [];
|
||||
growAfter = 2;
|
||||
growTo = 5 * ctor.BYTES_PER_ELEMENT;
|
||||
assertEquals(undefined, fixedLength.find(CollectValuesAndGrow));
|
||||
assertEquals(undefined, findHelper(fixedLength, CollectValuesAndGrow));
|
||||
assertEquals([0, 2, 4, 6], values);
|
||||
}
|
||||
|
||||
@ -1597,7 +1606,8 @@ CopyWithinParameterConversionGrows(ArrayCopyWithinHelper);
|
||||
values = [];
|
||||
growAfter = 1;
|
||||
growTo = 5 * ctor.BYTES_PER_ELEMENT;
|
||||
assertEquals(undefined, fixedLengthWithOffset.find(CollectValuesAndGrow));
|
||||
assertEquals(undefined,
|
||||
findHelper(fixedLengthWithOffset, CollectValuesAndGrow));
|
||||
assertEquals([4, 6], values);
|
||||
}
|
||||
|
||||
@ -1607,7 +1617,7 @@ CopyWithinParameterConversionGrows(ArrayCopyWithinHelper);
|
||||
values = [];
|
||||
growAfter = 2;
|
||||
growTo = 5 * ctor.BYTES_PER_ELEMENT;
|
||||
assertEquals(undefined, lengthTracking.find(CollectValuesAndGrow));
|
||||
assertEquals(undefined, findHelper(lengthTracking, CollectValuesAndGrow));
|
||||
assertEquals([0, 2, 4, 6], values);
|
||||
}
|
||||
|
||||
@ -1617,12 +1627,15 @@ CopyWithinParameterConversionGrows(ArrayCopyWithinHelper);
|
||||
values = [];
|
||||
growAfter = 1;
|
||||
growTo = 5 * ctor.BYTES_PER_ELEMENT;
|
||||
assertEquals(undefined, lengthTrackingWithOffset.find(CollectValuesAndGrow));
|
||||
assertEquals(undefined,
|
||||
findHelper(lengthTrackingWithOffset, CollectValuesAndGrow));
|
||||
assertEquals([4, 6], values);
|
||||
}
|
||||
})();
|
||||
}
|
||||
FindGrowMidIteration(TypedArrayFindHelper);
|
||||
FindGrowMidIteration(ArrayFindHelper);
|
||||
|
||||
(function FindIndexGrowMidIteration() {
|
||||
function FindIndexGrowMidIteration(findIndexHelper) {
|
||||
// Orig. array: [0, 2, 4, 6]
|
||||
// [0, 2, 4, 6] << fixedLength
|
||||
// [4, 6] << fixedLengthWithOffset
|
||||
@ -1661,7 +1674,7 @@ CopyWithinParameterConversionGrows(ArrayCopyWithinHelper);
|
||||
values = [];
|
||||
growAfter = 2;
|
||||
growTo = 5 * ctor.BYTES_PER_ELEMENT;
|
||||
assertEquals(-1, fixedLength.findIndex(CollectValuesAndGrow));
|
||||
assertEquals(-1, findIndexHelper(fixedLength, CollectValuesAndGrow));
|
||||
assertEquals([0, 2, 4, 6], values);
|
||||
}
|
||||
|
||||
@ -1671,7 +1684,8 @@ CopyWithinParameterConversionGrows(ArrayCopyWithinHelper);
|
||||
values = [];
|
||||
growAfter = 1;
|
||||
growTo = 5 * ctor.BYTES_PER_ELEMENT;
|
||||
assertEquals(-1, fixedLengthWithOffset.findIndex(CollectValuesAndGrow));
|
||||
assertEquals(-1,
|
||||
findIndexHelper(fixedLengthWithOffset, CollectValuesAndGrow));
|
||||
assertEquals([4, 6], values);
|
||||
}
|
||||
|
||||
@ -1681,7 +1695,7 @@ CopyWithinParameterConversionGrows(ArrayCopyWithinHelper);
|
||||
values = [];
|
||||
growAfter = 2;
|
||||
growTo = 5 * ctor.BYTES_PER_ELEMENT;
|
||||
assertEquals(-1, lengthTracking.findIndex(CollectValuesAndGrow));
|
||||
assertEquals(-1, findIndexHelper(lengthTracking, CollectValuesAndGrow));
|
||||
assertEquals([0, 2, 4, 6], values);
|
||||
}
|
||||
|
||||
@ -1691,12 +1705,15 @@ CopyWithinParameterConversionGrows(ArrayCopyWithinHelper);
|
||||
values = [];
|
||||
growAfter = 1;
|
||||
growTo = 5 * ctor.BYTES_PER_ELEMENT;
|
||||
assertEquals(-1, lengthTrackingWithOffset.findIndex(CollectValuesAndGrow));
|
||||
assertEquals(-1,
|
||||
findIndexHelper(lengthTrackingWithOffset, CollectValuesAndGrow));
|
||||
assertEquals([4, 6], values);
|
||||
}
|
||||
})();
|
||||
}
|
||||
FindIndexGrowMidIteration(TypedArrayFindIndexHelper);
|
||||
FindIndexGrowMidIteration(ArrayFindIndexHelper);
|
||||
|
||||
(function FindLastGrowMidIteration() {
|
||||
function FindLastGrowMidIteration(findLastHelper) {
|
||||
// Orig. array: [0, 2, 4, 6]
|
||||
// [0, 2, 4, 6] << fixedLength
|
||||
// [4, 6] << fixedLengthWithOffset
|
||||
@ -1735,7 +1752,7 @@ CopyWithinParameterConversionGrows(ArrayCopyWithinHelper);
|
||||
values = [];
|
||||
growAfter = 2;
|
||||
growTo = 5 * ctor.BYTES_PER_ELEMENT;
|
||||
assertEquals(undefined, fixedLength.findLast(CollectValuesAndGrow));
|
||||
assertEquals(undefined, findLastHelper(fixedLength, CollectValuesAndGrow));
|
||||
assertEquals([6, 4, 2, 0], values);
|
||||
}
|
||||
|
||||
@ -1745,7 +1762,8 @@ CopyWithinParameterConversionGrows(ArrayCopyWithinHelper);
|
||||
values = [];
|
||||
growAfter = 1;
|
||||
growTo = 5 * ctor.BYTES_PER_ELEMENT;
|
||||
assertEquals(undefined, fixedLengthWithOffset.findLast(CollectValuesAndGrow));
|
||||
assertEquals(undefined,
|
||||
findLastHelper(fixedLengthWithOffset, CollectValuesAndGrow));
|
||||
assertEquals([6, 4], values);
|
||||
}
|
||||
|
||||
@ -1755,7 +1773,8 @@ CopyWithinParameterConversionGrows(ArrayCopyWithinHelper);
|
||||
values = [];
|
||||
growAfter = 2;
|
||||
growTo = 5 * ctor.BYTES_PER_ELEMENT;
|
||||
assertEquals(undefined, lengthTracking.findLast(CollectValuesAndGrow));
|
||||
assertEquals(undefined,
|
||||
findLastHelper(lengthTracking, CollectValuesAndGrow));
|
||||
assertEquals([6, 4, 2, 0], values);
|
||||
}
|
||||
|
||||
@ -1765,12 +1784,15 @@ CopyWithinParameterConversionGrows(ArrayCopyWithinHelper);
|
||||
values = [];
|
||||
growAfter = 1;
|
||||
growTo = 5 * ctor.BYTES_PER_ELEMENT;
|
||||
assertEquals(undefined, lengthTrackingWithOffset.findLast(CollectValuesAndGrow));
|
||||
assertEquals(undefined,
|
||||
findLastHelper(lengthTrackingWithOffset, CollectValuesAndGrow));
|
||||
assertEquals([6, 4], values);
|
||||
}
|
||||
})();
|
||||
}
|
||||
FindLastGrowMidIteration(TypedArrayFindLastHelper);
|
||||
FindLastGrowMidIteration(ArrayFindLastHelper);
|
||||
|
||||
(function FindLastIndexGrowMidIteration() {
|
||||
function FindLastIndexGrowMidIteration(findLastIndexHelper) {
|
||||
// Orig. array: [0, 2, 4, 6]
|
||||
// [0, 2, 4, 6] << fixedLength
|
||||
// [4, 6] << fixedLengthWithOffset
|
||||
@ -1809,7 +1831,7 @@ CopyWithinParameterConversionGrows(ArrayCopyWithinHelper);
|
||||
values = [];
|
||||
growAfter = 2;
|
||||
growTo = 5 * ctor.BYTES_PER_ELEMENT;
|
||||
assertEquals(-1, fixedLength.findLastIndex(CollectValuesAndGrow));
|
||||
assertEquals(-1, findLastIndexHelper(fixedLength, CollectValuesAndGrow));
|
||||
assertEquals([6, 4, 2, 0], values);
|
||||
}
|
||||
|
||||
@ -1819,7 +1841,8 @@ CopyWithinParameterConversionGrows(ArrayCopyWithinHelper);
|
||||
values = [];
|
||||
growAfter = 1;
|
||||
growTo = 5 * ctor.BYTES_PER_ELEMENT;
|
||||
assertEquals(-1, fixedLengthWithOffset.findLastIndex(CollectValuesAndGrow));
|
||||
assertEquals(-1,
|
||||
findLastIndexHelper(fixedLengthWithOffset, CollectValuesAndGrow));
|
||||
assertEquals([6, 4], values);
|
||||
}
|
||||
|
||||
@ -1829,7 +1852,8 @@ CopyWithinParameterConversionGrows(ArrayCopyWithinHelper);
|
||||
values = [];
|
||||
growAfter = 2;
|
||||
growTo = 5 * ctor.BYTES_PER_ELEMENT;
|
||||
assertEquals(-1, lengthTracking.findLastIndex(CollectValuesAndGrow));
|
||||
assertEquals(-1,
|
||||
findLastIndexHelper(lengthTracking, CollectValuesAndGrow));
|
||||
assertEquals([6, 4, 2, 0], values);
|
||||
}
|
||||
|
||||
@ -1839,10 +1863,13 @@ CopyWithinParameterConversionGrows(ArrayCopyWithinHelper);
|
||||
values = [];
|
||||
growAfter = 1;
|
||||
growTo = 5 * ctor.BYTES_PER_ELEMENT;
|
||||
assertEquals(-1, lengthTrackingWithOffset.findLastIndex(CollectValuesAndGrow));
|
||||
assertEquals(-1,
|
||||
findLastIndexHelper(lengthTrackingWithOffset, CollectValuesAndGrow));
|
||||
assertEquals([6, 4], values);
|
||||
}
|
||||
})();
|
||||
}
|
||||
FindLastIndexGrowMidIteration(TypedArrayFindLastIndexHelper);
|
||||
FindLastIndexGrowMidIteration(ArrayFindLastIndexHelper);
|
||||
|
||||
(function Filter() {
|
||||
for (let ctor of ctors) {
|
||||
|
@ -152,22 +152,54 @@ function AtHelper(array, index) {
|
||||
return result;
|
||||
}
|
||||
|
||||
function FillHelper(array, n, start, end) {
|
||||
if (array instanceof BigInt64Array || array instanceof BigUint64Array) {
|
||||
array.fill(BigInt(n), start, end);
|
||||
function TypedArrayFillHelper(ta, n, start, end) {
|
||||
if (ta instanceof BigInt64Array || ta instanceof BigUint64Array) {
|
||||
ta.fill(BigInt(n), start, end);
|
||||
} else {
|
||||
array.fill(n, start, end);
|
||||
ta.fill(n, start, end);
|
||||
}
|
||||
}
|
||||
|
||||
function ArrayFillHelper(array, n, start, end) {
|
||||
if (array instanceof BigInt64Array || array instanceof BigUint64Array) {
|
||||
Array.prototype.fill.call(array, BigInt(n), start, end);
|
||||
function ArrayFillHelper(ta, n, start, end) {
|
||||
if (ta instanceof BigInt64Array || ta instanceof BigUint64Array) {
|
||||
Array.prototype.fill.call(ta, BigInt(n), start, end);
|
||||
} else {
|
||||
Array.prototype.fill.call(array, n, start, end);
|
||||
Array.prototype.fill.call(ta, n, start, end);
|
||||
}
|
||||
}
|
||||
|
||||
function TypedArrayFindHelper(ta, p) {
|
||||
return ta.find(p);
|
||||
}
|
||||
|
||||
function ArrayFindHelper(ta, p) {
|
||||
return Array.prototype.find.call(ta, p);
|
||||
}
|
||||
|
||||
function TypedArrayFindIndexHelper(ta, p) {
|
||||
return ta.findIndex(p);
|
||||
}
|
||||
|
||||
function ArrayFindIndexHelper(ta, p) {
|
||||
return Array.prototype.findIndex.call(ta, p);
|
||||
}
|
||||
|
||||
function TypedArrayFindLastHelper(ta, p) {
|
||||
return ta.findLast(p);
|
||||
}
|
||||
|
||||
function ArrayFindLastHelper(ta, p) {
|
||||
return Array.prototype.findLast.call(ta, p);
|
||||
}
|
||||
|
||||
function TypedArrayFindLastIndexHelper(ta, p) {
|
||||
return ta.findLastIndex(p);
|
||||
}
|
||||
|
||||
function ArrayFindLastIndexHelper(ta, p) {
|
||||
return Array.prototype.findLastIndex.call(ta, p);
|
||||
}
|
||||
|
||||
function IncludesHelper(array, n, fromIndex) {
|
||||
if (typeof n == 'number' &&
|
||||
(array instanceof BigInt64Array || array instanceof BigUint64Array)) {
|
||||
|
@ -133,9 +133,23 @@ d8.file.execute('test/mjsunit/typedarray-helpers.js');
|
||||
// The length is read after converting the first parameter ('value'), so the
|
||||
// detaching parameter has to be the 2nd ('start') or 3rd ('end').
|
||||
assertThrows(function() {
|
||||
FillHelper(fixedLength, 1, 0, evil);
|
||||
TypedArrayFillHelper(fixedLength, 1, 0, evil);
|
||||
}, TypeError);
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
let evil = { valueOf: () => { %ArrayBufferDetach(rab); return 1;}};
|
||||
// The length is read after converting the first parameter ('value'), so the
|
||||
// detaching parameter has to be the 2nd ('start') or 3rd ('end').
|
||||
// Assert that this doesn't throw (since the buffer is detached, we cannot
|
||||
// assert anything about the contents):
|
||||
ArrayFillHelper(fixedLength, 1, 0, evil);
|
||||
assertEquals(0, fixedLength.length);
|
||||
}
|
||||
})();
|
||||
|
||||
(function CopyWithinParameterConversionDetaches() {
|
||||
@ -289,7 +303,7 @@ d8.file.execute('test/mjsunit/typedarray-helpers.js');
|
||||
}
|
||||
})();
|
||||
|
||||
(function FindDetachMidIteration() {
|
||||
function FindDetachMidIteration(findHelper) {
|
||||
// Orig. array: [0, 2, 4, 6]
|
||||
// [0, 2, 4, 6] << fixedLength
|
||||
// [4, 6] << fixedLengthWithOffset
|
||||
@ -326,7 +340,7 @@ d8.file.execute('test/mjsunit/typedarray-helpers.js');
|
||||
const fixedLength = new ctor(rab, 0, 4);
|
||||
values = [];
|
||||
detachAfter = 2;
|
||||
assertEquals(undefined, fixedLength.find(CollectValuesAndDetach));
|
||||
assertEquals(undefined, findHelper(fixedLength, CollectValuesAndDetach));
|
||||
assertEquals([0, 2, undefined, undefined], values);
|
||||
}
|
||||
|
||||
@ -335,7 +349,8 @@ d8.file.execute('test/mjsunit/typedarray-helpers.js');
|
||||
const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2);
|
||||
values = [];
|
||||
detachAfter = 1;
|
||||
assertEquals(undefined, fixedLengthWithOffset.find(CollectValuesAndDetach));
|
||||
assertEquals(undefined,
|
||||
findHelper(fixedLengthWithOffset, CollectValuesAndDetach));
|
||||
assertEquals([4, undefined], values);
|
||||
}
|
||||
|
||||
@ -344,7 +359,7 @@ d8.file.execute('test/mjsunit/typedarray-helpers.js');
|
||||
const lengthTracking = new ctor(rab, 0);
|
||||
values = [];
|
||||
detachAfter = 2;
|
||||
assertEquals(undefined, lengthTracking.find(CollectValuesAndDetach));
|
||||
assertEquals(undefined, findHelper(lengthTracking, CollectValuesAndDetach));
|
||||
assertEquals([0, 2, undefined, undefined], values);
|
||||
}
|
||||
|
||||
@ -353,12 +368,15 @@ d8.file.execute('test/mjsunit/typedarray-helpers.js');
|
||||
const lengthTrackingWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT);
|
||||
values = [];
|
||||
detachAfter = 1;
|
||||
assertEquals(undefined, lengthTrackingWithOffset.find(CollectValuesAndDetach));
|
||||
assertEquals(undefined,
|
||||
findHelper(lengthTrackingWithOffset, CollectValuesAndDetach));
|
||||
assertEquals([4, undefined], values);
|
||||
}
|
||||
})();
|
||||
}
|
||||
FindDetachMidIteration(TypedArrayFindHelper);
|
||||
FindDetachMidIteration(ArrayFindHelper);
|
||||
|
||||
(function FindIndexDetachMidIteration() {
|
||||
function FindIndexDetachMidIteration(findIndexHelper) {
|
||||
// Orig. array: [0, 2, 4, 6]
|
||||
// [0, 2, 4, 6] << fixedLength
|
||||
// [4, 6] << fixedLengthWithOffset
|
||||
@ -395,7 +413,7 @@ d8.file.execute('test/mjsunit/typedarray-helpers.js');
|
||||
const fixedLength = new ctor(rab, 0, 4);
|
||||
values = [];
|
||||
detachAfter = 2;
|
||||
assertEquals(-1, fixedLength.findIndex(CollectValuesAndDetach));
|
||||
assertEquals(-1, findIndexHelper(fixedLength, CollectValuesAndDetach));
|
||||
assertEquals([0, 2, undefined, undefined], values);
|
||||
}
|
||||
|
||||
@ -404,7 +422,8 @@ d8.file.execute('test/mjsunit/typedarray-helpers.js');
|
||||
const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2);
|
||||
values = [];
|
||||
detachAfter = 1;
|
||||
assertEquals(-1, fixedLengthWithOffset.findIndex(CollectValuesAndDetach));
|
||||
assertEquals(-1,
|
||||
findIndexHelper(fixedLengthWithOffset, CollectValuesAndDetach));
|
||||
assertEquals([4, undefined], values);
|
||||
}
|
||||
|
||||
@ -413,7 +432,7 @@ d8.file.execute('test/mjsunit/typedarray-helpers.js');
|
||||
const lengthTracking = new ctor(rab, 0);
|
||||
values = [];
|
||||
detachAfter = 2;
|
||||
assertEquals(-1, lengthTracking.findIndex(CollectValuesAndDetach));
|
||||
assertEquals(-1, findIndexHelper(lengthTracking, CollectValuesAndDetach));
|
||||
assertEquals([0, 2, undefined, undefined], values);
|
||||
}
|
||||
|
||||
@ -422,12 +441,15 @@ d8.file.execute('test/mjsunit/typedarray-helpers.js');
|
||||
const lengthTrackingWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT);
|
||||
values = [];
|
||||
detachAfter = 1;
|
||||
assertEquals(-1, lengthTrackingWithOffset.findIndex(CollectValuesAndDetach));
|
||||
assertEquals(-1,
|
||||
findIndexHelper(lengthTrackingWithOffset, CollectValuesAndDetach));
|
||||
assertEquals([4, undefined], values);
|
||||
}
|
||||
})();
|
||||
}
|
||||
FindIndexDetachMidIteration(TypedArrayFindIndexHelper);
|
||||
FindIndexDetachMidIteration(ArrayFindIndexHelper);
|
||||
|
||||
(function FindLastDetachMidIteration() {
|
||||
function FindLastDetachMidIteration(findLastHelper) {
|
||||
// Orig. array: [0, 2, 4, 6]
|
||||
// [0, 2, 4, 6] << fixedLength
|
||||
// [4, 6] << fixedLengthWithOffset
|
||||
@ -464,7 +486,8 @@ d8.file.execute('test/mjsunit/typedarray-helpers.js');
|
||||
const fixedLength = new ctor(rab, 0, 4);
|
||||
values = [];
|
||||
detachAfter = 2;
|
||||
assertEquals(undefined, fixedLength.findLast(CollectValuesAndDetach));
|
||||
assertEquals(undefined,
|
||||
findLastHelper(fixedLength, CollectValuesAndDetach));
|
||||
assertEquals([6, 4, undefined, undefined], values);
|
||||
}
|
||||
|
||||
@ -473,7 +496,8 @@ d8.file.execute('test/mjsunit/typedarray-helpers.js');
|
||||
const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2);
|
||||
values = [];
|
||||
detachAfter = 1;
|
||||
assertEquals(undefined, fixedLengthWithOffset.findLast(CollectValuesAndDetach));
|
||||
assertEquals(undefined,
|
||||
findLastHelper(fixedLengthWithOffset, CollectValuesAndDetach));
|
||||
assertEquals([6, undefined], values);
|
||||
}
|
||||
|
||||
@ -482,7 +506,8 @@ d8.file.execute('test/mjsunit/typedarray-helpers.js');
|
||||
const lengthTracking = new ctor(rab, 0);
|
||||
values = [];
|
||||
detachAfter = 2;
|
||||
assertEquals(undefined, lengthTracking.findLast(CollectValuesAndDetach));
|
||||
assertEquals(undefined,
|
||||
findLastHelper(lengthTracking, CollectValuesAndDetach));
|
||||
assertEquals([6, 4, undefined, undefined], values);
|
||||
}
|
||||
|
||||
@ -491,12 +516,15 @@ d8.file.execute('test/mjsunit/typedarray-helpers.js');
|
||||
const lengthTrackingWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT);
|
||||
values = [];
|
||||
detachAfter = 1;
|
||||
assertEquals(undefined, lengthTrackingWithOffset.findLast(CollectValuesAndDetach));
|
||||
assertEquals(undefined,
|
||||
findLastHelper(lengthTrackingWithOffset, CollectValuesAndDetach));
|
||||
assertEquals([6, undefined], values);
|
||||
}
|
||||
})();
|
||||
}
|
||||
FindLastDetachMidIteration(TypedArrayFindLastHelper);
|
||||
FindLastDetachMidIteration(ArrayFindLastHelper);
|
||||
|
||||
(function FindLastIndexDetachMidIteration() {
|
||||
function FindLastIndexDetachMidIteration(findLastIndexHelper) {
|
||||
// Orig. array: [0, 2, 4, 6]
|
||||
// [0, 2, 4, 6] << fixedLength
|
||||
// [4, 6] << fixedLengthWithOffset
|
||||
@ -533,7 +561,7 @@ d8.file.execute('test/mjsunit/typedarray-helpers.js');
|
||||
const fixedLength = new ctor(rab, 0, 4);
|
||||
values = [];
|
||||
detachAfter = 2;
|
||||
assertEquals(-1, fixedLength.findLastIndex(CollectValuesAndDetach));
|
||||
assertEquals(-1, findLastIndexHelper(fixedLength, CollectValuesAndDetach));
|
||||
assertEquals([6, 4, undefined, undefined], values);
|
||||
}
|
||||
|
||||
@ -542,7 +570,8 @@ d8.file.execute('test/mjsunit/typedarray-helpers.js');
|
||||
const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2);
|
||||
values = [];
|
||||
detachAfter = 1;
|
||||
assertEquals(-1, fixedLengthWithOffset.findLastIndex(CollectValuesAndDetach));
|
||||
assertEquals(-1,
|
||||
findLastIndexHelper(fixedLengthWithOffset, CollectValuesAndDetach));
|
||||
assertEquals([6, undefined], values);
|
||||
}
|
||||
|
||||
@ -551,7 +580,8 @@ d8.file.execute('test/mjsunit/typedarray-helpers.js');
|
||||
const lengthTracking = new ctor(rab, 0);
|
||||
values = [];
|
||||
detachAfter = 2;
|
||||
assertEquals(-1, lengthTracking.findLastIndex(CollectValuesAndDetach));
|
||||
assertEquals(-1,
|
||||
findLastIndexHelper(lengthTracking, CollectValuesAndDetach));
|
||||
assertEquals([6, 4, undefined, undefined], values);
|
||||
}
|
||||
|
||||
@ -560,10 +590,13 @@ d8.file.execute('test/mjsunit/typedarray-helpers.js');
|
||||
const lengthTrackingWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT);
|
||||
values = [];
|
||||
detachAfter = 1;
|
||||
assertEquals(-1, lengthTrackingWithOffset.findLastIndex(CollectValuesAndDetach));
|
||||
assertEquals(-1,
|
||||
findLastIndexHelper(lengthTrackingWithOffset, CollectValuesAndDetach));
|
||||
assertEquals([6, undefined], values);
|
||||
}
|
||||
})();
|
||||
}
|
||||
FindLastIndexDetachMidIteration(TypedArrayFindLastIndexHelper);
|
||||
FindLastIndexDetachMidIteration(ArrayFindLastIndexHelper);
|
||||
|
||||
(function FilterShrinkMidIteration() {
|
||||
// Orig. array: [0, 2, 4, 6]
|
||||
|
@ -1231,7 +1231,7 @@ function TestFill(helper, oobThrows) {
|
||||
assertEquals([15, 19, 19, 20, 16, 16], ReadDataFromBuffer(rab, ctor));
|
||||
}
|
||||
}
|
||||
TestFill(FillHelper, true);
|
||||
TestFill(TypedArrayFillHelper, true);
|
||||
TestFill(ArrayFillHelper, false);
|
||||
|
||||
(function FillParameterConversionResizes() {
|
||||
@ -1243,7 +1243,8 @@ TestFill(ArrayFillHelper, false);
|
||||
const evil = { valueOf: () => {
|
||||
rab.resize(2 * ctor.BYTES_PER_ELEMENT); return 3;
|
||||
}};
|
||||
assertThrows(() => { FillHelper(fixedLength, evil, 1, 2); }, TypeError);
|
||||
assertThrows(
|
||||
() => { TypedArrayFillHelper(fixedLength, evil, 1, 2); }, TypeError);
|
||||
}
|
||||
for (let ctor of ctors) {
|
||||
const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT,
|
||||
@ -1253,7 +1254,8 @@ TestFill(ArrayFillHelper, false);
|
||||
const evil = { valueOf: () => {
|
||||
rab.resize(2 * ctor.BYTES_PER_ELEMENT); return 1;
|
||||
}};
|
||||
assertThrows(() => { FillHelper(fixedLength, 3, evil, 2); }, TypeError);
|
||||
assertThrows(
|
||||
() => { TypedArrayFillHelper(fixedLength, 3, evil, 2); }, TypeError);
|
||||
}
|
||||
for (let ctor of ctors) {
|
||||
const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT,
|
||||
@ -1263,7 +1265,8 @@ TestFill(ArrayFillHelper, false);
|
||||
const evil = { valueOf: () => {
|
||||
rab.resize(2 * ctor.BYTES_PER_ELEMENT); return 2;
|
||||
}};
|
||||
assertThrows(() => { FillHelper(fixedLength, 3, 1, evil); }, TypeError);
|
||||
assertThrows(
|
||||
() => { TypedArrayFillHelper(fixedLength, 3, 1, evil); }, TypeError);
|
||||
}
|
||||
})();
|
||||
|
||||
@ -2620,7 +2623,9 @@ TestCopyWithin(ArrayCopyWithinHelper, false);
|
||||
}
|
||||
})();
|
||||
|
||||
(function FindFindIndexFindLastFindLastIndex() {
|
||||
function FindFindIndexFindLastFindLastIndex(
|
||||
findHelper, findIndexHelper, findLastHelper, findLastIndexHelper,
|
||||
oobThrows) {
|
||||
for (let ctor of ctors) {
|
||||
const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT,
|
||||
8 * ctor.BYTES_PER_ELEMENT);
|
||||
@ -2645,25 +2650,26 @@ TestCopyWithin(ArrayCopyWithinHelper, false);
|
||||
return n == 2 || n == 4;
|
||||
}
|
||||
|
||||
assertEquals(2, Number(fixedLength.find(isTwoOrFour)));
|
||||
assertEquals(4, Number(fixedLengthWithOffset.find(isTwoOrFour)));
|
||||
assertEquals(2, Number(lengthTracking.find(isTwoOrFour)));
|
||||
assertEquals(4, Number(lengthTrackingWithOffset.find(isTwoOrFour)));
|
||||
assertEquals(2, Number(findHelper(fixedLength, isTwoOrFour)));
|
||||
assertEquals(4, Number(findHelper(fixedLengthWithOffset, isTwoOrFour)));
|
||||
assertEquals(2, Number(findHelper(lengthTracking, isTwoOrFour)));
|
||||
assertEquals(4, Number(findHelper(lengthTrackingWithOffset, isTwoOrFour)));
|
||||
|
||||
assertEquals(1, fixedLength.findIndex(isTwoOrFour));
|
||||
assertEquals(0, fixedLengthWithOffset.findIndex(isTwoOrFour));
|
||||
assertEquals(1, lengthTracking.findIndex(isTwoOrFour));
|
||||
assertEquals(0, lengthTrackingWithOffset.findIndex(isTwoOrFour));
|
||||
assertEquals(1, findIndexHelper(fixedLength, isTwoOrFour));
|
||||
assertEquals(0, findIndexHelper(fixedLengthWithOffset, isTwoOrFour));
|
||||
assertEquals(1, findIndexHelper(lengthTracking, isTwoOrFour));
|
||||
assertEquals(0, findIndexHelper(lengthTrackingWithOffset, isTwoOrFour));
|
||||
|
||||
assertEquals(4, Number(fixedLength.findLast(isTwoOrFour)));
|
||||
assertEquals(4, Number(fixedLengthWithOffset.findLast(isTwoOrFour)));
|
||||
assertEquals(4, Number(lengthTracking.findLast(isTwoOrFour)));
|
||||
assertEquals(4, Number(lengthTrackingWithOffset.findLast(isTwoOrFour)));
|
||||
assertEquals(4, Number(findLastHelper(fixedLength, isTwoOrFour)));
|
||||
assertEquals(4, Number(findLastHelper(fixedLengthWithOffset, isTwoOrFour)));
|
||||
assertEquals(4, Number(findLastHelper(lengthTracking, isTwoOrFour)));
|
||||
assertEquals(4,
|
||||
Number(findLastHelper(lengthTrackingWithOffset, isTwoOrFour)));
|
||||
|
||||
assertEquals(2, fixedLength.findLastIndex(isTwoOrFour));
|
||||
assertEquals(0, fixedLengthWithOffset.findLastIndex(isTwoOrFour));
|
||||
assertEquals(2, lengthTracking.findLastIndex(isTwoOrFour));
|
||||
assertEquals(0, lengthTrackingWithOffset.findLastIndex(isTwoOrFour));
|
||||
assertEquals(2, findLastIndexHelper(fixedLength, isTwoOrFour));
|
||||
assertEquals(0, findLastIndexHelper(fixedLengthWithOffset, isTwoOrFour));
|
||||
assertEquals(2, findLastIndexHelper(lengthTracking, isTwoOrFour));
|
||||
assertEquals(0, findLastIndexHelper(lengthTrackingWithOffset, isTwoOrFour));
|
||||
|
||||
// Shrink so that fixed length TAs go out of bounds.
|
||||
rab.resize(3 * ctor.BYTES_PER_ELEMENT);
|
||||
@ -2672,73 +2678,156 @@ TestCopyWithin(ArrayCopyWithinHelper, false);
|
||||
// [0, 2, 4, ...] << lengthTracking
|
||||
// [4, ...] << lengthTrackingWithOffset
|
||||
|
||||
assertThrows(() => { fixedLength.find(isTwoOrFour); });
|
||||
assertThrows(() => { fixedLength.findIndex(isTwoOrFour); });
|
||||
assertThrows(() => { fixedLength.findLast(isTwoOrFour); });
|
||||
assertThrows(() => { fixedLength.findLastIndex(isTwoOrFour); });
|
||||
if (oobThrows) {
|
||||
assertThrows(() => { findHelper(fixedLength, isTwoOrFour); });
|
||||
assertThrows(() => { findIndexHelper(fixedLength, isTwoOrFour); });
|
||||
assertThrows(() => { findLastHelper(fixedLength, isTwoOrFour); });
|
||||
assertThrows(() => { findLastIndexHelper(fixedLength, isTwoOrFour); });
|
||||
|
||||
assertThrows(() => { fixedLengthWithOffset.find(isTwoOrFour); });
|
||||
assertThrows(() => { fixedLengthWithOffset.findIndex(isTwoOrFour); });
|
||||
assertThrows(() => { fixedLengthWithOffset.findLast(isTwoOrFour); });
|
||||
assertThrows(() => { fixedLengthWithOffset.findLastIndex(isTwoOrFour); });
|
||||
assertThrows(() => { findHelper(fixedLengthWithOffset, isTwoOrFour); });
|
||||
assertThrows(() => {
|
||||
findIndexHelper(fixedLengthWithOffset, isTwoOrFour); });
|
||||
assertThrows(() => {
|
||||
findLastHelper(fixedLengthWithOffset, isTwoOrFour); });
|
||||
assertThrows(() => {
|
||||
findLastIndexHelper(fixedLengthWithOffset, isTwoOrFour); });
|
||||
} else {
|
||||
assertEquals(undefined, findHelper(fixedLength, isTwoOrFour));
|
||||
assertEquals(-1, findIndexHelper(fixedLength, isTwoOrFour));
|
||||
assertEquals(undefined, findLastHelper(fixedLength, isTwoOrFour));
|
||||
assertEquals(-1, findLastIndexHelper(fixedLength, isTwoOrFour));
|
||||
|
||||
assertEquals(2, Number(lengthTracking.find(isTwoOrFour)));
|
||||
assertEquals(4, Number(lengthTrackingWithOffset.find(isTwoOrFour)));
|
||||
assertEquals(undefined, findHelper(fixedLengthWithOffset, isTwoOrFour));
|
||||
assertEquals(-1,
|
||||
findIndexHelper(fixedLengthWithOffset, isTwoOrFour));
|
||||
assertEquals(undefined,
|
||||
findLastHelper(fixedLengthWithOffset, isTwoOrFour));
|
||||
assertEquals(-1,
|
||||
findLastIndexHelper(fixedLengthWithOffset, isTwoOrFour));
|
||||
}
|
||||
|
||||
assertEquals(1, lengthTracking.findIndex(isTwoOrFour));
|
||||
assertEquals(0, lengthTrackingWithOffset.findIndex(isTwoOrFour));
|
||||
assertEquals(2, Number(findHelper(lengthTracking, isTwoOrFour)));
|
||||
assertEquals(4, Number(findHelper(lengthTrackingWithOffset, isTwoOrFour)));
|
||||
|
||||
assertEquals(4, Number(lengthTracking.findLast(isTwoOrFour)));
|
||||
assertEquals(4, Number(lengthTrackingWithOffset.findLast(isTwoOrFour)));
|
||||
assertEquals(1, findIndexHelper(lengthTracking, isTwoOrFour));
|
||||
assertEquals(0, findIndexHelper(lengthTrackingWithOffset, isTwoOrFour));
|
||||
|
||||
assertEquals(2, lengthTracking.findLastIndex(isTwoOrFour));
|
||||
assertEquals(0, lengthTrackingWithOffset.findLastIndex(isTwoOrFour));
|
||||
assertEquals(4, Number(findLastHelper(lengthTracking, isTwoOrFour)));
|
||||
assertEquals(4,
|
||||
Number(findLastHelper(lengthTrackingWithOffset, isTwoOrFour)));
|
||||
|
||||
assertEquals(2, findLastIndexHelper(lengthTracking, isTwoOrFour));
|
||||
assertEquals(0, findLastIndexHelper(lengthTrackingWithOffset, isTwoOrFour));
|
||||
|
||||
// Shrink so that the TAs with offset go out of bounds.
|
||||
rab.resize(1 * ctor.BYTES_PER_ELEMENT);
|
||||
|
||||
assertThrows(() => { fixedLength.find(isTwoOrFour); });
|
||||
assertThrows(() => { fixedLength.findIndex(isTwoOrFour); });
|
||||
assertThrows(() => { fixedLength.findLast(isTwoOrFour); });
|
||||
assertThrows(() => { fixedLength.findLastIndex(isTwoOrFour); });
|
||||
if (oobThrows) {
|
||||
assertThrows(() => { findHelper(fixedLength, isTwoOrFour); });
|
||||
assertThrows(() => { findIndexHelper(fixedLength, isTwoOrFour); });
|
||||
assertThrows(() => { findLastHelper(fixedLength, isTwoOrFour); });
|
||||
assertThrows(() => { findLastIndexHelper(fixedLength, isTwoOrFour); });
|
||||
|
||||
assertThrows(() => { fixedLengthWithOffset.find(isTwoOrFour); });
|
||||
assertThrows(() => { fixedLengthWithOffset.findIndex(isTwoOrFour); });
|
||||
assertThrows(() => { fixedLengthWithOffset.findLast(isTwoOrFour); });
|
||||
assertThrows(() => { fixedLengthWithOffset.findLastIndex(isTwoOrFour); });
|
||||
assertThrows(() => { findHelper(fixedLengthWithOffset, isTwoOrFour); });
|
||||
assertThrows(
|
||||
() => { findIndexHelper(fixedLengthWithOffset, isTwoOrFour); });
|
||||
assertThrows(
|
||||
() => { findLastHelper(fixedLengthWithOffset, isTwoOrFour); });
|
||||
assertThrows(
|
||||
() => { findLastIndexHelper(fixedLengthWithOffset, isTwoOrFour); });
|
||||
|
||||
assertThrows(() => { lengthTrackingWithOffset.find(isTwoOrFour); });
|
||||
assertThrows(() => { lengthTrackingWithOffset.findIndex(isTwoOrFour); });
|
||||
assertThrows(() => { lengthTrackingWithOffset.findLast(isTwoOrFour); });
|
||||
assertThrows(() => { lengthTrackingWithOffset.findLastIndex(isTwoOrFour); });
|
||||
assertThrows(
|
||||
() => { findHelper(lengthTrackingWithOffset, isTwoOrFour); });
|
||||
assertThrows(
|
||||
() => { findIndexHelper(lengthTrackingWithOffset, isTwoOrFour); });
|
||||
assertThrows(
|
||||
() => { findLastHelper(lengthTrackingWithOffset, isTwoOrFour); });
|
||||
assertThrows(
|
||||
() => {
|
||||
findLastIndexHelper(lengthTrackingWithOffset, isTwoOrFour); });
|
||||
} else {
|
||||
assertEquals(undefined, findHelper(fixedLength, isTwoOrFour));
|
||||
assertEquals(-1, findIndexHelper(fixedLength, isTwoOrFour));
|
||||
assertEquals(undefined, findLastHelper(fixedLength, isTwoOrFour));
|
||||
assertEquals(-1, findLastIndexHelper(fixedLength, isTwoOrFour));
|
||||
|
||||
assertEquals(undefined, lengthTracking.find(isTwoOrFour));
|
||||
assertEquals(-1, lengthTracking.findIndex(isTwoOrFour));
|
||||
assertEquals(undefined, lengthTracking.findLast(isTwoOrFour));
|
||||
assertEquals(-1, lengthTracking.findLastIndex(isTwoOrFour));
|
||||
assertEquals(undefined, findHelper(fixedLengthWithOffset, isTwoOrFour));
|
||||
assertEquals(-1,
|
||||
findIndexHelper(fixedLengthWithOffset, isTwoOrFour));
|
||||
assertEquals(undefined,
|
||||
findLastHelper(fixedLengthWithOffset, isTwoOrFour));
|
||||
assertEquals(-1,
|
||||
findLastIndexHelper(fixedLengthWithOffset, isTwoOrFour));
|
||||
|
||||
assertEquals(undefined,
|
||||
findHelper(lengthTrackingWithOffset, isTwoOrFour));
|
||||
assertEquals(-1,
|
||||
findIndexHelper(lengthTrackingWithOffset, isTwoOrFour));
|
||||
assertEquals(undefined,
|
||||
findLastHelper(lengthTrackingWithOffset, isTwoOrFour));
|
||||
assertEquals(-1,
|
||||
findLastIndexHelper(lengthTrackingWithOffset, isTwoOrFour));
|
||||
}
|
||||
|
||||
assertEquals(undefined, findHelper(lengthTracking, isTwoOrFour));
|
||||
assertEquals(-1, findIndexHelper(lengthTracking, isTwoOrFour));
|
||||
assertEquals(undefined, findLastHelper(lengthTracking, isTwoOrFour));
|
||||
assertEquals(-1, findLastIndexHelper(lengthTracking, isTwoOrFour));
|
||||
|
||||
// Shrink to zero.
|
||||
rab.resize(0);
|
||||
|
||||
assertThrows(() => { fixedLength.find(isTwoOrFour); });
|
||||
assertThrows(() => { fixedLength.findIndex(isTwoOrFour); });
|
||||
assertThrows(() => { fixedLength.findLast(isTwoOrFour); });
|
||||
assertThrows(() => { fixedLength.findLastIndex(isTwoOrFour); });
|
||||
if (oobThrows) {
|
||||
assertThrows(() => { findHelper(fixedLength, isTwoOrFour); });
|
||||
assertThrows(() => { findIndexHelper(fixedLength, isTwoOrFour); });
|
||||
assertThrows(() => { findLastHelper(fixedLength, isTwoOrFour); });
|
||||
assertThrows(() => { findLastIndexHelper(fixedLength, isTwoOrFour); });
|
||||
|
||||
assertThrows(() => { fixedLengthWithOffset.find(isTwoOrFour); });
|
||||
assertThrows(() => { fixedLengthWithOffset.findIndex(isTwoOrFour); });
|
||||
assertThrows(() => { fixedLengthWithOffset.findLast(isTwoOrFour); });
|
||||
assertThrows(() => { fixedLengthWithOffset.findLastIndex(isTwoOrFour); });
|
||||
assertThrows(() => { findHelper(fixedLengthWithOffset, isTwoOrFour); });
|
||||
assertThrows(
|
||||
() => { findIndexHelper(fixedLengthWithOffset, isTwoOrFour); });
|
||||
assertThrows(
|
||||
() => { findLastHelper(fixedLengthWithOffset, isTwoOrFour); });
|
||||
assertThrows(
|
||||
() => { findLastIndexHelper(fixedLengthWithOffset, isTwoOrFour); });
|
||||
|
||||
assertThrows(() => { lengthTrackingWithOffset.find(isTwoOrFour); });
|
||||
assertThrows(() => { lengthTrackingWithOffset.findIndex(isTwoOrFour); });
|
||||
assertThrows(() => { lengthTrackingWithOffset.findLast(isTwoOrFour); });
|
||||
assertThrows(() => { lengthTrackingWithOffset.findLastIndex(isTwoOrFour); });
|
||||
assertThrows(
|
||||
() => { findHelper(lengthTrackingWithOffset, isTwoOrFour); });
|
||||
assertThrows(
|
||||
() => { findIndexHelper(lengthTrackingWithOffset, isTwoOrFour); });
|
||||
assertThrows(
|
||||
() => { findLastHelper(lengthTrackingWithOffset, isTwoOrFour); });
|
||||
assertThrows(
|
||||
() => {
|
||||
findLastIndexHelper(lengthTrackingWithOffset, isTwoOrFour); });
|
||||
} else {
|
||||
assertEquals(undefined, findHelper(fixedLength, isTwoOrFour));
|
||||
assertEquals(-1, findIndexHelper(fixedLength, isTwoOrFour));
|
||||
assertEquals(undefined, findLastHelper(fixedLength, isTwoOrFour));
|
||||
assertEquals(-1, findLastIndexHelper(fixedLength, isTwoOrFour));
|
||||
|
||||
assertEquals(undefined, lengthTracking.find(isTwoOrFour));
|
||||
assertEquals(-1, lengthTracking.findIndex(isTwoOrFour));
|
||||
assertEquals(undefined, lengthTracking.findLast(isTwoOrFour));
|
||||
assertEquals(-1, lengthTracking.findLastIndex(isTwoOrFour));
|
||||
assertEquals(undefined, findHelper(fixedLengthWithOffset, isTwoOrFour));
|
||||
assertEquals(-1,
|
||||
findIndexHelper(fixedLengthWithOffset, isTwoOrFour));
|
||||
assertEquals(undefined,
|
||||
findLastHelper(fixedLengthWithOffset, isTwoOrFour));
|
||||
assertEquals(-1,
|
||||
findLastIndexHelper(fixedLengthWithOffset, isTwoOrFour));
|
||||
|
||||
assertEquals(undefined,
|
||||
findHelper(lengthTrackingWithOffset, isTwoOrFour));
|
||||
assertEquals(-1,
|
||||
findIndexHelper(lengthTrackingWithOffset, isTwoOrFour));
|
||||
assertEquals(undefined,
|
||||
findLastHelper(lengthTrackingWithOffset, isTwoOrFour));
|
||||
assertEquals(-1,
|
||||
findLastIndexHelper(lengthTrackingWithOffset, isTwoOrFour));
|
||||
}
|
||||
|
||||
assertEquals(undefined, findHelper(lengthTracking, isTwoOrFour));
|
||||
assertEquals(-1, findIndexHelper(lengthTracking, isTwoOrFour));
|
||||
assertEquals(undefined, findLastHelper(lengthTracking, isTwoOrFour));
|
||||
assertEquals(-1, findLastIndexHelper(lengthTracking, isTwoOrFour));
|
||||
|
||||
// Grow so that all TAs are back in-bounds.
|
||||
rab.resize(6 * ctor.BYTES_PER_ELEMENT);
|
||||
@ -2754,29 +2843,35 @@ TestCopyWithin(ArrayCopyWithinHelper, false);
|
||||
// [0, 0, 0, 0, 2, 4, ...] << lengthTracking
|
||||
// [0, 0, 2, 4, ...] << lengthTrackingWithOffset
|
||||
|
||||
assertEquals(undefined, fixedLength.find(isTwoOrFour));
|
||||
assertEquals(undefined, fixedLengthWithOffset.find(isTwoOrFour));
|
||||
assertEquals(2, Number(lengthTracking.find(isTwoOrFour)));
|
||||
assertEquals(2, Number(lengthTrackingWithOffset.find(isTwoOrFour)));
|
||||
assertEquals(undefined, findHelper(fixedLength, isTwoOrFour));
|
||||
assertEquals(undefined, findHelper(fixedLengthWithOffset, isTwoOrFour));
|
||||
assertEquals(2, Number(findHelper(lengthTracking, isTwoOrFour)));
|
||||
assertEquals(2, Number(findHelper(lengthTrackingWithOffset, isTwoOrFour)));
|
||||
|
||||
assertEquals(-1, fixedLength.findIndex(isTwoOrFour));
|
||||
assertEquals(-1, fixedLengthWithOffset.findIndex(isTwoOrFour));
|
||||
assertEquals(4, lengthTracking.findIndex(isTwoOrFour));
|
||||
assertEquals(2, lengthTrackingWithOffset.findIndex(isTwoOrFour));
|
||||
assertEquals(-1, findIndexHelper(fixedLength, isTwoOrFour));
|
||||
assertEquals(-1, findIndexHelper(fixedLengthWithOffset, isTwoOrFour));
|
||||
assertEquals(4, findIndexHelper(lengthTracking, isTwoOrFour));
|
||||
assertEquals(2, findIndexHelper(lengthTrackingWithOffset, isTwoOrFour));
|
||||
|
||||
assertEquals(undefined, fixedLength.findLast(isTwoOrFour));
|
||||
assertEquals(undefined, fixedLengthWithOffset.findLast(isTwoOrFour));
|
||||
assertEquals(4, Number(lengthTracking.findLast(isTwoOrFour)));
|
||||
assertEquals(4, Number(lengthTrackingWithOffset.findLast(isTwoOrFour)));
|
||||
assertEquals(undefined, findLastHelper(fixedLength, isTwoOrFour));
|
||||
assertEquals(undefined, findLastHelper(fixedLengthWithOffset, isTwoOrFour));
|
||||
assertEquals(4, Number(findLastHelper(lengthTracking, isTwoOrFour)));
|
||||
assertEquals(4, Number(findLastHelper(lengthTrackingWithOffset, isTwoOrFour)));
|
||||
|
||||
assertEquals(-1, fixedLength.findLastIndex(isTwoOrFour));
|
||||
assertEquals(-1, fixedLengthWithOffset.findLastIndex(isTwoOrFour));
|
||||
assertEquals(5, lengthTracking.findLastIndex(isTwoOrFour));
|
||||
assertEquals(3, lengthTrackingWithOffset.findLastIndex(isTwoOrFour));
|
||||
assertEquals(-1, findLastIndexHelper(fixedLength, isTwoOrFour));
|
||||
assertEquals(-1, findLastIndexHelper(fixedLengthWithOffset, isTwoOrFour));
|
||||
assertEquals(5, findLastIndexHelper(lengthTracking, isTwoOrFour));
|
||||
assertEquals(3, findLastIndexHelper(lengthTrackingWithOffset, isTwoOrFour));
|
||||
}
|
||||
})();
|
||||
}
|
||||
FindFindIndexFindLastFindLastIndex(
|
||||
TypedArrayFindHelper, TypedArrayFindIndexHelper, TypedArrayFindLastHelper,
|
||||
TypedArrayFindLastIndexHelper, true);
|
||||
FindFindIndexFindLastFindLastIndex(
|
||||
ArrayFindHelper, ArrayFindIndexHelper, ArrayFindLastHelper,
|
||||
ArrayFindLastIndexHelper, false);
|
||||
|
||||
(function FindShrinkMidIteration() {
|
||||
function FindShrinkMidIteration(findHelper) {
|
||||
// Orig. array: [0, 2, 4, 6]
|
||||
// [0, 2, 4, 6] << fixedLength
|
||||
// [4, 6] << fixedLengthWithOffset
|
||||
@ -2815,7 +2910,7 @@ TestCopyWithin(ArrayCopyWithinHelper, false);
|
||||
values = [];
|
||||
resizeAfter = 2;
|
||||
resizeTo = 3 * ctor.BYTES_PER_ELEMENT;
|
||||
assertEquals(undefined, fixedLength.find(CollectValuesAndResize));
|
||||
assertEquals(undefined, findHelper(fixedLength, CollectValuesAndResize));
|
||||
assertEquals([0, 2, undefined, undefined], values);
|
||||
}
|
||||
|
||||
@ -2825,7 +2920,8 @@ TestCopyWithin(ArrayCopyWithinHelper, false);
|
||||
values = [];
|
||||
resizeAfter = 1;
|
||||
resizeTo = 3 * ctor.BYTES_PER_ELEMENT;
|
||||
assertEquals(undefined, fixedLengthWithOffset.find(CollectValuesAndResize));
|
||||
assertEquals(undefined,
|
||||
findHelper(fixedLengthWithOffset, CollectValuesAndResize));
|
||||
assertEquals([4, undefined], values);
|
||||
}
|
||||
|
||||
@ -2835,7 +2931,7 @@ TestCopyWithin(ArrayCopyWithinHelper, false);
|
||||
values = [];
|
||||
resizeAfter = 2;
|
||||
resizeTo = 3 * ctor.BYTES_PER_ELEMENT;
|
||||
assertEquals(undefined, lengthTracking.find(CollectValuesAndResize));
|
||||
assertEquals(undefined, findHelper(lengthTracking, CollectValuesAndResize));
|
||||
assertEquals([0, 2, 4, undefined], values);
|
||||
}
|
||||
|
||||
@ -2845,12 +2941,15 @@ TestCopyWithin(ArrayCopyWithinHelper, false);
|
||||
values = [];
|
||||
resizeAfter = 1;
|
||||
resizeTo = 3 * ctor.BYTES_PER_ELEMENT;
|
||||
assertEquals(undefined, lengthTrackingWithOffset.find(CollectValuesAndResize));
|
||||
assertEquals(undefined,
|
||||
findHelper(lengthTrackingWithOffset, CollectValuesAndResize));
|
||||
assertEquals([4, undefined], values);
|
||||
}
|
||||
})();
|
||||
}
|
||||
FindShrinkMidIteration(TypedArrayFindHelper);
|
||||
FindShrinkMidIteration(ArrayFindHelper);
|
||||
|
||||
(function FindGrowMidIteration() {
|
||||
function FindGrowMidIteration(findHelper) {
|
||||
// Orig. array: [0, 2, 4, 6]
|
||||
// [0, 2, 4, 6] << fixedLength
|
||||
// [4, 6] << fixedLengthWithOffset
|
||||
@ -2889,7 +2988,7 @@ TestCopyWithin(ArrayCopyWithinHelper, false);
|
||||
values = [];
|
||||
resizeAfter = 2;
|
||||
resizeTo = 5 * ctor.BYTES_PER_ELEMENT;
|
||||
assertEquals(undefined, fixedLength.find(CollectValuesAndResize));
|
||||
assertEquals(undefined, findHelper(fixedLength, CollectValuesAndResize));
|
||||
assertEquals([0, 2, 4, 6], values);
|
||||
}
|
||||
|
||||
@ -2899,7 +2998,8 @@ TestCopyWithin(ArrayCopyWithinHelper, false);
|
||||
values = [];
|
||||
resizeAfter = 1;
|
||||
resizeTo = 5 * ctor.BYTES_PER_ELEMENT;
|
||||
assertEquals(undefined, fixedLengthWithOffset.find(CollectValuesAndResize));
|
||||
assertEquals(undefined,
|
||||
findHelper(fixedLengthWithOffset, CollectValuesAndResize));
|
||||
assertEquals([4, 6], values);
|
||||
}
|
||||
|
||||
@ -2909,7 +3009,7 @@ TestCopyWithin(ArrayCopyWithinHelper, false);
|
||||
values = [];
|
||||
resizeAfter = 2;
|
||||
resizeTo = 5 * ctor.BYTES_PER_ELEMENT;
|
||||
assertEquals(undefined, lengthTracking.find(CollectValuesAndResize));
|
||||
assertEquals(undefined, findHelper(lengthTracking, CollectValuesAndResize));
|
||||
assertEquals([0, 2, 4, 6], values);
|
||||
}
|
||||
|
||||
@ -2919,12 +3019,15 @@ TestCopyWithin(ArrayCopyWithinHelper, false);
|
||||
values = [];
|
||||
resizeAfter = 1;
|
||||
resizeTo = 5 * ctor.BYTES_PER_ELEMENT;
|
||||
assertEquals(undefined, lengthTrackingWithOffset.find(CollectValuesAndResize));
|
||||
assertEquals(undefined,
|
||||
findHelper(lengthTrackingWithOffset, CollectValuesAndResize));
|
||||
assertEquals([4, 6], values);
|
||||
}
|
||||
})();
|
||||
}
|
||||
FindGrowMidIteration(TypedArrayFindHelper);
|
||||
FindGrowMidIteration(ArrayFindHelper);
|
||||
|
||||
(function FindIndexShrinkMidIteration() {
|
||||
function FindIndexShrinkMidIteration(findIndexHelper) {
|
||||
// Orig. array: [0, 2, 4, 6]
|
||||
// [0, 2, 4, 6] << fixedLength
|
||||
// [4, 6] << fixedLengthWithOffset
|
||||
@ -2963,7 +3066,7 @@ TestCopyWithin(ArrayCopyWithinHelper, false);
|
||||
values = [];
|
||||
resizeAfter = 2;
|
||||
resizeTo = 3 * ctor.BYTES_PER_ELEMENT;
|
||||
assertEquals(-1, fixedLength.findIndex(CollectValuesAndResize));
|
||||
assertEquals(-1, findIndexHelper(fixedLength, CollectValuesAndResize));
|
||||
assertEquals([0, 2, undefined, undefined], values);
|
||||
}
|
||||
|
||||
@ -2973,7 +3076,7 @@ TestCopyWithin(ArrayCopyWithinHelper, false);
|
||||
values = [];
|
||||
resizeAfter = 1;
|
||||
resizeTo = 3 * ctor.BYTES_PER_ELEMENT;
|
||||
assertEquals(-1, fixedLengthWithOffset.findIndex(CollectValuesAndResize));
|
||||
assertEquals(-1, findIndexHelper(fixedLengthWithOffset, CollectValuesAndResize));
|
||||
assertEquals([4, undefined], values);
|
||||
}
|
||||
|
||||
@ -2983,7 +3086,7 @@ TestCopyWithin(ArrayCopyWithinHelper, false);
|
||||
values = [];
|
||||
resizeAfter = 2;
|
||||
resizeTo = 3 * ctor.BYTES_PER_ELEMENT;
|
||||
assertEquals(-1, lengthTracking.findIndex(CollectValuesAndResize));
|
||||
assertEquals(-1, findIndexHelper(lengthTracking, CollectValuesAndResize));
|
||||
assertEquals([0, 2, 4, undefined], values);
|
||||
}
|
||||
|
||||
@ -2993,12 +3096,14 @@ TestCopyWithin(ArrayCopyWithinHelper, false);
|
||||
values = [];
|
||||
resizeAfter = 1;
|
||||
resizeTo = 3 * ctor.BYTES_PER_ELEMENT;
|
||||
assertEquals(-1, lengthTrackingWithOffset.findIndex(CollectValuesAndResize));
|
||||
assertEquals(-1, findIndexHelper(lengthTrackingWithOffset, CollectValuesAndResize));
|
||||
assertEquals([4, undefined], values);
|
||||
}
|
||||
})();
|
||||
}
|
||||
FindIndexShrinkMidIteration(TypedArrayFindIndexHelper);
|
||||
FindIndexShrinkMidIteration(ArrayFindIndexHelper);
|
||||
|
||||
(function FindIndexGrowMidIteration() {
|
||||
function FindIndexGrowMidIteration(findIndexHelper) {
|
||||
// Orig. array: [0, 2, 4, 6]
|
||||
// [0, 2, 4, 6] << fixedLength
|
||||
// [4, 6] << fixedLengthWithOffset
|
||||
@ -3037,7 +3142,7 @@ TestCopyWithin(ArrayCopyWithinHelper, false);
|
||||
values = [];
|
||||
resizeAfter = 2;
|
||||
resizeTo = 5 * ctor.BYTES_PER_ELEMENT;
|
||||
assertEquals(-1, fixedLength.findIndex(CollectValuesAndResize));
|
||||
assertEquals(-1, findIndexHelper(fixedLength, CollectValuesAndResize));
|
||||
assertEquals([0, 2, 4, 6], values);
|
||||
}
|
||||
|
||||
@ -3047,7 +3152,7 @@ TestCopyWithin(ArrayCopyWithinHelper, false);
|
||||
values = [];
|
||||
resizeAfter = 1;
|
||||
resizeTo = 5 * ctor.BYTES_PER_ELEMENT;
|
||||
assertEquals(-1, fixedLengthWithOffset.findIndex(CollectValuesAndResize));
|
||||
assertEquals(-1, findIndexHelper(fixedLengthWithOffset, CollectValuesAndResize));
|
||||
assertEquals([4, 6], values);
|
||||
}
|
||||
|
||||
@ -3057,7 +3162,7 @@ TestCopyWithin(ArrayCopyWithinHelper, false);
|
||||
values = [];
|
||||
resizeAfter = 2;
|
||||
resizeTo = 5 * ctor.BYTES_PER_ELEMENT;
|
||||
assertEquals(-1, lengthTracking.findIndex(CollectValuesAndResize));
|
||||
assertEquals(-1, findIndexHelper(lengthTracking, CollectValuesAndResize));
|
||||
assertEquals([0, 2, 4, 6], values);
|
||||
}
|
||||
|
||||
@ -3067,12 +3172,14 @@ TestCopyWithin(ArrayCopyWithinHelper, false);
|
||||
values = [];
|
||||
resizeAfter = 1;
|
||||
resizeTo = 5 * ctor.BYTES_PER_ELEMENT;
|
||||
assertEquals(-1, lengthTrackingWithOffset.findIndex(CollectValuesAndResize));
|
||||
assertEquals(-1, findIndexHelper(lengthTrackingWithOffset, CollectValuesAndResize));
|
||||
assertEquals([4, 6], values);
|
||||
}
|
||||
})();
|
||||
}
|
||||
FindIndexGrowMidIteration(TypedArrayFindIndexHelper);
|
||||
FindIndexGrowMidIteration(ArrayFindIndexHelper);
|
||||
|
||||
(function FindLastShrinkMidIteration() {
|
||||
function FindLastShrinkMidIteration(findLastHelper) {
|
||||
// Orig. array: [0, 2, 4, 6]
|
||||
// [0, 2, 4, 6] << fixedLength
|
||||
// [4, 6] << fixedLengthWithOffset
|
||||
@ -3111,7 +3218,7 @@ TestCopyWithin(ArrayCopyWithinHelper, false);
|
||||
values = [];
|
||||
resizeAfter = 2;
|
||||
resizeTo = 3 * ctor.BYTES_PER_ELEMENT;
|
||||
assertEquals(undefined, fixedLength.findLast(CollectValuesAndResize));
|
||||
assertEquals(undefined, findLastHelper(fixedLength, CollectValuesAndResize));
|
||||
assertEquals([6, 4, undefined, undefined], values);
|
||||
}
|
||||
|
||||
@ -3121,7 +3228,8 @@ TestCopyWithin(ArrayCopyWithinHelper, false);
|
||||
values = [];
|
||||
resizeAfter = 1;
|
||||
resizeTo = 3 * ctor.BYTES_PER_ELEMENT;
|
||||
assertEquals(undefined, fixedLengthWithOffset.findLast(CollectValuesAndResize));
|
||||
assertEquals(undefined,
|
||||
findLastHelper(fixedLengthWithOffset, CollectValuesAndResize));
|
||||
assertEquals([6, undefined], values);
|
||||
}
|
||||
|
||||
@ -3131,7 +3239,8 @@ TestCopyWithin(ArrayCopyWithinHelper, false);
|
||||
values = [];
|
||||
resizeAfter = 2;
|
||||
resizeTo = 3 * ctor.BYTES_PER_ELEMENT;
|
||||
assertEquals(undefined, lengthTracking.findLast(CollectValuesAndResize));
|
||||
assertEquals(undefined,
|
||||
findLastHelper(lengthTracking, CollectValuesAndResize));
|
||||
assertEquals([6, 4, 2, 0], values);
|
||||
}
|
||||
|
||||
@ -3141,12 +3250,15 @@ TestCopyWithin(ArrayCopyWithinHelper, false);
|
||||
values = [];
|
||||
resizeAfter = 1;
|
||||
resizeTo = 3 * ctor.BYTES_PER_ELEMENT;
|
||||
assertEquals(undefined, lengthTrackingWithOffset.findLast(CollectValuesAndResize));
|
||||
assertEquals(undefined,
|
||||
findLastHelper(lengthTrackingWithOffset, CollectValuesAndResize));
|
||||
assertEquals([6, 4], values);
|
||||
}
|
||||
})();
|
||||
}
|
||||
FindLastShrinkMidIteration(TypedArrayFindLastHelper);
|
||||
FindLastShrinkMidIteration(ArrayFindLastHelper);
|
||||
|
||||
(function FindLastGrowMidIteration() {
|
||||
function FindLastGrowMidIteration(findLastHelper) {
|
||||
// Orig. array: [0, 2, 4, 6]
|
||||
// [0, 2, 4, 6] << fixedLength
|
||||
// [4, 6] << fixedLengthWithOffset
|
||||
@ -3185,7 +3297,8 @@ TestCopyWithin(ArrayCopyWithinHelper, false);
|
||||
values = [];
|
||||
resizeAfter = 2;
|
||||
resizeTo = 5 * ctor.BYTES_PER_ELEMENT;
|
||||
assertEquals(undefined, fixedLength.findLast(CollectValuesAndResize));
|
||||
assertEquals(undefined,
|
||||
findLastHelper(fixedLength, CollectValuesAndResize));
|
||||
assertEquals([6, 4, 2, 0], values);
|
||||
}
|
||||
|
||||
@ -3195,7 +3308,8 @@ TestCopyWithin(ArrayCopyWithinHelper, false);
|
||||
values = [];
|
||||
resizeAfter = 1;
|
||||
resizeTo = 5 * ctor.BYTES_PER_ELEMENT;
|
||||
assertEquals(undefined, fixedLengthWithOffset.findLast(CollectValuesAndResize));
|
||||
assertEquals(undefined,
|
||||
findLastHelper(fixedLengthWithOffset, CollectValuesAndResize));
|
||||
assertEquals([6, 4], values);
|
||||
}
|
||||
|
||||
@ -3205,7 +3319,8 @@ TestCopyWithin(ArrayCopyWithinHelper, false);
|
||||
values = [];
|
||||
resizeAfter = 2;
|
||||
resizeTo = 5 * ctor.BYTES_PER_ELEMENT;
|
||||
assertEquals(undefined, lengthTracking.findLast(CollectValuesAndResize));
|
||||
assertEquals(undefined,
|
||||
findLastHelper(lengthTracking, CollectValuesAndResize));
|
||||
assertEquals([6, 4, 2, 0], values);
|
||||
}
|
||||
|
||||
@ -3215,12 +3330,15 @@ TestCopyWithin(ArrayCopyWithinHelper, false);
|
||||
values = [];
|
||||
resizeAfter = 1;
|
||||
resizeTo = 5 * ctor.BYTES_PER_ELEMENT;
|
||||
assertEquals(undefined, lengthTrackingWithOffset.findLast(CollectValuesAndResize));
|
||||
assertEquals(undefined,
|
||||
findLastHelper(lengthTrackingWithOffset, CollectValuesAndResize));
|
||||
assertEquals([6, 4], values);
|
||||
}
|
||||
})();
|
||||
}
|
||||
FindLastGrowMidIteration(TypedArrayFindLastHelper);
|
||||
FindLastGrowMidIteration(ArrayFindLastHelper);
|
||||
|
||||
(function FindLastIndexShrinkMidIteration() {
|
||||
function FindLastIndexShrinkMidIteration(findLastIndexHelper) {
|
||||
// Orig. array: [0, 2, 4, 6]
|
||||
// [0, 2, 4, 6] << fixedLength
|
||||
// [4, 6] << fixedLengthWithOffset
|
||||
@ -3259,7 +3377,7 @@ TestCopyWithin(ArrayCopyWithinHelper, false);
|
||||
values = [];
|
||||
resizeAfter = 2;
|
||||
resizeTo = 3 * ctor.BYTES_PER_ELEMENT;
|
||||
assertEquals(-1, fixedLength.findLastIndex(CollectValuesAndResize));
|
||||
assertEquals(-1, findLastIndexHelper(fixedLength, CollectValuesAndResize));
|
||||
assertEquals([6, 4, undefined, undefined], values);
|
||||
}
|
||||
|
||||
@ -3269,7 +3387,8 @@ TestCopyWithin(ArrayCopyWithinHelper, false);
|
||||
values = [];
|
||||
resizeAfter = 1;
|
||||
resizeTo = 3 * ctor.BYTES_PER_ELEMENT;
|
||||
assertEquals(-1, fixedLengthWithOffset.findLastIndex(CollectValuesAndResize));
|
||||
assertEquals(-1,
|
||||
findLastIndexHelper(fixedLengthWithOffset, CollectValuesAndResize));
|
||||
assertEquals([6, undefined], values);
|
||||
}
|
||||
|
||||
@ -3279,7 +3398,8 @@ TestCopyWithin(ArrayCopyWithinHelper, false);
|
||||
values = [];
|
||||
resizeAfter = 2;
|
||||
resizeTo = 3 * ctor.BYTES_PER_ELEMENT;
|
||||
assertEquals(-1, lengthTracking.findLastIndex(CollectValuesAndResize));
|
||||
assertEquals(-1,
|
||||
findLastIndexHelper(lengthTracking, CollectValuesAndResize));
|
||||
assertEquals([6, 4, 2, 0], values);
|
||||
}
|
||||
|
||||
@ -3289,7 +3409,8 @@ TestCopyWithin(ArrayCopyWithinHelper, false);
|
||||
values = [];
|
||||
resizeAfter = 1;
|
||||
resizeTo = 2 * ctor.BYTES_PER_ELEMENT;
|
||||
assertEquals(-1, lengthTracking.findLastIndex(CollectValuesAndResize));
|
||||
assertEquals(-1,
|
||||
findLastIndexHelper(lengthTracking, CollectValuesAndResize));
|
||||
assertEquals([6, undefined, 2, 0], values);
|
||||
}
|
||||
|
||||
@ -3299,12 +3420,15 @@ TestCopyWithin(ArrayCopyWithinHelper, false);
|
||||
values = [];
|
||||
resizeAfter = 1;
|
||||
resizeTo = 3 * ctor.BYTES_PER_ELEMENT;
|
||||
assertEquals(-1, lengthTrackingWithOffset.findLastIndex(CollectValuesAndResize));
|
||||
assertEquals(-1,
|
||||
findLastIndexHelper(lengthTrackingWithOffset, CollectValuesAndResize));
|
||||
assertEquals([6, 4], values);
|
||||
}
|
||||
})();
|
||||
}
|
||||
FindLastIndexShrinkMidIteration(TypedArrayFindLastIndexHelper);
|
||||
FindLastIndexShrinkMidIteration(ArrayFindLastIndexHelper);
|
||||
|
||||
(function FindLastIndexGrowMidIteration() {
|
||||
function FindLastIndexGrowMidIteration(findLastIndexHelper) {
|
||||
// Orig. array: [0, 2, 4, 6]
|
||||
// [0, 2, 4, 6] << fixedLength
|
||||
// [4, 6] << fixedLengthWithOffset
|
||||
@ -3343,7 +3467,7 @@ TestCopyWithin(ArrayCopyWithinHelper, false);
|
||||
values = [];
|
||||
resizeAfter = 2;
|
||||
resizeTo = 5 * ctor.BYTES_PER_ELEMENT;
|
||||
assertEquals(-1, fixedLength.findLastIndex(CollectValuesAndResize));
|
||||
assertEquals(-1, findLastIndexHelper(fixedLength, CollectValuesAndResize));
|
||||
assertEquals([6, 4, 2, 0], values);
|
||||
}
|
||||
|
||||
@ -3353,7 +3477,8 @@ TestCopyWithin(ArrayCopyWithinHelper, false);
|
||||
values = [];
|
||||
resizeAfter = 1;
|
||||
resizeTo = 5 * ctor.BYTES_PER_ELEMENT;
|
||||
assertEquals(-1, fixedLengthWithOffset.findLastIndex(CollectValuesAndResize));
|
||||
assertEquals(-1,
|
||||
findLastIndexHelper(fixedLengthWithOffset, CollectValuesAndResize));
|
||||
assertEquals([6, 4], values);
|
||||
}
|
||||
|
||||
@ -3363,7 +3488,8 @@ TestCopyWithin(ArrayCopyWithinHelper, false);
|
||||
values = [];
|
||||
resizeAfter = 2;
|
||||
resizeTo = 5 * ctor.BYTES_PER_ELEMENT;
|
||||
assertEquals(-1, lengthTracking.findLastIndex(CollectValuesAndResize));
|
||||
assertEquals(-1,
|
||||
findLastIndexHelper(lengthTracking, CollectValuesAndResize));
|
||||
assertEquals([6, 4, 2, 0], values);
|
||||
}
|
||||
|
||||
@ -3373,10 +3499,13 @@ TestCopyWithin(ArrayCopyWithinHelper, false);
|
||||
values = [];
|
||||
resizeAfter = 1;
|
||||
resizeTo = 5 * ctor.BYTES_PER_ELEMENT;
|
||||
assertEquals(-1, lengthTrackingWithOffset.findLastIndex(CollectValuesAndResize));
|
||||
assertEquals(-1,
|
||||
findLastIndexHelper(lengthTrackingWithOffset, CollectValuesAndResize));
|
||||
assertEquals([6, 4], values);
|
||||
}
|
||||
})();
|
||||
}
|
||||
FindLastIndexGrowMidIteration(TypedArrayFindLastIndexHelper);
|
||||
FindLastIndexGrowMidIteration(ArrayFindLastIndexHelper);
|
||||
|
||||
(function Filter() {
|
||||
for (let ctor of ctors) {
|
||||
|
Loading…
Reference in New Issue
Block a user