Skip to content

Commit

Permalink
tests/float: Add tests for round() of inf, nan and large number.
Browse files Browse the repository at this point in the history
  • Loading branch information
dpgeorge committed Mar 24, 2017
1 parent c236ebf commit bfb48c1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
7 changes: 7 additions & 0 deletions tests/float/builtin_float_round.py
Expand Up @@ -15,3 +15,10 @@
# test second arg
for i in range(-1, 3):
print(round(1.47, i))

# test inf and nan
for val in (float('inf'), float('nan')):
try:
round(val)
except (ValueError, OverflowError) as e:
print(type(e))
4 changes: 4 additions & 0 deletions tests/float/builtin_float_round_intbig.py
@@ -0,0 +1,4 @@
# test round() with floats that return large integers

for x in (-1e25, 1e25):
print('%.3g' % round(x))

0 comments on commit bfb48c1

Please sign in to comment.