aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/functional/treesitter/language_spec.lua24
-rw-r--r--test/functional/treesitter/parser_spec.lua4
2 files changed, 13 insertions, 15 deletions
diff --git a/test/functional/treesitter/language_spec.lua b/test/functional/treesitter/language_spec.lua
index e1e34fcecc..633a2dc725 100644
--- a/test/functional/treesitter/language_spec.lua
+++ b/test/functional/treesitter/language_spec.lua
@@ -51,7 +51,7 @@ describe('treesitter language API', function()
it('inspects language', function()
local keys, fields, symbols = unpack(exec_lua(function()
local lang = vim.treesitter.language.inspect('c')
- local keys, symbols = {}, {}
+ local keys = {}
for k, v in pairs(lang) do
if type(v) == 'boolean' then
keys[k] = v
@@ -60,12 +60,7 @@ describe('treesitter language API', function()
end
end
- -- symbols array can have "holes" and is thus not a valid msgpack array
- -- but we don't care about the numbers here (checked in the parser test)
- for _, v in pairs(lang.symbols) do
- table.insert(symbols, v)
- end
- return { keys, lang.fields, symbols }
+ return { keys, lang.fields, lang.symbols }
end))
eq({ fields = true, symbols = true, _abi_version = true, _wasm = false }, keys)
@@ -79,16 +74,19 @@ describe('treesitter language API', function()
eq(true, fset['initializer'])
local has_named, has_anonymous
- for _, s in pairs(symbols) do
- eq('string', type(s[1]))
- eq('boolean', type(s[2]))
- if s[1] == 'for_statement' and s[2] == true then
+ for symbol, named in pairs(symbols) do
+ eq('string', type(symbol))
+ eq('boolean', type(named))
+ if symbol == 'for_statement' and named == true then
has_named = true
- elseif s[1] == '|=' and s[2] == false then
+ elseif symbol == '"|="' and named == false then
has_anonymous = true
end
end
- eq({ true, true }, { has_named, has_anonymous })
+ eq(
+ { has_named = true, has_anonymous = true },
+ { has_named = has_named, has_anonymous = has_anonymous }
+ )
end)
it(
diff --git a/test/functional/treesitter/parser_spec.lua b/test/functional/treesitter/parser_spec.lua
index c8829f4785..2f8d204d36 100644
--- a/test/functional/treesitter/parser_spec.lua
+++ b/test/functional/treesitter/parser_spec.lua
@@ -42,13 +42,13 @@ describe('treesitter parser API', function()
eq('function_definition', exec_lua('return child:type()'))
eq(true, exec_lua('return child:named()'))
eq('number', type(exec_lua('return child:symbol()')))
- eq({ 'function_definition', true }, exec_lua('return lang.symbols[child:symbol()]'))
+ eq(true, exec_lua('return lang.symbols[child:type()]'))
exec_lua('anon = root:descendant_for_range(0,8,0,9)')
eq('(', exec_lua('return anon:type()'))
eq(false, exec_lua('return anon:named()'))
eq('number', type(exec_lua('return anon:symbol()')))
- eq({ '(', false }, exec_lua('return lang.symbols[anon:symbol()]'))
+ eq(false, exec_lua([=[return lang.symbols[string.format('"%s"', anon:type())]]=]))
exec_lua('descendant = root:descendant_for_range(1,2,1,12)')
eq('<node declaration>', exec_lua('return tostring(descendant)'))