aboutsummaryrefslogtreecommitdiff
path: root/test/functional/eval/execute_spec.lua
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2017-01-31 03:40:02 +0100
committerJames McCoy <jamessan@jamessan.com>2017-02-01 18:31:53 -0500
commitf8b21b6d82a4bd50810c71b63632e5ba514feb76 (patch)
treefe99cd9a4c35157ebd6cecf02c9987f1ddf7fbcc /test/functional/eval/execute_spec.lua
parent7e7f01a3be90a4024d779a4032e5a914f850abdc (diff)
downloadrneovim-f8b21b6d82a4bd50810c71b63632e5ba514feb76.tar.gz
rneovim-f8b21b6d82a4bd50810c71b63632e5ba514feb76.tar.bz2
rneovim-f8b21b6d82a4bd50810c71b63632e5ba514feb76.zip
test: execute() + :redir
Diffstat (limited to 'test/functional/eval/execute_spec.lua')
-rw-r--r--test/functional/eval/execute_spec.lua35
1 files changed, 32 insertions, 3 deletions
diff --git a/test/functional/eval/execute_spec.lua b/test/functional/eval/execute_spec.lua
index 5614935ec2..91966ed3dd 100644
--- a/test/functional/eval/execute_spec.lua
+++ b/test/functional/eval/execute_spec.lua
@@ -22,7 +22,11 @@ describe('execute()', function()
eq("\nfoo\nbar", funcs.execute({'echo "foo"', 'echo "bar"'}))
end)
- it('supports nested redirection', function()
+ it('supports nested execute("execute(...)")', function()
+ eq('42', funcs.execute([[echon execute("echon execute('echon 42')")]]))
+ end)
+
+ it('supports nested :redir to a variable', function()
source([[
function! g:Foo()
let a = ''
@@ -34,14 +38,39 @@ describe('execute()', function()
function! g:Bar()
let a = ''
redir => a
+ silent echon "bar1"
call g:Foo()
+ silent echon "bar2"
redir END
+ silent echon "bar3"
return a
endfunction
]])
- eq('foo', funcs.execute('call g:Bar()'))
+ eq('top1bar1foobar2bar3', funcs.execute('echon "top1"|call g:Bar()'))
+ end)
- eq('42', funcs.execute([[echon execute("echon execute('echon 42')")]]))
+ it('supports nested :redir to a register', function()
+ source([[
+ let @a = ''
+ function! g:Foo()
+ redir @a>>
+ silent echon "foo"
+ redir END
+ return @a
+ endfunction
+ function! g:Bar()
+ redir @a>>
+ silent echon "bar1"
+ call g:Foo()
+ silent echon "bar2"
+ redir END
+ silent echon "bar3"
+ return @a
+ endfunction
+ ]])
+ eq('top1bar1foobar2bar3', funcs.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()