From 5a729f01ea43d86c4d023036cb2a7dbf64706ae3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A9n=C3=A9dikt=20Tran?= <10796600+picnixz@users.noreply.github.com> Date: Fri, 27 Jun 2025 15:47:51 +0200 Subject: [PATCH] check the return type of isnormal() and issubnormal() --- Lib/test/test_math.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Lib/test/test_math.py b/Lib/test/test_math.py index 384ad5c828d9b3..52b337370947cb 100644 --- a/Lib/test/test_math.py +++ b/Lib/test/test_math.py @@ -1974,6 +1974,11 @@ def testIsfinite(self): self.assertFalse(math.isfinite(float("-inf"))) def testIsnormal(self): + # C11, ยง7.12.3.5 requires isnormal() to return + # a nonzero value if and only its argument has + # a normal value. + self.assertIsInstance(math.isnormal(1.0), bool) + self.assertTrue(math.isnormal(1.25)) self.assertTrue(math.isnormal(-1.0)) self.assertFalse(math.isnormal(0.0)) @@ -1985,6 +1990,11 @@ def testIsnormal(self): self.assertFalse(math.isnormal(-FLOAT_MIN/2)) def testIssubnormal(self): + # issubnormal() is a C extension (ISO/IEC TS 18661-1:2014) + # and part of the C23 standard. In particular, it follows + # the same convention as isnormal() for its return value. + self.assertIsInstance(math.issubnormal(FLOAT_MIN/2), bool) + self.assertFalse(math.issubnormal(1.25)) self.assertFalse(math.issubnormal(-1.0)) self.assertFalse(math.issubnormal(0.0))