diff options
-rw-r--r-- | coverage/parser.py | 16 | ||||
-rw-r--r-- | test/test_arcs.py | 29 |
2 files changed, 28 insertions, 17 deletions
diff --git a/coverage/parser.py b/coverage/parser.py index 9460f083..8884e413 100644 --- a/coverage/parser.py +++ b/coverage/parser.py @@ -274,7 +274,10 @@ class ByteParser: return last_line _code_enders = set([opcode.opmap[name] for name in ['RETURN_VALUE']]) - _chunk_enders = set([opcode.opmap[name] for name in ['JUMP_ABSOLUTE', 'JUMP_FORWARD']]) + _chunk_enders = set([opcode.opmap[name] for name in [ + 'JUMP_ABSOLUTE', 'JUMP_FORWARD', 'BREAK_LOOP', 'CONTINUE_LOOP', + 'RAISE_VARARGS' + ]]) _chunk_enders |= _code_enders def _split_into_chunks(self): @@ -391,7 +394,7 @@ class ByteParser: for bp in self.child_parsers(): chunks.extend(bp._split_into_chunks()) - return [], chunks + return chunks def _all_arcs(self): arcs = [] @@ -452,16 +455,13 @@ class AdHocMain(object): bp._disassemble() if options.chunks: - warnings, chunks = bp._all_chunks() + chunks = bp._all_chunks() if options.recursive: print("%6d: %s" % (len(chunks), filename)) - if warnings: - print("\t%r" % (warnings,)) else: - print(warnings) - print(chunks) + print("Chunks: %r" % chunks) arcs = bp._all_arcs() - print(arcs) + print("Arcs: %r" % arcs) if options.source or options.tokens: cp = CodeParser(filename=filename, exclude=r"no\s*cover") diff --git a/test/test_arcs.py b/test/test_arcs.py index 6c68e397..48e1b282 100644 --- a/test/test_arcs.py +++ b/test/test_arcs.py @@ -63,32 +63,43 @@ class ArcTest(CoverageTest): if len([]) == 0: a = 2 else: - b = 4 - c = 5 + a = 4 + assert a == 2 """, arcz=".1 12 25 14 45 5.", arcz_missing="14 45") self.check_coverage("""\ if len([]) == 1: a = 2 else: - b = 4 - c = 5 + a = 4 + assert a == 4 """, arcz=".1 12 25 14 45 5.", arcz_missing="12 25") def test_loop(self): self.check_coverage("""\ for i in range(10): - a = 2 - b = 3 + a = i + assert a == 9 """, arcz=".1 12 21 13 3.", arcz_missing="") self.check_coverage("""\ + a = -1 for i in range(0): - a = 2 - b = 3 + a = i + assert a == -1 + """, + arcz=".1 12 23 32 24 4.", arcz_missing="23 32") + + def test_break(self): + self.check_coverage("""\ + for i in range(10): + a = i + break # 3 + a = 99 + assert a == 0 # 5 """, - arcz=".1 12 21 13 3.", arcz_missing="12 21") + arcz=".1 12 23 35 15 41 5.", arcz_missing="15 41") def xest_xx(self): self.check_coverage("""\ |