Permalink
Browse files

Add "h" as a monitor shortcut for "help"

  • Loading branch information...
1 parent 24f9849 commit 02ff83d18bbefd0199a790d734c35a86b82d713d @mnaberez committed Feb 9, 2012
Showing with 33 additions and 7 deletions.
  1. +2 −0 CHANGES.txt
  2. +2 −1 src/py65/monitor.py
  3. +29 −6 src/py65/tests/test_monitor.py
View
2 CHANGES.txt
@@ -10,6 +10,8 @@
- Fixed the cycle count of 0xD2 (CMP zero page indirect) in
the 65C02 simulation. Thanks to Brian Cassidy for reporting it.
+ - Added "h" as a monitor shortcut for "help".
+
0.11 (2012-01-07)
- Added a new 65Org16 MPU simulation written by Ed Spittles.
View
3 src/py65/monitor.py
@@ -117,14 +117,15 @@ def _reset(self, mpu_type):
def _add_shortcuts(self):
self._shortcuts = {'~': 'tilde',
- '?': 'help',
'a': 'assemble',
'al': 'add_label',
'd': 'disassemble',
'dl': 'delete_label',
'f': 'fill',
'>': 'fill',
'g': 'goto',
+ 'h': 'help',
+ '?': 'help',
'l': 'load',
'm': 'mem',
'q': 'quit',
View
35 src/py65/tests/test_monitor.py
@@ -379,18 +379,41 @@ def test_shortcut_for_goto(self):
# help
- def test_help_accepts_command_shortcuts(self):
+ def test_help_without_args_shows_documented_commands(self):
stdout = StringIO()
mon = Monitor(stdout=stdout)
+ mon.onecmd('help')
+ out = stdout.getvalue()
+ self.assertTrue("Documented commands" in out)
- mon.onecmd("help assemble \t ")
- help_for_command = stdout.getvalue()
+ stdout.truncate(0)
+ mon.onecmd('h')
+ out = stdout.getvalue()
+ self.assertTrue("Documented commands" in out)
stdout.truncate(0)
- mon.onecmd("help a \t ")
- help_for_shortcut = stdout.getvalue()
+ mon.onecmd('?')
+ out = stdout.getvalue()
+ self.assertTrue("Documented commands" in out)
- self.assertEqual(help_for_command, help_for_shortcut)
+ def test_help_with_args_shows_command_help(self):
+ stdout = StringIO()
+ mon = Monitor(stdout=stdout)
+ mon.onecmd('help assemble')
+ out = stdout.getvalue()
+ self.assertTrue(out.startswith("assemble <address>"))
+
+ stdout.truncate(0)
+ mon.onecmd('h a')
+ out = stdout.getvalue()
+ self.assertTrue("assemble <address>" in out)
+
+ def test_help_with_invalid_args_shows_error(self):
+ stdout = StringIO()
+ mon = Monitor(stdout=stdout)
+ mon.onecmd('help foo')
+ out = stdout.getvalue()
+ self.assertTrue(out.startswith("*** No help on foo"))
# load

0 comments on commit 02ff83d

Please sign in to comment.