summaryrefslogtreecommitdiffstats
path: root/js/src/tests/non262/class/bytecodePatternMatching.js
blob: 446184f805146126484eff37aab0cc85ff3e285f (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
// Constructors can't be called so we can't pattern match
// them in replace and sort.
function a() {
    var b = {a: "A"};

    class X {
        constructor(a) {
            return b[a]
        }
    };

    assertThrowsInstanceOf(() => "a".replace(/a/, X), TypeError);
}

function b() {
    class X {
        constructor(x, y) {
            return x - y;
        }
    }

    assertThrowsInstanceOf(() => [1, 2, 3].sort(X), TypeError);
}

a();
b();

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