diff options
author | Thomas Vigouroux <tomvig38@gmail.com> | 2020-06-14 18:50:22 +0200 |
---|---|---|
committer | Thomas Vigouroux <tomvig38@gmail.com> | 2020-06-29 22:21:06 +0200 |
commit | ac18403d6e58a08956f9465998f2223df4e19108 (patch) | |
tree | 8ffd5c48a1da8bf005b2575710c078a03758a13f /test/functional/lua/treesitter_spec.lua | |
parent | 333f3f19db612acc893791f04624da174efe04b5 (diff) | |
download | rneovim-ac18403d6e58a08956f9465998f2223df4e19108.tar.gz rneovim-ac18403d6e58a08956f9465998f2223df4e19108.tar.bz2 rneovim-ac18403d6e58a08956f9465998f2223df4e19108.zip |
treesitter: test newly added set_included_ranges
Diffstat (limited to 'test/functional/lua/treesitter_spec.lua')
-rw-r--r-- | test/functional/lua/treesitter_spec.lua | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/test/functional/lua/treesitter_spec.lua b/test/functional/lua/treesitter_spec.lua index ecee471386..1fd93d5f56 100644 --- a/test/functional/lua/treesitter_spec.lua +++ b/test/functional/lua/treesitter_spec.lua @@ -404,4 +404,44 @@ static int nlua_schedule(lua_State *const lstate) end eq({true,true}, {has_named,has_anonymous}) end) + it('allows to set ranges', function() + if not check_parser() then return end + + insert(test_text) + + local res = exec_lua([[ + parser = vim.treesitter.get_parser(0, "c") + return { parser:parse():root():range() } + ]]) + + eq({0, 0, 19, 0}, res) + + local res = exec_lua([[ + parser:set_included_ranges({{0, 0, 1, 0}}) + parser.valid = false + return { parser:parse():root():range() } + ]]) + + eq({0, 0, 1, 0}, res) + + -- Pick random samples + local res = exec_lua([[ + parser:set_included_ranges({{8, 0, 9, 0}, {12, 0, 13 ,0}}) + local root = parser:parse():root() + return {{root:child(0):range()}, {root:child(1):range()}} + ]]) + + eq({{ + 8, + 2, + 8, + 33 + }, + { + 12, + 4, + 12, + 37 + }}, res) + end) end) |