1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 23:37:35 +00:00

LibJS: Add some assertions and tests for TypedArray limitations

This commit is contained in:
Andreas Kling 2021-01-24 18:52:57 +01:00
parent 0e3ee03e2b
commit 7a71d4b887
2 changed files with 21 additions and 0 deletions

View file

@ -0,0 +1,18 @@
test("some oversized typed arrays", () => {
expect(() => new Uint8Array(2 * 1024 * 1024 * 1024)).toThrowWithMessage(
RangeError,
"Invalid typed array length"
);
expect(() => new Uint16Array(2 * 1024 * 1024 * 1024)).toThrowWithMessage(
RangeError,
"Invalid typed array length"
);
expect(() => new Uint32Array(1024 * 1024 * 1024)).toThrowWithMessage(
RangeError,
"Invalid typed array length"
);
expect(() => new Uint32Array(4 * 1024 * 1024 * 1024)).toThrowWithMessage(
RangeError,
"Invalid typed array length"
);
});