aboutsummaryrefslogtreecommitdiff
path: root/test/functional/lua/commands_spec.lua
diff options
context:
space:
mode:
authorLewis Russell <lewis6991@gmail.com>2024-07-29 11:20:15 +0100
committerLewis Russell <me@lewisr.dev>2024-08-02 19:04:37 +0100
commit7d24c4d6b0413cd5af8d0579f0a9a694db7f775e (patch)
treed9954c2001fe512c60a76561e7a19566b9de638b /test/functional/lua/commands_spec.lua
parentf32557ca679cbb1d7de52ab54dc35585af9ab9d0 (diff)
downloadrneovim-7d24c4d6b0413cd5af8d0579f0a9a694db7f775e.tar.gz
rneovim-7d24c4d6b0413cd5af8d0579f0a9a694db7f775e.tar.bz2
rneovim-7d24c4d6b0413cd5af8d0579f0a9a694db7f775e.zip
test: allow exec_lua to handle functions
Problem: Tests have lots of exec_lua calls which input blocks of code provided as unformatted strings. Solution: Teach exec_lua how to handle functions.
Diffstat (limited to 'test/functional/lua/commands_spec.lua')
-rw-r--r--test/functional/lua/commands_spec.lua14
1 files changed, 8 insertions, 6 deletions
diff --git a/test/functional/lua/commands_spec.lua b/test/functional/lua/commands_spec.lua
index 57b084d3d6..456ee13da2 100644
--- a/test/functional/lua/commands_spec.lua
+++ b/test/functional/lua/commands_spec.lua
@@ -178,13 +178,15 @@ describe(':lua', function()
eq('hello', exec_capture(':lua = x()'))
exec_lua('x = {a = 1, b = 2}')
eq('{\n a = 1,\n b = 2\n}', exec_capture(':lua =x'))
- exec_lua([[function x(success)
- if success then
- return true, "Return value"
- else
- return false, nil, "Error message"
+ exec_lua(function()
+ function _G.x(success)
+ if success then
+ return true, 'Return value'
+ else
+ return false, nil, 'Error message'
+ end
end
- end]])
+ end)
eq(
dedent [[
true