diff options
Diffstat (limited to 'tests/run.lua')
| -rw-r--r-- | tests/run.lua | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/tests/run.lua b/tests/run.lua index 17d5b4b..7e5659a 100644 --- a/tests/run.lua +++ b/tests/run.lua @@ -3935,6 +3935,60 @@ test("Zero repeat timeout keeps repetition without reading time", function() end end) +test("Expired repeat applies Public Reset and requests acquisition", function() + local state, transitions = fresh_sequence_state() + local retained_target = target("a") + transitions:BeginAcquisition("n", "f") + transitions:CommitAcquiredTarget("n", retained_target, 100) + transitions:CommitCommandSuccess("n", domain.Position.new(1, 2), true) + transitions:CacheMigemo("utf-8", { dictionary = true }) + transitions:SetHighlightTimer("timer-expired") + transitions:AddTargetOverlay("char-current", "window-1", 1) + transitions:AddTargetOverlay("char-peer", "window-2", 1) + transitions:AddFinalizer("finalizer-retained", "buffer-1") + + local timestamp_at_reset + local observed_window + local ordered_transitions = { + SetRepeatTimestamp = function(_, time_ms) + return transitions:SetRepeatTimestamp(time_ms) + end, + PublicReset = function(_, current_window) + timestamp_at_reset = state.repeat_timestamp_ms + observed_window = current_window + return transitions:PublicReset(current_window) + end, + } + local host = MemoryHost.new({ + configuration = { repeat_timeout_ms = 100 }, + time_values_ms = { 201 }, + }) + local resolver = repeat_resolver.new({ + clock = host, + policy = policy.new(host), + transitions = ordered_transitions, + }) + + local decision, elapsed_ms, cleanup = resolver:evaluate_timeout("window-1") + same(repeat_resolver.Decision.ACQUIRE, decision) + same(101, elapsed_ms) + same(201, timestamp_at_reset) + same("window-1", observed_window) + same(nil, state:get_previous_descriptor("n")) + same(nil, state:get_previous_landing("n")) + same(nil, state:get_first_move("n")) + same(retained_target, state:get_previous_target("n")) + truthy(state.moved_forward) + same(0, state.repeat_timestamp_ms) + same(0, map_size(state.migemo_cache)) + same(nil, state.highlight_timer) + same(1, #state.target_overlays) + same("window-2", state.target_overlays[1].window) + same(1, #state.finalizers) + same("timer-expired", cleanup.highlight_timer) + same("char-current", cleanup.target_overlays[1].identity) +end) + for _, item in ipairs(tests) do local ok, failure = xpcall(item.body, debug.traceback) if not ok then |
