[pypy-svn] r10669 - in pypy/dist/pypy: annotation translator/test

pedronis at codespeak.net pedronis at codespeak.net
Fri Apr 15 15:44:32 CEST 2005


Author: pedronis
Date: Fri Apr 15 15:44:32 2005
New Revision: 10669

Modified:
   pypy/dist/pypy/annotation/builtin.py
   pypy/dist/pypy/translator/test/test_annrpython.py
Log:
annotation for bool(.)



Modified: pypy/dist/pypy/annotation/builtin.py
==============================================================================
--- pypy/dist/pypy/annotation/builtin.py	(original)
+++ pypy/dist/pypy/annotation/builtin.py	Fri Apr 15 15:44:32 2005
@@ -24,6 +24,12 @@
 
 builtin_xrange = builtin_range # xxx for now allow it
 
+def builtin_bool(s_obj):
+    r = SomeBool()
+    if s_obj.is_constant():
+        r.const = bool(s_obj.const)
+    return r
+
 def builtin_int(s_obj):
     return SomeInteger()
 

Modified: pypy/dist/pypy/translator/test/test_annrpython.py
==============================================================================
--- pypy/dist/pypy/translator/test/test_annrpython.py	(original)
+++ pypy/dist/pypy/translator/test/test_annrpython.py	Fri Apr 15 15:44:32 2005
@@ -710,6 +710,13 @@
         s = a.build_types(snippet.harmonic, [int])
         assert s.knowntype == float
 
+    def test_bool(self):
+        def f(a,b):
+            return bool(a) or bool(b)
+        a = RPythonAnnotator()
+        s = a.build_types(f, [int,list])
+        assert s.knowntype == bool
+
     def test_float(self):
         def f(n):
             return float(n)



More information about the Pypy-commit mailing list