summaryrefslogtreecommitdiff
path: root/tests/run.lua
diff options
context:
space:
mode:
Diffstat (limited to 'tests/run.lua')
-rw-r--r--tests/run.lua69
1 files changed, 69 insertions, 0 deletions
diff --git a/tests/run.lua b/tests/run.lua
index 393d51a..1c07824 100644
--- a/tests/run.lua
+++ b/tests/run.lua
@@ -3537,6 +3537,75 @@ test("Forward operator motions toggle characterwise inclusivity", function()
end
end)
+test("Operator execution preserves FIND and TILL endpoint conventions", function()
+ local source = "hoge fuge piye poye"
+ local cases = {
+ {
+ descriptor = "f",
+ origin = 1,
+ expected = " fuge piye poye",
+ cursor = 1,
+ },
+ {
+ descriptor = "t",
+ origin = 1,
+ expected = "e fuge piye poye",
+ cursor = 1,
+ },
+ {
+ descriptor = "F",
+ origin = 19,
+ expected = "hoge fuge piye",
+ cursor = 14,
+ },
+ {
+ descriptor = "T",
+ origin = 19,
+ expected = "hoge fuge piyee",
+ cursor = 14,
+ },
+ }
+
+ for _, case in ipairs(cases) do
+ fresh_sequence_state()
+ local host = MemoryHost.new({
+ buffer_lines = { source },
+ cursor = { line = 1, byte_column = case.origin },
+ mode = "no",
+ pending_operator = "delete",
+ })
+ local plan = motion_plan.build(
+ target_plan.build(target("e"), matching_policy()),
+ case.descriptor
+ )
+ local outcome = motion_executor.new(host):execute(
+ text_topology.from_host(host),
+ "no",
+ plan,
+ 1,
+ true
+ )
+
+ same(domain.ActionKind.MOVEMENT, outcome.kind, case.descriptor)
+ list_same({ case.expected }, host:read_text():lines())
+ same(
+ domain.Position.new(1, case.cursor),
+ host:read_cursor(),
+ case.descriptor
+ )
+ if case.descriptor == "F" or case.descriptor == "T" then
+ falsy(host:operator_inclusive(), case.descriptor)
+ local toggles = 0
+ for _, operation in ipairs(host:operations()) do
+ if operation.operation == "set_operator_inclusive" then
+ toggles = toggles + 1
+ end
+ end
+ same(0, toggles, case.descriptor)
+ end
+ end
+end)
+
for _, item in ipairs(tests) do
local ok, failure = xpcall(item.body, debug.traceback)
if not ok then