[pypy-svn] r48341 - in pypy/branch/pypy-rpython-unicode/annotation: . test

fijal at codespeak.net fijal at codespeak.net
Tue Nov 6 17:10:38 CET 2007


Author: fijal
Date: Tue Nov  6 17:10:38 2007
New Revision: 48341

Modified:
   pypy/branch/pypy-rpython-unicode/annotation/test/test_annrpython.py
   pypy/branch/pypy-rpython-unicode/annotation/unaryop.py
Log:
Expose string methods to unicode strings


Modified: pypy/branch/pypy-rpython-unicode/annotation/test/test_annrpython.py
==============================================================================
--- pypy/branch/pypy-rpython-unicode/annotation/test/test_annrpython.py	(original)
+++ pypy/branch/pypy-rpython-unicode/annotation/test/test_annrpython.py	Tue Nov  6 17:10:38 2007
@@ -2918,7 +2918,15 @@
         assert isinstance(s, annmodel.SomeUnicodeString)
         a = self.RPythonAnnotator()
         s = a.build_types(f, [int])
-        assert isinstance(s, annmodel.SomeUnicodeString)            
+        assert isinstance(s, annmodel.SomeUnicodeString)
+
+    def test_unicode_startswith(self):
+        def f(x):
+            return u'xxxx'.replace(x, u'z')
+
+        a = self.RPythonAnnotator()
+        s = a.build_types(f, [unicode])
+        assert isinstance(s, annmodel.SomeUnicodeString)
 
 
 def g(n):

Modified: pypy/branch/pypy-rpython-unicode/annotation/unaryop.py
==============================================================================
--- pypy/branch/pypy-rpython-unicode/annotation/unaryop.py	(original)
+++ pypy/branch/pypy-rpython-unicode/annotation/unaryop.py	Tue Nov  6 17:10:38 2007
@@ -410,7 +410,8 @@
         return s_Bool
 
 
-class __extend__(SomeString):
+class __extend__(SomeString,
+                 SomeUnicodeString):
 
     def method_startswith(str, frag):
         return s_Bool
@@ -441,7 +442,7 @@
         s_item = s_list.listdef.read_item()
         if isinstance(s_item, SomeImpossibleValue):
             return immutablevalue("")
-        return SomeString()
+        return str.__class__()
 
     def iter(str):
         return SomeIterator(str)
@@ -458,16 +459,16 @@
 
     def method_split(str, patt): # XXX
         getbookkeeper().count("str_split", str, patt)
-        return getbookkeeper().newlist(SomeString())
+        return getbookkeeper().newlist(str.__class__())
 
     def method_replace(str, s1, s2):
-        return SomeString()
+        return str.__class__()
 
     def method_lower(str):
-        return SomeString()
+        return str.__class__()
 
     def method_upper(str):
-        return SomeString()
+        return str.__class__()
 
 
 class __extend__(SomeChar):



More information about the Pypy-commit mailing list