summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/ion/call-generic-throw.js
blob: 3d04259b59ce24beec905f43af18f3377b526a8e (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
// Verify that we throw when calling/constructing functions that must be
// constructed/called.

function foo(f) {
  f();
}

function new_foo(f) {
  new f();
}

with ({}) {}

function f1() {}
function f2() {}

// Ion-compile the generic trampoline.
for (var i = 0; i < 1000; i++) {
  foo(f1);
  foo(f2);
  new_foo(f1);
  new_foo(f2);
}

class A {}
class B extends A {}
var caught_constructor = false;
try {
  foo(B);
} catch {
  caught_constructor = true;
}
assertEq(caught_constructor, true);

var caught_non_constructor = false;
try {
  new_foo(() => {});
} catch {
  caught_non_constructor = true;
}
assertEq(caught_non_constructor, true);