Having written a lot of NodeJS test code using libraries like Mocha, Rewire, Should I was able to catch a lot of bugs early, and more importantly to catch bugs introduced during rewrites, just by re-running the test code. Further, we use gitlab for our code repository which allows us to write macros for various events, especially during commits which allows us to run test code automatically.
I would like 2 features added to the simulator:
- Make some kind of object available in the simulator that can be called using special functions in code where test data can be stored, whether variables, memory, data from the Watch Clock, etc.
- Further, make this object (and the debugger) accessible from the command line in the form of stdin (to push the object into the simulator) and stdout (to get the results of the test).
Code: Select all
void updateMikroCstdoutPointer() {
//Code to find the end of the data in mikroC.stdout
}
main() {
unsigned short testValue, returnValue;
unsigned int mikrocStdOutPointer = 0;
char strData[20];
testValue = 1;
returnValue = lib_function(testValue);
if (returnValue == 1) { //the right result
strcpy(mikroc.stdout[mikrocStdOutPointer], "Test 1 Passed\n");
updateMikroCstdoutPointer();
} else {
strcpy(mikroc.stdout[mikrocStdOutPointer], "Test 1 Failed line: returnValue (should be 1), was ");
updateMikroCstdoutPointer();
IntToStr(returnValue, strData);
strcpy(mikroc.stdout[mikrocStdOutPointer], strData);
updateMikroCstdoutPointer();
}
- mikroc.stdin, mikroc.stdout - strings passed into the debugger when called and out of the debugger (when the sim is done)
- mikroc.sim.pause, mikroc.sim.stop - control the debugger
- mikroc.clock.current.cycles, .delta.cycles, .resetToZero, .MHz - access to the Watch Clock
- This would enable powerful tests for time critical functions
- mikroc.statistics - access to the function, variable and structure sizes