summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/fields/superproperty.js
blob: 406df449d602de5cda8491cf42328a7d591738ac (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
// SuperProperty syntax is allowed in fields.

class Base {
  get accessor() {
    return this.constructor.name;
  }
  method() {
    return this.constructor.name;
  }
}

class Derived extends Base {
  constructor() {
    super();
  }
  get accessor() {
    throw new Error("don't call this");
  }
  method() {
    throw new Error("don't call this");
  }
  field1 = super.accessor;
  field2 = super.method();
}

assertEq(new Derived().field1, "Derived");
assertEq(new Derived().field2, "Derived");

if (typeof reportCompare === "function") {
  reportCompare(true, true);
}