]> git.saurik.com Git - apple/javascriptcore.git/blobdiff - tests/stress/ic-throw-through-optimized-code.js
JavaScriptCore-7600.1.4.9.tar.gz
[apple/javascriptcore.git] / tests / stress / ic-throw-through-optimized-code.js
diff --git a/tests/stress/ic-throw-through-optimized-code.js b/tests/stress/ic-throw-through-optimized-code.js
new file mode 100644 (file)
index 0000000..9640426
--- /dev/null
@@ -0,0 +1,29 @@
+function foo(o) {
+    return o.f + 1;
+}
+
+Number.prototype.f = 42;
+
+noInline(foo);
+
+for (var i = 0; i < 100000; ++i) {
+    var result = foo(23);
+    if (result != 43)
+        throw "Error: bad result: " + result;
+    result = foo({f:25});
+    if (result != 26)
+        throw "Error: bad result: " + result;
+    result = foo({g:12, f:13});
+    if (result != 14)
+        throw "Error: bad result: " + result;
+}
+
+var didThrow;
+try {
+    foo(void 0);
+} catch (e) {
+    didThrow = e;
+}
+
+if (!didThrow || didThrow.toString().indexOf("TypeError:") != 0)
+    throw "Error: didn't throw or threw wrong exception: " + didThrow;