diff options
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/run.lua | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/run.lua b/tests/run.lua index 209cf28..c6905b5 100644 --- a/tests/run.lua +++ b/tests/run.lua @@ -2744,6 +2744,33 @@ test("Sequential counts reuse each accepted destination as origin", function() ) end) +test("Count calculation stops when its fixed boundary is reached", function() + local visits = 0 + local view = text_topology.new({ "axaxa" }, "utf-8") + local target_match = domain.TargetPlan.new({ + target = target("a"), + kind = domain.TargetPlanKind.LITERAL, + case_mode = domain.CaseMode.SENSITIVE, + matcher = function(character) + visits = visits + 1 + return character == "a" + end, + }) + local plan = motion_plan.build(target_match, "f", "buffer") + local engine = destination_engine.new() + local origin = domain.Position.new(1, 1) + + local complete = engine:calculate(view, origin, plan, 2, true) + same(domain.SearchStatus.COMPLETE, complete.status) + same(domain.Position.new(1, 5), complete.endpoint) + same(4, visits) + + visits = 0 + local incomplete = engine:calculate(view, origin, plan, 3, true) + falsy(incomplete.complete) + same(4, visits) +end) + for _, item in ipairs(tests) do local ok, failure = xpcall(item.body, debug.traceback) if not ok then |
