def test_typeconv(self): tm = TypeManager() i32 = types.int32 i64 = types.int64 f32 = types.float32 tm.set_promote(i32, i64) tm.set_unsafe_convert(i32, f32) sig = (i32, f32) ovs = [ (i32, i32), (f32, f32), ] sel = tm.select_overload(sig, ovs) self.assertEqual(sel, 1)
def test_typeconv(self): tm = TypeManager() i32 = types.int32 i64 = types.int64 f32 = types.float32 tm.set_promote(i32, i64) tm.set_unsafe_convert(i32, f32) sig = (i32, f32) ovs = [ (i32, i32), (f32, f32), ] sel = tm.select_overload(sig, ovs) self.assertEqual(sel, 1)
def test_typeconv(self): tm = TypeManager() i32 = types.int32 i64 = types.int64 f32 = types.float32 tm.set_promote(i32, i64) tm.set_unsafe_convert(i32, f32) sig = (i32, f32) ovs = [ (i32, i32), (f32, f32), (i64, i64), ] # allow_unsafe = True => a conversion from i32 to f32 is chosen sel = tm.select_overload(sig, ovs, True) self.assertEqual(sel, 1) # allow_unsafe = False => no overload available with self.assertRaises(TypeError): sel = tm.select_overload(sig, ovs, False)
def test_typeconv(self): tm = TypeManager() i32 = types.int32 i64 = types.int64 f32 = types.float32 tm.set_promote(i32, i64) tm.set_unsafe_convert(i32, f32) sig = (i32, f32) ovs = [ (i32, i32), (f32, f32), (i64, i64), ] # allow_unsafe = True => a conversion from i32 to f32 is chosen sel = tm.select_overload(sig, ovs, True) self.assertEqual(sel, 1) # allow_unsafe = False => no overload available with self.assertRaises(TypeError): sel = tm.select_overload(sig, ovs, False)