mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-05-01 12:07:14 +02:00
LibJS: Add the WeakSet built-in object
This commit is contained in:
committed by
Linus Groh
parent
ee9fe288b2
commit
8b6beac5ce
Notes:
sideshowbarker
2024-07-18 12:30:55 +09:00
Author: https://github.com/IdanHo Commit: https://github.com/SerenityOS/serenity/commit/8b6beac5ce5 Pull-request: https://github.com/SerenityOS/serenity/pull/7954 Reviewed-by: https://github.com/linusg
30
Userland/Libraries/LibJS/Tests/builtins/WeakSet/WeakSet.js
Normal file
30
Userland/Libraries/LibJS/Tests/builtins/WeakSet/WeakSet.js
Normal file
@@ -0,0 +1,30 @@
|
||||
test("constructor properties", () => {
|
||||
expect(WeakSet).toHaveLength(0);
|
||||
expect(WeakSet.name).toBe("WeakSet");
|
||||
});
|
||||
|
||||
describe("errors", () => {
|
||||
test("invalid array iterators", () => {
|
||||
[-100, Infinity, NaN, {}, 152n].forEach(value => {
|
||||
expect(() => {
|
||||
new WeakSet(value);
|
||||
}).toThrowWithMessage(TypeError, "is not iterable");
|
||||
});
|
||||
});
|
||||
test("called without new", () => {
|
||||
expect(() => {
|
||||
WeakSet();
|
||||
}).toThrowWithMessage(TypeError, "WeakSet constructor must be called with 'new'");
|
||||
});
|
||||
});
|
||||
|
||||
describe("normal behavior", () => {
|
||||
test("typeof", () => {
|
||||
expect(typeof new WeakSet()).toBe("object");
|
||||
});
|
||||
|
||||
test("constructor with single array argument", () => {
|
||||
var a = new WeakSet([{ a: 1 }, { a: 2 }, { a: 3 }]);
|
||||
expect(a instanceof WeakSet).toBeTrue();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user