mirror of
https://github.com/neovim/neovim.git
synced 2025-09-07 11:58:17 +00:00
refactor: use kwargs parameter in vim.split
This commit is contained in:
@@ -237,8 +237,8 @@ describe('lua stdlib', function()
|
||||
end)
|
||||
|
||||
it("vim.split", function()
|
||||
local split = function(str, sep, plain, trimempty)
|
||||
return exec_lua('return vim.split(...)', str, sep, plain, trimempty)
|
||||
local split = function(str, sep, kwargs)
|
||||
return exec_lua('return vim.split(...)', str, sep, kwargs)
|
||||
end
|
||||
|
||||
local tests = {
|
||||
@@ -259,9 +259,12 @@ describe('lua stdlib', function()
|
||||
}
|
||||
|
||||
for _, t in ipairs(tests) do
|
||||
eq(t[5], split(t[1], t[2], t[3], t[4]))
|
||||
eq(t[5], split(t[1], t[2], {plain=t[3], trimempty=t[4]}))
|
||||
end
|
||||
|
||||
-- Test old signature
|
||||
eq({'x', 'yz', 'oo', 'l'}, split("x*yz*oo*l", "*", true))
|
||||
|
||||
local loops = {
|
||||
{ "abc", ".-" },
|
||||
}
|
||||
@@ -285,16 +288,10 @@ describe('lua stdlib', function()
|
||||
vim/shared.lua:0: in function <vim/shared.lua:0>]]),
|
||||
pcall_err(split, 'string', 1))
|
||||
eq(dedent([[
|
||||
Error executing lua: vim/shared.lua:0: plain: expected boolean, got number
|
||||
Error executing lua: vim/shared.lua:0: kwargs: expected table, got number
|
||||
stack traceback:
|
||||
vim/shared.lua:0: in function 'gsplit'
|
||||
vim/shared.lua:0: in function <vim/shared.lua:0>]]),
|
||||
pcall_err(split, 'string', 'string', 1))
|
||||
eq(dedent([[
|
||||
Error executing lua: vim/shared.lua:0: trimempty: expected boolean, got number
|
||||
stack traceback:
|
||||
vim/shared.lua:0: in function <vim/shared.lua:0>]]),
|
||||
pcall_err(split, 'string', 'string', false, 42))
|
||||
end)
|
||||
|
||||
it('vim.trim', function()
|
||||
|
Reference in New Issue
Block a user