Commits

Jürgen Bömmels  committed d333d80

Equality for Characters

  • Participants
  • Parent commits d188b00

Comments (0)

Files changed (2)

File scheme/object.py

     def __repr__(self):
         return "<W_Character #\\" + self.chrval + ">"
 
+    def eqv(self, w_obj):
+        if not isinstance(w_obj, W_Character):
+            return False
+        return self.chrval == w_obj.chrval
+    equal = eqv
+
 class W_Real(W_Root):
     def __init__(self, val):
         self.exact = False

File scheme/test/test_object.py

     w_str = W_String(str)
     assert str == w_str.to_string()
     assert w_str.to_repr() == r'''"\\ \\\\ \\' \" \\\""'''
+
     str1 = "foobar"
     w_str1 = W_String(str1)
     str2 = "foo" + "bar"
     w_str2 = W_String(str2)
     assert w_str1.equal(w_str2)
+    w_str2 = W_String("foo")
+    assert not w_str1.equal(w_str2)
+    w_sym = symbol(str1)
+    assert not w_str1.equal(w_str2)    
 
 def test_char():
     c = 'x'
     assert w_char.to_boolean() is True
     assert w_char.to_string() == ' '
     assert w_char.to_repr() == r'#\space'
+    assert w_char.eqv(W_Character(' '))
 
 def test_fixnum():
     num = 12345