patch 9.1.0319: Using heredoc in string not tested with :execute

Commit: 
https://github.com/vim/vim/commit/3d93630605df60e8de5a38918eaff62165b42382
Author: zeertzjq <zeert...@outlook.com>
Date:   Sun Apr 14 18:49:56 2024 +0200

    patch 9.1.0319: Using heredoc in string not tested with :execute
    
    Problem:  Using heredoc in string not tested with :execute.
    Solution: Test with both :execute and execute() (zeertzjq).
    
    closes: #14546
    
    Signed-off-by: zeertzjq <zeert...@outlook.com>
    Signed-off-by: Christian Brabandt <c...@256bit.org>

diff --git a/src/testdir/test_let.vim b/src/testdir/test_let.vim
index 974e8f1a3..17f78ea34 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("
['one', 'two']",
-    \ execute("let x =<< trim END
  one
  two
END
echo x"))
-  call assert_equal("
['one', '  two']",
-    \ execute("let x =<< trim END
  one
    two
END
echo x"))
-  call assert_equal("
['one', 'two']",
-    \ execute("  let x =<< trim END
    one
    two
  END
echo x"))
-  call assert_equal("
['one', '  two']",
-    \ execute("  let x =<< trim END
    one
      two
  END
echo x"))
-  call assert_equal("
['  one', '  two']",
-    \ execute("let x =<< END
  one
  two
END
echo x"))
-  call assert_equal("
['one', 'two']",
-    \ execute("let x =<< END
one
two
END
echo x"))
-  call assert_equal("
['one', 'two']",
-    \ execute("let x =<< END \" comment
one
two
END
echo x"))
-  let cmd = 'execute("let x =<< END
  one
  two
echo x")'
-  call assert_fails(cmd, "E990: Missing end marker 'END'")
-  let cmd = 'execute("let x =<<
  one
  two
echo x")'
-  call assert_fails(cmd, "E172: Missing marker")
-  let cmd = 'execute("let x =<< trim
  one
  two
echo x")'
-  call assert_fails(cmd, "E172: Missing marker")
-  let cmd = 'execute("let x =<< end
  one
  two
end
echo x")'
-  call assert_fails(cmd, "E221: Marker cannot start with lower case letter")
-  let cmd = 'execute("let x =<< eval END
  one
  two{y}
END
echo 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
  one
  two
END": ['one', 'two'],
+      \ "let x =<< trim END
  one
    two
END": ['one', '  two'],
+      \ "  let x =<< trim END
    one
    two
  END": ['one', 'two'],
+      \ "  let x =<< trim END
    one
      two
  END": ['one', '  two'],
+      \ "let x =<< END
  one
  two
END": ['  one', '  two'],
+      \ "let x =<< END
one
two
END": ['one', 'two'],
+      \ "let x =<< END \" comment
one
two
END": ['one', 'two'],
+      \ })
+    execute cmd
+    call assert_equal(res, x)
+    unlet x
+    call assert_equal($"
{string(res)}", execute($"{cmd}
echo x"))
+    unlet x
+  endfor
+  for [cmd, err] in items({
+      \ "let x =<<
one
two": "E172:",
+      \ "let x =<< trim
  one
  two": "E172:",
+      \ "let x =<< end
one
two
end": "E221:",
+      \ "let x =<< END
one
two": "E990: Missing end marker 'END'",
+      \ "let x =<< END !
one
two
END": "E488: Trailing characters:  !",
+      \ "let x =<< eval END
one
two{y}
END": "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 b6c4e96c1..35ab83f2e 100644
--- a/src/version.c
+++ b/src/version.c
@@ -704,6 +704,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    319,
 /**/
     318,
 /**/

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/E1rw3DA-00AJt9-LX%40256bit.org.

Raspunde prin e-mail lui