[Updated files. Test now reads back Screen to ensure that the horizontal lines are present.]
longj_silver wrote
I rely on command line executions of the simulators and I stumbled on testing the Memory chip by means of HardwareSimulator. When I execute it in command line mode, it seems to indefinitely loop: probably that is due to the test mechanism requiring for this chip to press a couple of keys.
Memory.tst is definitely hanging because the keys are never being pressed.
I don't know how the Coursera grader works; I'm not involved with that.
The quickest solution would be to remove the code in the test script that is waiting for a key and modifying the compare file to match the new output, but this is non-ideal because the Keyboard interface in Memory.hdl then goes untested.
The better solution is to give the test scripts some way to press keys. I took a look at the source code and saw that all the infrastructure for the built-in Keyboard part to recieve values from the test script's "set" command is already there; it just raises an "unimplemented" exception.
So I've spent the last hour or so hacking code... (Warning, I'm not a Java programmer; somebody who is should vet my changes!)
So, here's a Keyboard part that tests can drive, and a test script that will work from the command line.
Keep a copy of the original Keyboard.class in case mine is buggy.
Test script examples:
set Keyboard[] 75; // press 'K'
set Keyboard[] 0; // release key
--Mark