]> git.saurik.com Git - apple/javascriptcore.git/blobdiff - tests/stress/throw-from-ftl.js
JavaScriptCore-7601.1.46.3.tar.gz
[apple/javascriptcore.git] / tests / stress / throw-from-ftl.js
diff --git a/tests/stress/throw-from-ftl.js b/tests/stress/throw-from-ftl.js
new file mode 100644 (file)
index 0000000..aac2e9e
--- /dev/null
@@ -0,0 +1,25 @@
+function foo(p) {
+    var o = {f:42};
+    if (p)
+        throw o;
+    return o;
+}
+
+noInline(foo);
+
+for (var i = 0; i < 100000; ++i) {
+    var o = foo(false);
+    if (o.f != 42)
+        throw "Error: bad result: " + o.f;
+}
+
+var didThrow = false;
+try {
+    foo(true);
+} catch (e) {
+    if (e.f != 42)
+        throw "Error: bad result in catch: " + o.f;
+    didThrow = true;
+}
+if (!didThrow)
+    throw "Error: should have thrown but didn't.";