functests: Fix tests

This commit is contained in:
ZyX
2017-05-08 21:06:23 +03:00
parent 85bf64da0a
commit 5b6d598ca8
2 changed files with 12 additions and 2 deletions

View File

@@ -9,6 +9,7 @@ local funcs = helpers.funcs
local request = helpers.request local request = helpers.request
local NIL = helpers.NIL local NIL = helpers.NIL
local meth_pcall = helpers.meth_pcall local meth_pcall = helpers.meth_pcall
local meths = helpers.meths
local command = helpers.command local command = helpers.command
-- check if str is visible at the beginning of some line -- check if str is visible at the beginning of some line
@@ -55,6 +56,12 @@ describe('api/win', function()
eq('typing\n some dumb text', curbuf_contents()) eq('typing\n some dumb text', curbuf_contents())
end) end)
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"}))
end)
it('updates the screen, and also when the window is unfocused', function() it('updates the screen, and also when the window is unfocused', function()
insert("prologue") insert("prologue")
feed('100o<esc>') feed('100o<esc>')

View File

@@ -37,13 +37,16 @@ describe('luaeval(vim.api.…)', function()
it('transforms API error from nvim_win_set_cursor into lua error', function() it('transforms API error from nvim_win_set_cursor into lua error', function()
eq({false, 'Argument "pos" must be a [row, col] array'}, eq({false, 'Argument "pos" must be a [row, col] array'},
funcs.luaeval('{pcall(vim.api.nvim_win_set_cursor, 1, {1, 2, 3})}')) funcs.luaeval('{pcall(vim.api.nvim_win_set_cursor, 0, {1, 2, 3})}'))
-- Used to produce a memory leak due to a bug in nvim_win_set_cursor
eq({false, 'Invalid window id'},
funcs.luaeval('{pcall(vim.api.nvim_win_set_cursor, -1, {1, 2, 3})}'))
end) end)
it('transforms API error from nvim_win_set_cursor + same array as in first test into lua error', it('transforms API error from nvim_win_set_cursor + same array as in first test into lua error',
function() function()
eq({false, 'Argument "pos" must be a [row, col] array'}, eq({false, 'Argument "pos" must be a [row, col] array'},
funcs.luaeval('{pcall(vim.api.nvim_win_set_cursor, 1, {"b\\na"})}')) funcs.luaeval('{pcall(vim.api.nvim_win_set_cursor, 0, {"b\\na"})}'))
end) end)
end) end)