[pypy-svn] r42002 - in pypy/dist/pypy/rpython: lltypesystem test

fijal at codespeak.net fijal at codespeak.net
Thu Apr 12 14:36:08 CEST 2007


Author: fijal
Date: Thu Apr 12 14:36:07 2007
New Revision: 42002

Modified:
   pypy/dist/pypy/rpython/lltypesystem/rstr.py
   pypy/dist/pypy/rpython/test/test_rstr.py
Log:
Support for 'x' * negative, apparently this worked in ootypesystem
before (not sure if backends support it though)


Modified: pypy/dist/pypy/rpython/lltypesystem/rstr.py
==============================================================================
--- pypy/dist/pypy/rpython/lltypesystem/rstr.py	(original)
+++ pypy/dist/pypy/rpython/lltypesystem/rstr.py	Thu Apr 12 14:36:07 2007
@@ -149,6 +149,8 @@
 class LLHelpers(AbstractLLHelpers):
 
     def ll_char_mul(ch, times):
+        if times < 0:
+            times = 0
         newstr = mallocstr(times)
         j = 0
         while j < times:

Modified: pypy/dist/pypy/rpython/test/test_rstr.py
==============================================================================
--- pypy/dist/pypy/rpython/test/test_rstr.py	(original)
+++ pypy/dist/pypy/rpython/test/test_rstr.py	Thu Apr 12 14:36:07 2007
@@ -600,6 +600,13 @@
         res = self.interpret(f, ['a', 0])
         assert self.ll_to_string(res) == ""
 
+    def test_char_mul_negative(self):
+        def f(c):
+            return c * -3
+
+        res = self.interpret(f, ['a'])
+        assert self.ll_to_string(res) == ''
+
     def test_n_mul_char(self):
         def f(c, n):
             return n*c



More information about the Pypy-commit mailing list