@@ -1248,7 +1248,8 @@ def control_unsigned(a, b):
12481248 return control_unsigned
12491249
12501250 def run_binary (self , pyfunc , control_func , operands , types ,
1251- expected_type = int , ** assertPreciseEqualArgs ):
1251+ expected_type = int , force_type = lambda x : x ,
1252+ ** assertPreciseEqualArgs ):
12521253 for xt , yt in types :
12531254 cr = compile_isolated (pyfunc , (xt , yt ), flags = Noflags )
12541255 cfunc = cr .entry_point
@@ -1261,6 +1262,7 @@ def run_binary(self, pyfunc, control_func, operands, types,
12611262 self .assertIsInstance (got , expected_type )
12621263 msg = ("mismatch for (%r, %r) with types %s"
12631264 % (x , y , (xt , yt )))
1265+ got , expected = force_type (got ), force_type (expected )
12641266 self .assertPreciseEqual (got , expected , msg = msg ,
12651267 ** assertPreciseEqualArgs )
12661268
@@ -1280,11 +1282,16 @@ def run_unary(self, pyfunc, control_func, operands, types,
12801282 % (x , xt , got , expected ))
12811283
12821284 def run_arith_binop (self , pyfunc , opname , samples ,
1283- expected_type = int ):
1285+ expected_type = int , force_type = lambda x : x ,
1286+ ** assertPreciseEqualArgs ):
12841287 self .run_binary (pyfunc , self .get_control_signed (opname ),
1285- samples , self .signed_pairs , expected_type )
1288+ samples , self .signed_pairs , expected_type ,
1289+ force_type = force_type ,
1290+ ** assertPreciseEqualArgs )
12861291 self .run_binary (pyfunc , self .get_control_unsigned (opname ),
1287- samples , self .unsigned_pairs , expected_type )
1292+ samples , self .unsigned_pairs , expected_type ,
1293+ force_type = force_type ,
1294+ ** assertPreciseEqualArgs )
12881295
12891296 def test_add (self ):
12901297 self .run_arith_binop (self .op .add_usecase , 'add' , self .int_samples )
@@ -1304,11 +1311,14 @@ def test_mod(self):
13041311 self .run_arith_binop (self .op .mod_usecase , 'mod' , samples )
13051312
13061313 def test_pow (self ):
1314+ extra_cast = {}
1315+ if utils .PYVERSION == (3 , 11 ):
1316+ extra_cast ["force_type" ] = float
13071317 pyfunc = self .op .pow_usecase
13081318 # Only test with positive values, as otherwise trying to write the
13091319 # control function in terms of Python or Numpy power turns out insane.
13101320 samples = [x for x in self .int_samples if x >= 0 ]
1311- self .run_arith_binop (pyfunc , 'pow' , samples )
1321+ self .run_arith_binop (pyfunc , 'pow' , samples , ** extra_cast )
13121322
13131323 # Now test all non-zero values, but only with signed types
13141324 def control_signed (a , b ):
@@ -1325,7 +1335,7 @@ def control_signed(a, b):
13251335 signed_pairs = [(u , v ) for u , v in self .type_pairs
13261336 if u .signed and v .signed ]
13271337 self .run_binary (pyfunc , control_signed ,
1328- samples , signed_pairs )
1338+ samples , signed_pairs , ** extra_cast )
13291339
13301340 def test_truediv (self ):
13311341
0 commit comments