[pypy-commit] pypy default: Tests for the same situation with other set operations. Fix for
arigo
noreply at buildbot.pypy.org
Wed Jul 9 21:26:46 CEST 2014
Author: Armin Rigo <arigo at tunes.org>
Branch:
Changeset: r72408:e27d1225e4ca
Date: 2014-07-09 21:26 +0200
http://bitbucket.org/pypy/pypy/changeset/e27d1225e4ca/
Log: Tests for the same situation with other set operations. Fix for
symmetric_difference.
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
@@ -1060,10 +1060,14 @@
return storage, strategy
def symmetric_difference(self, w_set, w_other):
+ if w_other.length() == 0:
+ return w_set.copy_real()
storage, strategy = self._symmetric_difference_base(w_set, w_other)
return w_set.from_storage_and_strategy(storage, strategy)
def symmetric_difference_update(self, w_set, w_other):
+ if w_other.length() == 0:
+ return
storage, strategy = self._symmetric_difference_base(w_set, w_other)
w_set.strategy = strategy
w_set.sstorage = storage
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
@@ -967,3 +967,28 @@
assert strategy(s) == "IntegerSetStrategy"
s.update(set())
assert strategy(s) == "IntegerSetStrategy"
+ #
+ s = set([1, 2, 3])
+ s |= set()
+ assert strategy(s) == "IntegerSetStrategy"
+ #
+ s = set([1, 2, 3]).difference(set())
+ assert strategy(s) == "IntegerSetStrategy"
+ #
+ s = set([1, 2, 3])
+ s.difference_update(set())
+ assert strategy(s) == "IntegerSetStrategy"
+ #
+ s = set([1, 2, 3]).symmetric_difference(set())
+ assert strategy(s) == "IntegerSetStrategy"
+ #
+ s = set([1, 2, 3])
+ s.symmetric_difference_update(set())
+ assert strategy(s) == "IntegerSetStrategy"
+ #
+ s = set([1, 2, 3]).intersection(set())
+ assert strategy(s) == "EmptySetStrategy"
+ #
+ s = set([1, 2, 3])
+ s.intersection_update(set())
+ assert strategy(s) == "EmptySetStrategy"
More information about the pypy-commit
mailing list