From 1e61504b8b941494f3ac03e0449ddbbba8960175 Mon Sep 17 00:00:00 2001 From: Pablo Galindo Date: Thu, 20 Jun 2019 22:17:03 +0100 Subject: [PATCH] bpo-37289: Add a test for if with ifexpr in the peephole optimiser to detect regressions (GH-14127) --- Lib/test/test_peepholer.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Lib/test/test_peepholer.py b/Lib/test/test_peepholer.py index 5d00240e259..b5f85bd5597 100644 --- a/Lib/test/test_peepholer.py +++ b/Lib/test/test_peepholer.py @@ -421,6 +421,14 @@ class TestTranforms(BytecodeTestCase): return 0 self.assertEqual(f(), 1) + def test_if_with_if_expression(self): + # Check bpo-37289 + def f(x): + if (True if x else False): + return True + return False + self.assertTrue(f(True)) + class TestBuglets(unittest.TestCase):