[pypy-commit] pypy numpy-minilang: a test and a fix. took a while :/
fijal
noreply at buildbot.pypy.org
Fri Oct 28 00:01:10 CEST 2011
Author: Maciej Fijalkowski <fijall at gmail.com>
Branch: numpy-minilang
Changeset: r48544:41172dd9df6f
Date: 2011-10-27 23:57 +0200
http://bitbucket.org/pypy/pypy/changeset/41172dd9df6f/
Log: a test and a fix. took a while :/
diff --git a/pypy/rpython/lltypesystem/rstr.py b/pypy/rpython/lltypesystem/rstr.py
--- a/pypy/rpython/lltypesystem/rstr.py
+++ b/pypy/rpython/lltypesystem/rstr.py
@@ -20,6 +20,7 @@
from pypy.rpython.rmodel import Repr
from pypy.rpython.lltypesystem import llmemory
from pypy.tool.sourcetools import func_with_new_name
+from pypy.rpython.lltypesystem.lloperation import llop
# ____________________________________________________________
#
@@ -366,6 +367,8 @@
if right:
while lpos < rpos and s.chars[rpos] == ch:
rpos -= 1
+ if rpos <= lpos:
+ return s.empty()
r_len = rpos - lpos + 1
result = s.malloc(r_len)
s.copy_contents(s, result, lpos, 0, r_len)
diff --git a/pypy/rpython/test/test_rstr.py b/pypy/rpython/test/test_rstr.py
--- a/pypy/rpython/test/test_rstr.py
+++ b/pypy/rpython/test/test_rstr.py
@@ -372,12 +372,16 @@
return const('!ab!').lstrip(const('!'))
def right():
return const('!ab!').rstrip(const('!'))
+ def empty():
+ return const(' ').strip(' ')
res = self.interpret(both, [])
assert self.ll_to_string(res) == const('ab')
res = self.interpret(left, [])
assert self.ll_to_string(res) == const('ab!')
res = self.interpret(right, [])
assert self.ll_to_string(res) == const('!ab')
+ res = self.interpret(empty, [])
+ assert self.ll_to_string(res) == const('')
def test_upper(self):
const = self.const
More information about the pypy-commit
mailing list