New part in Zframework
This commit is contained in:
@@ -9,6 +9,7 @@ TABLE= require'Zframework.tableExtend'
|
||||
STRING= require'Zframework.stringExtend'
|
||||
PROFILE= require'Zframework.profile'
|
||||
JSON= require'Zframework.json'
|
||||
TESTING= require'Zframework.testing'
|
||||
do--Add pcall & MES for JSON lib
|
||||
local encode,decode=JSON.encode,JSON.decode
|
||||
JSON.encode=function(val)
|
||||
|
||||
13
Zframework/testing.lua
Normal file
13
Zframework/testing.lua
Normal file
@@ -0,0 +1,13 @@
|
||||
--Utils for testing
|
||||
local testing={}
|
||||
|
||||
--Wait for the scene swapping animation to finish
|
||||
function testing.switchSCN()
|
||||
while SCN.swapping do YIELD()end
|
||||
end
|
||||
|
||||
function testing.sleep(frames)
|
||||
for _=1,frames do YIELD()end
|
||||
end
|
||||
|
||||
return testing
|
||||
11
main.lua
11
main.lua
@@ -582,24 +582,25 @@ for i=1,#_LOADTIMELIST_ do LOG(_LOADTIMELIST_[i])end
|
||||
|
||||
if TABLE.find(arg,'--test')then
|
||||
TASK.new(function()
|
||||
local switchSCN,sleep=TESTING.switchSCN,TESTING.sleep
|
||||
while not LOADED do YIELD()end
|
||||
|
||||
print("\27[92m\27[1mAutomatic Test Started\27[0m")
|
||||
BGM.setVol(0)SFX.setVol(0)
|
||||
love.keypressed('space')
|
||||
while SCN.swapping do YIELD()end
|
||||
switchSCN()
|
||||
|
||||
for k,mode in next,MODES do
|
||||
if k~='netBattle'then
|
||||
print("Scanning mode: "..mode.name)
|
||||
loadGame(mode.name,true)
|
||||
while SCN.swapping do YIELD()end
|
||||
switchSCN()
|
||||
SCN.back()
|
||||
while SCN.swapping do YIELD()end
|
||||
switchSCN()
|
||||
end
|
||||
end
|
||||
print("\27[92m\27[1mAutomatic Test Passed :)\27[0m")
|
||||
for _=1,60 do YIELD()end
|
||||
sleep(60)
|
||||
love.event.quit(0)
|
||||
end)
|
||||
TASK.new(function()
|
||||
@@ -608,7 +609,7 @@ if TABLE.find(arg,'--test')then
|
||||
if ERRDATA[1]then break end
|
||||
end
|
||||
print("\27[91m\27[1mAutomatic Test Failed :(\27[0m\nThe error message is:\n"..table.concat(ERRDATA[1].mes,"\n").."\27[91m\nAborting\27[0m")
|
||||
for _=1,60 do YIELD()end
|
||||
TESTING.sleep(60)
|
||||
love.event.quit(1)
|
||||
end)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user