]> git.saurik.com Git - apple/javascriptcore.git/blobdiff - tests/stress/infinite-loop-that-uses-captured-variables-but-they-do-not-escape.js
JavaScriptCore-7600.1.4.9.tar.gz
[apple/javascriptcore.git] / tests / stress / infinite-loop-that-uses-captured-variables-but-they-do-not-escape.js
diff --git a/tests/stress/infinite-loop-that-uses-captured-variables-but-they-do-not-escape.js b/tests/stress/infinite-loop-that-uses-captured-variables-but-they-do-not-escape.js
new file mode 100644 (file)
index 0000000..ebce9fe
--- /dev/null
@@ -0,0 +1,33 @@
+var count = 0;
+
+function bar(f) {
+    if (++count < 10) {
+        var result = f();
+        if (result != i + 1)
+            throw "Error: bad result insie closure for i = " + i + ": " + result;
+        return;
+    }
+    count = 0;
+    throw "done";
+}
+
+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 (done) {
+        if (done != "done")
+            throw "Error: bad exception: " + done;
+    }
+}
+