[pypy-svn] rev 1029 - in pypy/trunk/src/pypy/objspace/std: . test
hpk at codespeak.net
hpk at codespeak.net
Tue Jun 24 12:00:12 CEST 2003
Author: hpk
Date: Tue Jun 24 12:00:12 2003
New Revision: 1029
Modified:
pypy/trunk/src/pypy/objspace/std/stringobject.py
pypy/trunk/src/pypy/objspace/std/test/test_stringobject.py
Log:
added an iter-method + test to strings.
Modified: pypy/trunk/src/pypy/objspace/std/stringobject.py
==============================================================================
--- pypy/trunk/src/pypy/objspace/std/stringobject.py (original)
+++ pypy/trunk/src/pypy/objspace/std/stringobject.py Tue Jun 24 12:00:12 2003
@@ -816,6 +816,9 @@
return w_str
+def iter__String(space, w_list):
+ import iterobject
+ return iterobject.W_SeqIterObject(space, w_list)
def repr__String(space, w_str):
# XXX this is bogus -- mwh
Modified: pypy/trunk/src/pypy/objspace/std/test/test_stringobject.py
==============================================================================
--- pypy/trunk/src/pypy/objspace/std/test/test_stringobject.py (original)
+++ pypy/trunk/src/pypy/objspace/std/test/test_stringobject.py Tue Jun 24 12:00:12 2003
@@ -126,6 +126,9 @@
# self.assertEqual_w(w(s).ljust(5), w(s + " "))
class TestStringObject(test.AppTestCase):
+ def setUp(self):
+ self.space = test.objspace('std')
+
def test_split(self):
self.assertEquals("".split(), [])
self.assertEquals("a".split(), ['a'])
@@ -360,5 +363,11 @@
self.assertEquals("aaa AAA 111".swapcase(), "AAA aaa 111")
self.assertEquals("".swapcase(), "")
+ def test_iter(self):
+ l=[]
+ for i in iter("42"):
+ l.append(i)
+ self.assertEquals(l, ['4','2'])
+
if __name__ == '__main__':
test.main()
More information about the Pypy-commit
mailing list