mirror of
https://github.com/neovim/neovim.git
synced 2025-12-15 19:05:40 +00:00
test: support upvalues in exec_lua
This commit is contained in:
committed by
Lewis Russell
parent
a19e89022d
commit
e5c174421d
@@ -660,8 +660,8 @@ print()
|
||||
end)
|
||||
|
||||
local function run_query()
|
||||
return exec_lua(function(query_str)
|
||||
local query = vim.treesitter.query.parse('c', query_str)
|
||||
return exec_lua(function()
|
||||
local query = vim.treesitter.query.parse('c', query0)
|
||||
local parser = vim.treesitter.get_parser()
|
||||
local tree = parser:parse()[1]
|
||||
local res = {}
|
||||
@@ -669,7 +669,7 @@ print()
|
||||
table.insert(res, { query.captures[id], node:range() })
|
||||
end
|
||||
return res
|
||||
end, query0)
|
||||
end)
|
||||
end
|
||||
|
||||
eq({
|
||||
@@ -707,15 +707,15 @@ print()
|
||||
]]
|
||||
]==]
|
||||
|
||||
local r = exec_lua(function(src)
|
||||
local parser = vim.treesitter.get_string_parser(src, 'lua')
|
||||
local r = exec_lua(function()
|
||||
local parser = vim.treesitter.get_string_parser(source, 'lua')
|
||||
parser:parse(true)
|
||||
local ranges = {}
|
||||
parser:for_each_tree(function(tstree, tree)
|
||||
ranges[tree:lang()] = { tstree:root():range(true) }
|
||||
end)
|
||||
return ranges
|
||||
end, source)
|
||||
end)
|
||||
|
||||
eq({
|
||||
lua = { 0, 6, 6, 16, 4, 438 },
|
||||
@@ -727,14 +727,14 @@ print()
|
||||
-- the ranges but only provide a Range4. Strip the byte entries from the ranges and make sure
|
||||
-- add_bytes() produces the same result.
|
||||
|
||||
local rb = exec_lua(function(r0, source0)
|
||||
local rb = exec_lua(function()
|
||||
local add_bytes = require('vim.treesitter._range').add_bytes
|
||||
for lang, range in pairs(r0) do
|
||||
r0[lang] = { range[1], range[2], range[4], range[5] }
|
||||
r0[lang] = add_bytes(source0, r0[lang])
|
||||
for lang, range in pairs(r) do
|
||||
r[lang] = { range[1], range[2], range[4], range[5] }
|
||||
r[lang] = add_bytes(source, r[lang])
|
||||
end
|
||||
return r0
|
||||
end, r, source)
|
||||
return r
|
||||
end)
|
||||
|
||||
eq(rb, r)
|
||||
end)
|
||||
|
||||
Reference in New Issue
Block a user