aboutsummaryrefslogtreecommitdiff
path: root/test/functional/lua/vim_spec.lua
diff options
context:
space:
mode:
authorThomas Vigouroux <thomas.vigouroux@protonmail.com>2022-09-07 08:39:56 +0200
committerGitHub <noreply@github.com>2022-09-07 08:39:56 +0200
commitfd1595514b747d8b083f78007579d869ccfbe89c (patch)
tree41e52c9e43db9351de3aa33a8628b76db07906c3 /test/functional/lua/vim_spec.lua
parentf32fd19f1eedbd75e6a37b73f28cf8761e0e875c (diff)
downloadrneovim-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.lua18
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()