test: Rename meth_pcall to pcall_err

- Rename `meth_pcall`.
- Make `pcall_err` raise an error if the function does not fail.
- Add `vim.pesc()` to treat a string as literal where a Lua pattern is
  expected.
This commit is contained in:
Justin M. Keyes
2019-09-03 22:51:45 +02:00
parent 638f2b6dee
commit af946046b9
13 changed files with 124 additions and 112 deletions

View File

@@ -6,7 +6,7 @@ local curtabmeths = helpers.curtabmeths
local funcs = helpers.funcs
local request = helpers.request
local NIL = helpers.NIL
local meth_pcall = helpers.meth_pcall
local pcall_err = helpers.pcall_err
local command = helpers.command
describe('api/tabpage', function()
@@ -34,11 +34,11 @@ describe('api/tabpage', function()
eq(1, funcs.exists('t:lua'))
curtabmeths.del_var('lua')
eq(0, funcs.exists('t:lua'))
eq({false, 'Key not found: lua'}, meth_pcall(curtabmeths.del_var, 'lua'))
eq('Key not found: lua', pcall_err(curtabmeths.del_var, 'lua'))
curtabmeths.set_var('lua', 1)
command('lockvar t:lua')
eq({false, 'Key is locked: lua'}, meth_pcall(curtabmeths.del_var, 'lua'))
eq({false, 'Key is locked: lua'}, meth_pcall(curtabmeths.set_var, 'lua', 1))
eq('Key is locked: lua', pcall_err(curtabmeths.del_var, 'lua'))
eq('Key is locked: lua', pcall_err(curtabmeths.set_var, 'lua', 1))
end)
it('tabpage_set_var returns the old value', function()