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

pedronis at codespeak.net pedronis at codespeak.net
Fri Apr 15 16:28:20 CEST 2005


Author: pedronis
Date: Fri Apr 15 16:28:19 2005
New Revision: 10674

Modified:
   pypy/dist/pypy/annotation/binaryop.py
   pypy/dist/pypy/translator/test/test_annrpython.py
Log:
for now support annotating str*int, int*str



Modified: pypy/dist/pypy/annotation/binaryop.py
==============================================================================
--- pypy/dist/pypy/annotation/binaryop.py	(original)
+++ pypy/dist/pypy/annotation/binaryop.py	Fri Apr 15 16:28:19 2005
@@ -317,6 +317,13 @@
     def getitem((str1, int2)):
         return SomeChar()
 
+    def mul((str1, int2)): # xxx do we want to support this
+        return SomeString()
+
+class __extend__(pairtype(SomeInteger, SomeString)):
+    
+    def mul((int1, str2)): # xxx do we want to support this
+        return SomeString()
 
 class __extend__(pairtype(SomeInteger, SomeList)):
     

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 16:28:19 2005
@@ -841,7 +841,13 @@
         s = a.build_types(f, [])
         assert s.knowntype == list
         assert s.s_item.knowntype == T
-          
+
+    def test_int_str_mul(self):
+        def f(x,a,b):
+            return a*x+x*b
+        a = RPythonAnnotator()
+        s = a.build_types(f, [str,int,int])
+        assert s.knowntype == str
 
 
 def g(n):



More information about the Pypy-commit mailing list