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:
parent
ee1d9217aa
commit
be30dc2b18
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