mirror of
https://github.com/folke/lazy.nvim.git
synced 2025-04-18 20:36:45 +00:00
fix(util): Util.merge now skips nil args
This commit is contained in:
parent
3769461194
commit
70f764bf73
2 changed files with 25 additions and 8 deletions
|
@ -101,6 +101,22 @@ describe("util", function()
|
|||
input = { { a = 1 }, { b = 2 } },
|
||||
output = { a = 1, b = 2 },
|
||||
},
|
||||
{
|
||||
input = { nil, { a = 1 }, { b = 2 } },
|
||||
output = { a = 1, b = 2 },
|
||||
},
|
||||
{
|
||||
input = { { a = 1 }, { b = 2 }, nil },
|
||||
output = { a = 1, b = 2 },
|
||||
},
|
||||
{
|
||||
input = { { a = 1 }, nil, { b = 2 } },
|
||||
output = { a = 1, b = 2 },
|
||||
},
|
||||
{
|
||||
input = { nil, { a = 1 }, nil, { b = 2 }, nil },
|
||||
output = { a = 1, b = 2 },
|
||||
},
|
||||
{
|
||||
input = { { a = 1 }, { a = 2 } },
|
||||
output = { a = 2 },
|
||||
|
@ -120,7 +136,11 @@ describe("util", function()
|
|||
}
|
||||
|
||||
for _, test in ipairs(tests) do
|
||||
assert.same(test.output, Util.merge(unpack(test.input)))
|
||||
local n = 0
|
||||
for i in pairs(test.input) do
|
||||
n = math.max(n, i)
|
||||
end
|
||||
assert.same(test.output, Util.merge(unpack(test.input, 1, n)))
|
||||
end
|
||||
end)
|
||||
end)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue