]> git.saurik.com Git - apple/javascriptcore.git/blobdiff - tests/stress/math-pow-becomes-custom-function.js
JavaScriptCore-7601.1.46.3.tar.gz
[apple/javascriptcore.git] / tests / stress / math-pow-becomes-custom-function.js
diff --git a/tests/stress/math-pow-becomes-custom-function.js b/tests/stress/math-pow-becomes-custom-function.js
new file mode 100644 (file)
index 0000000..8893acc
--- /dev/null
@@ -0,0 +1,18 @@
+function mathPowWrapper(x, y) {
+    return Math.pow(x, y);
+}
+noInline(mathPowWrapper);
+
+function testChangingMathPow() {
+    var result = 0;
+    for (var i = 0; i < 10000; ++i) {
+        result += mathPowWrapper(3, 2);
+    }
+    Math.pow = function(a, b) { return a + b; }
+    for (var i = 0; i < 10000; ++i) {
+        result += mathPowWrapper(3, 2);
+    }
+    if (result !== 140000)
+        throw "Result = " + result + ", expected 140000";
+}
+testChangingMathPow();
\ No newline at end of file