aboutsummaryrefslogtreecommitdiff
path: root/test/functional/vimscript/execute_spec.lua
diff options
context:
space:
mode:
Diffstat (limited to 'test/functional/vimscript/execute_spec.lua')
-rw-r--r--test/functional/vimscript/execute_spec.lua95
1 files changed, 44 insertions, 51 deletions
diff --git a/test/functional/vimscript/execute_spec.lua b/test/functional/vimscript/execute_spec.lua
index bb28938708..29488ed31c 100644
--- a/test/functional/vimscript/execute_spec.lua
+++ b/test/functional/vimscript/execute_spec.lua
@@ -5,7 +5,7 @@ local clear = helpers.clear
local source = helpers.source
local exc_exec = helpers.exc_exec
local pcall_err = helpers.pcall_err
-local funcs = helpers.funcs
+local fn = helpers.fn
local Screen = require('test.functional.ui.screen')
local command = helpers.command
local feed = helpers.feed
@@ -22,16 +22,16 @@ describe('execute()', function()
silent! messages
redir END
]])
- eq(eval('g:__redir_output'), funcs.execute('messages'))
+ eq(eval('g:__redir_output'), fn.execute('messages'))
end)
it('captures the concatenated outputs of a List of commands', function()
- eq("foobar", funcs.execute({'echon "foo"', 'echon "bar"'}))
- eq("\nfoo\nbar", funcs.execute({'echo "foo"', 'echo "bar"'}))
+ eq('foobar', fn.execute({ 'echon "foo"', 'echon "bar"' }))
+ eq('\nfoo\nbar', fn.execute({ 'echo "foo"', 'echo "bar"' }))
end)
it('supports nested execute("execute(...)")', function()
- eq('42', funcs.execute([[echon execute("echon execute('echon 42')")]]))
+ eq('42', fn.execute([[echon execute("echon execute('echon 42')")]]))
end)
it('supports nested :redir to a variable', function()
@@ -54,7 +54,7 @@ describe('execute()', function()
return a
endfunction
]])
- eq('top1bar1foobar2bar3', funcs.execute('echon "top1"|call g:Bar()'))
+ eq('top1bar1foobar2bar3', fn.execute('echon "top1"|call g:Bar()'))
end)
it('supports nested :redir to a register', function()
@@ -76,17 +76,17 @@ describe('execute()', function()
return @a
endfunction
]])
- eq('top1bar1foobar2bar3', funcs.execute('echon "top1"|call g:Bar()'))
+ eq('top1bar1foobar2bar3', fn.execute('echon "top1"|call g:Bar()'))
-- :redir itself doesn't nest, so the redirection ends in g:Foo
eq('bar1foo', eval('@a'))
end)
it('captures a transformed string', function()
- eq('^A', funcs.execute('echon "\\<C-a>"'))
+ eq('^A', fn.execute('echon "\\<C-a>"'))
end)
it('returns empty string if the argument list is empty', function()
- eq('', funcs.execute({}))
+ eq('', fn.execute({}))
eq(0, exc_exec('let g:ret = execute(v:_null_list)'))
eq('', eval('g:ret'))
end)
@@ -104,27 +104,31 @@ describe('execute()', function()
end)
it('captures output with highlights', function()
- eq('\nErrorMsg xxx ctermfg=15 ctermbg=1 guifg=White guibg=Red',
- eval('execute("hi ErrorMsg")'))
+ eq(
+ '\nErrorMsg xxx ctermfg=15 ctermbg=1 guifg=White guibg=Red',
+ eval('execute("hi ErrorMsg")')
+ )
end)
it('does not corrupt the command display #5422', function()
local screen = Screen.new(70, 7)
screen:attach()
feed(':echo execute("hi ErrorMsg")<CR>')
- screen:expect([[
+ screen:expect(
+ [[
|
- {1:~ }|
- {1:~ }|
+ {1:~ }|*2
{2: }|
|
ErrorMsg xxx ctermfg=15 ctermbg=1 guifg=White guibg=Red |
{3:Press ENTER or type command to continue}^ |
- ]], {
- [1] = {bold = true, foreground = Screen.colors.Blue1},
- [2] = {bold = true, reverse = true},
- [3] = {bold = true, foreground = Screen.colors.SeaGreen4},
- })
+ ]],
+ {
+ [1] = { bold = true, foreground = Screen.colors.Blue1 },
+ [2] = { bold = true, reverse = true },
+ [3] = { bold = true, foreground = Screen.colors.SeaGreen4 },
+ }
+ )
feed('<CR>')
end)
@@ -187,30 +191,21 @@ describe('execute()', function()
feed([[:call Test1()<cr>]])
screen:expect([[
^ |
- ~ |
- ~ |
- ~ |
- ~ |
+ ~ |*4
ABCD |
]])
feed([[:call Test2()<cr>]])
screen:expect([[
^ |
- ~ |
- ~ |
- ~ |
- ~ |
+ ~ |*4
1234ABCD |
]])
feed([[:call Test3()<cr>]])
screen:expect([[
^ |
- ~ |
- ~ |
- ~ |
- ~ |
+ ~ |*4
1234ABCDXZYZ |
]])
@@ -231,10 +226,7 @@ describe('execute()', function()
feed([[:call Test5()<cr>]])
screen:expect([[
^ |
- ~ |
- ~ |
- ~ |
- ~ |
+ ~ |*4
1234ABCD |
]])
@@ -263,7 +255,7 @@ describe('execute()', function()
-- with how nvim currently displays the output.
it('captures shell-command output', function()
local win_lf = is_os('win') and '\13' or ''
- eq('\n:!echo foo\r\n\nfoo'..win_lf..'\n', funcs.execute('!echo foo'))
+ eq('\n:!echo foo\r\n\nfoo' .. win_lf .. '\n', fn.execute('!echo foo'))
end)
describe('{silent} argument', function()
@@ -273,9 +265,7 @@ describe('execute()', function()
command('let g:mes = execute("echon 42", "")')
screen:expect([[
^ |
- ~ |
- ~ |
- ~ |
+ ~ |*3
42 |
]])
eq('42', eval('g:mes'))
@@ -283,10 +273,14 @@ describe('execute()', function()
it('gives E493 instead of prompting on backwards range for ""', function()
command('split')
- eq('Vim(windo):E493: Backwards range given: 2,1windo echo',
- pcall_err(funcs.execute, '2,1windo echo', ''))
- eq('Vim(windo):E493: Backwards range given: 2,1windo echo',
- pcall_err(funcs.execute, {'2,1windo echo'}, ''))
+ eq(
+ 'Vim(windo):E493: Backwards range given: 2,1windo echo',
+ pcall_err(fn.execute, '2,1windo echo', '')
+ )
+ eq(
+ 'Vim(windo):E493: Backwards range given: 2,1windo echo',
+ pcall_err(fn.execute, { '2,1windo echo' }, '')
+ )
end)
it('captures but does not display output for "silent"', function()
@@ -295,21 +289,20 @@ describe('execute()', function()
command('let g:mes = execute("echon 42")')
screen:expect([[
^ |
- ~ |
- ~ |
- ~ |
+ ~ |*3
|
]])
eq('42', eval('g:mes'))
command('let g:mes = execute("echon 13", "silent")')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
^ |
- ~ |
- ~ |
- ~ |
+ ~ |*3
|
- ]], unchanged=true}
+ ]],
+ unchanged = true,
+ }
eq('13', eval('g:mes'))
end)