blob: 3c1183f3e59c01c2a97f3934ece4f8094eb731ea [file] [log] [blame] [edit]
// Copyright 2025 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --allow-natives-syntax --js-staging
// Flags: --experimental-wasm-rab-integration
'use strict';
d8.file.execute('test/mjsunit/typedarray-helpers.js');
const kPageSize = 0x10000;
(function ArrayPopShift() {
// These functions always fail since setting the length fails.
for (let ctor of ctors) {
const rab = CreateResizableArrayBufferViaWasm(1, 2);
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, kPageSize - 2 * ctor.BYTES_PER_ELEMENT);
function testAllFuncsThrow() {
for (let func of [Array.prototype.pop, Array.prototype.shift]) {
assertThrows(() => {
func.call(fixedLength); }, TypeError);
assertThrows(() => {
func.call(fixedLengthWithOffset); }, TypeError);
assertThrows(() => {
func.call(lengthTracking); }, TypeError);
assertThrows(() => {
func.call(lengthTrackingWithOffset); }, TypeError);
}
}
testAllFuncsThrow();
%ArrayBufferDetachForceWasm(rab);
testAllFuncsThrow();
}
})();