diff options
author | bfredl <bjorn.linse@gmail.com> | 2023-08-02 13:00:13 +0200 |
---|---|---|
committer | bfredl <bjorn.linse@gmail.com> | 2023-08-07 13:18:11 +0200 |
commit | 0b351c3740d621689b17267171e162abd421e759 (patch) | |
tree | 5773dd83f2b93eda90d10376bb608f19e41da9e0 | |
parent | 6c0812d92e0c7937b913175b8856064cb45f55c2 (diff) | |
download | rneovim-0b351c3740d621689b17267171e162abd421e759.tar.gz rneovim-0b351c3740d621689b17267171e162abd421e759.tar.bz2 rneovim-0b351c3740d621689b17267171e162abd421e759.zip |
test(api): update tests to new error messages
-rw-r--r-- | test/functional/api/autocmd_spec.lua | 2 | ||||
-rw-r--r-- | test/functional/api/vim_spec.lua | 9 | ||||
-rw-r--r-- | test/functional/lua/api_spec.lua | 24 | ||||
-rw-r--r-- | test/functional/lua/vim_spec.lua | 2 |
4 files changed, 18 insertions, 19 deletions
diff --git a/test/functional/api/autocmd_spec.lua b/test/functional/api/autocmd_spec.lua index 4cfe8672b1..ba267e7539 100644 --- a/test/functional/api/autocmd_spec.lua +++ b/test/functional/api/autocmd_spec.lua @@ -737,7 +737,7 @@ describe('autocmd api', function() eq("Invalid 'group': 0", pcall_err(meths.exec_autocmds, 'FileType', { group = 0, })) - eq("Invalid 'buffer': expected Integer, got Array", pcall_err(meths.exec_autocmds, 'FileType', { + eq("Invalid 'buffer': expected Buffer, got Array", pcall_err(meths.exec_autocmds, 'FileType', { buffer = {}, })) eq("Invalid 'event' item: expected String, got Array", pcall_err(meths.exec_autocmds, diff --git a/test/functional/api/vim_spec.lua b/test/functional/api/vim_spec.lua index 6aa9dcc8fa..70fa80f2a2 100644 --- a/test/functional/api/vim_spec.lua +++ b/test/functional/api/vim_spec.lua @@ -4112,12 +4112,10 @@ describe('API', function() it('validation', function() eq("Invalid 'cmd': expected non-empty String", pcall_err(meths.cmd, { cmd = ""}, {})) - eq("Invalid 'cmd': expected non-empty String", + eq("Invalid 'cmd': expected String, got Array", pcall_err(meths.cmd, { cmd = {}}, {})) eq("Invalid 'args': expected Array, got Boolean", pcall_err(meths.cmd, { cmd = "set", args = true }, {})) - eq("Invalid 'magic': expected Dict, got Array", - pcall_err(meths.cmd, { cmd = "set", args = {}, magic = {} }, {})) eq("Invalid command arg: expected non-whitespace", pcall_err(meths.cmd, { cmd = "set", args = {' '}, }, {})) eq("Invalid command arg: expected valid type, got Array", @@ -4138,7 +4136,7 @@ describe('API', function() eq("Command cannot accept count: set", pcall_err(meths.cmd, { cmd = "set", args = {}, count = 1 }, {})) - eq("Invalid 'count': expected non-negative Integer", + eq("Invalid 'count': expected Integer, got Boolean", pcall_err(meths.cmd, { cmd = "print", args = {}, count = true }, {})) eq("Invalid 'count': expected non-negative Integer", pcall_err(meths.cmd, { cmd = "print", args = {}, count = -1 }, {})) @@ -4158,9 +4156,10 @@ describe('API', function() -- Lua call allows empty {} for dict item. eq('', exec_lua([[return vim.cmd{ cmd = "set", args = {}, magic = {} }]])) eq('', exec_lua([[return vim.cmd{ cmd = "set", args = {}, mods = {} }]])) + eq('', meths.cmd({ cmd = "set", args = {}, magic = {} }, {})) -- Lua call does not allow non-empty list-like {} for dict item. - eq("Invalid 'magic': expected Dict, got Array", + eq("Invalid 'magic': Expected Dict-like Lua table", pcall_err(exec_lua, [[return vim.cmd{ cmd = "set", args = {}, magic = { 'a' } }]])) eq("Invalid key: 'bogus'", pcall_err(exec_lua, [[return vim.cmd{ cmd = "set", args = {}, magic = { bogus = true } }]])) diff --git a/test/functional/lua/api_spec.lua b/test/functional/lua/api_spec.lua index ffa2f40e91..5dfc2eb83b 100644 --- a/test/functional/lua/api_spec.lua +++ b/test/functional/lua/api_spec.lua @@ -173,7 +173,7 @@ describe('luaeval(vim.api.…)', function() it('errors out correctly when working with API', function() -- Conversion errors - eq('Vim(call):E5108: Error executing lua [string "luaeval()"]:1: Cannot convert given lua table', + eq([[Vim(call):E5108: Error executing lua [string "luaeval()"]:1: Invalid 'obj': Cannot convert given Lua table]], remove_trace(exc_exec([[call luaeval("vim.api.nvim__id({1, foo=42})")]]))) -- Errors in number of arguments eq('Vim(call):E5108: Error executing lua [string "luaeval()"]:1: Expected 1 argument', @@ -183,32 +183,32 @@ describe('luaeval(vim.api.…)', function() eq('Vim(call):E5108: Error executing lua [string "luaeval()"]:1: Expected 2 arguments', remove_trace(exc_exec([[call luaeval("vim.api.nvim_set_var(1, 2, 3)")]]))) -- Error in argument types - eq('Vim(call):E5108: Error executing lua [string "luaeval()"]:1: Expected lua string', + eq([[Vim(call):E5108: Error executing lua [string "luaeval()"]:1: Invalid 'name': Expected Lua string]], remove_trace(exc_exec([[call luaeval("vim.api.nvim_set_var(1, 2)")]]))) - eq('Vim(call):E5108: Error executing lua [string "luaeval()"]:1: Expected lua number', + eq([[Vim(call):E5108: Error executing lua [string "luaeval()"]:1: Invalid 'start': Expected Lua number]], remove_trace(exc_exec([[call luaeval("vim.api.nvim_buf_get_lines(0, 'test', 1, false)")]]))) - eq('Vim(call):E5108: Error executing lua [string "luaeval()"]:1: Number is not integral', + eq([[Vim(call):E5108: Error executing lua [string "luaeval()"]:1: Invalid 'start': Number is not integral]], remove_trace(exc_exec([[call luaeval("vim.api.nvim_buf_get_lines(0, 1.5, 1, false)")]]))) - eq('Vim(call):E5108: Error executing lua [string "luaeval()"]:1: Expected Lua number', + eq([[Vim(call):E5108: Error executing lua [string "luaeval()"]:1: Invalid 'window': Expected Lua number]], remove_trace(exc_exec([[call luaeval("vim.api.nvim_win_is_valid(nil)")]]))) - eq('Vim(call):E5108: Error executing lua [string "luaeval()"]:1: Expected lua table', + eq([[Vim(call):E5108: Error executing lua [string "luaeval()"]:1: Invalid 'flt': Expected Lua number]], remove_trace(exc_exec([[call luaeval("vim.api.nvim__id_float('test')")]]))) - eq('Vim(call):E5108: Error executing lua [string "luaeval()"]:1: Unexpected type', + eq([[Vim(call):E5108: Error executing lua [string "luaeval()"]:1: Invalid 'flt': Expected Float-like Lua table]], remove_trace(exc_exec([[call luaeval("vim.api.nvim__id_float({[vim.type_idx]=vim.types.dictionary})")]]))) - eq('Vim(call):E5108: Error executing lua [string "luaeval()"]:1: Expected lua table', + eq([[Vim(call):E5108: Error executing lua [string "luaeval()"]:1: Invalid 'arr': Expected Lua table]], remove_trace(exc_exec([[call luaeval("vim.api.nvim__id_array(1)")]]))) - eq('Vim(call):E5108: Error executing lua [string "luaeval()"]:1: Unexpected type', + eq([[Vim(call):E5108: Error executing lua [string "luaeval()"]:1: Invalid 'arr': Expected Array-like Lua table]], remove_trace(exc_exec([[call luaeval("vim.api.nvim__id_array({[vim.type_idx]=vim.types.dictionary})")]]))) - eq('Vim(call):E5108: Error executing lua [string "luaeval()"]:1: Expected lua table', + eq([[Vim(call):E5108: Error executing lua [string "luaeval()"]:1: Invalid 'dct': Expected Lua table]], remove_trace(exc_exec([[call luaeval("vim.api.nvim__id_dictionary(1)")]]))) - eq('Vim(call):E5108: Error executing lua [string "luaeval()"]:1: Unexpected type', + eq([[Vim(call):E5108: Error executing lua [string "luaeval()"]:1: Invalid 'dct': Expected Dict-like Lua table]], remove_trace(exc_exec([[call luaeval("vim.api.nvim__id_dictionary({[vim.type_idx]=vim.types.array})")]]))) - eq('Vim(call):E5108: Error executing lua [string "luaeval()"]:1: Expected lua table', + eq([[Vim(call):E5108: Error executing lua [string "luaeval()"]:1: Expected Lua table]], remove_trace(exc_exec([[call luaeval("vim.api.nvim_set_keymap('', '', '', '')")]]))) -- TODO: check for errors with Tabpage argument diff --git a/test/functional/lua/vim_spec.lua b/test/functional/lua/vim_spec.lua index f1a617fb70..35e87b71da 100644 --- a/test/functional/lua/vim_spec.lua +++ b/test/functional/lua/vim_spec.lua @@ -1511,7 +1511,7 @@ describe('lua stdlib', function() eq(true, funcs.luaeval "vim.bo[BUF].modifiable") matches("Unknown option 'nosuchopt'$", pcall_err(exec_lua, 'return vim.bo.nosuchopt')) - matches("Expected lua string$", + matches("Expected Lua string$", pcall_err(exec_lua, 'return vim.bo[0][0].autoread')) matches("Invalid buffer id: %-1$", pcall_err(exec_lua, 'return vim.bo[-1].filetype')) |