mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 10:27:35 +00:00
LibJS: Make Function.prototype a callable function object
20.2.3 Properties of the Function Prototype Object https://tc39.es/ecma262/#sec-properties-of-the-function-prototype-object The Function prototype object: - is itself a built-in function object.
This commit is contained in:
parent
913412e0c5
commit
849495915b
3 changed files with 45 additions and 5 deletions
|
@ -0,0 +1,26 @@
|
|||
describe("correct behavior", () => {
|
||||
test("length is 0", () => {
|
||||
expect(Function.prototype).toHaveLength(0);
|
||||
});
|
||||
|
||||
test("name is empty string", () => {
|
||||
expect(Function.prototype.name).toBe("");
|
||||
});
|
||||
|
||||
test("basic functionality", () => {
|
||||
function fn() {}
|
||||
expect(Object.getPrototypeOf(fn)).toBe(Function.prototype);
|
||||
expect(Object.getPrototypeOf(Function.prototype)).toBe(Object.prototype);
|
||||
});
|
||||
|
||||
test("is callable", () => {
|
||||
expect(Function.prototype()).toBeUndefined();
|
||||
});
|
||||
|
||||
test("is not constructable", () => {
|
||||
expect(() => new Function.prototype()).toThrowWithMessage(
|
||||
TypeError,
|
||||
"[object FunctionPrototype] is not a constructor (evaluated from 'Function.prototype')"
|
||||
);
|
||||
});
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue