@@ -208,6 +208,45 @@ def testMethodCallFlagsConversion(self):
208
208
r = object .TestFlagsConversion (flags )
209
209
self .assertTrue (r == flags )
210
210
211
+ def testSimpleTypePromotionIntToDouble (self ):
212
+ object = MethodTest ()
213
+ try :
214
+ sum_of_a_plus_b = object .TestSimpleIntToDoubleTypePromotion (2 ,2 )
215
+ self .assertAlmostEqual (sum_of_a_plus_b ,2 + 2 )
216
+ sum_of_a_plus_b = object .TestSimpleIntToDoubleTypePromotion (2.0 ,2 )
217
+ self .assertAlmostEqual (sum_of_a_plus_b ,2 + 2 )
218
+ sum_of_a_plus_b = object .TestSimpleIntToDoubleTypePromotion (2 ,2.0 )
219
+ self .assertAlmostEqual (sum_of_a_plus_b ,2 + 2 )
220
+ sum_of_a_plus_b = object .TestSimpleIntToDoubleTypePromotion (2.0 ,2.0 )
221
+ self .assertAlmostEqual (sum_of_a_plus_b ,2.0 + 2.0 )
222
+ except :
223
+ self .assertTrue (False ,"Type promotion from int to double failed" )
224
+
225
+ try :
226
+ should_fail = object .TestSimpleIntToDoubleTypePromotion (2 ,'2.0' )
227
+ self .assertTrue (False ,"the promotion of string to double should fail" )
228
+ except :
229
+ pass
230
+
231
+ def testSimpleTypePromotionIntToFloat (self ):
232
+ object = MethodTest ()
233
+ try :
234
+ sum_of_a_plus_b = object .TestSimpleIntToFloatTypePromotion (2 ,2 )
235
+ self .assertAlmostEqual (sum_of_a_plus_b ,2 + 2 )
236
+ sum_of_a_plus_b = object .TestSimpleIntToFloatTypePromotion (2.0 ,2 )
237
+ self .assertAlmostEqual (sum_of_a_plus_b ,2 + 2 )
238
+ sum_of_a_plus_b = object .TestSimpleIntToFloatTypePromotion (2 ,2.0 )
239
+ self .assertAlmostEqual (sum_of_a_plus_b ,2 + 2 )
240
+ sum_of_a_plus_b = object .TestSimpleIntToFloatTypePromotion (2.0 ,2.0 )
241
+ self .assertAlmostEqual (sum_of_a_plus_b ,2.0 + 2.0 )
242
+ except :
243
+ self .assertTrue (False ,"Type promotion from int to float failed" )
244
+ try :
245
+ should_fail = object .TestSimpleIntToDoubleTypePromotion (2 ,'2.0' )
246
+ self .assertTrue (False ,"the promotion of string to float should fail" )
247
+ except :
248
+ pass
249
+
211
250
def testMethodCallStructConversion (self ):
212
251
"""Test struct conversion in method call."""
213
252
from System import Guid
0 commit comments