summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--coverage/parser.py8
-rw-r--r--test/test_arcs.py14
2 files changed, 18 insertions, 4 deletions
diff --git a/coverage/parser.py b/coverage/parser.py
index 29144859..6f15b12f 100644
--- a/coverage/parser.py
+++ b/coverage/parser.py
@@ -376,20 +376,20 @@ class ByteParser(object):
if bc.op in OPS_CODE_END:
# The opcode can exit the code object.
chunk.exits.add(-1)
- elif bc.op in OPS_PUSH_BLOCK:
+ if bc.op in OPS_PUSH_BLOCK:
# The opcode adds a block to the block_stack.
block_stack.append((bc.op, bc.jump_to))
- elif bc.op in OPS_POP_BLOCK:
+ if bc.op in OPS_POP_BLOCK:
# The opcode pops a block from the block stack.
block_stack.pop()
- elif bc.op in OPS_CHUNK_END:
+ if bc.op in OPS_CHUNK_END:
# This opcode forces the end of the chunk.
if bc.op == OP_BREAK_LOOP:
# A break is implicit: jump where the top of the
# block_stack points.
chunk.exits.add(block_stack[-1][1])
chunk = None
- elif bc.op == OP_END_FINALLY:
+ if bc.op == OP_END_FINALLY:
if block_stack:
# A break that goes through a finally will jump to whatever
# block is on top of the stack.
diff --git a/test/test_arcs.py b/test/test_arcs.py
index bc54429e..aafbb1d3 100644
--- a/test/test_arcs.py
+++ b/test/test_arcs.py
@@ -327,3 +327,17 @@ class ExceptionArcTest(CoverageTest):
""",
arcz=".1 12 .3 3. 24 45 56 67 7B 89 9B BC C.",
arcz_missing="67 7B", arcz_unpredicted="68")
+
+ def test_if_return(self):
+ self.check_coverage("""\
+ def if_ret(a):
+ if a:
+ return 3
+ b = 4
+ return 5
+ x = if_ret(0) + if_ret(1)
+ assert x == 8
+ """,
+ arcz=".1 16 67 7. .2 23 24 3. 45 5.",
+ arcz_missing=""
+ ) \ No newline at end of file