functests: Check whether it is a problem with an array

This commit is contained in:
ZyX 2017-04-11 10:38:57 +03:00
parent a8ade2441d
commit 78082e8d3e

View File

@ -29,17 +29,22 @@ describe('luaeval(vim.api.…)', function()
end) end)
end) end)
describe('with errors', function() describe('with errors', function()
it('transforms API errors from nvim_buf_set_lines into lua errors', function() it('transforms API error from nvim_buf_set_lines into lua error', function()
funcs.setline(1, {"abc", "def", "a\nb", "ttt"}) funcs.setline(1, {"abc", "def", "a\nb", "ttt"})
eq({false, 'string cannot contain newlines'}, eq({false, 'string cannot contain newlines'},
funcs.luaeval('{pcall(vim.api.nvim_buf_set_lines, 1, 1, 2, false, {"b\\na"})}')) funcs.luaeval('{pcall(vim.api.nvim_buf_set_lines, 1, 1, 2, false, {"b\\na"})}'))
end) end)
it('transforms API errors from nvim_win_set_cursor into lua errors', function() it('transforms API error from nvim_win_set_cursor into lua error', function()
funcs.setline(1, {"abc", "def", "a\nb", "ttt"})
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, 1, {1, 2, 3})}'))
end) end)
it('transforms API error from nvim_win_set_cursor + same array as in first test into lua error',
function()
eq({false, 'Argument "pos" must be a [row, col] array'},
funcs.luaeval('{pcall(vim.api.nvim_win_set_cursor, 1, {"b\\na"})}'))
end)
end) end)
it('correctly evaluates API code which calls luaeval', function() it('correctly evaluates API code which calls luaeval', function()