Testing in CEbox#
CEbox is a TI-84 Plus CE emulator with a Lua test runner. It is deterministic, so the same keys always give the same screen and the same cycle count. CEUI’s own tests run in it, and your program’s tests can too. You need a ROM dumped from your own calculator.
A test#
local LAUNCH_MS = 2500
setup(function(calc)
calc:send("libs/libload.8xv")
calc:send("libs/graphx.8xv")
calc:send("../bin/HELLO.8xp")
calc:launch("HELLO")
calc:run{ms = LAUNCH_MS}
end)
test("counts three presses", function(calc)
for _ = 1, 3 do
calc:key("enter", true)
calc:run{ms = 50}
calc:key("enter", false)
calc:run{ms = 350}
end
expect_screen(calc):to_match("golden/hello_three_presses.png")
end)
Put it in a folder as hello.test.lua, with a cebox.toml next to it that names the ROM:
rom = "path/to/rom.rom"
and run:
cebox test tests
Tips#
Press keys with
calc:key(name, down)and run a few milliseconds between down and up.calc:presswaits for an idle OS, which a C program never is.Wait until CEUI is idle before comparing the screen. CEUI’s tests put a breakpoint on
ui__poll, whose address they read from the program’s.mapfile, and run until it is hit.On a mismatch, CEbox saves
actual.pnganddiff.pngin its artifacts folder. When a golden PNG does not exist yet, the test fails and saves the screen asactual.png; check it by eye and copy it next to the test to accept it.For animated screens, pass a tolerance, the fraction of pixels that may differ:
expect_screen(calc):to_match("golden/canvas.png", 0.02).CEbox cannot send the
clibs.8xggroup, so sendlibload.8xvandgraphx.8xvas separate files, taken from the CE libraries build.
CEUI’s own suite in tests/cebox is a complete example:
driver.lua has the helpers for launching, tapping keys and waiting for idle, and each *.test.lua file covers one
screen of the showcase.