aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorPham Huy Hoang <hoangtun0810@gmail.com>2023-04-03 23:47:41 +0900
committerStephan Seitz <stephan.seitz@fau.de>2023-04-08 09:56:06 -0700
commit474c59dcf1d5586d6ef0d3f91b380c6c25eb314b (patch)
tree19d156bee39b9246be68bb6a450a77628924010e /tests
parentfix(indent): Make indent ignore trailing spaces/comment (diff)
downloadnvim-treesitter-474c59dcf1d5586d6ef0d3f91b380c6c25eb314b.tar
nvim-treesitter-474c59dcf1d5586d6ef0d3f91b380c6c25eb314b.tar.gz
nvim-treesitter-474c59dcf1d5586d6ef0d3f91b380c6c25eb314b.tar.bz2
nvim-treesitter-474c59dcf1d5586d6ef0d3f91b380c6c25eb314b.tar.lz
nvim-treesitter-474c59dcf1d5586d6ef0d3f91b380c6c25eb314b.tar.xz
nvim-treesitter-474c59dcf1d5586d6ef0d3f91b380c6c25eb314b.tar.zst
nvim-treesitter-474c59dcf1d5586d6ef0d3f91b380c6c25eb314b.zip
add test
Diffstat (limited to 'tests')
-rw-r--r--tests/indent/algorithm/trailing.py6
-rw-r--r--tests/indent/algorithm/trailing_whitespace.html11
-rw-r--r--tests/indent/algorithm_spec.lua18
3 files changed, 35 insertions, 0 deletions
diff --git a/tests/indent/algorithm/trailing.py b/tests/indent/algorithm/trailing.py
new file mode 100644
index 000000000..9a753ae33
--- /dev/null
+++ b/tests/indent/algorithm/trailing.py
@@ -0,0 +1,6 @@
+class x: # Ignore comment
+
+class y:
+ def z(): # Ignore comment
+
+class t:
diff --git a/tests/indent/algorithm/trailing_whitespace.html b/tests/indent/algorithm/trailing_whitespace.html
new file mode 100644
index 000000000..f3cf177a2
--- /dev/null
+++ b/tests/indent/algorithm/trailing_whitespace.html
@@ -0,0 +1,11 @@
+<!DOCTYPE html>
+<html lang="en">
+ <body>
+ <!-- This file deliberately contains trailing whitespace -->
+ <!-- Don't remove them -->
+ <div>
+ a
+
+ </div>
+ </body>
+</html>
diff --git a/tests/indent/algorithm_spec.lua b/tests/indent/algorithm_spec.lua
new file mode 100644
index 000000000..faf7998ec
--- /dev/null
+++ b/tests/indent/algorithm_spec.lua
@@ -0,0 +1,18 @@
+local Runner = require("tests.indent.common").Runner
+-- local XFAIL = require("tests.indent.common").XFAIL
+
+local runner = Runner:new(it, "tests/indent/algorithm", {
+ tabstop = 4,
+ shiftwidth = 4,
+ softtabstop = 4,
+ expandtab = true,
+})
+
+describe("test indent algorithm: ", function()
+ describe("new line:", function()
+ runner:new_line("trailing.py", { on_line = 1, text = "x: str", indent = 4 }, "indent next line, ignore comment")
+ runner:new_line("trailing.py", { on_line = 4, text = "pass", indent = 8 }, "indent next line, ignore comment")
+ runner:new_line("trailing.py", { on_line = 6, text = "pass", indent = 4 }, "indent next line, ignore whitespace")
+ runner:new_line("trailing_whitespace.html", { on_line = 9, text = "x", indent = 8 }, "not ignore @indent.end")
+ end)
+end)