diff options
author | zeertzjq <zeertzjq@outlook.com> | 2023-12-12 20:34:02 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-12 20:34:02 +0800 |
commit | b40170f7a3ca4bd157eeb52c9d57cb2ebfe3c562 (patch) | |
tree | f7f58e7e15ee0fbd887587c19f740179d807d1b0 /test/functional/lua/vim_spec.lua | |
parent | 1d4a5cd18537d054a564ff19b9361120597d9dd7 (diff) | |
download | rneovim-b40170f7a3ca4bd157eeb52c9d57cb2ebfe3c562.tar.gz rneovim-b40170f7a3ca4bd157eeb52c9d57cb2ebfe3c562.tar.bz2 rneovim-b40170f7a3ca4bd157eeb52c9d57cb2ebfe3c562.zip |
fix(lua): memory leak when using invalid syntax with exists() (#26530)
Diffstat (limited to 'test/functional/lua/vim_spec.lua')
-rw-r--r-- | test/functional/lua/vim_spec.lua | 37 |
1 files changed, 14 insertions, 23 deletions
diff --git a/test/functional/lua/vim_spec.lua b/test/functional/lua/vim_spec.lua index 403e9f6a12..509958bbde 100644 --- a/test/functional/lua/vim_spec.lua +++ b/test/functional/lua/vim_spec.lua @@ -3351,32 +3351,23 @@ describe('vim.keymap', function() eq(1, exec_lua[[return GlobalCount]]) end) +end) - it('exists() can check a lua function', function() - eq(true, exec_lua[[ +describe('Vimscript function exists()', function() + it('can check a lua function', function() + eq(1, exec_lua[[ _G.test = function() print("hello") end - return vim.fn.exists('v:lua.test') == 1 - ]]) - - eq(true, exec_lua[[ - return vim.fn.exists('v:lua.require("mpack").decode') == 1 + return vim.fn.exists('v:lua.test') ]]) - eq(true, exec_lua[[ - return vim.fn.exists("v:lua.require('vim.lsp').start") == 1 - ]]) - - eq(true, exec_lua[[ - return vim.fn.exists('v:lua.require"vim.lsp".start') == 1 - ]]) - - eq(true, exec_lua[[ - return vim.fn.exists("v:lua.require'vim.lsp'.start") == 1 - ]]) - - eq(false, exec_lua[[ - return vim.fn.exists("v:lua.require'vim.lsp'.unknown") == 1 - ]]) + eq(1, funcs.exists('v:lua.require("mpack").decode')) + eq(1, funcs.exists("v:lua.require('mpack').decode")) + eq(1, funcs.exists('v:lua.require"mpack".decode')) + eq(1, funcs.exists("v:lua.require'mpack'.decode")) + eq(1, funcs.exists("v:lua.require('vim.lsp').start")) + eq(1, funcs.exists('v:lua.require"vim.lsp".start')) + eq(1, funcs.exists("v:lua.require'vim.lsp'.start")) + eq(0, funcs.exists("v:lua.require'vim.lsp'.unknown")) + eq(0, funcs.exists('v:lua.?')) end) - end) |