diff options
author | Michael Lingelbach <m.j.lbach@gmail.com> | 2022-03-24 12:01:04 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-24 12:01:04 -0700 |
commit | 69f1de86dca28d6e339351082df1309ef4fbb6a6 (patch) | |
tree | c65bd5aed8ab2d64a42b7dabc7180af0ad0fd68e /test/functional/lua/vim_spec.lua | |
parent | 39af40580a1788b4569c66aa710330f50707e976 (diff) | |
download | rneovim-69f1de86dca28d6e339351082df1309ef4fbb6a6.tar.gz rneovim-69f1de86dca28d6e339351082df1309ef4fbb6a6.tar.bz2 rneovim-69f1de86dca28d6e339351082df1309ef4fbb6a6.zip |
feat: add vim.tbl_get (#17831)
vim.tbl_get takes a table with subsequent string arguments (variadic) that
index into the table. If the value pointed to by the set of keys exists,
the function returns the value. If the set of keys does not exist, the
function returns nil.
Diffstat (limited to 'test/functional/lua/vim_spec.lua')
-rw-r--r-- | test/functional/lua/vim_spec.lua | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/test/functional/lua/vim_spec.lua b/test/functional/lua/vim_spec.lua index 38cb54fbc6..1547f3244e 100644 --- a/test/functional/lua/vim_spec.lua +++ b/test/functional/lua/vim_spec.lua @@ -490,6 +490,12 @@ describe('lua stdlib', function() eq(false, exec_lua("return vim.tbl_isempty({a=1, b=2, c=3})")) end) + it('vim.tbl_get', function() + eq(true, exec_lua("return vim.tbl_get({ test = { nested_test = true }}, 'test', 'nested_test')")) + eq(NIL, exec_lua("return vim.tbl_get({}, 'missing_key')")) + eq(NIL, exec_lua("return vim.tbl_get({})")) + end) + it('vim.tbl_extend', function() ok(exec_lua([[ local a = {x = 1} |