1
0
mirror of https://github.com/mnaberez/py65.git synced 2024-09-27 09:55:23 +00:00

Show help when address range is entered incorrectly

This commit is contained in:
Mike Naberezny 2012-02-07 15:03:00 -08:00
parent 38eb82563d
commit 09f08e727f
2 changed files with 23 additions and 2 deletions

View File

@ -597,9 +597,14 @@ class Monitor(cmd.Cmd):
def help_mem(self):
self._output("mem <address_range>")
self._output("Display the contents of memory.")
self._output('Range is specified like "<start:end>".')
def do_mem(self, args):
start, end = self._address_parser.range(args)
split = shlex.split(args)
if len(split) != 1:
return self.help_mem()
start, end = self._address_parser.range(split[0])
line = self.addrFmt % start + ":"
for address in range(start, end+1):

View File

@ -441,7 +441,23 @@ class MonitorTests(unittest.TestCase):
mon.do_help('m')
out = stdout.getvalue()
self.assertTrue(out.startswith('mem'))
self.assertTrue(out.startswith('mem <address_range>'))
def test_do_mem_shows_help_when_given_no_args(self):
stdout = StringIO()
mon = Monitor(stdout=stdout)
mon.do_mem('')
out = stdout.getvalue()
self.assertTrue(out.startswith('mem <address_range>'))
def test_do_mem_shows_help_when_given_extra_args(self):
stdout = StringIO()
mon = Monitor(stdout=stdout)
mon.do_mem('c000 c001')
out = stdout.getvalue()
self.assertTrue(out.startswith('mem <address_range>'))
# mpu