aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/functional/api/autocmd_spec.lua43
-rw-r--r--test/functional/api/buffer_updates_spec.lua2
-rw-r--r--test/functional/api/command_spec.lua14
-rw-r--r--test/functional/api/extmark_spec.lua16
-rw-r--r--test/functional/api/highlight_spec.lua2
-rw-r--r--test/functional/api/proc_spec.lua8
-rw-r--r--test/functional/api/ui_spec.lua18
-rw-r--r--test/functional/api/vim_spec.lua51
-rw-r--r--test/functional/ui/bufhl_spec.lua4
9 files changed, 95 insertions, 63 deletions
diff --git a/test/functional/api/autocmd_spec.lua b/test/functional/api/autocmd_spec.lua
index f10f18174e..d1a93b5a86 100644
--- a/test/functional/api/autocmd_spec.lua
+++ b/test/functional/api/autocmd_spec.lua
@@ -30,11 +30,11 @@ describe('autocmd api', function()
}))
eq("Required: 'command' or 'callback'", pcall_err(meths.create_autocmd, 'FileType', {
}))
- eq('Invalid desc: expected String, got Integer', pcall_err(meths.create_autocmd, 'FileType', {
+ eq("Invalid 'desc': expected String, got Integer", pcall_err(meths.create_autocmd, 'FileType', {
command = 'ls',
desc = 42,
}))
- eq('Invalid callback: expected Lua function or Vim function name, got Integer', pcall_err(meths.create_autocmd, 'FileType', {
+ eq("Invalid 'callback': expected Lua function or Vim function name, got Integer", pcall_err(meths.create_autocmd, 'FileType', {
callback = 0,
}))
eq("Invalid 'event' item: expected String, got Array", pcall_err(meths.create_autocmd,
@@ -301,6 +301,27 @@ describe('autocmd api', function()
end)
describe('nvim_get_autocmds', function()
+ it('validation', function()
+ eq("Invalid 'group': 9997999", pcall_err(meths.get_autocmds, {
+ group = 9997999,
+ }))
+ eq("Invalid 'group': 'bogus'", pcall_err(meths.get_autocmds, {
+ group = 'bogus',
+ }))
+ eq("Invalid 'group': expected String or Integer, got Array", pcall_err(meths.get_autocmds, {
+ group = {},
+ }))
+ eq("Invalid 'buffer': expected Integer or Array, got Boolean", pcall_err(meths.get_autocmds, {
+ buffer = true,
+ }))
+ eq("Invalid 'event': expected String or Array", pcall_err(meths.get_autocmds, {
+ event = true,
+ }))
+ eq("Invalid 'pattern': expected String or Array, got Boolean", pcall_err(meths.get_autocmds, {
+ pattern = true,
+ }))
+ end)
+
describe('events', function()
it('returns one autocmd when there is only one for an event', function()
command [[au! InsertEnter]]
@@ -414,8 +435,8 @@ describe('autocmd api', function()
pattern = "<buffer=2>",
}}, aus)
- eq("Invalid buffer: expected Integer or Array, got String", pcall_err(meths.get_autocmds, { event = "InsertEnter", buffer = "foo" }))
- eq("Invalid buffer: expected Integer, got String", pcall_err(meths.get_autocmds, { event = "InsertEnter", buffer = { "foo", 42 } }))
+ eq("Invalid 'buffer': expected Integer or Array, got String", pcall_err(meths.get_autocmds, { event = "InsertEnter", buffer = "foo" }))
+ eq("Invalid 'buffer': expected Integer, got String", pcall_err(meths.get_autocmds, { event = "InsertEnter", buffer = { "foo", 42 } }))
eq("Invalid buffer id: 42", pcall_err(meths.get_autocmds, { event = "InsertEnter", buffer = { 42 } }))
local bufs = {}
@@ -585,7 +606,7 @@ describe('autocmd api', function()
]], {}))
eq(false, success)
- matches("Invalid group: 'NotDefined'", code)
+ matches("Invalid 'group': 'NotDefined'", code)
end)
it('raises error for undefined augroup id', function()
@@ -603,7 +624,7 @@ describe('autocmd api', function()
]], {}))
eq(false, success)
- matches('Invalid group: 1', code)
+ matches("Invalid 'group': 1", code)
end)
it('raises error for invalid group type', function()
@@ -618,7 +639,7 @@ describe('autocmd api', function()
]], {}))
eq(false, success)
- matches("Invalid group: expected String or Integer, got Boolean", code)
+ matches("Invalid 'group': expected String or Integer, got Boolean", code)
end)
it('raises error for invalid pattern array', function()
@@ -695,16 +716,16 @@ describe('autocmd api', function()
describe('nvim_exec_autocmds', function()
it('validation', function()
- eq('Invalid group: 9997999', pcall_err(meths.exec_autocmds, 'FileType', {
+ eq("Invalid 'group': 9997999", pcall_err(meths.exec_autocmds, 'FileType', {
group = 9997999,
}))
- eq("Invalid group: 'bogus'", pcall_err(meths.exec_autocmds, 'FileType', {
+ eq("Invalid 'group': 'bogus'", pcall_err(meths.exec_autocmds, 'FileType', {
group = 'bogus',
}))
- eq('Invalid group: expected String or Integer, got Array', pcall_err(meths.exec_autocmds, 'FileType', {
+ eq("Invalid 'group': expected String or Integer, got Array", pcall_err(meths.exec_autocmds, 'FileType', {
group = {},
}))
- eq('Invalid buffer: expected Integer, got Array', pcall_err(meths.exec_autocmds, 'FileType', {
+ eq("Invalid 'buffer': expected Integer, 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/buffer_updates_spec.lua b/test/functional/api/buffer_updates_spec.lua
index 1510d31945..25b838a4af 100644
--- a/test/functional/api/buffer_updates_spec.lua
+++ b/test/functional/api/buffer_updates_spec.lua
@@ -762,7 +762,7 @@ describe('API: buffer events:', function()
it('returns a proper error on nonempty options dict', function()
clear()
local b = editoriginal(false)
- eq("Invalid key: 'builtin'", pcall_err(buffer, 'attach', b, false, {builtin="asfd"}))
+ eq("Invalid 'opts' key: 'builtin'", pcall_err(buffer, 'attach', b, false, {builtin="asfd"}))
end)
it('nvim_buf_attach returns response after delay #8634', function()
diff --git a/test/functional/api/command_spec.lua b/test/functional/api/command_spec.lua
index 189f9d4f98..9db687cc37 100644
--- a/test/functional/api/command_spec.lua
+++ b/test/functional/api/command_spec.lua
@@ -543,23 +543,19 @@ describe('nvim_create_user_command', function()
end)
it('does not allow invalid command names', function()
- matches("Invalid command name %(must begin with an uppercase letter%): 'test'", pcall_err(exec_lua, [[
+ eq("Invalid command name (must start with uppercase): 'test'", pcall_err(exec_lua, [[
vim.api.nvim_create_user_command('test', 'echo "hi"', {})
]]))
-
- matches('Invalid command name', pcall_err(exec_lua, [[
+ eq("Invalid command name: 't@'", pcall_err(exec_lua, [[
vim.api.nvim_create_user_command('t@', 'echo "hi"', {})
]]))
-
- matches('Invalid command name', pcall_err(exec_lua, [[
+ eq("Invalid command name: 'T@st'", pcall_err(exec_lua, [[
vim.api.nvim_create_user_command('T@st', 'echo "hi"', {})
]]))
-
- matches('Invalid command name', pcall_err(exec_lua, [[
+ eq("Invalid command name: 'Test!'", pcall_err(exec_lua, [[
vim.api.nvim_create_user_command('Test!', 'echo "hi"', {})
]]))
-
- matches('Invalid command name', pcall_err(exec_lua, [[
+ eq("Invalid command name: '💩'", pcall_err(exec_lua, [[
vim.api.nvim_create_user_command('💩', 'echo "hi"', {})
]]))
end)
diff --git a/test/functional/api/extmark_spec.lua b/test/functional/api/extmark_spec.lua
index fab1557204..3f9cb94260 100644
--- a/test/functional/api/extmark_spec.lua
+++ b/test/functional/api/extmark_spec.lua
@@ -101,6 +101,14 @@ describe('API/extmarks', function()
ns2 = request('nvim_create_namespace', "my-fancy-plugin2")
end)
+ it('validation', function()
+ eq("Invalid 'end_col': expected Integer, got Array", pcall_err(set_extmark, ns, marks[2], 0, 0, { end_col = {}, end_row = 1 }))
+ eq("Invalid 'end_row': expected Integer, got Array", pcall_err(set_extmark, ns, marks[2], 0, 0, { end_col = 1, end_row = {} }))
+ eq("Invalid 'id': expected positive Integer", pcall_err(set_extmark, ns, {}, 0, 0, { end_col = 1, end_row = 1 }))
+ eq("Invalid mark position: expected 2 Integer items", pcall_err(get_extmarks, ns, {}, {-1, -1}))
+ eq("Invalid mark position: expected mark id Integer or 2-item Array", pcall_err(get_extmarks, ns, true, {-1, -1}))
+ end)
+
it("can end extranges past final newline using end_col = 0", function()
set_extmark(ns, marks[1], 0, 0, {
end_col = 0,
@@ -1344,10 +1352,10 @@ describe('API/extmarks', function()
it('throws consistent error codes', function()
local ns_invalid = ns2 + 1
- eq("Invalid ns_id: 3", pcall_err(set_extmark, ns_invalid, marks[1], positions[1][1], positions[1][2]))
- eq("Invalid ns_id: 3", pcall_err(curbufmeths.del_extmark, ns_invalid, marks[1]))
- eq("Invalid ns_id: 3", pcall_err(get_extmarks, ns_invalid, positions[1], positions[2]))
- eq("Invalid ns_id: 3", pcall_err(get_extmark_by_id, ns_invalid, marks[1]))
+ eq("Invalid 'ns_id': 3", pcall_err(set_extmark, ns_invalid, marks[1], positions[1][1], positions[1][2]))
+ eq("Invalid 'ns_id': 3", pcall_err(curbufmeths.del_extmark, ns_invalid, marks[1]))
+ eq("Invalid 'ns_id': 3", pcall_err(get_extmarks, ns_invalid, positions[1], positions[2]))
+ eq("Invalid 'ns_id': 3", pcall_err(get_extmark_by_id, ns_invalid, marks[1]))
end)
it('when col = line-length, set the mark on eol', function()
diff --git a/test/functional/api/highlight_spec.lua b/test/functional/api/highlight_spec.lua
index 73551de42e..e1b3562329 100644
--- a/test/functional/api/highlight_spec.lua
+++ b/test/functional/api/highlight_spec.lua
@@ -240,7 +240,7 @@ describe("API: set highlight", function()
it('validation', function()
eq("Invalid 'blend': out of range",
pcall_err(meths.set_hl, 0, 'Test_hl3', {fg='#FF00FF', blend=999}))
- eq("Invalid blend: expected Integer, got Array",
+ eq("Invalid 'blend': expected Integer, got Array",
pcall_err(meths.set_hl, 0, 'Test_hl3', {fg='#FF00FF', blend={}}))
end)
diff --git a/test/functional/api/proc_spec.lua b/test/functional/api/proc_spec.lua
index 315653af14..20edea3feb 100644
--- a/test/functional/api/proc_spec.lua
+++ b/test/functional/api/proc_spec.lua
@@ -45,11 +45,11 @@ describe('API', function()
it('validation', function()
local status, rv = pcall(request, "nvim_get_proc_children", -1)
eq(false, status)
- eq("Invalid pid: -1", string.match(rv, "Invalid.*"))
+ eq("Invalid 'pid': -1", string.match(rv, "Invalid.*"))
status, rv = pcall(request, "nvim_get_proc_children", 0)
eq(false, status)
- eq("Invalid pid: 0", string.match(rv, "Invalid.*"))
+ eq("Invalid 'pid': 0", string.match(rv, "Invalid.*"))
-- Assume PID 99999 does not exist.
status, rv = pcall(request, "nvim_get_proc_children", 99999)
@@ -71,11 +71,11 @@ describe('API', function()
it('validation', function()
local status, rv = pcall(request, "nvim_get_proc", -1)
eq(false, status)
- eq("Invalid pid: -1", string.match(rv, "Invalid.*"))
+ eq("Invalid 'pid': -1", string.match(rv, "Invalid.*"))
status, rv = pcall(request, "nvim_get_proc", 0)
eq(false, status)
- eq("Invalid pid: 0", string.match(rv, "Invalid.*"))
+ eq("Invalid 'pid': 0", string.match(rv, "Invalid.*"))
-- Assume PID 99999 does not exist.
status, rv = pcall(request, "nvim_get_proc", 99999)
diff --git a/test/functional/api/ui_spec.lua b/test/functional/api/ui_spec.lua
index 5654ef31ef..b616f51d10 100644
--- a/test/functional/api/ui_spec.lua
+++ b/test/functional/api/ui_spec.lua
@@ -23,23 +23,23 @@ describe('nvim_ui_attach()', function()
eq('No such UI option: foo',
pcall_err(meths.ui_attach, 80, 24, { foo={'foo'} }))
- eq('Invalid ext_linegrid: expected Boolean, got Array',
+ eq("Invalid 'ext_linegrid': expected Boolean, got Array",
pcall_err(meths.ui_attach, 80, 24, { ext_linegrid={} }))
- eq('Invalid override: expected Boolean, got Array',
+ eq("Invalid 'override': expected Boolean, got Array",
pcall_err(meths.ui_attach, 80, 24, { override={} }))
- eq('Invalid rgb: expected Boolean, got Array',
+ eq("Invalid 'rgb': expected Boolean, got Array",
pcall_err(meths.ui_attach, 80, 24, { rgb={} }))
- eq('Invalid term_name: expected String, got Boolean',
+ eq("Invalid 'term_name': expected String, got Boolean",
pcall_err(meths.ui_attach, 80, 24, { term_name=true }))
- eq('Invalid term_colors: expected Integer, got Boolean',
+ eq("Invalid 'term_colors': expected Integer, got Boolean",
pcall_err(meths.ui_attach, 80, 24, { term_colors=true }))
- eq('Invalid term_background: expected String, got Boolean',
+ eq("Invalid 'term_background': expected String, got Boolean",
pcall_err(meths.ui_attach, 80, 24, { term_background=true }))
- eq('Invalid stdin_fd: expected Integer, got String',
+ eq("Invalid 'stdin_fd': expected Integer, got String",
pcall_err(meths.ui_attach, 80, 24, { stdin_fd='foo' }))
- eq('Invalid stdin_tty: expected Boolean, got String',
+ eq("Invalid 'stdin_tty': expected Boolean, got String",
pcall_err(meths.ui_attach, 80, 24, { stdin_tty='foo' }))
- eq('Invalid stdout_tty: expected Boolean, got String',
+ eq("Invalid 'stdout_tty': expected Boolean, got String",
pcall_err(meths.ui_attach, 80, 24, { stdout_tty='foo' }))
eq('UI not attached to channel: 1',
diff --git a/test/functional/api/vim_spec.lua b/test/functional/api/vim_spec.lua
index 469d8e8b6a..981fc19b36 100644
--- a/test/functional/api/vim_spec.lua
+++ b/test/functional/api/vim_spec.lua
@@ -490,7 +490,7 @@ describe('API', function()
eq('', eval('v:errmsg')) -- v:errmsg was not updated.
end)
- it('validates args', function()
+ it('validation', 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
@@ -532,7 +532,7 @@ describe('API', function()
eq('@it works@', nvim('call_dict_function', { result = 'it works', G = 'G'}, 'G', {}))
end)
- it('validates args', function()
+ it('validation', function()
command('let g:d={"baz":"zub","meep":[]}')
eq('Not found: bogus',
pcall_err(request, 'nvim_call_dict_function', 'g:d', 'bogus', {1,2}))
@@ -648,10 +648,10 @@ describe('API', function()
end)
describe('nvim_paste', function()
- it('validates args', function()
- eq('Invalid phase: -2',
+ it('validation', function()
+ eq("Invalid 'phase': -2",
pcall_err(request, 'nvim_paste', 'foo', true, -2))
- eq('Invalid phase: 4',
+ eq("Invalid 'phase': 4",
pcall_err(request, 'nvim_paste', 'foo', true, 4))
end)
local function run_streamed_paste_tests()
@@ -1154,10 +1154,10 @@ describe('API', function()
end)
describe('nvim_put', function()
- it('validates args', function()
- eq("Invalid line: expected String, got Integer",
+ it('validation', function()
+ eq("Invalid 'line': expected String, got Integer",
pcall_err(request, 'nvim_put', {42}, 'l', false, false))
- eq("Invalid type: 'x'",
+ eq("Invalid 'type': 'x'",
pcall_err(request, 'nvim_put', {'foo'}, 'x', false, false))
end)
it("fails if 'nomodifiable'", function()
@@ -1259,9 +1259,9 @@ describe('API', function()
yyybc line 2
line 3
]])
- eq("Invalid type: 'bx'",
+ eq("Invalid 'type': 'bx'",
pcall_err(meths.put, {'xxx', 'yyy'}, 'bx', false, true))
- eq("Invalid type: 'b3x'",
+ eq("Invalid 'type': 'b3x'",
pcall_err(meths.put, {'xxx', 'yyy'}, 'b3x', false, true))
end)
end)
@@ -1288,6 +1288,11 @@ describe('API', function()
end)
describe('set/get/del variables', function()
+ it('validation', function()
+ eq('Key not found: bogus', pcall_err(meths.get_var, 'bogus'))
+ eq('Key not found: bogus', pcall_err(meths.del_var, 'bogus'))
+ end)
+
it('nvim_get_var, nvim_set_var, nvim_del_var', function()
nvim('set_var', 'lua', {1, 2, {['3'] = 1}})
eq({1, 2, {['3'] = 1}}, nvim('get_var', 'lua'))
@@ -1411,12 +1416,14 @@ describe('API', function()
end)
it('validation', function()
- eq("Invalid scope: expected 'local' or 'global'",
+ eq("Invalid 'scope': expected 'local' or 'global'",
pcall_err(nvim, 'get_option_value', 'scrolloff', {scope = 'bogus'}))
- eq("Invalid scope: expected 'local' or 'global'",
+ eq("Invalid 'scope': expected 'local' or 'global'",
pcall_err(nvim, 'set_option_value', 'scrolloff', 1, {scope = 'bogus'}))
- eq("Invalid scope: expected String, got Integer",
+ eq("Invalid 'scope': expected String, got Integer",
pcall_err(nvim, 'get_option_value', 'scrolloff', {scope = 42}))
+ eq("Invalid 'scrolloff': expected Integer/Boolean/String, got Array",
+ pcall_err(nvim, 'set_option_value', 'scrolloff', {}, {}))
end)
it('can get local values when global value is set', function()
@@ -1786,12 +1793,12 @@ describe('API', function()
end)
describe('nvim_get_context', function()
- it('validates args', function()
+ it('validation', function()
eq("Invalid key: 'blah'",
pcall_err(nvim, 'get_context', {blah={}}))
- eq("Invalid types: expected Array, got Integer",
+ eq("Invalid 'types': expected Array, got Integer",
pcall_err(nvim, 'get_context', {types=42}))
- eq("Invalid type: 'zub'",
+ eq("Invalid 'type': 'zub'",
pcall_err(nvim, 'get_context', {types={'jumps', 'zub', 'zam',}}))
end)
it('returns map of current editor state', function()
@@ -2238,7 +2245,7 @@ describe('API', function()
{'nvim_set_var'},
{'nvim_set_var', {'avar', 2}},
}
- eq('calls item must be a 2-item Array',
+ eq("Invalid 'calls' item: expected 2-item Array",
pcall_err(meths.call_atomic, req))
-- call before was done, but not after
eq(1, meths.get_var('avar'))
@@ -2247,7 +2254,7 @@ describe('API', function()
{ 'nvim_set_var', { 'bvar', { 2, 3 } } },
12,
}
- eq("Invalid calls item: expected Array, got Integer",
+ eq("Invalid 'calls' item: expected Array, got Integer",
pcall_err(meths.call_atomic, req))
eq({2,3}, meths.get_var('bvar'))
@@ -2255,7 +2262,7 @@ describe('API', function()
{'nvim_set_current_line', 'little line'},
{'nvim_set_var', {'avar', 3}},
}
- eq("Invalid args: expected Array, got String",
+ eq("Invalid call args: expected Array, got String",
pcall_err(meths.call_atomic, req))
-- call before was done, but not after
eq(1, meths.get_var('avar'))
@@ -3119,15 +3126,15 @@ describe('API', function()
meths.eval_statusline('a%=b', { fillchar = '\031', maxwidth = 5 }))
end)
it('rejects multiple-character fillchar', function()
- eq('Invalid fillchar: expected single character',
+ eq("Invalid 'fillchar': expected single character",
pcall_err(meths.eval_statusline, '', { fillchar = 'aa' }))
end)
it('rejects empty string fillchar', function()
- eq('Invalid fillchar: expected single character',
+ eq("Invalid 'fillchar': expected single character",
pcall_err(meths.eval_statusline, '', { fillchar = '' }))
end)
it('rejects non-string fillchar', function()
- eq("Invalid fillchar: expected String, got Integer",
+ eq("Invalid 'fillchar': expected String, got Integer",
pcall_err(meths.eval_statusline, '', { fillchar = 1 }))
end)
it('rejects invalid string', function()
diff --git a/test/functional/ui/bufhl_spec.lua b/test/functional/ui/bufhl_spec.lua
index 76baf2cddb..418294ac07 100644
--- a/test/functional/ui/bufhl_spec.lua
+++ b/test/functional/ui/bufhl_spec.lua
@@ -751,8 +751,8 @@ describe('Buffer highlighting', function()
it('validates contents', function()
-- this used to leak memory
- eq('Invalid chunk: expected Array, got String', pcall_err(set_virtual_text, id1, 0, {"texty"}, {}))
- eq('Invalid chunk: expected Array, got String', pcall_err(set_virtual_text, id1, 0, {{"very"}, "texty"}, {}))
+ eq("Invalid 'chunk': expected Array, got String", pcall_err(set_virtual_text, id1, 0, {"texty"}, {}))
+ eq("Invalid 'chunk': expected Array, got String", pcall_err(set_virtual_text, id1, 0, {{"very"}, "texty"}, {}))
end)
it('can be retrieved', function()