mirror of
https://github.com/neovim/neovim.git
synced 2025-10-21 17:21:49 +00:00
test: API can return Lua function to Lua code (#28380)
This commit is contained in:
@@ -559,6 +559,16 @@ describe('API', function()
|
||||
eq('Vim:E121: Undefined variable: bogus', pcall_err(request, 'nvim_eval', 'bogus expression'))
|
||||
eq('', eval('v:errmsg')) -- v:errmsg was not updated.
|
||||
end)
|
||||
|
||||
it('can return Lua function to Lua code', function()
|
||||
eq(
|
||||
[["a string with \"double quotes\" and 'single quotes'"]],
|
||||
exec_lua([=[
|
||||
local fun = vim.api.nvim_eval([[luaeval('string.format')]])
|
||||
return fun('%q', [[a string with "double quotes" and 'single quotes']])
|
||||
]=])
|
||||
)
|
||||
end)
|
||||
end)
|
||||
|
||||
describe('nvim_call_function', function()
|
||||
@@ -624,6 +634,16 @@ describe('API', function()
|
||||
pcall_err(request, 'nvim_call_function', 'Foo', too_many_args)
|
||||
)
|
||||
end)
|
||||
|
||||
it('can return Lua function to Lua code', function()
|
||||
eq(
|
||||
[["a string with \"double quotes\" and 'single quotes'"]],
|
||||
exec_lua([=[
|
||||
local fun = vim.api.nvim_call_function('luaeval', { 'string.format' })
|
||||
return fun('%q', [[a string with "double quotes" and 'single quotes']])
|
||||
]=])
|
||||
)
|
||||
end)
|
||||
end)
|
||||
|
||||
describe('nvim_call_dict_function', function()
|
||||
|
Reference in New Issue
Block a user