@@ -475,6 +475,19 @@ def testCopysign(self):
475475 # similarly, copysign(2., NAN) could be 2. or -2.
476476 self .assertEqual (abs (math .copysign (2. , NAN )), 2. )
477477
478+ def test_signbit (self ):
479+ self .assertRaises (TypeError , math .signbit )
480+ self .assertRaises (TypeError , math .signbit , '1.0' )
481+
482+ # C11, §7.12.3.6 requires signbit() to return a nonzero value
483+ # if and only if the sign of its argument value is negative,
484+ # but in practice, we are only interested in a boolean value.
485+ self .assertIsInstance (math .signbit (1.0 ), bool )
486+
487+ for arg in [0. , 1. , INF , NAN ]:
488+ self .assertFalse (math .signbit (arg ))
489+ self .assertTrue (math .signbit (- arg ))
490+
478491 def testCos (self ):
479492 self .assertRaises (TypeError , math .cos )
480493 self .ftest ('cos(-pi/2)' , math .cos (- math .pi / 2 ), 0 , abs_tol = math .ulp (1 ))
@@ -1387,7 +1400,6 @@ def __rmul__(self, other):
13871400 args = ((- 5 , - 5 , 10 ), (1.5 , 4611686018427387904 , 2305843009213693952 ))
13881401 self .assertEqual (sumprod (* args ), 0.0 )
13891402
1390-
13911403 @requires_IEEE_754
13921404 @unittest .skipIf (HAVE_DOUBLE_ROUNDING ,
13931405 "sumprod() accuracy not guaranteed on machines with double rounding" )
@@ -2486,7 +2498,6 @@ def test_nextafter(self):
24862498 with self .assertRaises (ValueError ):
24872499 math .nextafter (1.0 , INF , steps = - 1 )
24882500
2489-
24902501 @requires_IEEE_754
24912502 def test_ulp (self ):
24922503 self .assertEqual (math .ulp (1.0 ), sys .float_info .epsilon )
0 commit comments