[pypy-svn] r48365 - in pypy/branch/pypy-rpython-unicode/rpython: . lltypesystem test

fijal at codespeak.net fijal at codespeak.net
Wed Nov 7 16:23:08 CET 2007


Author: fijal
Date: Wed Nov  7 16:23:07 2007
New Revision: 48365

Modified:
   pypy/branch/pypy-rpython-unicode/rpython/lltypesystem/rstr.py
   pypy/branch/pypy-rpython-unicode/rpython/rstr.py
   pypy/branch/pypy-rpython-unicode/rpython/test/test_rstr.py
   pypy/branch/pypy-rpython-unicode/rpython/test/test_runicode.py
Log:
One test passing, one skipped


Modified: pypy/branch/pypy-rpython-unicode/rpython/lltypesystem/rstr.py
==============================================================================
--- pypy/branch/pypy-rpython-unicode/rpython/lltypesystem/rstr.py	(original)
+++ pypy/branch/pypy-rpython-unicode/rpython/lltypesystem/rstr.py	Wed Nov  7 16:23:07 2007
@@ -802,7 +802,9 @@
 UnicodeRepr.repr = unicode_repr
 UniCharRepr.repr = unicode_repr
 UniCharRepr.char_repr = unichar_repr
+UnicodeRepr.char_repr = unichar_repr
 CharRepr.char_repr = char_repr
+StringRepr.char_repr = char_repr
 
 class BaseStringIteratorRepr(AbstractStringIteratorRepr):
 

Modified: pypy/branch/pypy-rpython-unicode/rpython/rstr.py
==============================================================================
--- pypy/branch/pypy-rpython-unicode/rpython/rstr.py	(original)
+++ pypy/branch/pypy-rpython-unicode/rpython/rstr.py	Wed Nov  7 16:23:07 2007
@@ -312,48 +312,43 @@
     rtype_inplace_add = rtype_add
 
     def rtype_eq((r_str1, r_str2), hop):
-        string_repr = hop.rtyper.type_system.rstr.string_repr
-        v_str1, v_str2 = hop.inputargs(string_repr, string_repr)
+        v_str1, v_str2 = hop.inputargs(r_str1.repr, r_str2.repr)
         return hop.gendirectcall(r_str1.ll.ll_streq, v_str1, v_str2)
     
     def rtype_ne((r_str1, r_str2), hop):
-        string_repr = hop.rtyper.type_system.rstr.string_repr
-        v_str1, v_str2 = hop.inputargs(string_repr, string_repr)
+        v_str1, v_str2 = hop.inputargs(r_str1.repr, r_str2.repr)
         vres = hop.gendirectcall(r_str1.ll.ll_streq, v_str1, v_str2)
         return hop.genop('bool_not', [vres], resulttype=Bool)
 
     def rtype_lt((r_str1, r_str2), hop):
-        string_repr = hop.rtyper.type_system.rstr.string_repr
-        v_str1, v_str2 = hop.inputargs(string_repr, string_repr)
+        v_str1, v_str2 = hop.inputargs(r_str1.repr, r_str2.repr)
         vres = hop.gendirectcall(r_str1.ll.ll_strcmp, v_str1, v_str2)
         return hop.genop('int_lt', [vres, hop.inputconst(Signed, 0)],
                          resulttype=Bool)
 
     def rtype_le((r_str1, r_str2), hop):
-        string_repr = hop.rtyper.type_system.rstr.string_repr
-        v_str1, v_str2 = hop.inputargs(string_repr, string_repr)
+        v_str1, v_str2 = hop.inputargs(r_str1.repr, r_str2.repr)
         vres = hop.gendirectcall(r_str1.ll.ll_strcmp, v_str1, v_str2)
         return hop.genop('int_le', [vres, hop.inputconst(Signed, 0)],
                          resulttype=Bool)
 
     def rtype_ge((r_str1, r_str2), hop):
-        string_repr = hop.rtyper.type_system.rstr.string_repr
-        v_str1, v_str2 = hop.inputargs(string_repr, string_repr)
+        v_str1, v_str2 = hop.inputargs(r_str1.repr, r_str2.repr)
         vres = hop.gendirectcall(r_str1.ll.ll_strcmp, v_str1, v_str2)
         return hop.genop('int_ge', [vres, hop.inputconst(Signed, 0)],
                          resulttype=Bool)
 
     def rtype_gt((r_str1, r_str2), hop):
-        string_repr = hop.rtyper.type_system.rstr.string_repr
-        v_str1, v_str2 = hop.inputargs(string_repr, string_repr)
+        v_str1, v_str2 = hop.inputargs(r_str1.repr, r_str2.repr)
         vres = hop.gendirectcall(r_str1.ll.ll_strcmp, v_str1, v_str2)
         return hop.genop('int_gt', [vres, hop.inputconst(Signed, 0)],
                          resulttype=Bool)
 
 class __extend__(pairtype(AbstractStringRepr, AbstractCharRepr)):
     def rtype_contains((r_str, r_chr), hop):
-        rstr = hop.rtyper.type_system.rstr
-        v_str, v_chr = hop.inputargs(rstr.string_repr, rstr.char_repr)
+        string_repr = r_str.repr
+        char_repr = r_chr.char_repr
+        v_str, v_chr = hop.inputargs(string_repr, char_repr)
         return hop.gendirectcall(r_str.ll.ll_contains, v_str, v_chr)
 
 class __extend__(pairtype(AbstractStringRepr, AbstractTupleRepr)):

Modified: pypy/branch/pypy-rpython-unicode/rpython/test/test_rstr.py
==============================================================================
--- pypy/branch/pypy-rpython-unicode/rpython/test/test_rstr.py	(original)
+++ pypy/branch/pypy-rpython-unicode/rpython/test/test_rstr.py	Wed Nov  7 16:23:07 2007
@@ -114,26 +114,31 @@
             assert res == fn(ch)
 
     def test_char_compare(self):
-        res = self.interpret(lambda c1, c2: c1 == c2,  ['a', 'b'])
+        const = self.const
+        res = self.interpret(lambda c1, c2: c1 == c2,  [const('a'),
+                                                        const('b')])
         assert res is False
-        res = self.interpret(lambda c1, c2: c1 == c2,  ['a', 'a'])
+        res = self.interpret(lambda c1, c2: c1 == c2,  [const('a'),
+                                                        const('a')])
         assert res is True
-        res = self.interpret(lambda c1, c2: c1 <= c2,  ['z', 'a'])
+        res = self.interpret(lambda c1, c2: c1 <= c2,  [const('z'),
+                                                        const('a')])
         assert res is False
 
     def test_char_mul(self):
+        const = self.const
         def fn(c, mul):
             s = c * mul
             res = 0
             for i in range(len(s)):
-                res = res*10 + ord(s[i]) - ord('0')
+                res = res*10 + ord(const(s[i])) - ord(const('0'))
             c2 = c
             c2 *= mul
             res = 10 * res + (c2 == s)
             return res
-        res = self.interpret(fn, ['3', 5])
+        res = self.interpret(fn, [const('3'), 5])
         assert res == 333331
-        res = self.interpret(fn, ['5', 3])
+        res = self.interpret(fn, [const('5'), 3])
         assert res == 5551
 
     def test_unichar_const(self):

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	Wed Nov  7 16:23:07 2007
@@ -13,5 +13,8 @@
     def test_char_isxxx(self):
         py.test.skip("not supported")
 
+    def test_char_mul(self):
+        py.test.skip("not supported by now")
+
 class TestLLtype(BaseTestRUnicode, LLRtypeMixin):
     pass



More information about the Pypy-commit mailing list