@@ -721,6 +721,7 @@ def test_intptr_construction():
721
721
UIntPtr (v )
722
722
723
723
def test_explicit_conversion ():
724
+ from operator import index
724
725
from System import (
725
726
Int64 , UInt64 , Int32 , UInt32 , Int16 , UInt16 , Byte , SByte , Boolean
726
727
)
@@ -730,18 +731,24 @@ def test_explicit_conversion():
730
731
assert int (Boolean (True )) == 1
731
732
732
733
for t in [UInt64 , UInt32 , UInt16 , Byte ]:
734
+ assert index (t (127 )) == 127
733
735
assert int (t (127 )) == 127
734
736
assert float (t (127 )) == 127.0
735
737
736
738
for t in [Int64 , Int32 , Int16 , SByte ]:
739
+ assert index (t (127 )) == 127
740
+ assert index (t (- 127 )) == - 127
737
741
assert int (t (127 )) == 127
738
742
assert int (t (- 127 )) == - 127
739
743
assert float (t (127 )) == 127.0
740
744
assert float (t (- 127 )) == - 127.0
741
745
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
745
749
746
750
for t in [Single , Double ]:
747
751
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