(self, code)
| 52 | class TestTranforms(BytecodeTestCase): |
| 53 | |
| 54 | def check_jump_targets(self, code): |
| 55 | instructions = list(dis.get_instructions(code)) |
| 56 | targets = {instr.offset: instr for instr in instructions} |
| 57 | for instr in instructions: |
| 58 | if 'JUMP_' not in instr.opname: |
| 59 | continue |
| 60 | tgt = targets[instr.argval] |
| 61 | # jump to unconditional jump |
| 62 | if tgt.opname in ('JUMP_BACKWARD', 'JUMP_FORWARD'): |
| 63 | self.fail(f'{instr.opname} at {instr.offset} ' |
| 64 | f'jumps to {tgt.opname} at {tgt.offset}') |
| 65 | # unconditional jump to RETURN_VALUE |
| 66 | if (instr.opname in ('JUMP_BACKWARD', 'JUMP_FORWARD') and |
| 67 | tgt.opname == 'RETURN_VALUE'): |
| 68 | self.fail(f'{instr.opname} at {instr.offset} ' |
| 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." |
no test coverage detected