diff options
Diffstat (limited to 'tests/run.lua')
| -rw-r--r-- | tests/run.lua | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/tests/run.lua b/tests/run.lua index 1df3d0e..4139544 100644 --- a/tests/run.lua +++ b/tests/run.lua @@ -5563,6 +5563,59 @@ test("Acquisition releases direct cursor and presentation resources", function() truthy(restore_index > removals[2].index) end) +test("Acquisition cleanup runs from a finally block", function() + local state = fresh_sequence_state() + local prior = { + hidden = false, + guicursor = "n:block", + } + local host = MemoryHost.new({ + buffer_lines = { "abc" }, + cursor_presentation = prior, + configuration = { + mark_cursor = true, + mark_direct = true, + mark_char = false, + show_prompt = true, + }, + input_packets = { { kind = "error", message = "input failed" } }, + }) + local service = acquisition_service.new(host) + + local result = service:acquire( + "f", + "n", + domain.Position.new(1, 1), + nil, + nil + ) + same(domain.ActionKind.ERROR, result.outcome.kind) + same("input failed", result.outcome.diagnostic) + falsy(service:last_temporary_scope().active) + same(0, #state:temporary_overlay_identities()) + same(0, map_size(host:highlights())) + same(prior.hidden, host:cursor_presentation().hidden) + same(prior.guicursor, host:cursor_presentation().guicursor) + same(1, #host:diagnostics()) + same("input failed", host:diagnostics()[1].text) + + local read_index + local remove_index + local restore_index + for index, operation in ipairs(host:operations()) do + if operation.operation == "read_input" then + read_index = index + elseif operation.operation == "remove_highlight" then + remove_index = index + elseif operation.operation == "restore_cursor_presentation" then + restore_index = index + end + end + truthy(remove_index > read_index) + truthy(restore_index > remove_index) + same(2, #host:redraws()) +end) + for _, item in ipairs(tests) do local ok, failure = xpcall(item.body, debug.traceback) if not ok then |
