diff options
author | zeertzjq <zeertzjq@outlook.com> | 2022-03-20 08:08:50 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-20 08:08:50 +0800 |
commit | 77eb6f9dc75ebe00aa835441ad623ba46d7108bb (patch) | |
tree | 9a968c1c192ea892f68b23c817fe487dc89df72d /test/functional/lua/vim_spec.lua | |
parent | 2ab52bd9889790dc7e47a09e801751aada418727 (diff) | |
download | rneovim-77eb6f9dc75ebe00aa835441ad623ba46d7108bb.tar.gz rneovim-77eb6f9dc75ebe00aa835441ad623ba46d7108bb.tar.bz2 rneovim-77eb6f9dc75ebe00aa835441ad623ba46d7108bb.zip |
fix(api, lua): return NIL on failure to find converted function (#17779)
Diffstat (limited to 'test/functional/lua/vim_spec.lua')
-rw-r--r-- | test/functional/lua/vim_spec.lua | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/test/functional/lua/vim_spec.lua b/test/functional/lua/vim_spec.lua index 5b4daf02ea..38cb54fbc6 100644 --- a/test/functional/lua/vim_spec.lua +++ b/test/functional/lua/vim_spec.lua @@ -1043,6 +1043,17 @@ describe('lua stdlib', function() exec_lua([[vim.api.nvim_get_var('funcs').add()]]) eq(6, exec_lua([[return vim.api.nvim_get_var('funcs').get()]])) + exec([[ + function Test() + endfunction + function s:Test() + endfunction + let g:Unknown_func = function('Test') + let g:Unknown_script_func = function('s:Test') + ]]) + eq(NIL, exec_lua([[return vim.g.Unknown_func]])) + eq(NIL, exec_lua([[return vim.g.Unknown_script_func]])) + -- Check if autoload works properly local pathsep = helpers.get_pathsep() local xconfig = 'Xhome' .. pathsep .. 'Xconfig' @@ -1136,6 +1147,17 @@ describe('lua stdlib', function() exec_lua([[vim.api.nvim_buf_get_var(0, 'funcs').add()]]) eq(6, exec_lua([[return vim.api.nvim_buf_get_var(0, 'funcs').get()]])) + exec([[ + function Test() + endfunction + function s:Test() + endfunction + let b:Unknown_func = function('Test') + let b:Unknown_script_func = function('s:Test') + ]]) + eq(NIL, exec_lua([[return vim.b.Unknown_func]])) + eq(NIL, exec_lua([[return vim.b.Unknown_script_func]])) + exec_lua [[ vim.cmd "vnew" ]] @@ -1219,6 +1241,17 @@ describe('lua stdlib', function() exec_lua([[vim.api.nvim_win_get_var(0, 'funcs').add()]]) eq(6, exec_lua([[return vim.api.nvim_win_get_var(0, 'funcs').get()]])) + exec([[ + function Test() + endfunction + function s:Test() + endfunction + let w:Unknown_func = function('Test') + let w:Unknown_script_func = function('s:Test') + ]]) + eq(NIL, exec_lua([[return vim.w.Unknown_func]])) + eq(NIL, exec_lua([[return vim.w.Unknown_script_func]])) + exec_lua [[ vim.cmd "vnew" ]] |