lua: allow deepcopy of functions (#12136)

This commit is contained in:
Tristan Konolige
2020-04-18 17:04:37 -06:00
committed by GitHub
parent c5466ba6ef
commit bf0f745861
3 changed files with 30 additions and 2 deletions

View File

@@ -341,6 +341,22 @@ describe('lua stdlib', function()
and vim.tbl_count(b) == 2
and tostring(a) ~= tostring(b)
]]))
ok(exec_lua([[
local f1 = function() return 1 end
local f2 = function() return 2 end
local t1 = {f = f1}
local t2 = vim.deepcopy(t1)
t1.f = f2
return t1.f() ~= t2.f()
]]))
eq('Error executing lua: .../shared.lua: Cannot deepcopy object of type thread',
pcall_err(exec_lua, [[
local thread = coroutine.create(function () return 0 end)
local t = {thr = thread}
vim.deepcopy(t)
]]))
end)
it('vim.pesc', function()