mindcode
mindcode copied to clipboard
Enhancement: unit tests
So, today's session of debugging some Mindcode has given me another idea: unit testing of Mindcode.
We already have a processor emulator, so we can run compiled Mindcode. Unit tests might be, for simplicity, contained in the same source file as the code being tested, perhaps in some separate section, perhaps just functions marked with some annotation.
All test functions would be run. If they return anything else than 0
, the test would fail and the output of the text buffer would be printed.
The processor emulator can already emulate memory cells and memory banks. In the future, more parts of the Mindustry World could be emulated (mocked). The mocked world would be static - certainly at the beginning.
As a first step, the mocked objects would just return values when sensed (this could be easily provided as a collection of property-value pairs) and would accept any calls. Later the calls might be somehow tracked too.