diff options
author | Josh Rahm <joshuarahm@gmail.com> | 2025-02-05 23:09:29 +0000 |
---|---|---|
committer | Josh Rahm <joshuarahm@gmail.com> | 2025-02-05 23:09:29 +0000 |
commit | d5f194ce780c95821a855aca3c19426576d28ae0 (patch) | |
tree | d45f461b19f9118ad2bb1f440a7a08973ad18832 /test/functional/treesitter/node_spec.lua | |
parent | c5d770d311841ea5230426cc4c868e8db27300a8 (diff) | |
parent | 44740e561fc93afe3ebecfd3618bda2d2abeafb0 (diff) | |
download | rneovim-rahm.tar.gz rneovim-rahm.tar.bz2 rneovim-rahm.zip |
Diffstat (limited to 'test/functional/treesitter/node_spec.lua')
-rw-r--r-- | test/functional/treesitter/node_spec.lua | 28 |
1 files changed, 2 insertions, 26 deletions
diff --git a/test/functional/treesitter/node_spec.lua b/test/functional/treesitter/node_spec.lua index c87a56b160..235bf7861c 100644 --- a/test/functional/treesitter/node_spec.lua +++ b/test/functional/treesitter/node_spec.lua @@ -20,6 +20,7 @@ describe('treesitter node API', function() insert('F') exec_lua(function() vim.treesitter.start(0, 'lua') + vim.treesitter.get_parser(0):parse() vim.treesitter.get_node():tree() vim.treesitter.get_node():tree() collectgarbage() @@ -45,6 +46,7 @@ describe('treesitter node API', function() -- this buffer doesn't have filetype set! insert('local foo = function() end') exec_lua(function() + vim.treesitter.get_parser(0, 'lua'):parse() _G.node = vim.treesitter.get_node({ bufnr = 0, pos = { 0, 6 }, -- on "foo" @@ -161,32 +163,6 @@ describe('treesitter node API', function() eq(3, lua_eval('child:byte_length()')) end) - it('child_containing_descendant() works', function() - insert([[ - int main() { - int x = 3; - }]]) - - exec_lua(function() - local tree = vim.treesitter.get_parser(0, 'c'):parse()[1] - _G.root = tree:root() - _G.main = _G.root:child(0) - _G.body = _G.main:child(2) - _G.statement = _G.body:child(1) - _G.declarator = _G.statement:child(1) - _G.value = _G.declarator:child(1) - end) - - eq(lua_eval('main:type()'), lua_eval('root:child_containing_descendant(value):type()')) - eq(lua_eval('body:type()'), lua_eval('main:child_containing_descendant(value):type()')) - eq(lua_eval('statement:type()'), lua_eval('body:child_containing_descendant(value):type()')) - eq( - lua_eval('declarator:type()'), - lua_eval('statement:child_containing_descendant(value):type()') - ) - eq(vim.NIL, lua_eval('declarator:child_containing_descendant(value)')) - end) - it('child_with_descendant() works', function() insert([[ int main() { |