Skip to content

Commit d21361c

Browse files
committed
test(math): stronger ldexp test (some is c_int as int32 only)
1 parent 2b8c3f2 commit d21361c

File tree

1 file changed

+22
-19
lines changed

1 file changed

+22
-19
lines changed

src/pylib/Lib/test/test_math.nim

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -307,22 +307,25 @@ suite "ldexp":
307307
ldexp(INF, 30) == INF
308308
ldexp(NINF, -213) == NINF
309309
isnan(ldexp(NAN, 0))
310-
test "large second arg":
311-
for f in [1e5, 1e10]:
312-
let n = int(f)
313-
check:
314-
ldexp(INF, -n) == INF
315-
ldexp(NINF, -n) == NINF
316-
ldexp(1.0, -n) == 0.0
317-
ldexp(-1.0, -n) == -0.0
318-
ldexp(0.0, -n) == 0.0
319-
ldexp(-0.0, -n) == -0.0
320-
isnan(math.ldexp(NAN, -n))
321-
expect OverflowDefect: discard ldexp(1.0, n)
322-
expect OverflowDefect: discard ldexp(-1.0, n)
323-
check:
324-
ldexp(0.0, n) == 0.0
325-
ldexp(-0.0, n) == -0.0
326-
ldexp(INF, n) == INF
327-
ldexp(NINF, n) == NINF
328-
isnan(ldexp(NAN, n))
310+
when c_int is int32:
311+
test "large second arg":
312+
# the following code from CPython is only for
313+
# platform where c_int is int32
314+
for f in [1e5, 1e10]:
315+
let n = int(f)
316+
check:
317+
ldexp(INF, -n) == INF
318+
ldexp(NINF, -n) == NINF
319+
ldexp(1.0, -n) == 0.0
320+
ldexp(-1.0, -n) == -0.0
321+
ldexp(0.0, -n) == 0.0
322+
ldexp(-0.0, -n) == -0.0
323+
isnan(math.ldexp(NAN, -n))
324+
expect OverflowDefect: discard ldexp(1.0, n)
325+
expect OverflowDefect: discard ldexp(-1.0, n)
326+
check:
327+
ldexp(0.0, n) == 0.0
328+
ldexp(-0.0, n) == -0.0
329+
ldexp(INF, n) == INF
330+
ldexp(NINF, n) == NINF
331+
isnan(ldexp(NAN, n))

0 commit comments

Comments
 (0)