diff options
Diffstat (limited to 'test/functional/eval')
-rw-r--r-- | test/functional/eval/api_functions_spec.lua | 6 | ||||
-rw-r--r-- | test/functional/eval/buf_functions_spec.lua | 6 | ||||
-rw-r--r-- | test/functional/eval/changedtick_spec.lua | 10 | ||||
-rw-r--r-- | test/functional/eval/ctx_functions_spec.lua | 38 | ||||
-rw-r--r-- | test/functional/eval/match_functions_spec.lua | 10 | ||||
-rw-r--r-- | test/functional/eval/server_spec.lua | 6 | ||||
-rw-r--r-- | test/functional/eval/wait_spec.lua | 15 |
7 files changed, 44 insertions, 47 deletions
diff --git a/test/functional/eval/api_functions_spec.lua b/test/functional/eval/api_functions_spec.lua index 3947f88c0a..4fbd08f102 100644 --- a/test/functional/eval/api_functions_spec.lua +++ b/test/functional/eval/api_functions_spec.lua @@ -4,7 +4,7 @@ local lfs = require('lfs') local neq, eq, command = helpers.neq, helpers.eq, helpers.command local clear, curbufmeths = helpers.clear, helpers.curbufmeths local exc_exec, expect, eval = helpers.exc_exec, helpers.expect, helpers.eval -local insert, meth_pcall = helpers.insert, helpers.meth_pcall +local insert, pcall_err = helpers.insert, helpers.pcall_err local meths = helpers.meths describe('eval-API', function() @@ -148,8 +148,8 @@ describe('eval-API', function() end) it('cannot be called from sandbox', function() - eq({false, 'Vim(call):E48: Not allowed in sandbox'}, - meth_pcall(command, "sandbox call nvim_input('ievil')")) + eq('Vim(call):E48: Not allowed in sandbox', + pcall_err(command, "sandbox call nvim_input('ievil')")) eq({''}, meths.buf_get_lines(0, 0, -1, true)) end) end) diff --git a/test/functional/eval/buf_functions_spec.lua b/test/functional/eval/buf_functions_spec.lua index 380ccfb5d5..37f4c89bfd 100644 --- a/test/functional/eval/buf_functions_spec.lua +++ b/test/functional/eval/buf_functions_spec.lua @@ -15,7 +15,7 @@ local curwinmeths = helpers.curwinmeths local curtabmeths = helpers.curtabmeths local get_pathsep = helpers.get_pathsep local rmdir = helpers.rmdir -local expect_err = helpers.expect_err +local pcall_err = helpers.pcall_err local fname = 'Xtest-functional-eval-buf_functions' local fname2 = fname .. '.2' @@ -297,8 +297,8 @@ describe('setbufvar() function', function() eq('Vim(call):E461: Illegal variable name: b:', exc_exec('call setbufvar(1, "", 0)')) eq(true, bufmeths.get_var(buf1, 'number')) - expect_err('Vim:E46: Cannot change read%-only variable "b:changedtick"', - funcs.setbufvar, 1, 'changedtick', true) + eq('Vim:E46: Cannot change read-only variable "b:changedtick"', + pcall_err(funcs.setbufvar, 1, 'changedtick', true)) eq(2, funcs.getbufvar(1, 'changedtick')) end) end) diff --git a/test/functional/eval/changedtick_spec.lua b/test/functional/eval/changedtick_spec.lua index 60ea9fa12b..99406d9d7a 100644 --- a/test/functional/eval/changedtick_spec.lua +++ b/test/functional/eval/changedtick_spec.lua @@ -9,7 +9,7 @@ local meths = helpers.meths local command = helpers.command local exc_exec = helpers.exc_exec local redir_exec = helpers.redir_exec -local meth_pcall = helpers.meth_pcall +local pcall_err = helpers.pcall_err local curbufmeths = helpers.curbufmeths before_each(clear) @@ -64,8 +64,8 @@ describe('b:changedtick', function() redir_exec('let b:.changedtick = ' .. ctn)) eq('\nE46: Cannot change read-only variable "d.changedtick"', redir_exec('let d.changedtick = ' .. ctn)) - eq({false, 'Key is read-only: changedtick'}, - meth_pcall(curbufmeths.set_var, 'changedtick', ctn)) + eq('Key is read-only: changedtick', + pcall_err(curbufmeths.set_var, 'changedtick', ctn)) eq('\nE795: Cannot delete variable b:changedtick', redir_exec('unlet b:changedtick')) @@ -75,8 +75,8 @@ describe('b:changedtick', function() redir_exec('unlet b:["changedtick"]')) eq('\nE46: Cannot change read-only variable "d.changedtick"', redir_exec('unlet d.changedtick')) - eq({false, 'Key is read-only: changedtick'}, - meth_pcall(curbufmeths.del_var, 'changedtick')) + eq('Key is read-only: changedtick', + pcall_err(curbufmeths.del_var, 'changedtick')) eq(ct, changedtick()) eq('\nE46: Cannot change read-only variable "b:["changedtick"]"', diff --git a/test/functional/eval/ctx_functions_spec.lua b/test/functional/eval/ctx_functions_spec.lua index 742fc4893b..7dde5d3194 100644 --- a/test/functional/eval/ctx_functions_spec.lua +++ b/test/functional/eval/ctx_functions_spec.lua @@ -5,7 +5,6 @@ local clear = helpers.clear local command = helpers.command local eq = helpers.eq local eval = helpers.eval -local expect_err = helpers.expect_err local feed = helpers.feed local map = helpers.map local nvim = helpers.nvim @@ -14,6 +13,7 @@ local redir_exec = helpers.redir_exec local source = helpers.source local trim = helpers.trim local write_file = helpers.write_file +local pcall_err = helpers.pcall_err describe('context functions', function() local fname1 = 'Xtest-functional-eval-ctx1' @@ -110,9 +110,9 @@ describe('context functions', function() nvim('del_var', 'one') nvim('del_var', 'Two') nvim('del_var', 'THREE') - expect_err('E121: Undefined variable: g:one', eval, 'g:one') - expect_err('E121: Undefined variable: g:Two', eval, 'g:Two') - expect_err('E121: Undefined variable: g:THREE', eval, 'g:THREE') + eq('Vim:E121: Undefined variable: g:one', pcall_err(eval, 'g:one')) + eq('Vim:E121: Undefined variable: g:Two', pcall_err(eval, 'g:Two')) + eq('Vim:E121: Undefined variable: g:THREE', pcall_err(eval, 'g:THREE')) call('ctxpop') eq({1, 2 ,3}, eval('[g:one, g:Two, g:THREE]')) @@ -120,9 +120,9 @@ describe('context functions', function() nvim('del_var', 'one') nvim('del_var', 'Two') nvim('del_var', 'THREE') - expect_err('E121: Undefined variable: g:one', eval, 'g:one') - expect_err('E121: Undefined variable: g:Two', eval, 'g:Two') - expect_err('E121: Undefined variable: g:THREE', eval, 'g:THREE') + eq('Vim:E121: Undefined variable: g:one', pcall_err(eval, 'g:one')) + eq('Vim:E121: Undefined variable: g:Two', pcall_err(eval, 'g:Two')) + eq('Vim:E121: Undefined variable: g:THREE', pcall_err(eval, 'g:THREE')) call('ctxpop') eq({1, 2 ,3}, eval('[g:one, g:Two, g:THREE]')) @@ -217,9 +217,9 @@ describe('context functions', function() command('delfunction Greet') command('delfunction GreetAll') - expect_err('Vim:E117: Unknown function: Greet', call, 'Greet', 'World') - expect_err('Vim:E117: Unknown function: Greet', call, 'GreetAll', - 'World', 'One', 'Two', 'Three') + eq('Vim:E117: Unknown function: Greet', pcall_err(call, 'Greet', 'World')) + eq('Vim:E117: Unknown function: GreetAll', + pcall_err(call, 'GreetAll', 'World', 'One', 'Two', 'Three')) call('ctxpop') @@ -233,13 +233,13 @@ describe('context functions', function() it('errors out when context stack is empty', function() local err = 'Vim:Context stack is empty' - expect_err(err, call, 'ctxpop') - expect_err(err, call, 'ctxpop') + eq(err, pcall_err(call, 'ctxpop')) + eq(err, pcall_err(call, 'ctxpop')) call('ctxpush') call('ctxpush') call('ctxpop') call('ctxpop') - expect_err(err, call, 'ctxpop') + eq(err, pcall_err(call, 'ctxpop')) end) end) @@ -263,11 +263,11 @@ describe('context functions', function() describe('ctxget()', function() it('errors out when index is out of bounds', function() - expect_err(outofbounds, call, 'ctxget') + eq(outofbounds, pcall_err(call, 'ctxget')) call('ctxpush') - expect_err(outofbounds, call, 'ctxget', 1) + eq(outofbounds, pcall_err(call, 'ctxget', 1)) call('ctxpop') - expect_err(outofbounds, call, 'ctxget', 0) + eq(outofbounds, pcall_err(call, 'ctxget', 0)) end) it('returns context dictionary at index in context stack', function() @@ -370,11 +370,11 @@ describe('context functions', function() describe('ctxset()', function() it('errors out when index is out of bounds', function() - expect_err(outofbounds, call, 'ctxset', {dummy = 1}) + eq(outofbounds, pcall_err(call, 'ctxset', {dummy = 1})) call('ctxpush') - expect_err(outofbounds, call, 'ctxset', {dummy = 1}, 1) + eq(outofbounds, pcall_err(call, 'ctxset', {dummy = 1}, 1)) call('ctxpop') - expect_err(outofbounds, call, 'ctxset', {dummy = 1}, 0) + eq(outofbounds, pcall_err(call, 'ctxset', {dummy = 1}, 0)) end) it('sets context dictionary at index in context stack', function() diff --git a/test/functional/eval/match_functions_spec.lua b/test/functional/eval/match_functions_spec.lua index 0ec465a34c..f399ef47d3 100644 --- a/test/functional/eval/match_functions_spec.lua +++ b/test/functional/eval/match_functions_spec.lua @@ -6,7 +6,7 @@ local clear = helpers.clear local funcs = helpers.funcs local command = helpers.command local exc_exec = helpers.exc_exec -local expect_err = helpers.expect_err +local pcall_err = helpers.pcall_err before_each(clear) @@ -41,11 +41,11 @@ describe('setmatches()', function() end) it('fails with -1 if highlight group is not defined', function() - expect_err('E28: No such highlight group name: 1', funcs.setmatches, - {{group=1, pattern=2, id=3, priority=4}}) + eq('Vim:E28: No such highlight group name: 1', + pcall_err(funcs.setmatches, {{group=1, pattern=2, id=3, priority=4}})) eq({}, funcs.getmatches()) - expect_err('E28: No such highlight group name: 1', funcs.setmatches, - {{group=1, pos1={2}, pos2={6}, id=3, priority=4, conceal=5}}) + eq('Vim:E28: No such highlight group name: 1', + pcall_err(funcs.setmatches, {{group=1, pos1={2}, pos2={6}, id=3, priority=4, conceal=5}})) eq({}, funcs.getmatches()) end) end) diff --git a/test/functional/eval/server_spec.lua b/test/functional/eval/server_spec.lua index 563e619b39..238d1aeb0f 100644 --- a/test/functional/eval/server_spec.lua +++ b/test/functional/eval/server_spec.lua @@ -5,7 +5,7 @@ local clear, funcs, meths = helpers.clear, helpers.funcs, helpers.meths local iswin = helpers.iswin local ok = helpers.ok local matches = helpers.matches -local expect_err = helpers.expect_err +local pcall_err = helpers.pcall_err local function clear_serverlist() for _, server in pairs(funcs.serverlist()) do @@ -102,8 +102,8 @@ describe('server', function() eq(expected, funcs.serverlist()) clear_serverlist() - expect_err('Failed to start server: invalid argument', - funcs.serverstart, '127.0.0.1:65536') -- invalid port + eq('Vim:Failed to start server: invalid argument', + pcall_err(funcs.serverstart, '127.0.0.1:65536')) -- invalid port eq({}, funcs.serverlist()) end) diff --git a/test/functional/eval/wait_spec.lua b/test/functional/eval/wait_spec.lua index 5bb27131f5..341f2dc435 100644 --- a/test/functional/eval/wait_spec.lua +++ b/test/functional/eval/wait_spec.lua @@ -4,12 +4,12 @@ local clear = helpers.clear local command = helpers.command local eval = helpers.eval local eq = helpers.eq -local expect_err = helpers.expect_err local feed = helpers.feed local feed_command = helpers.feed_command local next_msg = helpers.next_msg local nvim = helpers.nvim local source = helpers.source +local pcall_err = helpers.pcall_err before_each(function() clear() @@ -66,13 +66,10 @@ describe('wait()', function() eq(5, nvim('get_var', 'counter')) end) - it('errors out on invalid timeout value', function() - expect_err('Invalid value for argument', call, 'wait', '', 1) - end) - - it('errors out on invalid interval', function() - expect_err('Invalid value for argument', call, 'wait', 0, 1, -1) - expect_err('Invalid value for argument', call, 'wait', 0, 1, 0) - expect_err('Invalid value for argument', call, 'wait', 0, 1, '') + it('validates args', function() + eq('Vim:E475: Invalid value for argument 1', pcall_err(call, 'wait', '', 1)) + eq('Vim:E475: Invalid value for argument 3', pcall_err(call, 'wait', 0, 1, -1)) + eq('Vim:E475: Invalid value for argument 3', pcall_err(call, 'wait', 0, 1, 0)) + eq('Vim:E475: Invalid value for argument 3', pcall_err(call, 'wait', 0, 1, '')) end) end) |