tests/float: Add tests for round() of inf, nan and large number.

pull/1/head
Damien George 2017-03-24 10:56:02 +11:00
parent c236ebfea7
commit bfb48c1620
2 changed files with 11 additions and 0 deletions

View File

@ -15,3 +15,10 @@ for i in range(11):
# 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))

View File

@ -0,0 +1,4 @@
# test round() with floats that return large integers
for x in (-1e25, 1e25):
print('%.3g' % round(x))