aboutsummaryrefslogtreecommitdiff
path: root/test/functional/api/window_spec.lua
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2019-09-03 22:51:45 +0200
committerJustin M. Keyes <justinkz@gmail.com>2019-09-06 17:19:07 -0700
commitaf946046b922dc5d5285a70a23d11916d8389a5d (patch)
tree090d68a1dd675b5ad6e99abc829be0daafe2a7d9 /test/functional/api/window_spec.lua
parent638f2b6dee7439de303bea12dec80240617e8034 (diff)
downloadrneovim-af946046b922dc5d5285a70a23d11916d8389a5d.tar.gz
rneovim-af946046b922dc5d5285a70a23d11916d8389a5d.tar.bz2
rneovim-af946046b922dc5d5285a70a23d11916d8389a5d.zip
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.
Diffstat (limited to 'test/functional/api/window_spec.lua')
-rw-r--r--test/functional/api/window_spec.lua18
1 files changed, 9 insertions, 9 deletions
diff --git a/test/functional/api/window_spec.lua b/test/functional/api/window_spec.lua
index 3bc53cfc83..3323d3866d 100644
--- a/test/functional/api/window_spec.lua
+++ b/test/functional/api/window_spec.lua
@@ -8,10 +8,10 @@ local curwinmeths = helpers.curwinmeths
local funcs = helpers.funcs
local request = helpers.request
local NIL = helpers.NIL
-local meth_pcall = helpers.meth_pcall
local meths = helpers.meths
local command = helpers.command
local expect_err = helpers.expect_err
+local pcall_err = helpers.pcall_err
-- check if str is visible at the beginning of some line
local function is_visible(str)
@@ -74,8 +74,7 @@ describe('API/win', function()
it('does not leak memory when using invalid window ID with invalid pos',
function()
- eq({false, 'Invalid window id'},
- meth_pcall(meths.win_set_cursor, 1, {"b\na"}))
+ eq('Invalid window id', pcall_err(meths.win_set_cursor, 1, {"b\na"}))
end)
it('updates the screen, and also when the window is unfocused', function()
@@ -185,11 +184,11 @@ describe('API/win', function()
eq(1, funcs.exists('w:lua'))
curwinmeths.del_var('lua')
eq(0, funcs.exists('w:lua'))
- eq({false, 'Key not found: lua'}, meth_pcall(curwinmeths.del_var, 'lua'))
+ eq('Key not found: lua', pcall_err(curwinmeths.del_var, 'lua'))
curwinmeths.set_var('lua', 1)
command('lockvar w:lua')
- eq({false, 'Key is locked: lua'}, meth_pcall(curwinmeths.del_var, 'lua'))
- eq({false, 'Key is locked: lua'}, meth_pcall(curwinmeths.set_var, 'lua', 1))
+ eq('Key is locked: lua', pcall_err(curwinmeths.del_var, 'lua'))
+ eq('Key is locked: lua', pcall_err(curwinmeths.set_var, 'lua', 1))
end)
it('window_set_var returns the old value', function()
@@ -222,7 +221,8 @@ describe('API/win', function()
eq('', nvim('get_option', 'statusline'))
command("set modified")
command("enew") -- global-local: not preserved in new buffer
- eq({false, "Failed to get value for option 'statusline'"}, meth_pcall(curwin, 'get_option', 'statusline'))
+ eq("Failed to get value for option 'statusline'",
+ pcall_err(curwin, 'get_option', 'statusline'))
eq('', eval('&l:statusline')) -- confirm local value was not copied
end)
end)
@@ -317,8 +317,8 @@ describe('API/win', function()
insert('text')
command('new')
local newwin = meths.get_current_win()
- eq({false,"Vim:E37: No write since last change (add ! to override)"},
- meth_pcall(meths.win_close, oldwin,false))
+ eq("Vim:E37: No write since last change (add ! to override)",
+ pcall_err(meths.win_close, oldwin,false))
eq({newwin,oldwin}, meths.list_wins())
end)