Skip to content

Commit bacb52a

Browse files
committed
tests/float: Add tests for math funcs that return ints.
One should test bigint, inf and nan to make sure all cases are covered.
1 parent c073519 commit bacb52a

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

tests/float/math_fun_int.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# test the math functions that return ints
2+
3+
try:
4+
import math
5+
except ImportError:
6+
print("SKIP")
7+
import sys
8+
sys.exit()
9+
10+
for fun in (math.ceil, math.floor, math.trunc):
11+
for x in (-1.6, -0.2, 0, 0.6, 1.4, float('inf'), float('nan')):
12+
try:
13+
print(fun(x))
14+
except (ValueError, OverflowError) as e:
15+
print(type(e))

tests/float/math_fun_intbig.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# test the math functions that return ints, with very large results
2+
3+
try:
4+
import math
5+
except ImportError:
6+
print("SKIP")
7+
import sys
8+
sys.exit()
9+
10+
for fun in (math.ceil, math.floor, math.trunc):
11+
for x in (-1e25, 1e25):
12+
print('%.3g' % fun(x))

0 commit comments

Comments
 (0)