diff options
author | Thomas Vigouroux <thomas.vigouroux@protonmail.com> | 2022-09-07 08:39:56 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-09-07 08:39:56 +0200 |
commit | fd1595514b747d8b083f78007579d869ccfbe89c (patch) | |
tree | 41e52c9e43db9351de3aa33a8628b76db07906c3 /test/functional/lua/vim_spec.lua | |
parent | f32fd19f1eedbd75e6a37b73f28cf8761e0e875c (diff) | |
download | rneovim-fd1595514b747d8b083f78007579d869ccfbe89c.tar.gz rneovim-fd1595514b747d8b083f78007579d869ccfbe89c.tar.bz2 rneovim-fd1595514b747d8b083f78007579d869ccfbe89c.zip |
Use weak tables in tree-sitter code (#17117)
feat(treesitter): use weak tables when possible
Also add the defaulttable function to create a table whose values are created when a key is missing.
Diffstat (limited to 'test/functional/lua/vim_spec.lua')
-rw-r--r-- | test/functional/lua/vim_spec.lua | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/test/functional/lua/vim_spec.lua b/test/functional/lua/vim_spec.lua index f2fb661b70..cd3240cd30 100644 --- a/test/functional/lua/vim_spec.lua +++ b/test/functional/lua/vim_spec.lua @@ -2754,6 +2754,24 @@ describe('lua stdlib', function() end) + describe("vim.defaulttable", function() + it("creates nested table by default", function() + eq({ b = {c = 1 } }, exec_lua[[ + local a = vim.defaulttable() + a.b.c = 1 + return a + ]]) + end) + + it("allows to create default objects", function() + eq({ b = 1 }, exec_lua[[ + local a = vim.defaulttable(function() return 0 end) + a.b = a.b + 1 + return a + ]]) + end) + end) + end) describe('lua: builtin modules', function() |