Commit 70bcf024 authored by Marja Hölttä's avatar Marja Hölttä Committed by V8 LUCI CQ

[rab/gsab] Tests for Array.p methods, part 5

In this part: push, pop

Bug: v8:11111
Change-Id: I62ddc418acaec778270d69c9839e2236d3c8f1e4
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3738259
Commit-Queue: Marja Hölttä <marja@chromium.org>
Reviewed-by: 's avatarShu-yu Guo <syg@chromium.org>
Cr-Commit-Position: refs/heads/main@{#81483}
parent 3a3e4ad4
...@@ -155,3 +155,33 @@ d8.file.execute('test/mjsunit/typedarray-helpers.js'); ...@@ -155,3 +155,33 @@ d8.file.execute('test/mjsunit/typedarray-helpers.js');
assertArrayContents([3, 4, 5, 6], helper(lengthTrackingWithOffset)); assertArrayContents([3, 4, 5, 6], helper(lengthTrackingWithOffset));
} }
})(); })();
(function ArrayPushPop() {
// push() and pop() always fail since setting the length fails.
for (let ctor of ctors) {
const gsab = CreateGrowableSharedArrayBuffer(4 * ctor.BYTES_PER_ELEMENT,
8 * ctor.BYTES_PER_ELEMENT);
const fixedLength = new ctor(gsab, 0, 4);
const fixedLengthWithOffset = new ctor(gsab, 2 * ctor.BYTES_PER_ELEMENT, 2);
const lengthTracking = new ctor(gsab, 0);
const lengthTrackingWithOffset = new ctor(gsab, 2 * ctor.BYTES_PER_ELEMENT);
assertThrows(() => {
Array.prototype.push.call(fixedLength, 0); }, TypeError);
assertThrows(() => {
Array.prototype.push.call(fixedLengthWithOffset, 0); }, TypeError);
assertThrows(() => {
Array.prototype.push.call(lengthTracking, 0); }, TypeError);
assertThrows(() => {
Array.prototype.push.call(lengthTrackingWithOffset, 0); }, TypeError);
assertThrows(() => {
Array.prototype.pop.call(fixedLength, 0); }, TypeError);
assertThrows(() => {
Array.prototype.pop.call(fixedLengthWithOffset, 0); }, TypeError);
assertThrows(() => {
Array.prototype.pop.call(lengthTracking, 0); }, TypeError);
assertThrows(() => {
Array.prototype.pop.call(lengthTrackingWithOffset, 0); }, TypeError);
}
})();
...@@ -240,3 +240,73 @@ d8.file.execute('test/mjsunit/typedarray-helpers.js'); ...@@ -240,3 +240,73 @@ d8.file.execute('test/mjsunit/typedarray-helpers.js');
assertArrayContents([], helper(lengthTrackingWithOffset)); assertArrayContents([], helper(lengthTrackingWithOffset));
} }
})(); })();
(function ArrayPushPop() {
// push() and pop() always fail since setting the length fails.
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);
const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2);
const lengthTracking = new ctor(rab, 0);
const lengthTrackingWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT);
assertThrows(() => {
Array.prototype.push.call(fixedLength, 0); }, TypeError);
assertThrows(() => {
Array.prototype.push.call(fixedLengthWithOffset, 0); }, TypeError);
assertThrows(() => {
Array.prototype.push.call(lengthTracking, 0); }, TypeError);
assertThrows(() => {
Array.prototype.push.call(lengthTrackingWithOffset, 0); }, TypeError);
assertThrows(() => {
Array.prototype.pop.call(fixedLength, 0); }, TypeError);
assertThrows(() => {
Array.prototype.pop.call(fixedLengthWithOffset, 0); }, TypeError);
assertThrows(() => {
Array.prototype.pop.call(lengthTracking, 0); }, TypeError);
assertThrows(() => {
Array.prototype.pop.call(lengthTrackingWithOffset, 0); }, TypeError);
rab.resize(0);
assertThrows(() => {
Array.prototype.push.call(fixedLength, 0); }, TypeError);
assertThrows(() => {
Array.prototype.push.call(fixedLengthWithOffset, 0); }, TypeError);
assertThrows(() => {
Array.prototype.push.call(lengthTracking, 0); }, TypeError);
assertThrows(() => {
Array.prototype.push.call(lengthTrackingWithOffset, 0); }, TypeError);
assertThrows(() => {
Array.prototype.pop.call(fixedLength, 0); }, TypeError);
assertThrows(() => {
Array.prototype.pop.call(fixedLengthWithOffset, 0); }, TypeError);
assertThrows(() => {
Array.prototype.pop.call(lengthTracking, 0); }, TypeError);
assertThrows(() => {
Array.prototype.pop.call(lengthTrackingWithOffset, 0); }, TypeError);
%ArrayBufferDetach(rab);
assertThrows(() => {
Array.prototype.push.call(fixedLength, 0); }, TypeError);
assertThrows(() => {
Array.prototype.push.call(fixedLengthWithOffset, 0); }, TypeError);
assertThrows(() => {
Array.prototype.push.call(lengthTracking, 0); }, TypeError);
assertThrows(() => {
Array.prototype.push.call(lengthTrackingWithOffset, 0); }, TypeError);
assertThrows(() => {
Array.prototype.pop.call(fixedLength, 0); }, TypeError);
assertThrows(() => {
Array.prototype.pop.call(fixedLengthWithOffset, 0); }, TypeError);
assertThrows(() => {
Array.prototype.pop.call(lengthTracking, 0); }, TypeError);
assertThrows(() => {
Array.prototype.pop.call(lengthTrackingWithOffset, 0); }, TypeError);
}
})();
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment