[pypy-svn] r42219 - in pypy/branch/pypy-string-formatting/rpython: . test

arigo at codespeak.net arigo at codespeak.net
Fri Apr 20 21:40:51 CEST 2007


Author: arigo
Date: Fri Apr 20 21:40:50 2007
New Revision: 42219

Modified:
   pypy/branch/pypy-string-formatting/rpython/rstr.py
   pypy/branch/pypy-string-formatting/rpython/test/test_rstr.py
Log:
Support == and != between a character and a unichar.


Modified: pypy/branch/pypy-string-formatting/rpython/rstr.py
==============================================================================
--- pypy/branch/pypy-string-formatting/rpython/rstr.py	(original)
+++ pypy/branch/pypy-string-formatting/rpython/rstr.py	Fri Apr 20 21:40:50 2007
@@ -462,7 +462,9 @@
         return hop.genop('cast_unichar_to_int', vlist, resulttype=Signed)
 
 
-class __extend__(pairtype(AbstractUniCharRepr, AbstractUniCharRepr)):
+class __extend__(pairtype(AbstractUniCharRepr, AbstractUniCharRepr),
+                 pairtype(AbstractCharRepr, AbstractUniCharRepr),
+                 pairtype(AbstractUniCharRepr, AbstractCharRepr)):
     def rtype_eq(_, hop): return _rtype_unchr_compare_template(hop, 'eq')
     def rtype_ne(_, hop): return _rtype_unchr_compare_template(hop, 'ne')
 ##    def rtype_lt(_, hop): return _rtype_unchr_compare_template(hop, 'lt')

Modified: pypy/branch/pypy-string-formatting/rpython/test/test_rstr.py
==============================================================================
--- pypy/branch/pypy-string-formatting/rpython/test/test_rstr.py	(original)
+++ pypy/branch/pypy-string-formatting/rpython/test/test_rstr.py	Fri Apr 20 21:40:50 2007
@@ -160,6 +160,14 @@
         assert self.interpret(fn, [65]) == 65
         assert self.interpret(fn, [-5555]) == 5555
 
+    def test_char_unichar_eq(self):
+        def fn(c1, c2):
+            return c1 == c2
+        assert self.interpret(fn, [u'(', '(']) == True
+        assert self.interpret(fn, [u'\u1028', '(']) == False
+        assert self.interpret(fn, ['(', u'(']) == True
+        assert self.interpret(fn, ['(', u'\u1028']) == False
+
     def test_is_none(self):
         def fn(i):
             s1 = ['foo', None][i]



More information about the Pypy-commit mailing list