mirror of
https://github.com/mnaberez/py65.git
synced 2025-04-11 09:37:09 +00:00
Catch exception from bad label in "fill" command
This commit is contained in:
parent
60921f9691
commit
37cefce91a
@ -322,8 +322,8 @@ class Monitor(cmd.Cmd):
|
||||
end = start + len(bytes)
|
||||
self._mpu.memory[start:end] = bytes
|
||||
self.do_disassemble(self.addrFmt % start)
|
||||
except KeyError:
|
||||
self._output("Bad label: %s" % args)
|
||||
except KeyError as exc:
|
||||
self._output(exc.args[0]) # "Label not found: foo"
|
||||
except OverflowError:
|
||||
self._output("Overflow error: %s" % args)
|
||||
except SyntaxError:
|
||||
@ -343,8 +343,8 @@ class Monitor(cmd.Cmd):
|
||||
else:
|
||||
try:
|
||||
start = self._address_parser.number(args)
|
||||
except KeyError:
|
||||
self._output("Bad label: %s" % args)
|
||||
except KeyError as exc:
|
||||
self._output(exc.args[0]) # "Label not found: foo"
|
||||
return
|
||||
|
||||
while True:
|
||||
@ -696,10 +696,13 @@ class Monitor(cmd.Cmd):
|
||||
if len(split) < 2:
|
||||
return self.help_fill()
|
||||
|
||||
start, end = self._address_parser.range(split[0])
|
||||
filler = list(map(self._address_parser.number, split[1:]))
|
||||
|
||||
self._fill(start, end, filler)
|
||||
try:
|
||||
start, end = self._address_parser.range(split[0])
|
||||
filler = list(map(self._address_parser.number, split[1:]))
|
||||
except KeyError as exc:
|
||||
self._output(exc.args[0]) # "Label not found: foo"
|
||||
else:
|
||||
self._fill(start, end, filler)
|
||||
|
||||
def _fill(self, start, end, filler):
|
||||
address = start
|
||||
|
@ -150,10 +150,10 @@ class MonitorTests(unittest.TestCase):
|
||||
def test_do_assemble_shows_bad_label_error(self):
|
||||
stdout = StringIO()
|
||||
mon = Monitor(stdout=stdout)
|
||||
mon.do_assemble('nonexistant rts')
|
||||
mon.do_assemble('nonexistent rts')
|
||||
|
||||
out = stdout.getvalue()
|
||||
self.assertEqual("Bad label: nonexistant rts\n", out)
|
||||
self.assertEqual("Label not found: nonexistent\n", out)
|
||||
|
||||
def test_do_assemble_shows_bad_syntax_error(self):
|
||||
stdout = StringIO()
|
||||
@ -226,7 +226,7 @@ class MonitorTests(unittest.TestCase):
|
||||
def test_do_cd_with_bad_dir_shows_error(self):
|
||||
stdout = StringIO()
|
||||
mon = Monitor(stdout=stdout)
|
||||
mon.do_cd("/path/to/a/nonexistant/directory")
|
||||
mon.do_cd("/path/to/a/nonexistent/directory")
|
||||
|
||||
out = stdout.getvalue()
|
||||
self.assertTrue(out.startswith("Cannot change directory"))
|
||||
@ -442,6 +442,22 @@ class MonitorTests(unittest.TestCase):
|
||||
out = stdout.getvalue()
|
||||
self.assertTrue(out.startswith('Wrote +4 bytes from $c000 to $c003'))
|
||||
|
||||
def test_do_fill_bad_label_in_address_shows_error(self):
|
||||
stdout = StringIO()
|
||||
mon = Monitor(stdout=stdout)
|
||||
mon.do_fill('nonexistent 0')
|
||||
|
||||
out = stdout.getvalue()
|
||||
self.assertTrue(out.startswith("Label not found: nonexistent"))
|
||||
|
||||
def test_do_fill_bad_label_in_value_shows_error(self):
|
||||
stdout = StringIO()
|
||||
mon = Monitor(stdout=stdout)
|
||||
mon.do_fill('0 nonexistent')
|
||||
|
||||
out = stdout.getvalue()
|
||||
self.assertTrue(out.startswith("Label not found: nonexistent"))
|
||||
|
||||
# goto
|
||||
|
||||
def test_shortcut_for_goto(self):
|
||||
|
Loading…
x
Reference in New Issue
Block a user