| function shouldThrow(func, errorMessage) { |
| throw new Error('not thrown'); |
| if (String(error) !== errorMessage) |
| throw new Error(`bad error: ${String(error)}`); |
| return sloppyLoop(n - 1); |
| return strictLoop(n - 1); |
| // We have two of these so that we can test different stack alignments |
| function strictLoopArityFixup1(n, dummy) { |
| return strictLoopArityFixup1(n - 1); |
| function strictLoopArityFixup2(n, dummy1, dummy2) { |
| return strictLoopArityFixup2(n - 1); |
| shouldThrow(function () { sloppyLoop(100000); }, 'RangeError: Maximum call stack size exceeded.'); |
| // These should not throw |
| strictLoopArityFixup1(1000000); |
| strictLoopArityFixup2(1000000); |