1
0
mirror of https://github.com/mnaberez/py65.git synced 2025-01-06 13:31:08 +00:00

Show help when address range is entered incorrectly

This commit is contained in:
Mike Naberezny 2012-02-05 11:10:55 -08:00
parent 90d983c3cb
commit 1a6b3fd5a9
2 changed files with 20 additions and 1 deletions

View File

@ -328,7 +328,11 @@ class Monitor(cmd.Cmd):
start += bytes
def do_disassemble(self, args):
start, end = self._address_parser.range(args)
split = shlex.split(args)
if len(split) != 1:
return self.help_disassemble()
start, end = self._address_parser.range(split[0])
if start == end:
end += 1
@ -350,6 +354,7 @@ class Monitor(cmd.Cmd):
def help_disassemble(self):
self._output("disassemble <address_range>")
self._output("Disassemble instructions in the address range.")
self._output('Range is specified like "<start>:<end+1>".')
def help_step(self):
self._output("step")

View File

@ -246,6 +246,20 @@ class MonitorTests(unittest.TestCase):
out = stdout.getvalue()
self.assertTrue(out.startswith('disassemble'))
def test_help_disassemble(self):
stdout = StringIO()
mon = Monitor(stdout=stdout)
mon.help_disassemble()
out = stdout.getvalue()
self.assertTrue(out.startswith('disassemble <address_range>'))
def test_disassemble_shows_help_when_given_extra_args(self):
stdout = StringIO()
mon = Monitor(stdout=stdout)
mon.do_disassemble("c000 c001")
out = stdout.getvalue()
self.assertTrue(out.startswith('disassemble <address_range>'))
# fill
def test_shortcut_f_for_fill(self):