[pypy-svn] r54638 - in pypy/branch/io-improvements/pypy/rlib: . test
fijal at codespeak.net
fijal at codespeak.net
Sat May 10 22:07:25 CEST 2008
Author: fijal
Date: Sat May 10 22:07:24 2008
New Revision: 54638
Modified:
pypy/branch/io-improvements/pypy/rlib/rstring.py
pypy/branch/io-improvements/pypy/rlib/test/test_rstring.py
Log:
add an append_multiple_char operation as well
Modified: pypy/branch/io-improvements/pypy/rlib/rstring.py
==============================================================================
--- pypy/branch/io-improvements/pypy/rlib/rstring.py (original)
+++ pypy/branch/io-improvements/pypy/rlib/rstring.py Sat May 10 22:07:24 2008
@@ -17,6 +17,9 @@
def append_slice(self, s, start, end):
self.l.append(s[start:end])
+ def append_multiple_char(self, c, times):
+ self.l.append(c * times)
+
class StringBuilder(AbstractStringBuilder):
def build(self):
return "".join(self.l)
Modified: pypy/branch/io-improvements/pypy/rlib/test/test_rstring.py
==============================================================================
--- pypy/branch/io-improvements/pypy/rlib/test/test_rstring.py (original)
+++ pypy/branch/io-improvements/pypy/rlib/test/test_rstring.py Sat May 10 22:07:24 2008
@@ -7,12 +7,14 @@
s.append("abc")
s.append("a")
s.append_slice("abc", 1, 2)
- assert s.build() == "aabcab"
+ s.append_multiple_char('d', 4)
+ assert s.build() == "aabcabdddd"
def test_unicode_builder():
s = UnicodeBuilder()
s.append(u'a')
s.append(u'abc')
s.append_slice(u'abcdef', 1, 2)
- assert s.build() == 'aabcb'
+ s.append_multiple_char('d', 4)
+ assert s.build() == 'aabcbdddd'
assert isinstance(s.build(), unicode)
More information about the Pypy-commit
mailing list