]> git.saurik.com Git - apple/javascriptcore.git/blob - tests/stress/inferred-infinite-loop-that-uses-captured-variables.js
733dbf1af07454ae996fd7c3009b01b1079dff24
[apple/javascriptcore.git] / tests / stress / inferred-infinite-loop-that-uses-captured-variables.js
1 function bar(f) {
2 throw f;
3 }
4
5 noInline(bar);
6
7 var shouldContinue = true;
8
9 function foo(a) {
10 var x = a + 1;
11 while (shouldContinue) {
12 bar(function() { return x; });
13 }
14 }
15
16 noInline(foo);
17
18 for (var i = 0; i < 10000; ++i) {
19 try {
20 foo(i);
21 } catch (f) {
22 var result = f();
23 if (result != i + 1)
24 throw "Error: bad result for i = " + i + ": " + result;
25 }
26 }
27