Commit 4f250790 authored by Kevin Modzelewski's avatar Kevin Modzelewski

Merge pull request #915 from kmod/set_stuff

More set stuff
parents 328967bd d2f33c5e
# expected: fail
doctests = """
########### Tests mostly copied from test_listcomps.py ############
......
......@@ -3463,9 +3463,13 @@ void rearrangeArguments(ParamReceiveSpec paramspec, const ParamNames* param_name
BoxedDict* d_kwargs = static_cast<BoxedDict*>(kwargs);
BoxedDict* okwargs = NULL;
if (d_kwargs->d.size())
if (d_kwargs->d.size()) {
okwargs = get_okwargs();
if (!okwargs && (!param_names || !param_names->takes_param_names))
raiseExcHelper(TypeError, "%s() doesn't take keyword arguments", func_name);
}
for (const auto& p : *d_kwargs) {
auto k = coerceUnicodeToStr(p.first);
......
This diff is collapsed.
......@@ -62,8 +62,7 @@ test_random long("invalid number")
test_repr complex.__hash__; some unknown issues
test_richcmp PyObject_Not
test_scope eval of code object from existing function (not currently supported)
test_set weird function-picking issue
test_setcomps parser not raising a SyntaxError when assigning to a setcomp
test_set lots of set issues
test_sort argument specification issue in listSort?
test_str memory leak?
test_string infinite loops in test_replace
......
......@@ -12,7 +12,6 @@ def relpath(fn):
r = os.path.join(os.path.dirname(__file__), fn)
return r
print glob.glob("../from_cpython/Include/*.h")
builtin_headers = map(relpath, glob.glob("../../from_cpython/Include/*.h"))
for m in extensions:
......
......@@ -117,6 +117,22 @@ class MySet(set):
class MyFrozenset(frozenset):
pass
s = s1 = set()
s |= MySet(range(2))
print sorted(s), sorted(s1)
s &= MySet(range(1))
print sorted(s), sorted(s1)
s ^= MySet(range(4))
print sorted(s), sorted(s1)
s -= MySet(range(3))
print sorted(s), sorted(s1)
try:
set() | range(5)
assert 0
except TypeError as e:
print e
compare_to = []
for i in xrange(10):
compare_to.append(set(range(i)))
......@@ -125,10 +141,11 @@ for i in xrange(10):
compare_to.append(MyFrozenset(range(i)))
compare_to.append(range(i))
compare_to.append(range(i, 10))
compare_to.append([0, 0, 1, 1])
for s1 in set(range(5)), frozenset(range(5)):
for s2 in compare_to:
print type(s2), sorted(s2), s1.issubset(s2), s1.issuperset(s2), sorted(s1.difference(s2)), s1.isdisjoint(s2), sorted(s1.union(s2)), sorted(s1.intersection(s2))
print type(s2), sorted(s2), s1.issubset(s2), s1.issuperset(s2), sorted(s1.difference(s2)), s1.isdisjoint(s2), sorted(s1.union(s2)), sorted(s1.intersection(s2)), sorted(s1.symmetric_difference(s2))
print s1 == s2, s1 != s2
try:
print s1 < s2, s1 <= s2, s1 > s2, s1 >= s2
......@@ -138,11 +155,14 @@ f = float('nan')
s = set([f])
print f in s, f == list(s)[0]
s1 = set([3, 5])
s2 = set([1, 5])
s1.intersection_update(s2)
print sorted(s1)
for fn in (set.intersection_update, set.difference_update, set.symmetric_difference_update, set.__sub__,
set.__or__, set.__xor__, set.__and__):
s1 = set([3, 5])
s2 = set([1, 5])
r = fn(s1, s2)
if r:
print r,
print sorted(s1), sorted(s2)
def test_set_creation(base):
print "Testing with base =", base
......@@ -173,3 +193,9 @@ def test_set_creation(base):
print MySet(g())
test_set_creation(set)
test_set_creation(frozenset)
set(**{})
try:
set(**dict(a=1))
except TypeError:
print "TypeError"
# expected: fail
print hasattr(set, "__ior__")
print hasattr(set, "__isub__")
print hasattr(set, "__iand__")
print hasattr(set, "__ixor__")
s1 = set() | set(range(3))
s2 = set(range(1, 5))
s3 = s1
s1 -= s2
print s1, s2, s3
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment