mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-26 09:45:06 +02:00
LibJS: Move tests to /Tests/LibJS
This commit is contained in:
committed by
Tim Flynn
parent
c059c6a2f5
commit
e3faa9b5ad
Notes:
github-actions[bot]
2026-02-06 11:17:48 +00:00
Author: https://github.com/gmta Commit: https://github.com/LadybirdBrowser/ladybird/commit/e3faa9b5add Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/7572 Reviewed-by: https://github.com/trflynn89 ✅
31
Tests/LibJS/Runtime/builtins/ArrayBuffer/ArrayBuffer.js
Normal file
31
Tests/LibJS/Runtime/builtins/ArrayBuffer/ArrayBuffer.js
Normal file
@@ -0,0 +1,31 @@
|
||||
test("basic functionality", () => {
|
||||
expect(ArrayBuffer).toHaveLength(1);
|
||||
expect(ArrayBuffer.name).toBe("ArrayBuffer");
|
||||
expect(ArrayBuffer.prototype.constructor).toBe(ArrayBuffer);
|
||||
expect(new ArrayBuffer()).toBeInstanceOf(ArrayBuffer);
|
||||
expect(typeof new ArrayBuffer()).toBe("object");
|
||||
});
|
||||
|
||||
test("ArrayBuffer constructor must be invoked with 'new'", () => {
|
||||
expect(() => {
|
||||
ArrayBuffer();
|
||||
}).toThrowWithMessage(TypeError, "ArrayBuffer constructor must be called with 'new'");
|
||||
});
|
||||
|
||||
test("ArrayBuffer size limit", () => {
|
||||
expect(() => {
|
||||
new ArrayBuffer(2 ** 53);
|
||||
}).toThrowWithMessage(RangeError, "Invalid array buffer length");
|
||||
});
|
||||
|
||||
test("invalid ArrayBuffer maximum size option", () => {
|
||||
expect(() => {
|
||||
new ArrayBuffer(10, { maxByteLength: -1 });
|
||||
}).toThrowWithMessage(RangeError, "Index must be a positive integer");
|
||||
});
|
||||
|
||||
test("ArrayBuffer size exceeds maximum size", () => {
|
||||
expect(() => {
|
||||
new ArrayBuffer(10, { maxByteLength: 5 });
|
||||
}).toThrowWithMessage(RangeError, "ArrayBuffer byte length of 10 exceeds the max byte length of 5");
|
||||
});
|
||||
Reference in New Issue
Block a user