]> git.saurik.com Git - apple/javascriptcore.git/blob - tests/stress/tricky-infinite-loop-that-uses-captured-variables.js
JavaScriptCore-7601.1.46.3.tar.gz
[apple/javascriptcore.git] / tests / stress / tricky-infinite-loop-that-uses-captured-variables.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 foo(a) {
13 var x = a + 1;
14 for (;;) {
15 bar(function() { return x; });
16 }
17 }
18
19 noInline(foo);
20
21 for (var i = 0; i < 10000; ++i) {
22 try {
23 foo(i);
24 } catch (f) {
25 var result = f();
26 if (result != i + 1)
27 throw "Error: bad result for i = " + i + ": " + result;
28 }
29 }
30