From 6b67749d506634c6f64eedd0745c68fa16d69e5b Mon Sep 17 00:00:00 2001 From: Mike Naberezny Date: Sun, 14 Dec 2014 11:28:27 -0800 Subject: [PATCH] Add tests for list_breakpoints, minor changes --- py65/monitor.py | 13 +++++++------ py65/tests/test_monitor.py | 24 ++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 6 deletions(-) diff --git a/py65/monitor.py b/py65/monitor.py index 4672761..9483bdd 100644 --- a/py65/monitor.py +++ b/py65/monitor.py @@ -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") diff --git a/py65/tests/test_monitor.py b/py65/tests/test_monitor.py index 851e54b..f0a8952 100644 --- a/py65/tests/test_monitor.py +++ b/py65/tests/test_monitor.py @@ -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):