1
0
mirror of https://github.com/mnaberez/py65.git synced 2024-06-02 10:41:28 +00:00

Add tests for list_breakpoints, minor changes

This commit is contained in:
Mike Naberezny 2014-12-14 11:28:27 -08:00
parent 35307df2fc
commit 6b67749d50
2 changed files with 31 additions and 6 deletions

View File

@ -800,12 +800,13 @@ class Monitor(cmd.Cmd):
self._output("Delete the breakpoint on execution marked by the given number")
def do_list_breakpoints(self, args):
for (index, bp) in enumerate(self._breakpoints):
if bp is None:
continue
label = self._address_parser.label_for(bp, '')
output_string = "Breakpoint %d : $%04X %s" % (index, bp, label)
self._output(output_string.strip())
for i, address in enumerate(self._breakpoints):
if address is not None:
bpinfo = "Breakpoint %d: $%04X" % (i, address)
label = self._address_parser.label_for(address)
if label is not None:
bpinfo += " " + label
self._output(bpinfo)
def help_list_breakpoints(self):
self._output("list_breakpoints")

View File

@ -507,6 +507,30 @@ class MonitorTests(unittest.TestCase):
out = stdout.getvalue()
self.assertTrue(out.startswith("*** No help on foo"))
def test_shortcut_for_list_breakpoints(self):
stdout = StringIO()
mon = Monitor(stdout=stdout)
mon.do_help('lb')
out = stdout.getvalue()
self.assertTrue(out.startswith('list_breakpoints'))
def test_list_breakpoints_shows_breakpoints(self):
stdout = StringIO()
mon = Monitor(stdout=stdout)
mon._breakpoints = [0xffd2]
mon._address_parser.labels = {'chrout': 0xffd2}
mon.do_list_breakpoints('')
out = stdout.getvalue()
self.assertTrue(out.startswith("Breakpoint 0: $FFD2 chrout"))
def test_list_breakpoints_ignores_deleted_breakpoints(self):
stdout = StringIO()
mon = Monitor(stdout=stdout)
mon._breakpoints = [None, 0xffd2]
mon.do_list_breakpoints('')
out = stdout.getvalue()
self.assertTrue(out.startswith("Breakpoint 1: $FFD2"))
# load
def test_shortcut_for_load(self):