Skip to content

Commit bfb48c1

Browse files
committed
tests/float: Add tests for round() of inf, nan and large number.
1 parent c236ebf commit bfb48c1

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

tests/float/builtin_float_round.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,10 @@
1515
# test second arg
1616
for i in range(-1, 3):
1717
print(round(1.47, i))
18+
19+
# test inf and nan
20+
for val in (float('inf'), float('nan')):
21+
try:
22+
round(val)
23+
except (ValueError, OverflowError) as e:
24+
print(type(e))
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# test round() with floats that return large integers
2+
3+
for x in (-1e25, 1e25):
4+
print('%.3g' % round(x))

0 commit comments

Comments
 (0)