diff options
Diffstat (limited to 'Lib/test/test_capi/test_opt.py')
| -rw-r--r-- | Lib/test/test_capi/test_opt.py | 39 |
1 files changed, 33 insertions, 6 deletions
diff --git a/Lib/test/test_capi/test_opt.py b/Lib/test/test_capi/test_opt.py index f4fcdea..a0a1922 100644 --- a/Lib/test/test_capi/test_opt.py +++ b/Lib/test/test_capi/test_opt.py @@ -795,11 +795,14 @@ class TestUopsOptimization(unittest.TestCase): def testfunc(n): a = 1.0 for _ in range(n): - a = a + 0.1 + a = a + 0.25 + a = a + 0.25 + a = a + 0.25 + a = a + 0.25 return a res, ex = self._run_with_optimizer(testfunc, 32) - self.assertAlmostEqual(res, 4.2) + self.assertAlmostEqual(res, 33.0) self.assertIsNotNone(ex) uops = get_opnames(ex) guard_both_float_count = [opname for opname in iter_opnames(ex) if opname == "_GUARD_BOTH_FLOAT"] @@ -812,11 +815,14 @@ class TestUopsOptimization(unittest.TestCase): def testfunc(n): a = 1.0 for _ in range(n): - a = a - 0.1 + a = a - 0.25 + a = a - 0.25 + a = a - 0.25 + a = a - 0.25 return a res, ex = self._run_with_optimizer(testfunc, 32) - self.assertAlmostEqual(res, -2.2) + self.assertAlmostEqual(res, -31.0) self.assertIsNotNone(ex) uops = get_opnames(ex) guard_both_float_count = [opname for opname in iter_opnames(ex) if opname == "_GUARD_BOTH_FLOAT"] @@ -829,11 +835,14 @@ class TestUopsOptimization(unittest.TestCase): def testfunc(n): a = 1.0 for _ in range(n): - a = a * 2.0 + a = a * 1.0 + a = a * 1.0 + a = a * 1.0 + a = a * 1.0 return a res, ex = self._run_with_optimizer(testfunc, 32) - self.assertAlmostEqual(res, 2 ** 32) + self.assertAlmostEqual(res, 1.0) self.assertIsNotNone(ex) uops = get_opnames(ex) guard_both_float_count = [opname for opname in iter_opnames(ex) if opname == "_GUARD_BOTH_FLOAT"] @@ -842,6 +851,24 @@ class TestUopsOptimization(unittest.TestCase): # We'll also need to verify that propagation actually occurs. self.assertIn("_BINARY_OP_MULTIPLY_FLOAT", uops) + def test_add_unicode_propagation(self): + def testfunc(n): + a = "" + for _ in range(n): + a + a + a + a + a + a + a + a + return a + + res, ex = self._run_with_optimizer(testfunc, 32) + self.assertEqual(res, "") + self.assertIsNotNone(ex) + uops = get_opnames(ex) + guard_both_unicode_count = [opname for opname in iter_opnames(ex) if opname == "_GUARD_BOTH_UNICODE"] + self.assertLessEqual(len(guard_both_unicode_count), 1) + self.assertIn("_BINARY_OP_ADD_UNICODE", uops) + def test_compare_op_type_propagation_float(self): def testfunc(n): a = 1.0 |
