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

arigo at codespeak.net arigo at codespeak.net
Fri May 27 12:12:30 CEST 2005


Author: arigo
Date: Fri May 27 12:12:30 2005
New Revision: 12833

Modified:
   pypy/dist/pypy/annotation/binaryop.py
   pypy/dist/pypy/translator/test/test_annrpython.py
Log:
Fix a bug in the annotation of inplace_pow (thanks ericvrp).
Tests for pow and inplace_pow.


Modified: pypy/dist/pypy/annotation/binaryop.py
==============================================================================
--- pypy/dist/pypy/annotation/binaryop.py	(original)
+++ pypy/dist/pypy/annotation/binaryop.py	Fri May 27 12:12:30 2005
@@ -84,7 +84,8 @@
     def inplace_floordiv((obj1, obj2)): return pair(obj1, obj2).floordiv()
     def inplace_div((obj1, obj2)):      return pair(obj1, obj2).div()
     def inplace_mod((obj1, obj2)):      return pair(obj1, obj2).mod()
-    def inplace_pow((obj1, obj2), obj3):return pair(obj1, obj2).pow(obj3)
+    def inplace_pow((obj1, obj2)):      return pair(obj1, obj2).pow(
+                                                      SomePBC({None: True}))
     def inplace_lshift((obj1, obj2)):   return pair(obj1, obj2).lshift()
     def inplace_rshift((obj1, obj2)):   return pair(obj1, obj2).rshift()
     def inplace_and((obj1, obj2)):      return pair(obj1, obj2).and_()

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 May 27 12:12:30 2005
@@ -1037,7 +1037,15 @@
         finally:
             sys.argv = oldvalue
         assert s is not None
-            
+
+    def test_pow(self):
+        def f(n):
+            n **= 2
+            return 2 ** n
+        a = self.RPythonAnnotator()
+        s = a.build_types(f, [int])
+        # result should be an integer
+        assert s.knowntype == int
 
 
 def g(n):



More information about the Pypy-commit mailing list