Imported Upstream version 1.0.0
[platform/upstream/js.git] / js / src / jit-test / tests / basic / testStackQuotaExhausted.js
1 const numFatArgs = Math.pow(2,19) - 1024;
2
3 function fun(x) {
4     if (x <= 0)
5         return 0;
6     return fun(x-1);
7 }
8
9 function fatStack() {
10     return fun(10000);
11 }
12
13 function assertRightFailure(e) {
14     assertEq(e.toString() == "InternalError: script stack space quota is exhausted" ||
15              e.toString() == "InternalError: too much recursion",
16              true);
17 }
18
19 exception = false;
20 try {
21     fatStack.apply(null, new Array(numFatArgs));
22 } catch (e) {
23     assertRightFailure(e);
24     exception = true;
25 }
26 assertEq(exception, true);
27
28 // No more trace recursion w/ JM
29 checkStats({traceCompleted:0});