summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJackson Moore <jacksonmoore@tuta.io>2026-09-04 12:45:10 +0200
committerJackson Moore <jacksonmoore@tuta.io>2026-09-04 12:45:10 +0200
commit800ec4fae75b9bfb69b132ddffc28d88c8690a3b (patch)
tree9271569157983d1536b30f40241501b19cbb8347 /tests
parentf52894183ed7f8f0d19afc095fe711f35d6847f7 (diff)
Reject stale timer callbacks
Diffstat (limited to 'tests')
-rw-r--r--tests/run.lua21
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/run.lua b/tests/run.lua
index a511fb0..c3e7009 100644
--- a/tests/run.lua
+++ b/tests/run.lua
@@ -6645,6 +6645,27 @@ test("Each new highlight timer identity is stored in sequence state", function()
same(40, host:timers()[second].delay_ms)
end)
+test("Timer callbacks compare their identity with current state", function()
+ local state, transitions = fresh_sequence_state()
+ local host = MemoryHost.new({
+ configuration = {
+ mark_char = true,
+ highlight_timeout_ms = 10,
+ },
+ })
+ local feedback = feedback_service.new({
+ host = host,
+ transitions = transitions,
+ })
+ local stale = feedback:start_highlight_timer()
+ local current = feedback:start_highlight_timer()
+
+ falsy(feedback:handle_highlight_timer(stale))
+ same(current, state.highlight_timer)
+ truthy(feedback:handle_highlight_timer(current))
+ same(current, state.highlight_timer)
+end)
+
for _, item in ipairs(tests) do
local ok, failure = xpcall(item.body, debug.traceback)
if not ok then