mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
vim-patch:9.1.0319: Using heredoc in string not tested with :execute (#28333)
Problem: Using heredoc in string not tested with :execute.
Solution: Test with both :execute and execute() (zeertzjq).
closes: vim/vim#14546
3d93630605
This commit is contained in:
parent
aa1d0ac095
commit
1d73ecda7f
@ -720,31 +720,33 @@ END
|
|||||||
LINES
|
LINES
|
||||||
call CheckScriptFailure(lines, 'E15:')
|
call CheckScriptFailure(lines, 'E15:')
|
||||||
|
|
||||||
" Test for using heredoc in a single string using execute()
|
" Test for using heredoc in a single string using :execute or execute()
|
||||||
call assert_equal("\n['one', 'two']",
|
for [cmd, res] in items({
|
||||||
\ execute("let x =<< trim END\n one\n two\nEND\necho x"))
|
\ "let x =<< trim END\n one\n two\nEND": ['one', 'two'],
|
||||||
call assert_equal("\n['one', ' two']",
|
\ "let x =<< trim END\n one\n two\nEND": ['one', ' two'],
|
||||||
\ execute("let x =<< trim END\n one\n two\nEND\necho x"))
|
\ " let x =<< trim END\n one\n two\n END": ['one', 'two'],
|
||||||
call assert_equal("\n['one', 'two']",
|
\ " let x =<< trim END\n one\n two\n END": ['one', ' two'],
|
||||||
\ execute(" let x =<< trim END\n one\n two\n END\necho x"))
|
\ "let x =<< END\n one\n two\nEND": [' one', ' two'],
|
||||||
call assert_equal("\n['one', ' two']",
|
\ "let x =<< END\none\ntwo\nEND": ['one', 'two'],
|
||||||
\ execute(" let x =<< trim END\n one\n two\n END\necho x"))
|
\ "let x =<< END \" comment\none\ntwo\nEND": ['one', 'two'],
|
||||||
call assert_equal("\n[' one', ' two']",
|
\ })
|
||||||
\ execute("let x =<< END\n one\n two\nEND\necho x"))
|
execute cmd
|
||||||
call assert_equal("\n['one', 'two']",
|
call assert_equal(res, x)
|
||||||
\ execute("let x =<< END\none\ntwo\nEND\necho x"))
|
unlet x
|
||||||
call assert_equal("\n['one', 'two']",
|
call assert_equal($"\n{string(res)}", execute($"{cmd}\necho x"))
|
||||||
\ execute("let x =<< END \" comment\none\ntwo\nEND\necho x"))
|
unlet x
|
||||||
let cmd = 'execute("let x =<< END\n one\n two\necho x")'
|
endfor
|
||||||
call assert_fails(cmd, "E990: Missing end marker 'END'")
|
for [cmd, err] in items({
|
||||||
let cmd = 'execute("let x =<<\n one\n two\necho x")'
|
\ "let x =<<\none\ntwo": "E172:",
|
||||||
call assert_fails(cmd, "E172: Missing marker")
|
\ "let x =<< trim\n one\n two": "E172:",
|
||||||
let cmd = 'execute("let x =<< trim\n one\n two\necho x")'
|
\ "let x =<< end\none\ntwo\nend": "E221:",
|
||||||
call assert_fails(cmd, "E172: Missing marker")
|
\ "let x =<< END\none\ntwo": "E990: Missing end marker 'END'",
|
||||||
let cmd = 'execute("let x =<< end\n one\n two\nend\necho x")'
|
\ "let x =<< END !\none\ntwo\nEND": "E488: Trailing characters: !",
|
||||||
call assert_fails(cmd, "E221: Marker cannot start with lower case letter")
|
\ "let x =<< eval END\none\ntwo{y}\nEND": "E121: Undefined variable: y",
|
||||||
let cmd = 'execute("let x =<< eval END\n one\n two{y}\nEND\necho x")'
|
\ })
|
||||||
call assert_fails(cmd, 'E121: Undefined variable: y')
|
call assert_fails('execute cmd', err)
|
||||||
|
call assert_fails('call execute(cmd)', err)
|
||||||
|
endfor
|
||||||
|
|
||||||
" skipped heredoc
|
" skipped heredoc
|
||||||
if 0
|
if 0
|
||||||
|
Loading…
Reference in New Issue
Block a user