mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-03 14:50:18 +00:00
Everywhere: Hoist the Libraries folder to the top-level
This commit is contained in:
parent
950e819ee7
commit
93712b24bf
Notes:
github-actions[bot]
2024-11-10 11:51:52 +00:00
Author: https://github.com/trflynn89
Commit: 93712b24bf
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2256
Reviewed-by: https://github.com/sideshowbarker
4547 changed files with 104 additions and 113 deletions
69
Libraries/LibJS/Tests/builtins/Reflect/Reflect.construct.js
Normal file
69
Libraries/LibJS/Tests/builtins/Reflect/Reflect.construct.js
Normal file
|
@ -0,0 +1,69 @@
|
|||
test("length is 2", () => {
|
||||
expect(Reflect.construct).toHaveLength(2);
|
||||
});
|
||||
|
||||
describe("errors", () => {
|
||||
test("target must be a constructor", () => {
|
||||
[null, undefined, "foo", 123, NaN, Infinity, {}].forEach(value => {
|
||||
expect(() => {
|
||||
Reflect.construct(value);
|
||||
}).toThrowWithMessage(TypeError, `${value} is not a constructor`);
|
||||
});
|
||||
});
|
||||
|
||||
test("arguments list must be an object", () => {
|
||||
[null, undefined, "foo", 123, NaN, Infinity].forEach(value => {
|
||||
expect(() => {
|
||||
Reflect.construct(function () {}, value);
|
||||
}).toThrowWithMessage(TypeError, `${value} is not an object`);
|
||||
});
|
||||
});
|
||||
|
||||
test("new target must be a constructor", () => {
|
||||
[null, undefined, "foo", 123, NaN, Infinity, {}].forEach(value => {
|
||||
expect(() => {
|
||||
Reflect.construct(function () {}, [], value);
|
||||
}).toThrowWithMessage(TypeError, `${value} is not a constructor`);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("normal behavior", () => {
|
||||
test("built-in Array function", () => {
|
||||
var a = Reflect.construct(Array, [5]);
|
||||
expect(a instanceof Array).toBeTrue();
|
||||
expect(a).toHaveLength(5);
|
||||
});
|
||||
|
||||
test("built-in String function", () => {
|
||||
var s = Reflect.construct(String, [123]);
|
||||
expect(s instanceof String).toBeTrue();
|
||||
expect(s).toHaveLength(3);
|
||||
expect(s.toString()).toBe("123");
|
||||
});
|
||||
|
||||
test("user-defined function", () => {
|
||||
function Foo() {
|
||||
this.name = "foo";
|
||||
}
|
||||
|
||||
var o = Reflect.construct(Foo, []);
|
||||
expect(o.name).toBe("foo");
|
||||
expect(o instanceof Foo).toBeTrue();
|
||||
});
|
||||
|
||||
test("user-defined function with different new target", () => {
|
||||
function Foo() {
|
||||
this.name = "foo";
|
||||
}
|
||||
|
||||
function Bar() {
|
||||
this.name = "bar";
|
||||
}
|
||||
|
||||
var o = Reflect.construct(Foo, [], Bar);
|
||||
expect(o.name).toBe("foo");
|
||||
expect(o instanceof Foo).toBeFalse();
|
||||
expect(o instanceof Bar).toBeTrue();
|
||||
});
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue