Skip to content

Commit e812024

Browse files
committed
Add tests for seqeunce comparison
1 parent edf44a2 commit e812024

2 files changed

Lines changed: 80 additions & 0 deletions

File tree

tests/snippets/list.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -488,3 +488,42 @@ def bad_iter_assign():
488488
assert x == [0, 1, 2, 3, 4, 5]
489489
x = list(range(10))
490490
del x[-5:-1:-1]
491+
492+
# list gt, ge, lt, le
493+
assert_raises(TypeError, lambda: [0, []] < [0, 0])
494+
assert_raises(TypeError, lambda: [0, []] <= [0, 0])
495+
assert_raises(TypeError, lambda: [0, []] > [0, 0])
496+
assert_raises(TypeError, lambda: [0, []] >= [0, 0])
497+
498+
assert_raises(TypeError, lambda: [0, 0] < [0, []])
499+
assert_raises(TypeError, lambda: [0, 0] <= [0, []])
500+
assert_raises(TypeError, lambda: [0, 0] > [0, []])
501+
assert_raises(TypeError, lambda: [0, 0] >= [0, []])
502+
503+
assert [0, 0] < [1, -1]
504+
assert [0, 0] < [0, 0, 1]
505+
assert [0, 0] < [0, 0, -1]
506+
assert [0, 0] <= [0, 0, -1]
507+
assert not [0, 0, 0, 0] <= [0, -1]
508+
509+
assert [0, 0] > [-1, 1]
510+
assert [0, 0] >= [-1, 1]
511+
assert [0, 0, 0] >= [-1, 1]
512+
513+
assert [0, 0] <= [0, 1]
514+
assert [0, 0] <= [0, 0]
515+
assert [0, 0] <= [0, 0]
516+
assert not [0, 0] > [0, 0]
517+
assert not [0, 0] < [0, 0]
518+
519+
assert not [float('nan'), float('nan')] <= [float('nan'), 1]
520+
assert not [float('nan'), float('nan')] <= [float('nan'), float('nan')]
521+
assert not [float('nan'), float('nan')] >= [float('nan'), float('nan')]
522+
assert not [float('nan'), float('nan')] < [float('nan'), float('nan')]
523+
assert not [float('nan'), float('nan')] > [float('nan'), float('nan')]
524+
525+
assert [float('inf'), float('inf')] >= [float('inf'), 1]
526+
assert [float('inf'), float('inf')] <= [float('inf'), float('inf')]
527+
assert [float('inf'), float('inf')] >= [float('inf'), float('inf')]
528+
assert not [float('inf'), float('inf')] < [float('inf'), float('inf')]
529+
assert not [float('inf'), float('inf')] > [float('inf'), float('inf')]

tests/snippets/tuple.py

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from testutils import assert_raises
2+
13
assert (1,2) == (1,2)
24

35
x = (1,2)
@@ -47,3 +49,42 @@ def __eq__(self, x):
4749
a = ()
4850
b = ()
4951
assert a is b
52+
53+
# tuple gt, ge, lt, le
54+
assert_raises(TypeError, lambda: (0, ()) < (0, 0))
55+
assert_raises(TypeError, lambda: (0, ()) <= (0, 0))
56+
assert_raises(TypeError, lambda: (0, ()) > (0, 0))
57+
assert_raises(TypeError, lambda: (0, ()) >= (0, 0))
58+
59+
assert_raises(TypeError, lambda: (0, 0) < (0, ()))
60+
assert_raises(TypeError, lambda: (0, 0) <= (0, ()))
61+
assert_raises(TypeError, lambda: (0, 0) > (0, ()))
62+
assert_raises(TypeError, lambda: (0, 0) >= (0, ()))
63+
64+
assert (0, 0) < (1, -1)
65+
assert (0, 0) < (0, 0, 1)
66+
assert (0, 0) < (0, 0, -1)
67+
assert (0, 0) <= (0, 0, -1)
68+
assert not (0, 0, 0, 0) <= (0, -1)
69+
70+
assert (0, 0) > (-1, 1)
71+
assert (0, 0) >= (-1, 1)
72+
assert (0, 0, 0) >= (-1, 1)
73+
74+
assert (0, 0) <= (0, 1)
75+
assert (0, 0) <= (0, 0)
76+
assert (0, 0) <= (0, 0)
77+
assert not (0, 0) > (0, 0)
78+
assert not (0, 0) < (0, 0)
79+
80+
assert not (float('nan'), float('nan')) <= (float('nan'), 1)
81+
assert not (float('nan'), float('nan')) <= (float('nan'), float('nan'))
82+
assert not (float('nan'), float('nan')) >= (float('nan'), float('nan'))
83+
assert not (float('nan'), float('nan')) < (float('nan'), float('nan'))
84+
assert not (float('nan'), float('nan')) > (float('nan'), float('nan'))
85+
86+
assert (float('inf'), float('inf')) >= (float('inf'), 1)
87+
assert (float('inf'), float('inf')) <= (float('inf'), float('inf'))
88+
assert (float('inf'), float('inf')) >= (float('inf'), float('inf'))
89+
assert not (float('inf'), float('inf')) < (float('inf'), float('inf'))
90+
assert not (float('inf'), float('inf')) > (float('inf'), float('inf'))

0 commit comments

Comments
 (0)