From 3aba4ba37859e4407eff2bb3f4d99c44b108ed79 Mon Sep 17 00:00:00 2001 From: Quentin Rasmont Date: Fri, 22 Apr 2022 21:50:52 +0200 Subject: feat(treesitter): upstream is_parent() Util from the nvim-treesitter project. Renamed is_parent to is_ancestor for clarity. --- test/functional/treesitter/utils_spec.lua | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 test/functional/treesitter/utils_spec.lua (limited to 'test/functional/treesitter/utils_spec.lua') diff --git a/test/functional/treesitter/utils_spec.lua b/test/functional/treesitter/utils_spec.lua new file mode 100644 index 0000000000..c5609501a7 --- /dev/null +++ b/test/functional/treesitter/utils_spec.lua @@ -0,0 +1,29 @@ +local helpers = require('test.functional.helpers')(after_each) + +local clear = helpers.clear +local insert = helpers.insert +local eq = helpers.eq +local exec_lua = helpers.exec_lua + +before_each(clear) + +describe('treesitter utils', function() + clear() + it('can find an ancestor', function() + insert([[ + int main() { + int x = 3; + }]]) + + exec_lua([[ + parser = vim.treesitter.get_parser(0, "c") + tree = parser:parse()[1] + root = tree:root() + ancestor = root:child(0) + child = ancestor:child(0) + ]]) + + eq(true, exec_lua('return vim.treesitter.is_ancestor(ancestor, child)')) + eq(false, exec_lua('return vim.treesitter.is_ancestor(child, ancestor)')) + end) +end) -- cgit From 73ee2b35d1fc738be9bd4b99f49ce8f84351fbe6 Mon Sep 17 00:00:00 2001 From: bfredl Date: Thu, 25 Aug 2022 20:49:27 +0200 Subject: fix(tests): use pending_c_parser when needed --- test/functional/treesitter/utils_spec.lua | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'test/functional/treesitter/utils_spec.lua') diff --git a/test/functional/treesitter/utils_spec.lua b/test/functional/treesitter/utils_spec.lua index c5609501a7..4f4c18a748 100644 --- a/test/functional/treesitter/utils_spec.lua +++ b/test/functional/treesitter/utils_spec.lua @@ -4,12 +4,16 @@ local clear = helpers.clear local insert = helpers.insert local eq = helpers.eq local exec_lua = helpers.exec_lua +local pending_c_parser = helpers.pending_c_parser before_each(clear) describe('treesitter utils', function() - clear() + before_each(clear) + it('can find an ancestor', function() + if pending_c_parser(pending) then return end + insert([[ int main() { int x = 3; -- cgit From 6254b0fd3bc725705020192dc9e35635136b9929 Mon Sep 17 00:00:00 2001 From: Christian Clason Date: Sun, 4 Sep 2022 16:13:37 +0200 Subject: ci(tests): don't skip parsers on functionaltest Treesitter parsers are now a mandatory part of the installation and should be tested on all platforms. Remove `pending_c_parser` helper. --- test/functional/treesitter/utils_spec.lua | 2 -- 1 file changed, 2 deletions(-) (limited to 'test/functional/treesitter/utils_spec.lua') diff --git a/test/functional/treesitter/utils_spec.lua b/test/functional/treesitter/utils_spec.lua index 4f4c18a748..7f5a864c3d 100644 --- a/test/functional/treesitter/utils_spec.lua +++ b/test/functional/treesitter/utils_spec.lua @@ -4,7 +4,6 @@ local clear = helpers.clear local insert = helpers.insert local eq = helpers.eq local exec_lua = helpers.exec_lua -local pending_c_parser = helpers.pending_c_parser before_each(clear) @@ -12,7 +11,6 @@ describe('treesitter utils', function() before_each(clear) it('can find an ancestor', function() - if pending_c_parser(pending) then return end insert([[ int main() { -- cgit