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