check for 'error' mode in a few more places
In particular, I want to be able to switch to 'error' mode rather than throw a real error() on test failures, because that's a little more responsive and might be recoverable. (On some Android devices the font is slightly different, and tests fail as a result.)
This commit is contained in:
parent
d90dff3286
commit
7057ac74ec
19
main.lua
19
main.lua
|
@ -66,6 +66,7 @@ function App.load()
|
||||||
load_file_from_source_or_save_directory('colorize.lua')
|
load_file_from_source_or_save_directory('colorize.lua')
|
||||||
load_file_from_source_or_save_directory('source_text_tests.lua')
|
load_file_from_source_or_save_directory('source_text_tests.lua')
|
||||||
load_file_from_source_or_save_directory('source_tests.lua')
|
load_file_from_source_or_save_directory('source_tests.lua')
|
||||||
|
elseif Current_app == 'error' then
|
||||||
else
|
else
|
||||||
assert(false, 'unknown app "'..Current_app..'"')
|
assert(false, 'unknown app "'..Current_app..'"')
|
||||||
end
|
end
|
||||||
|
@ -93,6 +94,7 @@ function App.initialize_globals()
|
||||||
run.initialize_globals()
|
run.initialize_globals()
|
||||||
elseif Current_app == 'source' then
|
elseif Current_app == 'source' then
|
||||||
source.initialize_globals()
|
source.initialize_globals()
|
||||||
|
elseif Current_app == 'error' then
|
||||||
else
|
else
|
||||||
assert(false, 'unknown app "'..Current_app..'"')
|
assert(false, 'unknown app "'..Current_app..'"')
|
||||||
end
|
end
|
||||||
|
@ -113,6 +115,7 @@ function App.initialize(arg)
|
||||||
run.initialize(arg)
|
run.initialize(arg)
|
||||||
elseif Current_app == 'source' then
|
elseif Current_app == 'source' then
|
||||||
source.initialize(arg)
|
source.initialize(arg)
|
||||||
|
elseif Current_app == 'error' then
|
||||||
else
|
else
|
||||||
assert(false, 'unknown app "'..Current_app..'"')
|
assert(false, 'unknown app "'..Current_app..'"')
|
||||||
end
|
end
|
||||||
|
@ -123,6 +126,7 @@ function App.resize(w,h)
|
||||||
if run.resize then run.resize(w,h) end
|
if run.resize then run.resize(w,h) end
|
||||||
elseif Current_app == 'source' then
|
elseif Current_app == 'source' then
|
||||||
if source.resize then source.resize(w,h) end
|
if source.resize then source.resize(w,h) end
|
||||||
|
elseif Current_app == 'error' then
|
||||||
else
|
else
|
||||||
assert(false, 'unknown app "'..Current_app..'"')
|
assert(false, 'unknown app "'..Current_app..'"')
|
||||||
end
|
end
|
||||||
|
@ -134,6 +138,7 @@ function App.filedropped(file)
|
||||||
if run.file_drop then run.file_drop(file) end
|
if run.file_drop then run.file_drop(file) end
|
||||||
elseif Current_app == 'source' then
|
elseif Current_app == 'source' then
|
||||||
if source.file_drop then source.file_drop(file) end
|
if source.file_drop then source.file_drop(file) end
|
||||||
|
elseif Current_app == 'error' then
|
||||||
else
|
else
|
||||||
assert(false, 'unknown app "'..Current_app..'"')
|
assert(false, 'unknown app "'..Current_app..'"')
|
||||||
end
|
end
|
||||||
|
@ -147,21 +152,22 @@ function App.focus(in_focus)
|
||||||
if run.focus then run.focus(in_focus) end
|
if run.focus then run.focus(in_focus) end
|
||||||
elseif Current_app == 'source' then
|
elseif Current_app == 'source' then
|
||||||
if source.focus then source.focus(in_focus) end
|
if source.focus then source.focus(in_focus) end
|
||||||
|
elseif Current_app == 'error' then
|
||||||
else
|
else
|
||||||
assert(false, 'unknown app "'..Current_app..'"')
|
assert(false, 'unknown app "'..Current_app..'"')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function App.draw()
|
function App.draw()
|
||||||
if Current_app == 'error' then
|
if Current_app == 'run' then
|
||||||
|
run.draw()
|
||||||
|
elseif Current_app == 'source' then
|
||||||
|
source.draw()
|
||||||
|
elseif Current_app == 'error' then
|
||||||
love.graphics.setColor(0,0,1)
|
love.graphics.setColor(0,0,1)
|
||||||
love.graphics.rectangle('fill', 0,0, App.screen.width, App.screen.height)
|
love.graphics.rectangle('fill', 0,0, App.screen.width, App.screen.height)
|
||||||
love.graphics.setColor(1,1,1)
|
love.graphics.setColor(1,1,1)
|
||||||
love.graphics.printf(Error_message, 40,40, 600)
|
love.graphics.printf(Error_message, 40,40, 600)
|
||||||
elseif Current_app == 'run' then
|
|
||||||
run.draw()
|
|
||||||
elseif Current_app == 'source' then
|
|
||||||
source.draw()
|
|
||||||
else
|
else
|
||||||
assert(false, 'unknown app "'..Current_app..'"')
|
assert(false, 'unknown app "'..Current_app..'"')
|
||||||
end
|
end
|
||||||
|
@ -178,6 +184,7 @@ function App.update(dt)
|
||||||
run.update(dt)
|
run.update(dt)
|
||||||
elseif Current_app == 'source' then
|
elseif Current_app == 'source' then
|
||||||
source.update(dt)
|
source.update(dt)
|
||||||
|
elseif Current_app == 'error' then
|
||||||
else
|
else
|
||||||
assert(false, 'unknown app "'..Current_app..'"')
|
assert(false, 'unknown app "'..Current_app..'"')
|
||||||
end
|
end
|
||||||
|
@ -209,6 +216,7 @@ function App.keychord_press(chord, key)
|
||||||
if source.quit then source.quit() end
|
if source.quit then source.quit() end
|
||||||
Current_app = 'run'
|
Current_app = 'run'
|
||||||
Error_message = nil
|
Error_message = nil
|
||||||
|
elseif Current_app == 'error' then
|
||||||
else
|
else
|
||||||
assert(false, 'unknown app "'..Current_app..'"')
|
assert(false, 'unknown app "'..Current_app..'"')
|
||||||
end
|
end
|
||||||
|
@ -224,6 +232,7 @@ function App.keychord_press(chord, key)
|
||||||
if run.keychord_press then run.keychord_press(chord, key) end
|
if run.keychord_press then run.keychord_press(chord, key) end
|
||||||
elseif Current_app == 'source' then
|
elseif Current_app == 'source' then
|
||||||
if source.keychord_press then source.keychord_press(chord, key) end
|
if source.keychord_press then source.keychord_press(chord, key) end
|
||||||
|
elseif Current_app == 'error' then
|
||||||
else
|
else
|
||||||
assert(false, 'unknown app "'..Current_app..'"')
|
assert(false, 'unknown app "'..Current_app..'"')
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue