aboutsummaryrefslogtreecommitdiffstats
path: root/tests/query
diff options
context:
space:
mode:
authorStephan Seitz <stephan.seitz@fau.de>2021-11-27 17:12:27 +0100
committerStephan Seitz <stephan.seitz@fau.de>2021-12-20 18:16:45 +0100
commit881cb5b8f2260c1e3b9e2d68ac459d81c1dff57b (patch)
tree657e0bfe55ec488cab7a5f5c193dd0d9c8d34ca3 /tests/query
parentci: add injection tests (diff)
downloadnvim-treesitter-881cb5b8f2260c1e3b9e2d68ac459d81c1dff57b.tar
nvim-treesitter-881cb5b8f2260c1e3b9e2d68ac459d81c1dff57b.tar.gz
nvim-treesitter-881cb5b8f2260c1e3b9e2d68ac459d81c1dff57b.tar.bz2
nvim-treesitter-881cb5b8f2260c1e3b9e2d68ac459d81c1dff57b.tar.lz
nvim-treesitter-881cb5b8f2260c1e3b9e2d68ac459d81c1dff57b.tar.xz
nvim-treesitter-881cb5b8f2260c1e3b9e2d68ac459d81c1dff57b.tar.zst
nvim-treesitter-881cb5b8f2260c1e3b9e2d68ac459d81c1dff57b.zip
ci(injection tests): don't consider root language an injection
Diffstat (limited to 'tests/query')
-rw-r--r--tests/query/injection_spec.lua7
-rw-r--r--tests/query/injections/cuda/macro-self-injection.cu2
2 files changed, 8 insertions, 1 deletions
diff --git a/tests/query/injection_spec.lua b/tests/query/injection_spec.lua
index abbd7a8ae..7a98dd275 100644
--- a/tests/query/injection_spec.lua
+++ b/tests/query/injection_spec.lua
@@ -22,6 +22,7 @@ local function check_assertions(file)
local parser = parsers.get_parser(buf, lang)
local self = highlighter.new(parser, {})
+ local top_level_root = parser:parse()[1]:root()
for _, assertion in ipairs(assertions) do
local row = assertion.position.row
@@ -34,7 +35,11 @@ local function check_assertions(file)
end
local root = tstree:root()
- if ts_utils.is_in_node_range(root, row, col) and assertion.expected_capture_name == tree:lang() then
+ if
+ ts_utils.is_in_node_range(root, row, col)
+ and assertion.expected_capture_name == tree:lang()
+ and root ~= top_level_root
+ then
found = true
end
end, true)
diff --git a/tests/query/injections/cuda/macro-self-injection.cu b/tests/query/injections/cuda/macro-self-injection.cu
new file mode 100644
index 000000000..1acef197b
--- /dev/null
+++ b/tests/query/injections/cuda/macro-self-injection.cu
@@ -0,0 +1,2 @@
+#define FOO(X,Y) X + Y
+// ^ cuda