aboutsummaryrefslogtreecommitdiffstats
path: root/tests/runner_spec.lua
diff options
context:
space:
mode:
authorSteven Arcangeli <stevearc@stevearc.com>2023-09-12 20:10:05 -0700
committerSteven Arcangeli <stevearc@stevearc.com>2023-09-12 20:10:05 -0700
commit00a528818463b10d84699b2e0f4a960d5a4aeb5c (patch)
treeb1c809b69934279b8655e64724b1ec6a31f7486d /tests/runner_spec.lua
parentdd5b2f2f7ca01c2f28239cbbc7f97e6f9024cd94 (diff)
fix: modify diff calculation to handle end-of-file newlines better (#35)
Diffstat (limited to 'tests/runner_spec.lua')
-rw-r--r--tests/runner_spec.lua15
1 files changed, 6 insertions, 9 deletions
diff --git a/tests/runner_spec.lua b/tests/runner_spec.lua
index 8807d2d..10ea075 100644
--- a/tests/runner_spec.lua
+++ b/tests/runner_spec.lua
@@ -125,12 +125,6 @@ describe("runner", function()
local expected_lines = vim.split(expected, "\n", { plain = true })
test_util.set_formatter_output(expected_lines)
conform.format(vim.tbl_extend("force", opts or {}, { formatters = { "test" }, quiet = true }))
- -- We expect the last newline to be effectively "swallowed" by the formatter
- -- because vim will use that as the EOL at the end of the file. The exception is that we always
- -- expect at least one line in the output
- if #expected_lines > 1 and expected_lines[#expected_lines] == "" then
- table.remove(expected_lines)
- end
return expected_lines
end
@@ -193,11 +187,14 @@ print("a")
run_formatter_test("\nfoo", "\nhello\nfoo")
run_formatter_test("hello", "hello\n")
run_formatter_test("hello", "hello\n\n")
- run_formatter_test("hello", "hello\n")
- -- This should generate no changes to the buffer
- assert.falsy(vim.bo.modified)
run_formatter_test("hello\n", "hello")
run_formatter_test("hello\n ", "hello")
+
+ -- These should generate no changes to the buffer
+ run_formatter_test("hello\n", "hello\n")
+ assert.falsy(vim.bo.modified)
+ run_formatter_test("hello", "hello")
+ assert.falsy(vim.bo.modified)
end)
it("does not change output if formatter fails", function()