summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2024-04-14 18:49:56 +0200
committerChristian Brabandt <cb@256bit.org>2024-04-14 18:49:56 +0200
commit3d93630605df60e8de5a38918eaff62165b42382 (patch)
treede62b2427f7b0eb5682de323d43e3af059b47bf3
parentacba5af9572547dea7cbabe9a13e6a9a995a1281 (diff)
patch 9.1.0319: Using heredoc in string not tested with :executev9.1.0319
Problem: Using heredoc in string not tested with :execute. Solution: Test with both :execute and execute() (zeertzjq). closes: #14546 Signed-off-by: zeertzjq <zeertzjq@outlook.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
-rw-r--r--src/testdir/test_let.vim52
-rw-r--r--src/version.c2
2 files changed, 29 insertions, 25 deletions
diff --git a/src/testdir/test_let.vim b/src/testdir/test_let.vim
index 974e8f1a37..17f78ea347 100644
--- a/src/testdir/test_let.vim
+++ b/src/testdir/test_let.vim
@@ -722,31 +722,33 @@ END
LINES
call v9.CheckScriptFailure(lines, 'E15:')
- " Test for using heredoc in a single string using execute()
- call assert_equal("\n['one', 'two']",
- \ execute("let x =<< trim END\n one\n two\nEND\necho x"))
- call assert_equal("\n['one', ' two']",
- \ execute("let x =<< trim END\n one\n two\nEND\necho x"))
- call assert_equal("\n['one', 'two']",
- \ execute(" let x =<< trim END\n one\n two\n END\necho x"))
- call assert_equal("\n['one', ' two']",
- \ execute(" let x =<< trim END\n one\n two\n END\necho x"))
- call assert_equal("\n[' one', ' two']",
- \ execute("let x =<< END\n one\n two\nEND\necho x"))
- call assert_equal("\n['one', 'two']",
- \ execute("let x =<< END\none\ntwo\nEND\necho x"))
- call assert_equal("\n['one', 'two']",
- \ execute("let x =<< END \" comment\none\ntwo\nEND\necho x"))
- let cmd = 'execute("let x =<< END\n one\n two\necho x")'
- call assert_fails(cmd, "E990: Missing end marker 'END'")
- let cmd = 'execute("let x =<<\n one\n two\necho x")'
- call assert_fails(cmd, "E172: Missing marker")
- let cmd = 'execute("let x =<< trim\n one\n two\necho x")'
- call assert_fails(cmd, "E172: Missing marker")
- let cmd = 'execute("let x =<< end\n one\n two\nend\necho x")'
- call assert_fails(cmd, "E221: Marker cannot start with lower case letter")
- let cmd = 'execute("let x =<< eval END\n one\n two{y}\nEND\necho x")'
- call assert_fails(cmd, 'E121: Undefined variable: y')
+ " Test for using heredoc in a single string using :execute or execute()
+ for [cmd, res] in items({
+ \ "let x =<< trim END\n one\n two\nEND": ['one', 'two'],
+ \ "let x =<< trim END\n one\n two\nEND": ['one', ' two'],
+ \ " let x =<< trim END\n one\n two\n END": ['one', 'two'],
+ \ " let x =<< trim END\n one\n two\n END": ['one', ' two'],
+ \ "let x =<< END\n one\n two\nEND": [' one', ' two'],
+ \ "let x =<< END\none\ntwo\nEND": ['one', 'two'],
+ \ "let x =<< END \" comment\none\ntwo\nEND": ['one', 'two'],
+ \ })
+ execute cmd
+ call assert_equal(res, x)
+ unlet x
+ call assert_equal($"\n{string(res)}", execute($"{cmd}\necho x"))
+ unlet x
+ endfor
+ for [cmd, err] in items({
+ \ "let x =<<\none\ntwo": "E172:",
+ \ "let x =<< trim\n one\n two": "E172:",
+ \ "let x =<< end\none\ntwo\nend": "E221:",
+ \ "let x =<< END\none\ntwo": "E990: Missing end marker 'END'",
+ \ "let x =<< END !\none\ntwo\nEND": "E488: Trailing characters: !",
+ \ "let x =<< eval END\none\ntwo{y}\nEND": "E121: Undefined variable: y",
+ \ })
+ call assert_fails('execute cmd', err)
+ call assert_fails('call execute(cmd)', err)
+ endfor
" skipped heredoc
if 0
diff --git a/src/version.c b/src/version.c
index b6c4e96c19..35ab83f2e9 100644
--- a/src/version.c
+++ b/src/version.c
@@ -705,6 +705,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 319,
+/**/
318,
/**/
317,