blob: 008657d6e351a5c5a00b4dcfb876b0d5c5e4df61 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
// |jit-test| --enable-arraybuffer-resizable; skip-if: !ArrayBuffer.prototype.resize||!this.SharedArrayBuffer
function testResizableArrayBuffer() {
for (let i = 0; i < 4; ++i) {
let sab = new SharedArrayBuffer(i, {maxByteLength: i + 100});
let ta = new DataView(sab, 0, i);
for (let j = 0; j < 100; ++j) {
assertEq(ta.byteLength, i);
sab.grow(i + j + 1);
assertEq(ta.byteLength, i);
}
}
}
for (let i = 0; i < 2; ++i) testResizableArrayBuffer();
function testResizableArrayBufferAutoLength() {
for (let i = 0; i < 4; ++i) {
let sab = new SharedArrayBuffer(i, {maxByteLength: i + 100});
let ta = new DataView(sab);
for (let j = 0; j < 100; ++j) {
assertEq(ta.byteLength, i + j);
sab.grow(i + j + 1);
assertEq(ta.byteLength, i + j + 1);
}
}
}
for (let i = 0; i < 2; ++i) testResizableArrayBufferAutoLength();
|