MCPcopy Index your code
hub / github.com/python/cpython / check_lnotab

Method check_lnotab

Lib/test/test_peepholer.py:71–83  ·  view source on GitHub ↗

Check that the lnotab byte offsets are sensible.

(self, code)

Source from the content-addressed store, hash-verified

69 f'jumps to {tgt.opname} at {tgt.offset}')
70
71 def check_lnotab(self, code):
72 "Check that the lnotab byte offsets are sensible."
73 code = dis._get_code_object(code)
74 lnotab = list(dis.findlinestarts(code))
75 # Don't bother checking if the line info is sensible, because
76 # most of the line info we can get at comes from lnotab.
77 min_bytecode = min(t[0] for t in lnotab)
78 max_bytecode = max(t[0] for t in lnotab)
79 self.assertGreaterEqual(min_bytecode, 0)
80 self.assertLess(max_bytecode, len(code.co_code))
81 # This could conceivably test more (and probably should, as there
82 # aren't very many tests of lnotab), if peepholer wasn't scheduled
83 # to be replaced anyway.
84
85 def test_unot(self):
86 # UNARY_NOT POP_JUMP_IF_FALSE --> POP_JUMP_IF_TRUE'

Calls 3

listClass · 0.85
assertGreaterEqualMethod · 0.80
assertLessMethod · 0.45

Tested by

no test coverage detected