[pypy-svn] r31905 - pypy/dist/pypy/annotation/test

arigo at codespeak.net arigo at codespeak.net
Fri Sep 1 09:50:07 CEST 2006


Author: arigo
Date: Fri Sep  1 09:50:06 2006
New Revision: 31905

Modified:
   pypy/dist/pypy/annotation/test/test_annrpython.py
Log:
A pair of (passing) tests about range() returning a list of nonneg
integers.



Modified: pypy/dist/pypy/annotation/test/test_annrpython.py
==============================================================================
--- pypy/dist/pypy/annotation/test/test_annrpython.py	(original)
+++ pypy/dist/pypy/annotation/test/test_annrpython.py	Fri Sep  1 09:50:06 2006
@@ -2284,6 +2284,30 @@
         self.show(a)
         assert isinstance(s, annmodel.SomeChar)
 
+    def test_range_nonneg(self):
+        def fun(n, k):
+            for i in range(n):
+                if k == 17:
+                    return i
+            return 0
+        a = self.RPythonAnnotator()
+        s = a.build_types(fun, [int, int])
+        self.show(a)
+        assert isinstance(s, annmodel.SomeInteger)
+        assert s.nonneg
+
+    def test_reverse_range_nonneg(self):
+        def fun(n, k):
+            for i in range(n-1, -1, -1):
+                if k == 17:
+                    return i
+            return 0
+        a = self.RPythonAnnotator()
+        s = a.build_types(fun, [int, int])
+        self.show(a)
+        assert isinstance(s, annmodel.SomeInteger)
+        assert s.nonneg
+
 def g(n):
     return [0,1,2,n]
 



More information about the Pypy-commit mailing list