mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-01 13:49:16 +00:00
LibJS: Implement Object.prototype.isPrototypeOf
Spec: https://tc39.es/ecma262/#sec-object.prototype.isprototypeof
This commit is contained in:
parent
ee1d9217aa
commit
be30dc2b18
Notes:
sideshowbarker
2024-07-19 00:30:06 +09:00
Author: https://github.com/Lubrsi
Commit: be30dc2b18
Pull-request: https://github.com/SerenityOS/serenity/pull/4590
Reviewed-by: https://github.com/linusg
4 changed files with 40 additions and 0 deletions
|
@ -0,0 +1,18 @@
|
|||
test("basic functionality", () => {
|
||||
function A() {}
|
||||
function B() {}
|
||||
|
||||
A.prototype = new B();
|
||||
const C = new A();
|
||||
|
||||
expect(A.prototype.isPrototypeOf(C)).toBeTrue();
|
||||
expect(B.prototype.isPrototypeOf(C)).toBeTrue();
|
||||
|
||||
expect(A.isPrototypeOf(C)).toBeFalse();
|
||||
expect(B.isPrototypeOf(C)).toBeFalse();
|
||||
|
||||
const D = new Object();
|
||||
expect(Object.prototype.isPrototypeOf(D)).toBeTrue();
|
||||
expect(Function.prototype.isPrototypeOf(D.toString)).toBeTrue();
|
||||
expect(Array.prototype.isPrototypeOf([])).toBeTrue();
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue