summaryrefslogtreecommitdiff
path: root/Libraries/LibJS/Tests/instanceof-basic.js
blob: 29d22e7e6067d0eac548fbbc98fecf8ac4e00df6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
load("test-common.js");

try {
    function Foo() {
        this.x = 123;
    }

    var foo = new Foo();
    assert(foo instanceof Foo);

    function Base() {
        this.is_base = true;
    }

    function Derived() {
        this.is_derived = true;
    }

    Object.setPrototypeOf(Derived.prototype, Base.prototype);

    var d = new Derived();
    assert(d instanceof Derived);
    assert(d instanceof Base);

    console.log("PASS");
} catch(e) {
    console.log("FAIL: " + e);
}