mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 15:17:36 +00:00
LibJS: Add the FinalizationRegistry built-in object
As well as the needed functionality in VM to enqueue and run cleanup jobs for the FinalizationRegistry instances.
This commit is contained in:
parent
8c7fe8d6c8
commit
de9fa6622a
14 changed files with 365 additions and 20 deletions
|
@ -0,0 +1,33 @@
|
|||
test("constructor properties", () => {
|
||||
expect(FinalizationRegistry).toHaveLength(1);
|
||||
expect(FinalizationRegistry.name).toBe("FinalizationRegistry");
|
||||
});
|
||||
|
||||
describe("errors", () => {
|
||||
test("invalid callbacks", () => {
|
||||
[-100, Infinity, NaN, 152n, undefined].forEach(value => {
|
||||
expect(() => {
|
||||
new FinalizationRegistry(value);
|
||||
}).toThrowWithMessage(TypeError, "is not a function");
|
||||
});
|
||||
});
|
||||
test("called without new", () => {
|
||||
expect(() => {
|
||||
FinalizationRegistry();
|
||||
}).toThrowWithMessage(
|
||||
TypeError,
|
||||
"FinalizationRegistry constructor must be called with 'new'"
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe("normal behavior", () => {
|
||||
test("typeof", () => {
|
||||
expect(typeof new FinalizationRegistry(() => {})).toBe("object");
|
||||
});
|
||||
|
||||
test("constructor with single callback argument", () => {
|
||||
var a = new FinalizationRegistry(() => {});
|
||||
expect(a instanceof FinalizationRegistry).toBeTrue();
|
||||
});
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue