X-Git-Url: https://git.saurik.com/apple/javascriptcore.git/blobdiff_plain/4be4e30906bcb8ee30b4d189205cb70bad6707ce..81345200c95645a1b0d2635520f96ad55dfde63f:/tests/stress/tricky-infinite-loop-that-uses-captured-variables.js diff --git a/tests/stress/tricky-infinite-loop-that-uses-captured-variables.js b/tests/stress/tricky-infinite-loop-that-uses-captured-variables.js new file mode 100644 index 0000000..3f79f07 --- /dev/null +++ b/tests/stress/tricky-infinite-loop-that-uses-captured-variables.js @@ -0,0 +1,30 @@ +var count = 0; + +function bar(f) { + if (++count < 10) + return; + count = 0; + throw f; +} + +noInline(bar); + +function foo(a) { + var x = a + 1; + for (;;) { + bar(function() { return x; }); + } +} + +noInline(foo); + +for (var i = 0; i < 10000; ++i) { + try { + foo(i); + } catch (f) { + var result = f(); + if (result != i + 1) + throw "Error: bad result for i = " + i + ": " + result; + } +} +