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

// lies and the lying liars who tell them
function lies() { }
lies.prototype = 4;

assertThrowsInstanceOf(()=>Reflect.consruct(base, [], lies), TypeError);

// lie a slightly different way
function get(target, property, receiver) {
    if (property === "prototype")
        return 42;
    return Reflect.get(target, property, receiver);
}

class inst extends base {
    constructor() { super(); }
}
assertThrowsInstanceOf(()=>new new Proxy(inst, {get})(), TypeError);

class defaultInst extends base {}
assertThrowsInstanceOf(()=>new new Proxy(defaultInst, {get})(), TypeError);

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