diff options
Diffstat (limited to 'tests/run.lua')
| -rw-r--r-- | tests/run.lua | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/tests/run.lua b/tests/run.lua index 4549ab7..b4519fe 100644 --- a/tests/run.lua +++ b/tests/run.lua @@ -5622,6 +5622,40 @@ test("Acquisition cleanup runs from a finally block", function() same(2, #host:redraws()) end) +test("Each macro acquisition consumes and commits input", function() + local state = fresh_sequence_state() + local host = MemoryHost.new({ + buffer_lines = { "abc" }, + configuration = { + mark_cursor = false, + mark_char = false, + }, + input_packets = { + { kind = "text", text = "a" }, + { kind = "text", text = "b" }, + }, + }) + local service = acquisition_service.new(host) + local origin = domain.Position.new(1, 1) + + local first = service:acquire("f", "n", origin, nil, "q") + same("a", first.target.value) + same("a", state:get_previous_target("n").value) + local second = service:acquire("t", "n", origin, nil, "q") + same("b", second.target.value) + same("b", state:get_previous_target("n").value) + same(domain.Descriptor.TILL_FORWARD, state:get_previous_descriptor("n")) + same(domain.ModeContext.from_full_mode("n"), state.last_input_context) + + local reads = 0 + for _, operation in ipairs(host:operations()) do + if operation.operation == "read_input" then + reads = reads + 1 + end + end + same(2, reads) +end) + for _, item in ipairs(tests) do local ok, failure = xpcall(item.body, debug.traceback) if not ok then |
