aboutsummaryrefslogtreecommitdiff
path: root/test/functional/lua/luaeval_spec.lua
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2024-08-02 16:00:27 +0800
committerGitHub <noreply@github.com>2024-08-02 08:00:27 +0000
commit2a3561819e0e80150986779cee87659b7c92d0c1 (patch)
tree7a207bb4b67abd02eec85580689c7193774f4d59 /test/functional/lua/luaeval_spec.lua
parent76dea5feaa1ab3f2e987ac3ff35238f8e29f2242 (diff)
downloadrneovim-2a3561819e0e80150986779cee87659b7c92d0c1.tar.gz
rneovim-2a3561819e0e80150986779cee87659b7c92d0c1.tar.bz2
rneovim-2a3561819e0e80150986779cee87659b7c92d0c1.zip
fix(eval): handle wrong v:lua in expr option properly (#29953)
Diffstat (limited to 'test/functional/lua/luaeval_spec.lua')
-rw-r--r--test/functional/lua/luaeval_spec.lua37
1 files changed, 37 insertions, 0 deletions
diff --git a/test/functional/lua/luaeval_spec.lua b/test/functional/lua/luaeval_spec.lua
index 2f137e280c..f3db729c09 100644
--- a/test/functional/lua/luaeval_spec.lua
+++ b/test/functional/lua/luaeval_spec.lua
@@ -13,6 +13,7 @@ local fn = n.fn
local clear = n.clear
local eval = n.eval
local feed = n.feed
+local assert_alive = n.assert_alive
local NIL = vim.NIL
local eq = t.eq
@@ -558,5 +559,41 @@ describe('v:lua', function()
eq("Vim:E107: Missing parentheses: v:lua", pcall_err(eval, "'bad'->v:lua"))
eq("Vim:E1085: Not a callable type: v:lua", pcall_err(eval, "'bad'->v:lua()"))
eq([[Vim:E15: Invalid expression: "v:lua.()"]], pcall_err(eval, "'bad'->v:lua.()"))
+
+ eq("Vim:E1085: Not a callable type: v:lua", pcall_err(eval, "v:lua()"))
+ eq([[Vim:E15: Invalid expression: "v:lua.()"]], pcall_err(eval, "v:lua.()"))
+ end)
+
+ describe('invalid use in fold text', function()
+ before_each(function()
+ feed('ifoo<CR>bar<Esc>')
+ command('1,2fold')
+ end)
+
+ it('with missing function name when used as simple function', function()
+ api.nvim_set_option_value('debug', 'throw', {})
+ eq(
+ [[Vim(eval):E15: Invalid expression: "v:lua.()"]],
+ pcall_err(command, 'set foldtext=v:lua.() | eval foldtextresult(1)')
+ )
+ end)
+
+ it('with missing function name when used in expression', function()
+ api.nvim_set_option_value('debug', 'throw', {})
+ eq(
+ [[Vim(eval):E15: Invalid expression: "+v:lua.()"]],
+ pcall_err(command, 'set foldtext=+v:lua.() | eval foldtextresult(1)')
+ )
+ end)
+
+ it('with non-existent function when used as simple function', function()
+ command('set foldtext=v:lua.NoSuchFunc() | eval foldtextresult(1)')
+ assert_alive()
+ end)
+
+ it('with non-existent function when used in expression', function()
+ command('set foldtext=+v:lua.NoSuchFunc() | eval foldtextresult(1)')
+ assert_alive()
+ end)
end)
end)