From 90d983c3cbd88ce2e0aa02629869b81757524631 Mon Sep 17 00:00:00 2001 From: Mike Naberezny Date: Sat, 4 Feb 2012 19:24:56 -0800 Subject: [PATCH] Add tests for the cycles command --- src/py65/tests/test_monitor.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/py65/tests/test_monitor.py b/src/py65/tests/test_monitor.py index caa9b15..496cc3c 100644 --- a/src/py65/tests/test_monitor.py +++ b/src/py65/tests/test_monitor.py @@ -175,6 +175,34 @@ class MonitorTests(unittest.TestCase): out = stdout.getvalue() self.assertTrue(out.startswith("Cannot change directory")) + # cycles + + def test_help_cycles(self): + stdout = StringIO() + mon = Monitor(stdout=stdout) + mon.help_cycles() + + out = stdout.getvalue() + self.assertTrue(out.startswith("Display the total number of cycles")) + + def test_do_cycles_shows_zero_initially(self): + stdout = StringIO() + mon = Monitor(stdout=stdout) + mon.do_cycles("") + + out = stdout.getvalue() + self.assertEqual(out, "0\n") + + def test_do_cycles_shows_count_after_step(self): + stdout = StringIO() + mon = Monitor(stdout=stdout) + mon._mpu.memory[0x0000] = 0xEA #=> NOP (2 cycles) + mon._mpu.step() + mon.do_cycles("") + + out = stdout.getvalue() + self.assertEqual(out, "2\n") + # delete_label def test_shortcut_for_delete_label(self):