]> git.saurik.com Git - apple/javascriptcore.git/blob - tests/stress/infinite-loop-that-uses-captured-variables-but-they-do-not-escape.js
JavaScriptCore-7600.1.4.16.1.tar.gz
[apple/javascriptcore.git] / tests / stress / infinite-loop-that-uses-captured-variables-but-they-do-not-escape.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 "done";
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 (done) {
29 if (done != "done")
30 throw "Error: bad exception: " + done;
31 }
32 }
33