]> git.saurik.com Git - apple/javascriptcore.git/blob - tests/stress/tricky-indirectly-inferred-infinite-loop-that-uses-captured-variables-and-creates-the-activation-outside-the-loop.js
JavaScriptCore-7601.1.46.3.tar.gz
[apple/javascriptcore.git] / tests / stress / tricky-indirectly-inferred-infinite-loop-that-uses-captured-variables-and-creates-the-activation-outside-the-loop.js
1 var count = 0;
2
3 function bar(f) {
4 if (++count < 10)
5 return;
6 count = 0;
7 throw f;
8 }
9
10 noInline(bar);
11
12 function fuzz(a) {
13 return a != true;
14 }
15
16 function foo(a) {
17 var x = a + 1;
18 var y = a + 2;
19 var f = (function() { return x; });
20 while (fuzz(y)) {
21 bar(f);
22 }
23 }
24
25 noInline(foo);
26
27 for (var i = 0; i < 10000; ++i) {
28 try {
29 foo(i);
30 } catch (f) {
31 var result = f();
32 if (result != i + 1)
33 throw "Error: bad result for i = " + i + ": " + result;
34 }
35 }
36