aboutsummaryrefslogtreecommitdiff
path: root/test/functional/api/vim_spec.lua
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2023-03-26 10:49:32 +0800
committerGitHub <noreply@github.com>2023-03-26 10:49:32 +0800
commit4863ca6b8902c5b0aab95f2af640118cd417d379 (patch)
tree41a1ecb32984dc88f25df722abaf3ba381db3cf3 /test/functional/api/vim_spec.lua
parent4eef5ac453866dae7c03f5432fc8c4dfcda19f54 (diff)
downloadrneovim-4863ca6b8902c5b0aab95f2af640118cd417d379.tar.gz
rneovim-4863ca6b8902c5b0aab95f2af640118cd417d379.tar.bz2
rneovim-4863ca6b8902c5b0aab95f2af640118cd417d379.zip
test: use exec_capture() in more places (#22787)
Problem: Using `meths.exec2("code", { output = true })` is too verbose. Solution: Use exec_capture() in more places.
Diffstat (limited to 'test/functional/api/vim_spec.lua')
-rw-r--r--test/functional/api/vim_spec.lua17
1 files changed, 9 insertions, 8 deletions
diff --git a/test/functional/api/vim_spec.lua b/test/functional/api/vim_spec.lua
index 162735dbd7..d8fb1bc623 100644
--- a/test/functional/api/vim_spec.lua
+++ b/test/functional/api/vim_spec.lua
@@ -9,6 +9,7 @@ local NIL = helpers.NIL
local clear, nvim, eq, neq = helpers.clear, helpers.nvim, helpers.eq, helpers.neq
local command = helpers.command
local exec = helpers.exec
+local exec_capture = helpers.exec_capture
local eval = helpers.eval
local expect = helpers.expect
local funcs = helpers.funcs
@@ -588,7 +589,7 @@ describe('API', function()
it('sets previous directory', function()
meths.set_current_dir("Xtestdir")
- meths.exec2('cd -', { output = false })
+ command('cd -')
eq(funcs.getcwd(), start_dir)
end)
end)
@@ -2687,7 +2688,7 @@ describe('API', function()
eq(' 1 %a "[No Name]" line 1\n'..
' 3 h "[Scratch]" line 0\n'..
' 4 h "[Scratch]" line 0',
- meths.exec2('ls', { output = true }).output)
+ exec_capture('ls'))
-- current buffer didn't change
eq({id=1}, meths.get_current_buf())
@@ -2954,13 +2955,13 @@ describe('API', function()
it('can save message history', function()
nvim('command', 'set cmdheight=2') -- suppress Press ENTER
nvim("echo", {{"msg\nmsg"}, {"msg"}}, true, {})
- eq("msg\nmsgmsg", meths.exec2('messages', { output = true }).output)
+ eq("msg\nmsgmsg", exec_capture('messages'))
end)
it('can disable saving message history', function()
nvim('command', 'set cmdheight=2') -- suppress Press ENTER
nvim_async("echo", {{"msg\nmsg"}, {"msg"}}, false, {})
- eq("", meths.exec2("messages", { output = true }).output)
+ eq("", exec_capture('messages'))
end)
end)
@@ -3949,7 +3950,7 @@ describe('API', function()
it('sets correct script context', function()
meths.cmd({ cmd = "set", args = { "cursorline" } }, {})
- local str = meths.exec2([[verbose set cursorline?]], { output = true }).output
+ local str = exec_capture([[verbose set cursorline?]])
neq(nil, str:find("cursorline\n\tLast set from API client %(channel id %d+%)"))
end)
@@ -3999,7 +4000,7 @@ describe('API', function()
line6
]]
meths.cmd({ cmd = "del", range = { 2, 4 }, reg = 'a' }, {})
- meths.exec2("1put a", { output = false })
+ command('1put a')
expect [[
line1
line2
@@ -4064,11 +4065,11 @@ describe('API', function()
{ output = true }))
end)
it('splits arguments correctly', function()
- meths.exec2([[
+ exec([[
function! FooFunc(...)
echo a:000
endfunction
- ]], { output = false })
+ ]])
meths.create_user_command("Foo", "call FooFunc(<f-args>)", { nargs = '+' })
eq([=[['a quick', 'brown fox', 'jumps over the', 'lazy dog']]=],
meths.cmd({ cmd = "Foo", args = { "a quick", "brown fox", "jumps over the", "lazy dog"}},