Skip to content

Commit

Permalink
Corrected handling of if statements containing a return that end a me…
Browse files Browse the repository at this point in the history
…thod.
  • Loading branch information
freakboy3742 committed Dec 10, 2016
1 parent 179f0b4 commit df07d3b
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions tests/structures/test_if_elif_else.py
Original file line number Diff line number Diff line change
@@ -235,6 +235,21 @@ def test_end_of_block(self):
print('Done')
""")

def test_simple_end_of_function_block_with_return(self):
# Ensure that if the last instruction in an if block
# is a return, a GOTO isn't added to the end of the block.
self.assertCodeExecution("""
def foo(x):
print("Testing", x)
if x == 0:
return 42
y = foo(0)
print("Result", y)
y = foo(100)
print("Result", y)
print('Done')
""")

def test_end_of_function_block_with_return(self):
# Ensure that if the last instruction in an if/else block
# is a return, a GOTO isn't added to the end of the block.
@@ -264,6 +279,8 @@ def foo(x):
print("Result", y)
y = foo(100)
print("Result", y)
y = foo(0)
print("Result", y)
print('Done')
""")

0 comments on commit df07d3b

Please sign in to comment.