mirror of
https://github.com/neovim/neovim.git
synced 2025-01-01 17:23:36 -07:00
6254b0fd3b
Treesitter parsers are now a mandatory part of the installation and should be tested on all platforms. Remove `pending_c_parser` helper.
32 lines
726 B
Lua
32 lines
726 B
Lua
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()
|
|
before_each(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)
|