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