[pypy-svn] r48458 - in pypy/branch/pypy-rpython-unicode/rpython: ootypesystem test

fijal at codespeak.net fijal at codespeak.net
Thu Nov 8 23:37:42 CET 2007


Author: fijal
Date: Thu Nov  8 23:37:41 2007
New Revision: 48458

Modified:
   pypy/branch/pypy-rpython-unicode/rpython/ootypesystem/rstr.py
   pypy/branch/pypy-rpython-unicode/rpython/test/test_runicode.py
Log:
Yay! Turn on ootypesystem tests, as they're passing


Modified: pypy/branch/pypy-rpython-unicode/rpython/ootypesystem/rstr.py
==============================================================================
--- pypy/branch/pypy-rpython-unicode/rpython/ootypesystem/rstr.py	(original)
+++ pypy/branch/pypy-rpython-unicode/rpython/ootypesystem/rstr.py	Thu Nov  8 23:37:41 2007
@@ -4,7 +4,8 @@
      AbstractUniCharRepr, AbstractStringIteratorRepr,\
      AbstractLLHelpers, AbstractUnicodeRepr
 from pypy.rpython.rmodel import IntegerRepr
-from pypy.rpython.lltypesystem.lltype import Ptr, Char, UniChar, typeOf
+from pypy.rpython.lltypesystem.lltype import Ptr, Char, UniChar, typeOf,\
+     cast_primitive
 from pypy.rpython.ootypesystem import ootype
 from pypy.rpython.rmodel import Repr
 
@@ -54,6 +55,17 @@
     def make_string(self, value):
         return ootype.make_unicode(value)
 
+    def ll_str(self, value):
+        sb = ootype.new(ootype.StringBuilder)
+        lgt = value.ll_strlen()
+        sb.ll_allocate(lgt)
+        for i in range(lgt):
+            c = value.ll_stritem_nonneg(i)
+            if ord(c) > 127:
+                raise ValueError("%d > 127, not ascii" % ord(c))
+            sb.ll_append_char(cast_primitive(Char, c))
+        return sb.ll_build()
+
 class CharRepr(AbstractCharRepr, StringRepr):
     lowleveltype = Char
 
@@ -78,7 +90,7 @@
         lgt = s.ll_strlen()
         res.ll_allocate(lgt)
         for i in range(lgt):
-            res.ll_append_char(s.ll_stritem_nonneg(i))
+            res.ll_append_char(cast_primitive(UniChar, s.ll_stritem_nonneg(i)))
         return res.ll_build()
 
     def ll_unichr2unicode(ch):

Modified: pypy/branch/pypy-rpython-unicode/rpython/test/test_runicode.py
==============================================================================
--- pypy/branch/pypy-rpython-unicode/rpython/test/test_runicode.py	(original)
+++ pypy/branch/pypy-rpython-unicode/rpython/test/test_runicode.py	Thu Nov  8 23:37:41 2007
@@ -130,5 +130,5 @@
 class TestLLtype(BaseTestRUnicode, LLRtypeMixin):
     EMPTY_STRING_HASH = -1
 
-#class TestOOtype(BaseTestRUnicode, OORtypeMixin):
-#    pass
+class TestOOtype(BaseTestRUnicode, OORtypeMixin):
+    EMPTY_STRING_HASH = 0



More information about the Pypy-commit mailing list