[pypy-svn] r22581 - pypy/dist/pypy/rpython/test

cfbolz at codespeak.net cfbolz at codespeak.net
Tue Jan 24 12:08:52 CET 2006


Author: cfbolz
Date: Tue Jan 24 12:08:50 2006
New Revision: 22581

Modified:
   pypy/dist/pypy/rpython/test/test_rgenop.py
Log:
(arigo, cfbolz):

another test for the new graph-generating functions that unfortunately didn't
catch any bugs.


Modified: pypy/dist/pypy/rpython/test/test_rgenop.py
==============================================================================
--- pypy/dist/pypy/rpython/test/test_rgenop.py	(original)
+++ pypy/dist/pypy/rpython/test/test_rgenop.py	Tue Jan 24 12:08:50 2006
@@ -3,6 +3,7 @@
 
 
 def test_square():
+    """def square(v0): return v0*v0"""
     startlink = newgraph("square")
     block = newblock()
     v0 = geninputarg(block, Signed)
@@ -13,3 +14,26 @@
 
     res = runlink(startlink, [17])
     assert res == 289
+
+def test_if():
+    """
+    def f(v0):
+        if v0 < 0:
+            return 0
+        else:
+            return v0
+    """
+    startlink = newgraph("if")
+    block = newblock()
+    v0 = geninputarg(block, Signed)
+    const0 = genconst(block, 0)
+    v1 = genop(block, 'int_lt', [v0, const0], Bool)
+    true_link = newreturnlink(block, const0)
+    false_link = newreturnlink(block, v0)
+    closeblock2(block, v1, false_link, true_link)
+    closelink(startlink, block)
+
+    res = runlink(startlink, [-1])
+    assert res == 0
+    res = runlink(startlink, [42])
+    assert res == 42



More information about the Pypy-commit mailing list