summaryrefslogtreecommitdiffstats
path: root/js/src/tests/non262/class/superPropDestructuring.js
blob: 84d1bb517a5bbc7dcc8abde4b2c20ce2d9818b11 (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
class base {
    constructor() { }
}

let seenValues;
Object.defineProperty(base.prototype, "minutes",
                      {
                        set(x) {
                            assertEq(x, 525600);
                            seenValues.push(x);
                        }
                      });
Object.defineProperty(base.prototype, "intendent",
                      {
                        set(x) {
                            assertEq(x, "Fred");
                            seenValues.push(x)
                        }
                      });

const testArr = [525600, "Fred"];
class derived extends base {
    constructor() { super(); }
    prepForTest() { seenValues = []; }
    testAsserts() { assertDeepEq(seenValues, testArr); }
    testProps() {
        this.prepForTest();
        [super.minutes, super.intendent] = testArr;
        this.testAsserts();
    }
    testElems() {
        this.prepForTest();
        [super["minutes"], super["intendent"]] = testArr;
        this.testAsserts();
    }
}

let d = new derived();
d.testProps();
d.testElems();

if (typeof reportCompare === 'function')
    reportCompare(0,0,"OK");