mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-30 20:59:16 +00:00
LibJS: Add the WeakRef built-in object
This commit is contained in:
parent
6913f06b6f
commit
7eba63a8a3
Notes:
sideshowbarker
2024-07-18 12:22:00 +09:00
Author: https://github.com/IdanHo
Commit: 7eba63a8a3
Pull-request: https://github.com/SerenityOS/serenity/pull/8022
Reviewed-by: https://github.com/linusg
12 changed files with 268 additions and 1 deletions
30
Userland/Libraries/LibJS/Tests/builtins/WeakRef/WeakRef.js
Normal file
30
Userland/Libraries/LibJS/Tests/builtins/WeakRef/WeakRef.js
Normal 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();
|
||||
});
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue