@@ -643,6 +643,38 @@ def test_long_getsign(self):
643643
644644 # CRASHES getsign(NULL)
645645
646+ def test_long_ispositive (self ):
647+ ispositive = _testcapi .pylong_ispositive
648+ self .assertEqual (ispositive (1 ), 1 )
649+ self .assertEqual (ispositive (123 ), 1 )
650+ self .assertEqual (ispositive (- 1 ), 0 )
651+ self .assertEqual (ispositive (0 ), 0 )
652+ self .assertEqual (ispositive (True ), 1 )
653+ self .assertEqual (ispositive (False ), 0 )
654+ self .assertEqual (ispositive (IntSubclass (- 1 )), 0 )
655+ self .assertRaises (TypeError , ispositive , 1.0 )
656+ self .assertRaises (TypeError , ispositive , Index (123 ))
657+
658+ def test_long_isnegative (self ):
659+ isnegative = _testcapi .pylong_isnegative
660+ self .assertEqual (isnegative (1 ), 0 )
661+ self .assertEqual (isnegative (123 ), 0 )
662+ self .assertEqual (isnegative (- 1 ), 1 )
663+ self .assertEqual (isnegative (0 ), 0 )
664+ self .assertEqual (isnegative (True ), 0 )
665+ self .assertEqual (isnegative (False ), 0 )
666+ self .assertEqual (isnegative (IntSubclass (- 1 )), 1 )
667+ self .assertRaises (TypeError , isnegative , 1.0 )
668+ self .assertRaises (TypeError , isnegative , Index (123 ))
669+
670+ def test_long_iszero (self ):
671+ iszero = _testcapi .pylong_iszero
672+ self .assertEqual (iszero (1 ), 0 )
673+ self .assertEqual (iszero (- 1 ), 0 )
674+ self .assertEqual (iszero (0 ), 1 )
675+ self .assertRaises (TypeError , iszero , 1.0 )
676+ self .assertRaises (TypeError , iszero , Index (123 ))
677+
646678 def test_long_asint32 (self ):
647679 # Test PyLong_AsInt32() and PyLong_FromInt32()
648680 to_int32 = _testlimitedcapi .pylong_asint32
0 commit comments