summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/class/superProp.js
blob: 37b85ab652e84ee4ebcbbaa2c86c1776287d7cde (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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
var g_get_this = "get_this";
var g_prop_this = "prop_this";

class Base
{
    get get_prop() { return 7; }
    get get_this() { return this; }
    prop_call() { return 11; }
    prop_this() { return this.x; }
}
Base.prototype.prop_proto = 5;
Base.prototype.x = (-1);
Base.prototype[0] = 100;
Base.prototype[1] = 101;
Base.prototype[2] = 102;

class Derived extends Base
{
    get get_prop() { throw "Bad"; }
    get get_this() { throw "Bad"; }
    prop_call() { throw "Bad"; }
    prop_this() { throw "Bad"; }

    do_test_getprop()
    {
        this.x = 13;

        assertEq(super.prop_proto, 5);

        assertEq(super.get_prop, 7);
        assertEq(super.get_this, this);

        assertEq(super.prop_call(), 11);
        assertEq(super.prop_this(), 13);
    }

    do_test_getelem()
    {
        this.x = 13;

        assertEq(super[g_get_this], this);

        assertEq(super[g_prop_this](), 13);
        assertEq(super[0], 100);
        assertEq(super[1], 101);
        assertEq(super[2], 102);
    }
}
Derived.prototype.prop_proto = (-1);
Derived.prototype.x = (-2);
Derived.prototype[0] = (-3);
Derived.prototype[1] = (-4);
Derived.prototype[2] = (-5);

for (var i = 0; i < 20; ++i) {
    let t = new Derived();

    for (var j = 0; j < 20; ++j) {
        t.do_test_getprop();
        t.do_test_getelem();
    }
}