(self)
| 2294 | self.assertEqual(8, instructions[6].start_offset) |
| 2295 | |
| 2296 | def test_cache_offset_and_end_offset(self): |
| 2297 | code = bytes([ |
| 2298 | opcode.opmap["LOAD_GLOBAL"], 0x01, |
| 2299 | opcode.opmap["CACHE"], 0x00, |
| 2300 | opcode.opmap["CACHE"], 0x00, |
| 2301 | opcode.opmap["CACHE"], 0x00, |
| 2302 | opcode.opmap["CACHE"], 0x00, |
| 2303 | opcode.opmap["LOAD_FAST"], 0x00, |
| 2304 | opcode.opmap["CALL"], 0x01, |
| 2305 | opcode.opmap["CACHE"], 0x00, |
| 2306 | opcode.opmap["CACHE"], 0x00, |
| 2307 | opcode.opmap["CACHE"], 0x00 |
| 2308 | ]) |
| 2309 | instructions = list(self.get_instructions(code)) |
| 2310 | self.assertEqual(2, instructions[0].cache_offset) |
| 2311 | self.assertEqual(10, instructions[0].end_offset) |
| 2312 | self.assertEqual(12, instructions[1].cache_offset) |
| 2313 | self.assertEqual(12, instructions[1].end_offset) |
| 2314 | self.assertEqual(14, instructions[2].cache_offset) |
| 2315 | self.assertEqual(20, instructions[2].end_offset) |
| 2316 | |
| 2317 | # end_offset of the previous instruction should be equal to the |
| 2318 | # start_offset of the following instruction |
| 2319 | instructions = list(dis.Bytecode(self.test_cache_offset_and_end_offset)) |
| 2320 | for prev, curr in zip(instructions, instructions[1:]): |
| 2321 | self.assertEqual(prev.end_offset, curr.start_offset) |
| 2322 | |
| 2323 | |
| 2324 | # get_instructions has its own tests above, so can rely on it to validate |
nothing calls this directly
no test coverage detected