Debian Codegraph @

js/src/jit-test/tests/ion/call-generic-throw.js

raw
1 // Verify that we throw when calling/constructing functions that must be
2 // constructed/called.
3
4 function foo(f) {
5 f();
6 }
7
8 function new_foo(f) {
9 new f();
10 }
11
12 with ({}) {}
13
14 function f1() {}
15 function f2() {}
16
17 // Ion-compile the generic trampoline.
18 for (var i = 0; i < 1000; i++) {
19 foo(f1);
20 foo(f2);
21 new_foo(f1);
22 new_foo(f2);
23 }
24
25 class A {}
26 class B extends A {}
27 var caught_constructor = false;
28 try {
29 foo(B);
30 } catch {
31 caught_constructor = true;
32 }
33 assertEq(caught_constructor, true);
34
35 var caught_non_constructor = false;
36 try {
37 new_foo(() => {});
38 } catch {
39 caught_non_constructor = true;
40 }
41 assertEq(caught_non_constructor, true);