Skip to content

Commit 5a729f0

Browse files
committed
check the return type of isnormal() and issubnormal()
1 parent de0d014 commit 5a729f0

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

Lib/test/test_math.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1974,6 +1974,11 @@ def testIsfinite(self):
19741974
self.assertFalse(math.isfinite(float("-inf")))
19751975

19761976
def testIsnormal(self):
1977+
# C11, §7.12.3.5 requires isnormal() to return
1978+
# a nonzero value if and only its argument has
1979+
# a normal value.
1980+
self.assertIsInstance(math.isnormal(1.0), bool)
1981+
19771982
self.assertTrue(math.isnormal(1.25))
19781983
self.assertTrue(math.isnormal(-1.0))
19791984
self.assertFalse(math.isnormal(0.0))
@@ -1985,6 +1990,11 @@ def testIsnormal(self):
19851990
self.assertFalse(math.isnormal(-FLOAT_MIN/2))
19861991

19871992
def testIssubnormal(self):
1993+
# issubnormal() is a C extension (ISO/IEC TS 18661-1:2014)
1994+
# and part of the C23 standard. In particular, it follows
1995+
# the same convention as isnormal() for its return value.
1996+
self.assertIsInstance(math.issubnormal(FLOAT_MIN/2), bool)
1997+
19881998
self.assertFalse(math.issubnormal(1.25))
19891999
self.assertFalse(math.issubnormal(-1.0))
19902000
self.assertFalse(math.issubnormal(0.0))

0 commit comments

Comments
 (0)