[pypy-commit] pypy set-strategies: added test and fix for inplace_or

l.diekmann noreply at buildbot.pypy.org
Thu Nov 10 13:49:20 CET 2011


Author: Lukas Diekmann <lukas.diekmann at uni-duesseldorf.de>
Branch: set-strategies
Changeset: r49139:24946aadee81
Date: 2011-05-01 17:03 +0200
http://bitbucket.org/pypy/pypy/changeset/24946aadee81/

Log:	added test and fix for inplace_or

diff --git a/pypy/objspace/std/setobject.py b/pypy/objspace/std/setobject.py
--- a/pypy/objspace/std/setobject.py
+++ b/pypy/objspace/std/setobject.py
@@ -502,8 +502,7 @@
                 w_left.add(w_key)
 
 def inplace_or__Set_Set(space, w_left, w_other):
-    ld, rd = w_left.setdata, w_other.setdata
-    ld.update(rd)
+    w_left.update(w_other)
     return w_left
 
 inplace_or__Set_Frozenset = inplace_or__Set_Set
diff --git a/pypy/objspace/std/test/test_setobject.py b/pypy/objspace/std/test/test_setobject.py
--- a/pypy/objspace/std/test/test_setobject.py
+++ b/pypy/objspace/std/test/test_setobject.py
@@ -51,6 +51,7 @@
         assert self.space.eq_w(s,u)
 
 class AppTestAppSetTest:
+
     def test_simple(self):
         a = set([1,2,3])
         b = set()
@@ -58,13 +59,19 @@
         c = a.union(b)
         assert c == set([1,2,3,4])
 
+    def test_or(self):
+        a = set([0,1,2])
+        b = a | set([1,2,3])
+        assert b == set([0,1,2,3])
+
+        # test inplace or
+        a |= set([1,2,3])
+        assert a == b
+
     def test_subtype(self):
         class subset(set):pass
         a = subset()
-        print "a: ", type(a)
         b = a | set('abc')
-        print b
-        print "b: ", type(b)
         assert type(b) is subset
 
     def test_union(self):
@@ -354,3 +361,4 @@
         assert s == set([2,3])
         s.difference_update(s)
         assert s == set([])
+


More information about the pypy-commit mailing list