Author: David Schneider <david.schnei...@picle.org>
Branch: arm-backend-2
Changeset: r45107:1f2325fdd7c9
Date: 2011-06-24 17:17 +0200
http://bitbucket.org/pypy/pypy/changeset/1f2325fdd7c9/

Log:    add test for jit rewriting of math.sqrt

diff --git a/pypy/jit/backend/test/runner_test.py 
b/pypy/jit/backend/test/runner_test.py
--- a/pypy/jit/backend/test/runner_test.py
+++ b/pypy/jit/backend/test/runner_test.py
@@ -2554,6 +2554,29 @@
         assert mem2 < mem1
         assert mem2 == mem0
 
+    def test_math_sqrt(self):
+        if not self.cpu.supports_floats:
+            py.test.skip("requires floats")
+
+        def math_sqrt(a):
+            assert False, 'should not be called'
+        from pypy.jit.codewriter.effectinfo import EffectInfo
+
+        effectinfo = EffectInfo([], [], [], EffectInfo.EF_CAN_RAISE, 
EffectInfo.OS_MATH_SQRT)
+        FPTR = self.Ptr(self.FuncType([lltype.Float], lltype.Float))
+        func_ptr = llhelper(FPTR, math_sqrt)
+        FUNC = deref(FPTR)
+        funcbox = self.get_funcbox(self.cpu, func_ptr)
+
+        calldescr = self.cpu.calldescrof(FUNC, FUNC.ARGS, FUNC.RESULT, 
effectinfo)
+        testcases = [(4.0, 2.0), (6.25, 2.5)]
+        for arg, expected in testcases:
+            res = self.execute_operation(rop.CALL, 
+                        [funcbox, boxfloat(arg)],
+                         'float', descr=calldescr)
+            assert res.getfloat() == expected
+
+
 
 class OOtypeBackendTest(BaseBackendTest):
 
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to