Skip to content

Commit

Permalink
test: Add test for all compare operators on numbers
Browse files Browse the repository at this point in the history
Make sure all compare operators work against a range of numeric
values.

Signed-off-by: Keith Packard <keithp@keithp.com>
  • Loading branch information
keith-packard committed Sep 27, 2021
1 parent 8e0c916 commit 381c539
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions test/pass-op.py
Expand Up @@ -51,3 +51,23 @@
exit(1)
if not math.isclose(-7.8 % 2.2, 1.0):
exit(1)
inf = float("inf")

vals = (-inf, -2, -1, 0, 1, 2, inf)

for first in range(0, len(vals)):
assert vals[first] == vals[first] + 0

for second in range(first, len(vals)):
assert vals[first] <= vals[second] + 0

assert vals[second] >= vals[first] + 0

for second in range(first + 1, len(vals)):
assert vals[first] < vals[second] + 0

assert vals[second] > vals[first] + 0

for second in range(0, len(vals)):
if second != first:
assert vals[first] != vals[second] + 0

0 comments on commit 381c539

Please sign in to comment.