diff options
author | zeertzjq <zeertzjq@outlook.com> | 2024-04-17 06:34:10 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-17 06:34:10 +0800 |
commit | 329fc0e5b7f7777c405e4828650567a93620ba50 (patch) | |
tree | 197f43409fdabe4b459c748ea45a9d0fc5162428 /test/functional/api/vim_spec.lua | |
parent | f150b62423d57b6f9fbe57330589937dfbb34f4a (diff) | |
download | rneovim-329fc0e5b7f7777c405e4828650567a93620ba50.tar.gz rneovim-329fc0e5b7f7777c405e4828650567a93620ba50.tar.bz2 rneovim-329fc0e5b7f7777c405e4828650567a93620ba50.zip |
test: API can return Lua function to Lua code (#28380)
Diffstat (limited to 'test/functional/api/vim_spec.lua')
-rw-r--r-- | test/functional/api/vim_spec.lua | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/test/functional/api/vim_spec.lua b/test/functional/api/vim_spec.lua index 4e9a42f11d..c412773482 100644 --- a/test/functional/api/vim_spec.lua +++ b/test/functional/api/vim_spec.lua @@ -559,6 +559,16 @@ describe('API', function() eq('Vim:E121: Undefined variable: bogus', pcall_err(request, 'nvim_eval', 'bogus expression')) eq('', eval('v:errmsg')) -- v:errmsg was not updated. end) + + it('can return Lua function to Lua code', function() + eq( + [["a string with \"double quotes\" and 'single quotes'"]], + exec_lua([=[ + local fun = vim.api.nvim_eval([[luaeval('string.format')]]) + return fun('%q', [[a string with "double quotes" and 'single quotes']]) + ]=]) + ) + end) end) describe('nvim_call_function', function() @@ -624,6 +634,16 @@ describe('API', function() pcall_err(request, 'nvim_call_function', 'Foo', too_many_args) ) end) + + it('can return Lua function to Lua code', function() + eq( + [["a string with \"double quotes\" and 'single quotes'"]], + exec_lua([=[ + local fun = vim.api.nvim_call_function('luaeval', { 'string.format' }) + return fun('%q', [[a string with "double quotes" and 'single quotes']]) + ]=]) + ) + end) end) describe('nvim_call_dict_function', function() |