mirror of
https://github.com/neovim/neovim.git
synced 2025-11-03 17:24:29 +00:00
api: execute lua directly from the remote api
This commit is contained in:
@@ -81,6 +81,36 @@ describe('api', function()
|
||||
end)
|
||||
end)
|
||||
|
||||
describe('nvim_execute_lua', function()
|
||||
it('works', function()
|
||||
meths.execute_lua('vim.api.nvim_set_var("test", 3)', {})
|
||||
eq(3, meths.get_var('test'))
|
||||
|
||||
eq(17, meths.execute_lua('a, b = ...\nreturn a + b', {10,7}))
|
||||
|
||||
eq(NIL, meths.execute_lua('function xx(a,b)\nreturn a..b\nend',{}))
|
||||
eq("xy", meths.execute_lua('return xx(...)', {'x','y'}))
|
||||
end)
|
||||
|
||||
it('reports errors', function()
|
||||
eq({false, 'Error loading lua: [string "<nvim>"]:1: '..
|
||||
"'=' expected near '+'"},
|
||||
meth_pcall(meths.execute_lua, 'a+*b', {}))
|
||||
|
||||
eq({false, 'Error loading lua: [string "<nvim>"]:1: '..
|
||||
"unexpected symbol near '1'"},
|
||||
meth_pcall(meths.execute_lua, '1+2', {}))
|
||||
|
||||
eq({false, 'Error loading lua: [string "<nvim>"]:1: '..
|
||||
"unexpected symbol"},
|
||||
meth_pcall(meths.execute_lua, 'aa=bb\0', {}))
|
||||
|
||||
eq({false, 'Error executing lua: [string "<nvim>"]:1: '..
|
||||
"attempt to call global 'bork' (a nil value)"},
|
||||
meth_pcall(meths.execute_lua, 'bork()', {}))
|
||||
end)
|
||||
end)
|
||||
|
||||
describe('nvim_input', function()
|
||||
it("VimL error: does NOT fail, updates v:errmsg", function()
|
||||
local status, _ = pcall(nvim, "input", ":call bogus_fn()<CR>")
|
||||
|
||||
Reference in New Issue
Block a user