@@ -57,8 +57,45 @@ fn test_python_to_string() raises:
57
57
assert_true(String(os.environ).startswith(" environ({" ))
58
58
59
59
60
+ fn test_python_to_int () raises :
61
+ var py_int = PythonObject(1 )
62
+ var mojo_int = Int(1 )
63
+ assert_equal(Int(py_int), mojo_int)
64
+
65
+
66
+ fn test_python_to_float () raises :
67
+ var py_float = PythonObject(1.0 )
68
+ var mojo_float = Float64(1.0 )
69
+ assert_equal(Float64(py_float), mojo_float)
70
+
71
+
72
+ fn test_python_to_bool () raises :
73
+ var py_bool = PythonObject(True )
74
+ var mojo_bool = Bool(True )
75
+ assert_equal(Bool(py_bool), mojo_bool)
76
+
77
+
78
+ fn test_python_numpy_int_to_mojo_int () raises :
79
+ var np = Python.import_module(" numpy" )
80
+ var py_numpy_int = np.int64(1 )
81
+ var mojo_int = Int(1 )
82
+ assert_equal(Int(py_numpy_int), mojo_int)
83
+
84
+
85
+ fn test_python_numpy_float_to_mojo_float () raises :
86
+ var np = Python.import_module(" numpy" )
87
+ var py_numpy_float = np.float64(1.0 )
88
+ var mojo_float = Float64(1.0 )
89
+ assert_equal(Float64(py_numpy_float), mojo_float)
90
+
91
+
60
92
def main ():
61
93
var python = Python()
62
94
test_string_to_python_to_mojo(python)
63
95
test_range()
64
96
test_python_to_string()
97
+ test_python_to_int()
98
+ test_python_to_float()
99
+ test_python_to_bool()
100
+ test_python_numpy_int_to_mojo_int()
101
+ test_python_numpy_float_to_mojo_float()
0 commit comments