[pypy-svn] r57903 - pypy/dist/pypy/translator/c/test

pedronis at codespeak.net pedronis at codespeak.net
Sat Sep 6 20:49:43 CEST 2008


Author: pedronis
Date: Sat Sep  6 20:49:41 2008
New Revision: 57903

Modified:
   pypy/dist/pypy/translator/c/test/test_typed.py
Log:
a recent gcc was happily tail optimizing these into failure, make them non tail-recursive



Modified: pypy/dist/pypy/translator/c/test/test_typed.py
==============================================================================
--- pypy/dist/pypy/translator/c/test/test_typed.py	(original)
+++ pypy/dist/pypy/translator/c/test/test_typed.py	Sat Sep  6 20:49:41 2008
@@ -684,21 +684,21 @@
         assert fn() == 1
 
     def test_recursion_detection(self):
-        def f(n, accum):
+        def f(n):
             if n == 0:
-                return accum
+                return 1
             else:
-                return f(n-1, accum*n)
-        fn = self.getcompiled(f, [int, int])
-        assert fn(7, 1) == 5040
-        assert fn(7, 1) == 5040    # detection must work several times, too
-        assert fn(7, 1) == 5040
-        py.test.raises(RuntimeError, fn, -1, 0)
+                return n*f(n-1)
+        fn = self.getcompiled(f, [int])
+        assert fn(7) == 5040
+        assert fn(7) == 5040    # detection must work several times, too
+        assert fn(7) == 5040
+        py.test.raises(RuntimeError, fn, -1)
 
     def test_infinite_recursion(self):
         def f(x):
             if x:
-                return f(x)
+                return 1+f(x)
             return 1
         def g(x):
             try:



More information about the Pypy-commit mailing list