summaryrefslogtreecommitdiff
path: root/tests/run.lua
diff options
context:
space:
mode:
Diffstat (limited to 'tests/run.lua')
-rw-r--r--tests/run.lua42
1 files changed, 42 insertions, 0 deletions
diff --git a/tests/run.lua b/tests/run.lua
index fa9930e..959de66 100644
--- a/tests/run.lua
+++ b/tests/run.lua
@@ -5336,6 +5336,48 @@ test("Positive repeat timeout stores acquisition time", function()
end
end)
+test("Acquisition builds one target plan from live matching policy", function()
+ fresh_sequence_state()
+ local host = MemoryHost.new({
+ buffer_lines = { "aA" },
+ configuration = {
+ mark_cursor = false,
+ ignore_case = false,
+ smart_case = false,
+ },
+ input_packets = { { kind = "text", text = "a" } },
+ })
+ local policy_service = policy.new(host)
+ local underlying = target_plan.new({ policy = policy_service })
+ local build_count = 0
+ local factory = {
+ build = function(_, ...)
+ build_count = build_count + 1
+ return underlying:build(...)
+ end,
+ }
+ local service = acquisition_service.new({
+ host = host,
+ policy = policy_service,
+ target_factory = factory,
+ })
+ host:set_configuration("ignore_case", true)
+
+ local result = service:acquire(
+ "f",
+ "n",
+ domain.Position.new(1, 1),
+ nil,
+ nil
+ )
+ same(1, build_count)
+ truthy(domain.TargetPlan.is(result.target_plan))
+ same(domain.CaseMode.INSENSITIVE, result.target_plan.case_mode)
+ truthy(result.target_plan:matches("A"))
+ same(result.target, result.target_plan.target)
+ same(result.target_plan, service:last_temporary_scope().target_plan)
+end)
+
for _, item in ipairs(tests) do
local ok, failure = xpcall(item.body, debug.traceback)
if not ok then