summaryrefslogtreecommitdiff
path: root/tests/run.lua
diff options
context:
space:
mode:
Diffstat (limited to 'tests/run.lua')
-rw-r--r--tests/run.lua38
1 files changed, 38 insertions, 0 deletions
diff --git a/tests/run.lua b/tests/run.lua
index d657870..183c9af 100644
--- a/tests/run.lua
+++ b/tests/run.lua
@@ -2309,6 +2309,44 @@ test("DestinationEngine stops target starts at selected boundaries", function()
)
end)
+test("FIND destinations use matching target positions", function()
+ local view = text_topology.new({ "poge huga hiyo poyo" }, "utf-8")
+ local engine = destination_engine.new()
+ local h = target_plan.build(target("h"), matching_policy())
+ local forward = motion_plan.build(h, "f")
+ local backward = motion_plan.build(h, "F")
+
+ local first = engine:calculate(
+ view,
+ domain.Position.new(1, 1),
+ forward,
+ 1,
+ true
+ )
+ same(domain.Position.new(1, 6), first.endpoint)
+ local second = engine:calculate(view, first.endpoint, forward, 1, false)
+ same(domain.Position.new(1, 11), second.endpoint)
+ same(
+ domain.Position.new(1, 6),
+ engine:calculate(view, second.endpoint, backward, 1, false).endpoint
+ )
+
+ local o = target_plan.build(target("o"), matching_policy())
+ local find_o_backward = motion_plan.build(o, "F")
+ local previous = engine:calculate(
+ view,
+ domain.Position.new(1, 19),
+ find_o_backward,
+ 1,
+ true
+ )
+ same(domain.Position.new(1, 17), previous.endpoint)
+ same(
+ domain.Position.new(1, 14),
+ engine:calculate(view, previous.endpoint, find_o_backward, 1, false).endpoint
+ )
+end)
+
for _, item in ipairs(tests) do
local ok, failure = xpcall(item.body, debug.traceback)
if not ok then