[pypy-commit] lang-scheme default: Implement String equal

boemmels noreply at buildbot.pypy.org
Sat Dec 3 18:21:58 CET 2011


Author: Juergen Boemmels <boemmels at web.de>
Branch: 
Changeset: r23:d188b009732f
Date: 2011-11-29 23:02 +0100
http://bitbucket.org/pypy/lang-scheme/changeset/d188b009732f/

Log:	Implement String equal

diff --git a/scheme/object.py b/scheme/object.py
--- a/scheme/object.py
+++ b/scheme/object.py
@@ -143,6 +143,11 @@
     def __repr__(self):
         return "<W_String \"" + self.strval + "\">"
 
+    def equal(self, w_obj):
+        if not isinstance(w_obj, W_String):
+            return False
+        return self.strval == w_obj.strval
+
 _charname_to_char = {
     'space': ' ',
     'newline': '\n',
diff --git a/scheme/test/test_object.py b/scheme/test/test_object.py
--- a/scheme/test/test_object.py
+++ b/scheme/test/test_object.py
@@ -24,6 +24,11 @@
     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)
 
 def test_char():
     c = 'x'


More information about the pypy-commit mailing list