mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 08:37:46 +00:00
LibJS: Implement and test ArrayBuffer.prototype.resize
This commit is contained in:
parent
b29e19c52a
commit
f350c153e8
7 changed files with 118 additions and 0 deletions
|
@ -0,0 +1,35 @@
|
|||
test("length is 1", () => {
|
||||
expect(ArrayBuffer.prototype.resize).toHaveLength(1);
|
||||
});
|
||||
|
||||
test("resize up to max", () => {
|
||||
let a = new ArrayBuffer(0, { maxByteLength: 10 });
|
||||
a.resize(10);
|
||||
expect(a.byteLength).toEqual(10);
|
||||
});
|
||||
|
||||
test("resize less than max", () => {
|
||||
let a = new ArrayBuffer(10, { maxByteLength: 10 });
|
||||
a.resize(5);
|
||||
expect(a.byteLength).toEqual(5);
|
||||
});
|
||||
|
||||
test("resize with negative length", () => {
|
||||
let a = new ArrayBuffer(10, { maxByteLength: 10 });
|
||||
expect(() => {
|
||||
a.resize(-1);
|
||||
}).toThrowWithMessage(
|
||||
RangeError,
|
||||
"New byte length outside range supported by ArrayBuffer instance"
|
||||
);
|
||||
});
|
||||
|
||||
test("resize past max length", () => {
|
||||
let a = new ArrayBuffer(10, { maxByteLength: 10 });
|
||||
expect(() => {
|
||||
a.resize(11);
|
||||
}).toThrowWithMessage(
|
||||
RangeError,
|
||||
"New byte length outside range supported by ArrayBuffer instance"
|
||||
);
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue