Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add test
  • Loading branch information
picnixz committed Aug 20, 2024
commit aed2959b4fec788168169d6f4bb522770c8ab25a
19 changes: 19 additions & 0 deletions Lib/test/test_dis.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,22 @@ def _f(a):
_f.__code__.co_firstlineno + 1,
_f.__code__.co_firstlineno + 2)

dis_f_with_positions = f"""\
%-14s RESUME 0

%-14s LOAD_GLOBAL 1 (print + NULL)
%-14s LOAD_FAST 0 (a)
%-14s CALL 1
%-14s POP_TOP

%-14s RETURN_CONST 1 (1)
""" % tuple(map('%s:%s-%s:%s'.__mod__, [
tuple('?' if __p is None else __p for __p in __instruction.positions)
for __instruction in dis._get_instructions_bytes(
dis._get_code_array(_f.__code__, True),
co_positions=_f.__code__.co_positions(),
)
]))
Comment thread
picnixz marked this conversation as resolved.
Outdated

dis_f_co_code = """\
RESUME 0
Expand Down Expand Up @@ -950,6 +966,9 @@ def test_dis(self):
def test_dis_with_offsets(self):
self.do_disassembly_test(_f, dis_f_with_offsets, show_offsets=True)

def test_dis_with_positions(self):
self.do_disassembly_test(_f, dis_f_with_positions, show_positions=True)

def test_bug_708901(self):
self.do_disassembly_test(bug708901, dis_bug708901)

Expand Down