Skip to content

Commit

Permalink
bpo-37289: Add a test for if with ifexpr in the peephole optimiser to…
Browse files Browse the repository at this point in the history
… detect regressions (GH-14127)
  • Loading branch information
pablogsal authored Jun 20, 2019
1 parent c68e3fb commit 1e61504
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Lib/test/test_peepholer.py
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,14 @@ def f():
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))

This comment has been minimized.

Copy link
@scoder

scoder Jun 24, 2019

Contributor

I'd also add self.assertFalse(f(False)), just to be sure that the test tests what it should, and the "optimisation" doesn't just start going the other way in the future without us noticing.



class TestBuglets(unittest.TestCase):

Expand Down

0 comments on commit 1e61504

Please sign in to comment.