@@ -721,6 +721,7 @@ def test_intptr_construction():
721721 UIntPtr (v )
722722
723723def test_explicit_conversion ():
724+ from operator import index
724725 from System import (
725726 Int64 , UInt64 , Int32 , UInt32 , Int16 , UInt16 , Byte , SByte , Boolean
726727 )
@@ -730,18 +731,24 @@ def test_explicit_conversion():
730731 assert int (Boolean (True )) == 1
731732
732733 for t in [UInt64 , UInt32 , UInt16 , Byte ]:
734+ assert index (t (127 )) == 127
733735 assert int (t (127 )) == 127
734736 assert float (t (127 )) == 127.0
735737
736738 for t in [Int64 , Int32 , Int16 , SByte ]:
739+ assert index (t (127 )) == 127
740+ assert index (t (- 127 )) == - 127
737741 assert int (t (127 )) == 127
738742 assert int (t (- 127 )) == - 127
739743 assert float (t (127 )) == 127.0
740744 assert float (t (- 127 )) == - 127.0
741745
742- assert int (Int64 .MaxValue ) == 2 ** 63 - 1
743- assert int (Int64 .MinValue ) == - 2 ** 63
744- assert int (UInt64 .MaxValue ) == 2 ** 64 - 1
746+ assert int (Int64 ( Int64 .MaxValue ) ) == 2 ** 63 - 1
747+ assert int (Int64 ( Int64 .MinValue ) ) == - 2 ** 63
748+ assert int (UInt64 ( UInt64 .MaxValue ) ) == 2 ** 64 - 1
745749
746750 for t in [Single , Double ]:
747751 assert float (t (0.125 )) == 0.125
752+ assert int (t (123.4 )) == 123
753+ with pytest .raises (TypeError ):
754+ index (t (123.4 ))
0 commit comments