1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 21:57:43 +00:00

LibJS: Add the WeakRef built-in object

This commit is contained in:
Idan Horowitz 2021-06-12 17:38:34 +03:00 committed by Linus Groh
parent 6913f06b6f
commit 7eba63a8a3
12 changed files with 268 additions and 1 deletions

View file

@ -0,0 +1,30 @@
test("constructor properties", () => {
expect(WeakRef).toHaveLength(1);
expect(WeakRef.name).toBe("WeakRef");
});
describe("errors", () => {
test("invalid array iterators", () => {
[-100, Infinity, NaN, 152n, undefined].forEach(value => {
expect(() => {
new WeakRef(value);
}).toThrowWithMessage(TypeError, "is not an object");
});
});
test("called without new", () => {
expect(() => {
WeakRef();
}).toThrowWithMessage(TypeError, "WeakRef constructor must be called with 'new'");
});
});
describe("normal behavior", () => {
test("typeof", () => {
expect(typeof new WeakRef({})).toBe("object");
});
test("constructor with single object argument", () => {
var a = new WeakRef({});
expect(a instanceof WeakRef).toBeTrue();
});
});