1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 06:17:34 +00:00

LibJS: Implement Object.prototype.isPrototypeOf

Spec: https://tc39.es/ecma262/#sec-object.prototype.isprototypeof
This commit is contained in:
Luke 2020-12-28 01:22:38 +00:00 committed by Andreas Kling
parent ee1d9217aa
commit be30dc2b18
4 changed files with 40 additions and 0 deletions

View file

@ -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();
});