summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/run.lua44
1 files changed, 43 insertions, 1 deletions
diff --git a/tests/run.lua b/tests/run.lua
index cab79c5..faad4ba 100644
--- a/tests/run.lua
+++ b/tests/run.lua
@@ -4898,7 +4898,9 @@ end)
test("Acquisition starts one temporary resource scope", function()
fresh_sequence_state()
- local service = acquisition_service.new(MemoryHost.new())
+ local service = acquisition_service.new(MemoryHost.new({
+ input_packets = { { kind = "text", text = "a" } },
+ }))
local request = service:acquire(
"f",
"n",
@@ -4920,6 +4922,7 @@ test("Acquisition creates cursor markers only when enabled", function()
local host = MemoryHost.new({
cursor = { line = 1, byte_column = 4 },
configuration = { mark_cursor = true },
+ input_packets = { { kind = "text", text = "a" } },
})
local service = acquisition_service.new({
host = host,
@@ -4936,6 +4939,7 @@ test("Acquisition creates cursor markers only when enabled", function()
fresh_sequence_state()
local disabled = acquisition_service.new(MemoryHost.new({
configuration = { mark_cursor = false },
+ input_packets = { { kind = "text", text = "a" } },
}))
disabled:acquire("f", "n", domain.Position.new(1, 1), nil, nil)
same(nil, disabled:last_temporary_scope().cursor_marker)
@@ -4945,6 +4949,7 @@ test("Interactive acquisition redraws after cursor marker creation", function()
fresh_sequence_state()
local host = MemoryHost.new({
configuration = { mark_cursor = true },
+ input_packets = { { kind = "text", text = "a" } },
})
local service = acquisition_service.new(host)
service:acquire("f", "n", domain.Position.new(1, 1), nil, nil)
@@ -4965,6 +4970,7 @@ test("Interactive acquisition redraws after cursor marker creation", function()
fresh_sequence_state()
local macro_host = MemoryHost.new({
configuration = { mark_cursor = true },
+ input_packets = { { kind = "text", text = "a" } },
})
acquisition_service.new(macro_host):acquire(
"f",
@@ -4988,6 +4994,7 @@ test("Interactive acquisition creates enabled direct previews", function()
ignore_case = false,
smart_case = false,
},
+ input_packets = { { kind = "text", text = "a" } },
})
local service = acquisition_service.new({
host = host,
@@ -5017,6 +5024,7 @@ test("Interactive acquisition creates enabled direct previews", function()
local macro_host = MemoryHost.new({
buffer_lines = { "xaxa" },
configuration = { mark_cursor = false, mark_direct = true },
+ input_packets = { { kind = "text", text = "a" } },
})
local macro_service = acquisition_service.new(macro_host)
macro_service:acquire(
@@ -5037,6 +5045,7 @@ test("Acquisition emits the exact enabled prompt", function()
mark_direct = false,
show_prompt = true,
},
+ input_packets = { { kind = "text", text = "a" } },
})
acquisition_service.new(host):acquire(
"f",
@@ -5054,6 +5063,7 @@ test("Acquisition emits the exact enabled prompt", function()
mark_cursor = false,
show_prompt = true,
},
+ input_packets = { { kind = "text", text = "a" } },
})
acquisition_service.new(macro_host):acquire(
"f",
@@ -5069,6 +5079,7 @@ test("Acquisition begins sequence state before input", function()
local state, transitions = fresh_sequence_state()
local host = MemoryHost.new({
configuration = { mark_cursor = false },
+ input_packets = { { kind = "text", text = "a" } },
})
acquisition_service.new({
host = host,
@@ -5087,6 +5098,37 @@ test("Acquisition begins sequence state before input", function()
same(nil, record.previous_target)
end)
+test("Acquisition reads one raw packet after sequence start", function()
+ local state, transitions = fresh_sequence_state()
+ local packet = domain.InputPacket.raw_bytes({ 0x41 })
+ local host = MemoryHost.new({
+ configuration = { mark_cursor = false },
+ input_packets = { packet },
+ })
+ local original_read_input = host.read_input
+ local state_at_read
+ function host:read_input()
+ state_at_read = state:get_context("n")
+ return original_read_input(self)
+ end
+ local service = acquisition_service.new({
+ host = host,
+ transitions = transitions,
+ })
+
+ service:acquire("f", "n", domain.Position.new(1, 1), nil, nil)
+ same(domain.Descriptor.FIND_FORWARD, state_at_read.previous_descriptor)
+ truthy(state_at_read.first_move)
+ same(packet, service:last_temporary_scope().input_packet)
+ local reads = 0
+ for _, operation in ipairs(host:operations()) do
+ if operation.operation == "read_input" then
+ reads = reads + 1
+ end
+ end
+ same(1, reads)
+end)
+
for _, item in ipairs(tests) do
local ok, failure = xpcall(item.body, debug.traceback)
if not ok then