mirror of
https://github.com/neovim/neovim.git
synced 2024-12-20 03:05:11 -07:00
fix(lua): make vim.deepcopy
work with vim.NIL
style: changed double quotes to single quotes feat: add tests fix tests
This commit is contained in:
parent
f8c6718277
commit
e15f61b1bd
@ -49,6 +49,9 @@ vim.deepcopy = (function()
|
|||||||
if f then
|
if f then
|
||||||
return f(orig, cache or {})
|
return f(orig, cache or {})
|
||||||
else
|
else
|
||||||
|
if type(orig) == 'userdata' and orig == vim.NIL then
|
||||||
|
return vim.NIL
|
||||||
|
end
|
||||||
error('Cannot deepcopy object of type ' .. type(orig))
|
error('Cannot deepcopy object of type ' .. type(orig))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -419,6 +419,12 @@ describe('lua stdlib', function()
|
|||||||
return getmetatable(t2) == mt
|
return getmetatable(t2) == mt
|
||||||
]]))
|
]]))
|
||||||
|
|
||||||
|
ok(exec_lua([[
|
||||||
|
local t1 = {a = vim.NIL}
|
||||||
|
local t2 = vim.deepcopy(t1)
|
||||||
|
return t2.a == vim.NIL
|
||||||
|
]]))
|
||||||
|
|
||||||
matches('Cannot deepcopy object of type thread',
|
matches('Cannot deepcopy object of type thread',
|
||||||
pcall_err(exec_lua, [[
|
pcall_err(exec_lua, [[
|
||||||
local thread = coroutine.create(function () return 0 end)
|
local thread = coroutine.create(function () return 0 end)
|
||||||
|
Loading…
Reference in New Issue
Block a user