[pypy-svn] r48793 - in pypy/branch/ropes-unicode/pypy/objspace/std: . test

cfbolz at codespeak.net cfbolz at codespeak.net
Mon Nov 19 15:55:17 CET 2007


Author: cfbolz
Date: Mon Nov 19 15:55:16 2007
New Revision: 48793

Modified:
   pypy/branch/ropes-unicode/pypy/objspace/std/ropeunicodeobject.py
   pypy/branch/ropes-unicode/pypy/objspace/std/test/test_unicodeobject.py
Log:
more bugs


Modified: pypy/branch/ropes-unicode/pypy/objspace/std/ropeunicodeobject.py
==============================================================================
--- pypy/branch/ropes-unicode/pypy/objspace/std/ropeunicodeobject.py	(original)
+++ pypy/branch/ropes-unicode/pypy/objspace/std/ropeunicodeobject.py	Mon Nov 19 15:55:16 2007
@@ -577,9 +577,9 @@
 def unicode_rfind__RopeUnicode_RopeUnicode_ANY_ANY(space, w_self, w_substr, w_start, w_end):
     self, start, end = _convert_idx_params(space, w_self, w_start, w_end)
     self = self.flatten_unicode()
-    sub = sub.flatten_unicode()
+    sub = w_substr._node.flatten_unicode()
     res = self.rfind(sub, start, end)
-    return wrapint(space, res)
+    return space.wrap(res)
 
 def unicode_index__RopeUnicode_RopeUnicode_ANY_ANY(space, w_self, w_substr, w_start, w_end):
     self, start, end = _convert_idx_params(space, w_self, w_start, w_end)
@@ -921,13 +921,13 @@
 
 def len__RopeUnicodeIter(space,  w_ropeiter):
     if w_ropeiter.node is None:
-        return wrapint(space, 0)
+        return space.wrap(0)
     index = w_ropeiter.index
     length = w_ropeiter.node.length()
     result = length - index
     if result < 0:
-        return wrapint(space, 0)
-    return wrapint(space, result)
+        return space.wrap(0)
+    return space.wrap(result)
 
 import unicodetype
 register_all(vars(), unicodetype)

Modified: pypy/branch/ropes-unicode/pypy/objspace/std/test/test_unicodeobject.py
==============================================================================
--- pypy/branch/ropes-unicode/pypy/objspace/std/test/test_unicodeobject.py	(original)
+++ pypy/branch/ropes-unicode/pypy/objspace/std/test/test_unicodeobject.py	Mon Nov 19 15:55:16 2007
@@ -520,3 +520,13 @@
         raises(TypeError, u'abcdefghijklmn'.rindex, u'abc', 0, 0.0)
         raises(TypeError, u'abcdefghijklmn'.rindex, u'abc', -10.0, 30)
 
+    def test_len_iter(self):
+        assert len(iter(u"abcdef\uffff")) == 7
+        for i in range(10):
+            assert len(iter(unicode(i))) == 1
+
+    def test_rfind(self):
+        assert u'abcdefghiabc'.rfind(u'abc') == 9
+        assert u'abcdefghiabc'.rfind(u'') == 12
+        assert u'abcdefghiabc'.rfind(u'abcd') == 0
+        assert u'abcdefghiabc'.rfind(u'abcz') == -1



More information about the Pypy-commit mailing list