[pypy-svn] r34471 - in pypy/dist/pypy/rpython: lltypesystem test
cfbolz at codespeak.net
cfbolz at codespeak.net
Fri Nov 10 17:55:03 CET 2006
Author: cfbolz
Date: Fri Nov 10 17:55:01 2006
New Revision: 34471
Modified:
pypy/dist/pypy/rpython/lltypesystem/rstr.py
pypy/dist/pypy/rpython/test/test_rstr.py
Log:
oops. count was counting overlapping occurences of the substring.
Modified: pypy/dist/pypy/rpython/lltypesystem/rstr.py
==============================================================================
--- pypy/dist/pypy/rpython/lltypesystem/rstr.py (original)
+++ pypy/dist/pypy/rpython/lltypesystem/rstr.py Fri Nov 10 17:55:01 2006
@@ -489,8 +489,9 @@
i += 1
if i==len2:
result += 1
- else:
- continue
+ i = 0
+ m += len2
+ continue
# mismatch, go back to the last possible starting pos
if i==0:
m += 1
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 Fri Nov 10 17:55:01 2006
@@ -596,6 +596,12 @@
res = self.interpret(fn, [4])
assert res == 4 + 6 + 2
+ def test_count_overlapping_occurences(self):
+ def fn():
+ return 'ababa'.count('aba')
+ res = self.interpret(fn, [])
+ assert res == 1
+
def FIXME_test_str_to_pystringobj():
def f(n):
if n >= 0:
More information about the Pypy-commit
mailing list