[pypy-svn] pypy default: port the first test from test_pypy_c to test_pypy_c_new :-)

antocuni commits-noreply at bitbucket.org
Tue Feb 22 17:41:33 CET 2011


Author: Antonio Cuni <anto.cuni at gmail.com>
Branch: 
Changeset: r42215:9cb986673405
Date: 2011-02-22 17:41 +0100
http://bitbucket.org/pypy/pypy/changeset/9cb986673405/

Log:	port the first test from test_pypy_c to test_pypy_c_new :-)

diff --git a/pypy/module/pypyjit/test_pypy_c/test_pypy_c_new.py b/pypy/module/pypyjit/test_pypy_c/test_pypy_c_new.py
--- a/pypy/module/pypyjit/test_pypy_c/test_pypy_c_new.py
+++ b/pypy/module/pypyjit/test_pypy_c/test_pypy_c_new.py
@@ -33,4 +33,34 @@
             )
 
 class TestPyPyCNew(BaseTestPyPyC):
-    pass
+
+    def test_f1(self):
+        def f1(n):
+            "Arbitrary test function."
+            i = 0
+            x = 1
+            while i<n:
+                j = 0
+                while j<=i:
+                    j = j + 1
+                    x = x + (i&j)
+                i = i + 1
+            return x
+        log = self.run(f1, [2117])
+        assert log.result == 1083876708
+        loop, = log.loops_by_filename(self.filepath)
+        assert loop.match("""
+            i9 = int_le(i7, i8)
+            guard_true(i9)
+            i11 = int_add_ovf(i7, 1)
+            guard_no_overflow()
+            i12 = int_and(i8, i11)
+            i13 = int_add_ovf(i6, i12)
+            guard_no_overflow()
+            i16 = getfield_raw(37212896)
+            i18 = int_sub(i16, 1)
+            setfield_raw(37212896, i18)
+            i20 = int_lt(i18, 0)
+            guard_false(i20)
+            jump(p0, p1, p2, p3, p4, p5, i13, i11, i8)
+        """)


More information about the Pypy-commit mailing list