diff options
author | Hirokazu Hata <h.hata.ai.t@gmail.com> | 2020-02-13 11:55:43 +0900 |
---|---|---|
committer | Hirokazu Hata <h.hata.ai.t@gmail.com> | 2020-02-13 11:55:43 +0900 |
commit | 417fc6ccf78801aef79a8731c5a85db6b12cd407 (patch) | |
tree | 99a92da313011aa0599fc7d9286e95394587c6ea /test/functional/lua/vim_spec.lua | |
parent | 68de6b17b8660adfeda93e46cec6ee6ebc7ebcf5 (diff) | |
download | rneovim-417fc6ccf78801aef79a8731c5a85db6b12cd407.tar.gz rneovim-417fc6ccf78801aef79a8731c5a85db6b12cd407.tar.bz2 rneovim-417fc6ccf78801aef79a8731c5a85db6b12cd407.zip |
lua: vim.deepcopy uses empty_dict() instead of {} for empty_dict()
fix: https://github.com/neovim/nvim-lsp/issues/94
Diffstat (limited to 'test/functional/lua/vim_spec.lua')
-rw-r--r-- | test/functional/lua/vim_spec.lua | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/test/functional/lua/vim_spec.lua b/test/functional/lua/vim_spec.lua index e879f8b925..b8edd7b3e0 100644 --- a/test/functional/lua/vim_spec.lua +++ b/test/functional/lua/vim_spec.lua @@ -322,6 +322,48 @@ describe('lua stdlib', function() ]]) assert(is_dc) + + local is_empty_list = exec_lua([[ + local a = {} + local b = vim.deepcopy(a) + + local count = 0 + for _ in pairs(b) do count = count + 1 end + + return getmetatable(b) ~= vim._empty_dict_mt + and count == 0 + and tostring(a) ~= tostring(b) + ]]) + + assert(is_empty_list) + + local is_empty_dic = exec_lua([[ + local a = vim.empty_dict() + local b = vim.deepcopy(a) + + local count = 0 + for _ in pairs(b) do count = count + 1 end + + return getmetatable(b) == vim._empty_dict_mt + and count == 0 + ]]) + + assert(is_empty_dic) + + local include_empty_dic = exec_lua([[ + local a = {x = vim.empty_dict(), y = {}} + local b = vim.deepcopy(a) + + local count = 0 + for _ in pairs(b) do count = count + 1 end + + return getmetatable(b.x) == vim._empty_dict_mt + and getmetatable(b.y) ~= vim._empty_dict_mt + and count == 2 + and tostring(a) ~= tostring(b) + ]]) + + assert(include_empty_dic) end) it('vim.pesc', function() |