test: nvim_call_function: verify "too many arguments" error

This commit is contained in:
Justin M. Keyes
2018-05-04 08:23:37 +02:00
parent 8abd677d82
commit f46f138fb6

View File

@@ -158,13 +158,23 @@ describe('api', function()
eq(17, nvim('call_function', 'eval', {17})) eq(17, nvim('call_function', 'eval', {17}))
eq('foo', nvim('call_function', 'simplify', {'this/./is//redundant/../../../foo'})) eq('foo', nvim('call_function', 'simplify', {'this/./is//redundant/../../../foo'}))
end) end)
it("VimL error: fails (generic error), does NOT update v:errmsg", function() it("VimL error: fails (generic error), does NOT update v:errmsg", function()
local status, rv = pcall(nvim, "call_function", "bogus function", {"arg1"}) local status, rv = pcall(nvim, "call_function", "bogus function", {"arg1"})
eq(false, status) -- nvim_call_function() failed. eq(false, status) -- nvim_call_function() failed.
ok(nil ~= string.find(rv, "Error calling function")) ok(nil ~= string.find(rv, "Error calling function"))
eq("", nvim("eval", "v:errmsg")) -- v:errmsg was not updated. eq("", nvim("eval", "v:errmsg")) -- v:errmsg was not updated.
end) end)
it('validates args', function()
local too_many_args = { 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x' }
source([[
function! Foo(...) abort
echo a:000
endfunction
]])
-- E740
expect_err('Function called with too many arguments', request,
'nvim_call_function', 'Foo', too_many_args)
end)
end) end)
describe('nvim_execute_lua', function() describe('nvim_execute_lua', function()