refactor: split the Lua runtime, share test stubs, add a Makefile
lua_app.cpp had grown to 701 lines holding every binding, the module loader and the app lifecycle, so new bindings landed wherever the cursor was. Each Lua table now has its own file under bindings/, and the app is recovered from the lua_State's extra space instead of a file-static, so a second state cannot reach the wrong app. Three tests each redeclared the binding surface, which broke twice this session when a binding changed; test/fake_device.lua is now the single stub. `make test` runs all four suites and pins Lua 5.4, matching the vendored interpreter rather than the 5.2 the tests had silently been using.
This commit is contained in:
+5
-19
@@ -1,29 +1,15 @@
|
||||
-- Run: lua test/ui_theme.lua
|
||||
-- Asserts the palette ui.lua derives from a theme's three seed colors.
|
||||
package.path = "sdcard/lib/?.lua;" .. package.path
|
||||
|
||||
local themeName = "light"
|
||||
|
||||
-- Packing the channels keeps them recoverable, so contrast is checkable.
|
||||
gui = {
|
||||
color = function(r, g, b) return r * 65536 + g * 256 + b end,
|
||||
width = function() return 320 end,
|
||||
height = function() return 480 end,
|
||||
clear = function() end,
|
||||
fillRect = function() end,
|
||||
drawText = function() end,
|
||||
roundRect = function() end,
|
||||
fontHeight = function() return 8 end,
|
||||
textWidth = function(text) return #text * 6 end,
|
||||
}
|
||||
sys = {millis = function() return 0 end, getTheme = function() return themeName end}
|
||||
-- Asserts the palette ui.lua derives from a theme's three seed colors. The fake packs
|
||||
-- channels into one integer, so contrast between roles stays checkable.
|
||||
package.path = "sdcard/lib/?.lua;test/?.lua;" .. package.path
|
||||
|
||||
local device = require("fake_device").install()
|
||||
local ui = require("ui")
|
||||
|
||||
local BLACK, WHITE = gui.color(0, 0, 0), gui.color(255, 255, 255)
|
||||
|
||||
local function reload(name)
|
||||
themeName = name
|
||||
device.theme = name
|
||||
return ui.reloadTheme()
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user