mirror of https://github.com/tc39/test262.git
RAB: Integrate staging tests for the .length method (#4154)
* Import relevant files from #3888 * Adds resizableArrayBufferUtils.js to includes and removes its content from each test. Also splits tests for .byteLength and .byteOffset to new files in the respective directories. Test lines calling .buffer in .../length/resizable-buffer-assorted.js were not split to .../buffer/ as they seem to only do a check for the test on .length but perhaps they need to be also split to a new file .../buffer/resizable-buffer-assorted.js
This commit is contained in:
parent
0a8622de68
commit
ba92881748
|
@ -0,0 +1,39 @@
|
|||
// Copyright 2023 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-get-%typedarray%.prototype.byteLength
|
||||
description: >
|
||||
TypedArray.p.byteLength behaves correctly when the underlying resizable buffer
|
||||
is resized such that the TypedArray becomes out of bounds.
|
||||
includes: [compareArray.js, resizableArrayBufferUtils.js]
|
||||
features: [resizable-arraybuffer]
|
||||
---*/
|
||||
|
||||
const rab = CreateResizableArrayBuffer(16, 40);
|
||||
|
||||
// Create TAs which cover the bytes 0-7.
|
||||
let tas_and_lengths = [];
|
||||
for (let ctor of ctors) {
|
||||
const length = 8 / ctor.BYTES_PER_ELEMENT;
|
||||
tas_and_lengths.push([
|
||||
new ctor(rab, 0, length),
|
||||
length
|
||||
]);
|
||||
}
|
||||
for (let [ta, length] of tas_and_lengths) {
|
||||
assert.sameValue(ta.byteLength, length * ta.BYTES_PER_ELEMENT);
|
||||
}
|
||||
rab.resize(2);
|
||||
for (let [ta, length] of tas_and_lengths) {
|
||||
assert.sameValue(ta.byteLength, 0);
|
||||
}
|
||||
// Resize the rab so that it just barely covers the needed 8 bytes.
|
||||
rab.resize(8);
|
||||
for (let [ta, length] of tas_and_lengths) {
|
||||
assert.sameValue(ta.byteLength, length * ta.BYTES_PER_ELEMENT);
|
||||
}
|
||||
rab.resize(40);
|
||||
for (let [ta, length] of tas_and_lengths) {
|
||||
assert.sameValue(ta.byteLength, length * ta.BYTES_PER_ELEMENT);
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
// Copyright 2023 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-get-%typedarray%.prototype.byteLength
|
||||
description: >
|
||||
TypedArray.p.byteLength behaves as expected when the underlying resizable
|
||||
buffer is resized such that the TypedArray becomes out of bounds.
|
||||
includes: [compareArray.js, resizableArrayBufferUtils.js]
|
||||
features: [resizable-arraybuffer]
|
||||
---*/
|
||||
|
||||
const rab = CreateResizableArrayBuffer(20, 40);
|
||||
|
||||
// Create TAs with offset, which cover the bytes 8-15.
|
||||
let tas_and_lengths = [];
|
||||
for (let ctor of ctors) {
|
||||
const length = 8 / ctor.BYTES_PER_ELEMENT;
|
||||
tas_and_lengths.push([
|
||||
new ctor(rab, 8, length),
|
||||
length
|
||||
]);
|
||||
}
|
||||
for (let [ta, length] of tas_and_lengths) {
|
||||
assert.sameValue(ta.byteLength, length * ta.BYTES_PER_ELEMENT);
|
||||
}
|
||||
rab.resize(10);
|
||||
for (let [ta, length] of tas_and_lengths) {
|
||||
assert.sameValue(ta.byteLength, 0);
|
||||
}
|
||||
// Resize the rab so that it just barely covers the needed 8 bytes.
|
||||
rab.resize(16);
|
||||
for (let [ta, length] of tas_and_lengths) {
|
||||
assert.sameValue(ta.byteLength, length * ta.BYTES_PER_ELEMENT);
|
||||
}
|
||||
rab.resize(40);
|
||||
for (let [ta, length] of tas_and_lengths) {
|
||||
assert.sameValue(ta.byteLength, length * ta.BYTES_PER_ELEMENT);
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
// Copyright 2023 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-get-%typedarray%.prototype.byteOffset
|
||||
description: >
|
||||
TypedArray.p.byteOffset behaves as expected when the underlying resizable
|
||||
buffer is resized such that the TypedArray becomes out of bounds.
|
||||
includes: [compareArray.js, resizableArrayBufferUtils.js]
|
||||
features: [resizable-arraybuffer]
|
||||
---*/
|
||||
|
||||
const rab = CreateResizableArrayBuffer(20, 40);
|
||||
|
||||
// Create TAs which cover the bytes 8-15.
|
||||
let tas_and_lengths = [];
|
||||
for (let ctor of ctors) {
|
||||
const length = 8 / ctor.BYTES_PER_ELEMENT;
|
||||
tas_and_lengths.push([
|
||||
new ctor(rab, 8, length),
|
||||
length
|
||||
]);
|
||||
}
|
||||
for (let [ta, length] of tas_and_lengths) {
|
||||
assert.sameValue(ta.byteOffset, 8);
|
||||
}
|
||||
rab.resize(10);
|
||||
for (let [ta, length] of tas_and_lengths) {
|
||||
assert.sameValue(ta.byteOffset, 0);
|
||||
}
|
||||
// Resize the rab so that it just barely covers the needed 8 bytes.
|
||||
rab.resize(16);
|
||||
for (let [ta, length] of tas_and_lengths) {
|
||||
assert.sameValue(ta.byteOffset, 8);
|
||||
}
|
||||
rab.resize(40);
|
||||
for (let [ta, length] of tas_and_lengths) {
|
||||
assert.sameValue(ta.byteOffset, 8);
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
// Copyright 2023 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-get-%typedarray%.prototype.length
|
||||
description: >
|
||||
TypedArray.p.length behaves correctly on TypedArrays backed by resizable
|
||||
buffers.
|
||||
includes: [compareArray.js, resizableArrayBufferUtils.js]
|
||||
features: [resizable-arraybuffer]
|
||||
---*/
|
||||
|
||||
const rab = CreateResizableArrayBuffer(40, 80);
|
||||
for (let ctor of ctors) {
|
||||
const ta = new ctor(rab, 0, 3);
|
||||
assert.compareArray(ta.buffer, rab);
|
||||
assert.sameValue(ta.length, 3);
|
||||
const empty_ta = new ctor(rab, 0, 0);
|
||||
assert.compareArray(empty_ta.buffer, rab);
|
||||
assert.sameValue(empty_ta.length, 0);
|
||||
const ta_with_offset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 3);
|
||||
assert.compareArray(ta_with_offset.buffer, rab);
|
||||
assert.sameValue(ta_with_offset.length, 3);
|
||||
const empty_ta_with_offset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 0);
|
||||
assert.compareArray(empty_ta_with_offset.buffer, rab);
|
||||
assert.sameValue(empty_ta_with_offset.length, 0);
|
||||
const length_tracking_ta = new ctor(rab);
|
||||
assert.compareArray(length_tracking_ta.buffer, rab);
|
||||
assert.sameValue(length_tracking_ta.length, 40 / ctor.BYTES_PER_ELEMENT);
|
||||
const offset = 8;
|
||||
const length_tracking_ta_with_offset = new ctor(rab, offset);
|
||||
assert.compareArray(length_tracking_ta_with_offset.buffer, rab);
|
||||
assert.sameValue(length_tracking_ta_with_offset.length, (40 - offset) / ctor.BYTES_PER_ELEMENT);
|
||||
const empty_length_tracking_ta_with_offset = new ctor(rab, 40);
|
||||
assert.compareArray(empty_length_tracking_ta_with_offset.buffer, rab);
|
||||
assert.sameValue(empty_length_tracking_ta_with_offset.length, 0);
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
// Copyright 2023 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-get-%typedarray%.prototype.length
|
||||
description: >
|
||||
TypedArray.p.length behaves correctly when the underlying resizable buffer is
|
||||
resized such that the TypedArray becomes out of bounds.
|
||||
includes: [compareArray.js, resizableArrayBufferUtils.js]
|
||||
features: [resizable-arraybuffer]
|
||||
---*/
|
||||
|
||||
const rab = CreateResizableArrayBuffer(16, 40);
|
||||
|
||||
// Create TAs which cover the bytes 0-7.
|
||||
let tas_and_lengths = [];
|
||||
for (let ctor of ctors) {
|
||||
const length = 8 / ctor.BYTES_PER_ELEMENT;
|
||||
tas_and_lengths.push([
|
||||
new ctor(rab, 0, length),
|
||||
length
|
||||
]);
|
||||
}
|
||||
for (let [ta, length] of tas_and_lengths) {
|
||||
assert.sameValue(ta.length, length);
|
||||
}
|
||||
rab.resize(2);
|
||||
for (let [ta, length] of tas_and_lengths) {
|
||||
assert.sameValue(ta.length, 0);
|
||||
}
|
||||
// Resize the rab so that it just barely covers the needed 8 bytes.
|
||||
rab.resize(8);
|
||||
for (let [ta, length] of tas_and_lengths) {
|
||||
assert.sameValue(ta.length, length);
|
||||
}
|
||||
rab.resize(40);
|
||||
for (let [ta, length] of tas_and_lengths) {
|
||||
assert.sameValue(ta.length, length);
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
// Copyright 2023 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-get-%typedarray%.prototype.length
|
||||
description: >
|
||||
TypedArray.p.length behaves correctly when the underlying resizable buffer is
|
||||
resized such that the TypedArray becomes out of bounds.
|
||||
includes: [compareArray.js, resizableArrayBufferUtils.js]
|
||||
features: [resizable-arraybuffer]
|
||||
---*/
|
||||
|
||||
// Like resized-out-of-bounds-1.js but with offsets.
|
||||
|
||||
const rab = CreateResizableArrayBuffer(20, 40);
|
||||
|
||||
// Create TAs with offset, which cover the bytes 8-15.
|
||||
let tas_and_lengths = [];
|
||||
for (let ctor of ctors) {
|
||||
const length = 8 / ctor.BYTES_PER_ELEMENT;
|
||||
tas_and_lengths.push([
|
||||
new ctor(rab, 8, length),
|
||||
length
|
||||
]);
|
||||
}
|
||||
for (let [ta, length] of tas_and_lengths) {
|
||||
assert.sameValue(ta.length, length);
|
||||
}
|
||||
rab.resize(10);
|
||||
for (let [ta, length] of tas_and_lengths) {
|
||||
assert.sameValue(ta.length, 0);
|
||||
}
|
||||
// Resize the rab so that it just barely covers the needed 8 bytes.
|
||||
rab.resize(16);
|
||||
for (let [ta, length] of tas_and_lengths) {
|
||||
assert.sameValue(ta.length, length);
|
||||
}
|
||||
rab.resize(40);
|
||||
for (let [ta, length] of tas_and_lengths) {
|
||||
assert.sameValue(ta.length, length);
|
||||
}
|
Loading…
Reference in New Issue