Skip to content

Commit b1684b2

Browse files
Merge pull request RustPython#1530 from youknowone/test-names
Rename some test filenames by convention
2 parents 2205fec + 95e8e2f commit b1684b2

24 files changed

+61
-64
lines changed
File renamed without changes.

tests/snippets/builtin_complex.py

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,4 +129,25 @@
129129

130130
# __getnewargs__
131131
assert (3 + 5j).__getnewargs__() == (3.0, 5.0)
132-
assert (5j).__getnewargs__() == (0.0, 5.0)
132+
assert (5j).__getnewargs__() == (0.0, 5.0)
133+
134+
135+
class Complex():
136+
def __init__(self, real, imag):
137+
self.real = real
138+
self.imag = imag
139+
140+
def __repr__(self):
141+
return "Com" + str((self.real, self.imag))
142+
143+
def __sub__(self, other):
144+
return Complex(self.real - other, self.imag)
145+
146+
def __rsub__(self, other):
147+
return Complex(other - self.real, -self.imag)
148+
149+
def __eq__(self, other):
150+
return self.real == other.real and self.imag == other.imag
151+
152+
assert Complex(4, 5) - 3 == Complex(1, 5)
153+
assert 7 - Complex(4, 5) == Complex(3, -5)
File renamed without changes.

tests/snippets/math_basics.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,22 @@
5151
assert_raises(TypeError, pow, 2.0, 4, 5)
5252
assert_raises(ValueError, pow, 2, -1, 5)
5353
assert_raises(ValueError, pow, 2, 2, 0)
54+
55+
# bitwise
56+
57+
assert 8 >> 3 == 1
58+
assert 8 << 3 == 64
59+
60+
# Left shift raises type error
61+
assert_raises(TypeError, lambda: 1 << 0.1)
62+
assert_raises(TypeError, lambda: 1 << "abc")
63+
64+
# Right shift raises type error
65+
assert_raises(TypeError, lambda: 1 >> 0.1)
66+
assert_raises(TypeError, lambda: 1 >> "abc")
67+
68+
# Left shift raises value error on negative
69+
assert_raises(ValueError, lambda: 1 << -1)
70+
71+
# Right shift raises value error on negative
72+
assert_raises(ValueError, lambda: 1 >> -1)

tests/snippets/set.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,3 +337,23 @@ def __hash__(self):
337337
assert not frozenset([1, 2]).__ne__(set([2, 1]))
338338
assert not frozenset([1, 2]).__ne__(frozenset([2, 1]))
339339
assert frozenset().__ne__(1) == NotImplemented
340+
341+
empty_set = set()
342+
non_empty_set = set([1,2,3])
343+
set_from_literal = {1,2,3}
344+
345+
assert 1 in non_empty_set
346+
assert 4 not in non_empty_set
347+
348+
assert 1 in set_from_literal
349+
assert 4 not in set_from_literal
350+
351+
# TODO: Assert that empty aruguments raises exception.
352+
non_empty_set.add('a')
353+
assert 'a' in non_empty_set
354+
355+
# TODO: Assert that empty arguments, or item not in set raises exception.
356+
non_empty_set.remove(1)
357+
assert 1 not in non_empty_set
358+
359+
# TODO: Assert that adding the same thing to a set once it's already there doesn't do anything.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)