Author: Lukas Diekmann <[email protected]>
Branch: 
Changeset: r44433:6230987c412f
Date: 2011-02-02 11:33 +0100
http://bitbucket.org/pypy/pypy/changeset/6230987c412f/

Log:    Implemented equals-Method for SmallTuples

diff --git a/.hgsub b/.hgsub
--- a/.hgsub
+++ b/.hgsub
@@ -1,4 +1,4 @@
-greenlet = [svn]http://codespeak.net/svn/greenlet/trunk/c
-testrunner = [svn]http://codespeak.net/svn/pypy/build/testrunner
-lib_pypy/pyrepl = [svn]http://codespeak.net/svn/pyrepl/trunk/pyrepl/pyrepl
-lib_pypy/sqlite3 = [svn]http://codespeak.net/svn/pypy/pysqlite2
+#greenlet = [svn]http://codespeak.net/svn/greenlet/trunk/c
+#testrunner = [svn]http://codespeak.net/svn/pypy/build/testrunner
+#lib_pypy/pyrepl = [svn]http://codespeak.net/svn/pyrepl/trunk/pyrepl/pyrepl
+#lib_pypy/sqlite3 = [svn]http://codespeak.net/svn/pypy/pysqlite2
diff --git a/pypy/objspace/std/smalltupleobject.py 
b/pypy/objspace/std/smalltupleobject.py
--- a/pypy/objspace/std/smalltupleobject.py
+++ b/pypy/objspace/std/smalltupleobject.py
@@ -101,5 +101,15 @@
 def mul__ANY_SmallTuple(space, w_times, w_tuple):
     return mul_smalltuple_times(space, w_tuple, w_times)
 
+def eq__SmallTuple_SmallTuple(space, w_tuple1, w_tuple2):
+    if w_tuple1.length() != w_tuple2.length():
+        return space.w_False
+    for i in range(w_tuple1.length()):
+        item1 = w_tuple1.getitem(i)
+        item2 = w_tuple2.getitem(i)
+        if not space.eq_w(item1, item2):
+            return space.w_False
+    return space.w_True
+
 from pypy.objspace.std import tupletype
 register_all(vars(), tupletype)
diff --git a/pypy/objspace/std/test/test_smalltupleobject.py 
b/pypy/objspace/std/test/test_smalltupleobject.py
--- a/pypy/objspace/std/test/test_smalltupleobject.py
+++ b/pypy/objspace/std/test/test_smalltupleobject.py
@@ -38,6 +38,11 @@
         assert (1,2)[0:1:1] == (1,)
         assert (1,2,3)[0:2:1] == (1,2)
 
+    def test_eq(self):
+        a = (1,2,3)
+        b = (1,2,3)
+        assert a == b
+
 class TestW_SmallTupleObject():
 
     def setup_class(cls):
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to