diff options
author | Yegappan Lakshmanan <yegappan@yahoo.com> | 2024-04-12 18:48:35 +0200 |
---|---|---|
committer | Christian Brabandt <cb@256bit.org> | 2024-04-12 18:53:08 +0200 |
commit | e74cad3321ce1dcefc1fc64f617511275b6cd930 (patch) | |
tree | b29c4a7843c748750a448800846bbff1b1dfde19 /src/testdir/test_vim9_script.vim | |
parent | a1dcd76ce791b5b8bd093765a99b71aa163300a5 (diff) |
patch 9.1.0312: heredocs are not supported for :commandsv9.1.0312
Problem: heredocs are not supported for :commands
(@balki)
Solution: Add heredoc support
(Yegappan Lakshmanan)
fixes: #14491
closes: #14528
Signed-off-by: Yegappan Lakshmanan <yegappan@yahoo.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
Diffstat (limited to 'src/testdir/test_vim9_script.vim')
-rw-r--r-- | src/testdir/test_vim9_script.vim | 102 |
1 files changed, 100 insertions, 2 deletions
diff --git a/src/testdir/test_vim9_script.vim b/src/testdir/test_vim9_script.vim index cd693e5993..136c81db7d 100644 --- a/src/testdir/test_vim9_script.vim +++ b/src/testdir/test_vim9_script.vim @@ -458,7 +458,7 @@ func s:InvokeSomeCommand() SomeCommand endfunc -def Test_autocommand_block() +def Test_command_block() com SomeCommand { g:someVar = 'some' } @@ -469,7 +469,105 @@ def Test_autocommand_block() unlet g:someVar enddef -def Test_command_block() +" Test for using heredoc in a :command command block +def Test_command_block_heredoc() + var lines =<< trim CODE + vim9script + com SomeCommand { + g:someVar =<< trim END + aaa + bbb + END + } + SomeCommand + assert_equal(['aaa', 'bbb'], g:someVar) + def Foo() + g:someVar = [] + SomeCommand + assert_equal(['aaa', 'bbb'], g:someVar) + enddef + Foo() + delcommand SomeCommand + unlet g:someVar + CODE + v9.CheckSourceSuccess( lines) + + # Execute a command with heredoc in a block + lines =<< trim CODE + vim9script + com SomeCommand { + g:someVar =<< trim END + aaa + bbb + END + } + execute('SomeCommand') + assert_equal(['aaa', 'bbb'], g:someVar) + delcommand SomeCommand + unlet g:someVar + CODE + v9.CheckSourceSuccess(lines) + + # heredoc evaluation + lines =<< trim CODE + vim9script + com SomeCommand { + var suffix = '---' + g:someVar =<< trim eval END + ccc{suffix} + ddd + END + } + SomeCommand + assert_equal(['ccc---', 'ddd'], g:someVar) + def Foo() + g:someVar = [] + SomeCommand + assert_equal(['ccc---', 'ddd'], g:someVar) + enddef + Foo() + delcommand SomeCommand + unlet g:someVar + CODE + v9.CheckSourceSuccess(lines) + + # command following heredoc + lines =<< trim CODE + vim9script + com SomeCommand { + var l =<< trim END + eee + fff + END + g:someVar = l + } + SomeCommand + assert_equal(['eee', 'fff'], g:someVar) + delcommand SomeCommand + unlet g:someVar + CODE + v9.CheckSourceSuccess(lines) + + # Error in heredoc + lines =<< trim CODE + vim9script + com SomeCommand { + g:someVar =<< trim END + eee + fff + } + try + SomeCommand + catch + assert_match("E990: Missing end marker 'END'", v:exception) + endtry + delcommand SomeCommand + unlet g:someVar + CODE + v9.CheckSourceSuccess(lines) +enddef + +def Test_autocommand_block() au BufNew *.xml { g:otherVar = 'other' } |