From f6c2b4c65e83118cc90da70db06bbc3d919e9d0b Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Mon, 13 Jun 2022 10:22:38 +0200 Subject: [PATCH] Add indent tests I made use of the 'nvim-treesitter' test runner for these. --- test/indent/groupings.tig | 10 ++++++++++ test/indent_spec.lua | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 test/indent/groupings.tig create mode 100644 test/indent_spec.lua diff --git a/test/indent/groupings.tig b/test/indent/groupings.tig new file mode 100644 index 0000000..870e0da --- /dev/null +++ b/test/indent/groupings.tig @@ -0,0 +1,10 @@ +let + var a := 42 +in + ( + 12; + 27; + 42 + ); + a +end diff --git a/test/indent_spec.lua b/test/indent_spec.lua new file mode 100644 index 0000000..f414d60 --- /dev/null +++ b/test/indent_spec.lua @@ -0,0 +1,39 @@ +package.path = package.path .. ";" .. vim.env.NVIM_TREESITTER .. "/?.lua" + +local Runner = require("tests.indent.common").Runner +local XFAIL = require("tests.indent.common").XFAIL + +local runner = Runner:new(it, "./test/indent/", { + tabstop = 2, + shiftwidth = 2, + softtabstop = 0, + expandtab = true, +}) + +describe("indent Tiger:", function() + describe("whole file:", function() + runner:whole_file("../highlight/", { + expected_failures = { + -- NOTE: none for now + }, + }) + runner:whole_file("../tags/", { + expected_failures = { + -- NOTE: none for now + }, + }) + runner:whole_file(".", { + expected_failures = { + -- NOTE: none for now + }, + }) + end) + + describe("new line:", function() + runner:new_line("groupings.tig", { on_line = 2, text = "var b := 0", indent = 2 }, "let declarations") + runner:new_line("groupings.tig", { on_line = 3, text = "a := a + 1", indent = 2 }, "after 'in'", XFAIL) + runner:new_line("groupings.tig", { on_line = 4, text = "a := a + 1;", indent = 4 }, "sequence", XFAIL) + runner:new_line("groupings.tig", { on_line = 8, text = "a := a + 1;", indent = 2 }, "after sequence") + runner:new_line("groupings.tig", { on_line = 10, text = "+ 1", indent = 0 }, "after 'end'") + end) +end)