aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/functional/api/vim_spec.lua2
-rw-r--r--test/functional/lua/commands_spec.lua30
-rw-r--r--test/functional/lua/vim_spec.lua21
3 files changed, 40 insertions, 13 deletions
diff --git a/test/functional/api/vim_spec.lua b/test/functional/api/vim_spec.lua
index 48ac491ade..2af041c706 100644
--- a/test/functional/api/vim_spec.lua
+++ b/test/functional/api/vim_spec.lua
@@ -4042,7 +4042,7 @@ describe('API', function()
it('splits arguments correctly for Lua callback', function()
meths.exec_lua([[
local function FooFunc(opts)
- vim.pretty_print(opts.fargs)
+ vim.print(opts.fargs)
end
vim.api.nvim_create_user_command("Foo", FooFunc, { nargs = '+' })
diff --git a/test/functional/lua/commands_spec.lua b/test/functional/lua/commands_spec.lua
index b8346df290..943095c51e 100644
--- a/test/functional/lua/commands_spec.lua
+++ b/test/functional/lua/commands_spec.lua
@@ -8,6 +8,8 @@ local eval = helpers.eval
local feed = helpers.feed
local clear = helpers.clear
local meths = helpers.meths
+local exec_lua = helpers.exec_lua
+local exec_capture = helpers.exec_capture
local funcs = helpers.funcs
local source = helpers.source
local dedent = helpers.dedent
@@ -15,7 +17,6 @@ local command = helpers.command
local exc_exec = helpers.exc_exec
local pcall_err = helpers.pcall_err
local write_file = helpers.write_file
-local exec_capture = helpers.exec_capture
local curbufmeths = helpers.curbufmeths
local remove_trace = helpers.remove_trace
@@ -142,22 +143,29 @@ describe(':lua command', function()
]]}
end)
- it('Can print results of =expr', function()
- helpers.exec_lua("x = 5")
- eq("5", helpers.exec_capture(':lua =x'))
- helpers.exec_lua("function x() return 'hello' end")
- eq([["hello"]], helpers.exec_capture(':lua = x()'))
- helpers.exec_lua("x = {a = 1, b = 2}")
- eq("{\n a = 1,\n b = 2\n}", helpers.exec_capture(':lua =x'))
- helpers.exec_lua([[function x(success)
+ it('prints result of =expr', function()
+ exec_lua("x = 5")
+ eq("5", exec_capture(':lua =x'))
+ exec_lua("function x() return 'hello' end")
+ 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"
end
end]])
- eq([[true "Return value"]], helpers.exec_capture(':lua =x(true)'))
- eq([[false nil "Error message"]], helpers.exec_capture(':lua =x(false)'))
+ eq(dedent[[
+ true
+ Return value]],
+ exec_capture(':lua =x(true)'))
+ eq(dedent[[
+ false
+ nil
+ Error message]],
+ exec_capture(':lua =x(false)'))
end)
end)
diff --git a/test/functional/lua/vim_spec.lua b/test/functional/lua/vim_spec.lua
index 77628487ca..470102df5e 100644
--- a/test/functional/lua/vim_spec.lua
+++ b/test/functional/lua/vim_spec.lua
@@ -6,6 +6,7 @@ local nvim_prog = helpers.nvim_prog
local funcs = helpers.funcs
local meths = helpers.meths
local command = helpers.command
+local dedent = helpers.dedent
local insert = helpers.insert
local clear = helpers.clear
local eq = helpers.eq
@@ -2269,7 +2270,7 @@ describe('lua stdlib', function()
describe('vim.region', function()
it('charwise', function()
- insert(helpers.dedent( [[
+ insert(dedent( [[
text tααt tααt text
text tαxt txtα tex
text tαxt tαxt
@@ -2923,6 +2924,24 @@ describe('lua stdlib', function()
{4:-- Omni completion (^O^N^P) }{5:match 1 of 2} |
]]}
end)
+
+ it('vim.print', function()
+ -- vim.print() returns its args.
+ eq({42, 'abc', { a = { b = 77 }}},
+ exec_lua[[return {vim.print(42, 'abc', { a = { b = 77 }})}]])
+
+ -- vim.print() pretty-prints the args.
+ eq(dedent[[
+
+ 42
+ abc
+ {
+ a = {
+ b = 77
+ }
+ }]],
+ eval[[execute('lua vim.print(42, "abc", { a = { b = 77 }})')]])
+ end)
end)
describe('lua: builtin modules', function()