summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJackson Moore <jacksonmoore@tuta.io>2026-09-04 10:57:40 +0200
committerJackson Moore <jacksonmoore@tuta.io>2026-09-04 10:57:40 +0200
commit3622df8d1e99307d158e7dc5719a440e6c61cbd7 (patch)
tree5acb279f0e5216377e015fbe53b3cda96510dfd2 /tests
parentb7af716a32e548987e3853f5e91198e53d051d27 (diff)
Verify dot input consumption
Diffstat (limited to 'tests')
-rw-r--r--tests/run.lua85
1 files changed, 84 insertions, 1 deletions
diff --git a/tests/run.lua b/tests/run.lua
index a237bd9..48928e7 100644
--- a/tests/run.lua
+++ b/tests/run.lua
@@ -3703,6 +3703,89 @@ test("Dot payload replay uses resolved motions and current counts", function()
same(2, counted.successful_steps)
end)
+test("Dot replay consumes target input only for original acquisition", function()
+ fresh_sequence_state()
+ local host = MemoryHost.new({
+ buffer_lines = { "hoge fuge piye poye" },
+ cursor = { line = 1, byte_column = 1 },
+ mode = "no",
+ pending_operator = "delete",
+ input_packets = {
+ { kind = "text", text = "e" },
+ },
+ })
+ local packet = host:read_input()
+ local acquired_target = domain.TargetValue.character(
+ packet.text,
+ string.byte(packet.text, 1)
+ )
+ local plan = motion_plan.build(
+ target_plan.build(acquired_target, matching_policy()),
+ "f"
+ )
+ motion_executor.new(host):execute(
+ text_topology.from_host(host),
+ "no",
+ plan,
+ 1,
+ true
+ )
+ host:replay_dot(1)
+ host:replay_dot(1)
+ host:replay_dot(1)
+
+ local input_reads = 0
+ for _, operation in ipairs(host:operations()) do
+ if operation.operation == "read_input" then
+ input_reads = input_reads + 1
+ end
+ end
+ same(1, input_reads)
+ same("", host:read_text():line(1))
+end)
+
+test("Select contexts execute through the command path", function()
+ local state, transitions = fresh_sequence_state()
+ local target_value = target("x")
+ transitions:BeginAcquisition("s", "f")
+ transitions:CommitAcquiredTarget("s", target_value)
+ local origin = domain.Position.new(1, 1)
+ local host = MemoryHost.new({
+ buffer_lines = { "abx" },
+ cursor = origin,
+ mode = "s",
+ selection = domain.Selection.active(
+ domain.SelectionKind.CHARACTER,
+ origin,
+ origin,
+ domain.SelectionOption.INCLUSIVE
+ ),
+ })
+ local plan = motion_plan.build(
+ target_plan.build(target_value, matching_policy()),
+ "f"
+ )
+ local outcome = motion_executor.new(host):execute(
+ text_topology.from_host(host),
+ "s",
+ plan,
+ 1,
+ true
+ )
+
+ same(domain.ActionKind.MOVEMENT, outcome.kind)
+ same(domain.Position.new(1, 3), host:read_cursor())
+ same(domain.Position.new(1, 3), state:get_previous_landing("s"))
+ truthy(state.moved_forward)
+ local applied_selection = 0
+ for _, operation in ipairs(host:operations()) do
+ if operation.operation == "apply_selection" then
+ applied_selection = applied_selection + 1
+ end
+ end
+ same(0, applied_selection)
+end)
+
for _, item in ipairs(tests) do
local ok, failure = xpcall(item.body, debug.traceback)
if not ok then
@@ -3712,4 +3795,4 @@ for _, item in ipairs(tests) do
passed = passed + 1
end
-io.stdout:write(string.format("Phase 8: %d tests passed\n", passed))
+io.stdout:write(string.format("Phase 9: %d tests passed\n", passed))