aboutsummaryrefslogtreecommitdiff
path: root/test/functional/lua/treesitter_spec.lua
diff options
context:
space:
mode:
authorThomas Vigouroux <tomvig38@gmail.com>2020-06-26 20:11:16 +0200
committerThomas Vigouroux <tomvig38@gmail.com>2020-06-29 22:21:06 +0200
commit66af35fc85fb2e14fe8f91449289af06b9104dd4 (patch)
treef473858f47172951438f0972acdf9a4b69c95692 /test/functional/lua/treesitter_spec.lua
parent35cc8b6e839f07dbb738900c9c9593041266cdf7 (diff)
downloadrneovim-66af35fc85fb2e14fe8f91449289af06b9104dd4.tar.gz
rneovim-66af35fc85fb2e14fe8f91449289af06b9104dd4.tar.bz2
rneovim-66af35fc85fb2e14fe8f91449289af06b9104dd4.zip
treesitter: separate tests into smaller pieces
Diffstat (limited to 'test/functional/lua/treesitter_spec.lua')
-rw-r--r--test/functional/lua/treesitter_spec.lua12
1 files changed, 10 insertions, 2 deletions
diff --git a/test/functional/lua/treesitter_spec.lua b/test/functional/lua/treesitter_spec.lua
index 539c2b5e7c..16a7f365a8 100644
--- a/test/functional/lua/treesitter_spec.lua
+++ b/test/functional/lua/treesitter_spec.lua
@@ -404,7 +404,7 @@ static int nlua_schedule(lua_State *const lstate)
end
eq({true,true}, {has_named,has_anonymous})
end)
- it('allows to set ranges', function()
+ it('allows to set simple ranges', function()
if not check_parser() then return end
insert(test_text)
@@ -416,6 +416,8 @@ static int nlua_schedule(lua_State *const lstate)
eq({0, 0, 19, 0}, res)
+ -- The following sets the included ranges for the current parser
+ -- As stated here, this only includes the function (thus the whole buffer, without the last line)
local res = exec_lua([[
local root = parser:parse():root()
parser:set_included_ranges({{root:child(0), root:child(0)}})
@@ -424,9 +426,15 @@ static int nlua_schedule(lua_State *const lstate)
]])
eq({0, 0, 18, 1}, res)
+ end)
+ it("allows to set complex ranges", function()
+ if not check_parser() then return end
+
+ insert(test_text)
+
- -- Pick random samples
local res = exec_lua([[
+ parser = vim.treesitter.get_parser(0, "c")
query = vim.treesitter.parse_query("c", "(declaration) @decl")
local nodes = {}