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:
parent
6913f06b6f
commit
7eba63a8a3
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