From 80206387c712c2ef78eb1ce6546aa3d3969d7bb8 Mon Sep 17 00:00:00 2001 From: Jackson Moore Date: Fri, 4 Sep 2026 10:48:45 +0200 Subject: Preserve history after incomplete moves --- tests/run.lua | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'tests') diff --git a/tests/run.lua b/tests/run.lua index 65d831b..02f5e2d 100644 --- a/tests/run.lua +++ b/tests/run.lua @@ -3193,6 +3193,44 @@ test("Command execution applies the last reached count endpoint", function() same(domain.Position.new(1, 5), outcome.position) end) +test("Incomplete command execution preserves successful history", function() + local state, transitions = fresh_sequence_state() + local previous_target = target("a") + local previous_landing = domain.Position.new(1, 1) + transitions:BeginAcquisition("n", "f") + transitions:CommitAcquiredTarget("n", previous_target, 25) + transitions:CommitCommandSuccess("n", previous_landing, false) + + local host = MemoryHost.new({ + buffer_lines = { "axaxa" }, + cursor = previous_landing, + }) + local executor = motion_executor.new(host) + local plan = motion_plan.build( + target_plan.build(previous_target, matching_policy()), + "f" + ) + local descriptor_before = state:get_previous_descriptor("n") + local first_move_before = state:get_first_move("n") + local direction_before = state.moved_forward + + local outcome = executor:execute( + text_topology.from_host(host), + "n", + plan, + 3, + false + ) + same(domain.ActionKind.FAILED_SEARCH, outcome.kind) + same(domain.Position.new(1, 5), host:read_cursor()) + same(previous_landing, state:get_previous_landing("n")) + same(descriptor_before, state:get_previous_descriptor("n")) + same(first_move_before, state:get_first_move("n")) + same(previous_target, state:get_previous_target("n")) + same(direction_before, state.moved_forward) + same(25, state.repeat_timestamp_ms) +end) + for _, item in ipairs(tests) do local ok, failure = xpcall(item.body, debug.traceback) if not ok then -- cgit v1.2.3