[pypy-commit] pypy default: Write a test_pypy_c checking that "f ** 2" gets us just a float_mul

arigo noreply at buildbot.pypy.org
Sun Jan 22 12:31:00 CET 2012


Author: Armin Rigo <arigo at tunes.org>
Branch: 
Changeset: r51643:e82f6594d309
Date: 2012-01-22 12:30 +0100
http://bitbucket.org/pypy/pypy/changeset/e82f6594d309/

Log:	Write a test_pypy_c checking that "f ** 2" gets us just a float_mul
	operation. (Needs to check if the test really passes or if we are
	getting a few extra stuff too.)

diff --git a/pypy/module/pypyjit/test_pypy_c/test_math.py b/pypy/module/pypyjit/test_pypy_c/test_math.py
--- a/pypy/module/pypyjit/test_pypy_c/test_math.py
+++ b/pypy/module/pypyjit/test_pypy_c/test_math.py
@@ -90,3 +90,18 @@
             --TICK--
             jump(..., descr=)
         """)
+
+    def test_pow_two(self):
+        def main(n):
+            s = 0.123
+            while n > 0:
+                s -= s ** 2   # ID: pow
+                n -= 1
+            return s
+        log = self.run(main, [500])
+        assert abs(log.result - main(500)) < 1e-9
+        loop, = log.loops_by_filename(self.filepath)
+        assert loop.match_by_id("pow", """
+            f2 = float_mul(f1, f1)
+            f3 = float_sub(f1, f2)
+        """)


More information about the pypy-commit mailing list