Start some "unit tests" for Lua. This suite of scripts will demonstrate, document, and test the intended behavior of various lua methods

This commit is contained in:
adelikat 2014-03-27 01:16:38 +00:00
parent 51f480901b
commit f6699389f7
2 changed files with 43 additions and 0 deletions

View File

@ -0,0 +1,42 @@
console.log("Unit test for joypad.set")
console.log("Core Required: NES (or any multi-player core with U,D,L,R,select,start,A,B as buttons)")
console.log("Correct behavior:")
console.log("No Directional button shoudl be imparied in any way, should operate as if nothing was ever pressed")
console.log("A should be off and user can not push buttons to change that")
console.log("B should be on and the user can not push buttons to change that")
console.log("Select should be on, but pressing it turns it off")
console.log("Start should be unaffected")
console.log("After frame 600, the console will say 'cleared', and now all buttons should be off and unaffected, as if the script was never run");
buttons = { };
buttons["P1 Up"] = false;
buttons["P1 Down"] = true;
buttons["P1 Left"] = "invert";
buttons["P1 Right"] = null;
pushThings = false;
while true do
if (pushThings) then
buttons["P1 A"] = false;
buttons["P1 B"] = true;
buttons["P1 Select"] = "invert";
buttons["P1 Start"] = null;
joypad.set(buttons);
end
if (emu.framecount() == 600) then
pushThings = false;
turnoff = { };
turnoff["P1 A"] = null;
turnoff["P1 B"] = null;
turnoff["P1 Select"] = null;
turnoff["P1 Start"] = null;
joypad.set(turnoff);
console.log("cleared")
end
emu.frameadvance();
end

View File

@ -0,0 +1 @@
0 .\Lua\UnitTests\Joypad_Set.lua