]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.1.1695: Need more Vim script specific tests v9.1.1695
authorYegappan Lakshmanan <yegappan@yahoo.com>
Tue, 26 Aug 2025 19:32:46 +0000 (21:32 +0200)
committerChristian Brabandt <cb@256bit.org>
Tue, 26 Aug 2025 19:32:46 +0000 (21:32 +0200)
Problem:  Need more Vim script specific tests
Solution: Add more tests (Yegappan Lakshmanan).

closes: #18118

Signed-off-by: Yegappan Lakshmanan <yegappan@yahoo.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
src/testdir/test_vim9_script.vim
src/testdir/test_vimscript.vim
src/version.c

index f5e23e8eb7e7d370dd7367576f754a27673b9d9c..8726ee4836d38846c3b540342f29a8ef2753c27b 100644 (file)
@@ -613,6 +613,13 @@ def Test_block_in_a_string()
   v9.CheckSourceSuccess(lines)
 enddef
 
+" Test for using too many nested blocks
+def Test_too_many_nested_blocks()
+  var lines = ['vim9script']
+  lines += repeat(['{'], 51) + ['echo "Hello"'] + repeat(['}'], 51)
+  v9.CheckSourceFailure(lines, 'E579: Block nesting too deep: {')
+enddef
+
 func g:NoSuchFunc()
   echo 'none'
 endfunc
index e1b0425ee7105f887f7b1763e76efee4a85adf75..bf5a875f168980deb56e4d171f938d96a66de189 100644 (file)
@@ -7591,6 +7591,7 @@ func Test_deeply_nested_source()
   call system(cmd)
 endfunc
 
+" Test for impact of silent! on an exception  {{{1
 func Test_exception_silent()
   XpathINIT
   let lines =<< trim END
@@ -7616,6 +7617,70 @@ func Test_exception_silent()
   call RunInNewVim(lines, verify)
 endfunc
 
+" Test for an error message starting with "Vim E123: " {{{1
+func Test_skip_prefix_in_exception()
+  let emsg = ''
+  try
+    echoerr "Vim E123:"
+  catch
+    let emsg = v:exception
+  endtry
+  call assert_equal('Vim(echoerr):Vim E123:', emsg)
+
+  let emsg = ''
+  try
+    echoerr "Vim E123: abc"
+  catch
+    let emsg = v:exception
+  endtry
+  call assert_equal('Vim(echoerr):E123: abc', emsg)
+endfunc
+
+" Test for try/except messages displayed with 'verbose' level set to 13 {{{1
+func Test_verbose_try_except_messages()
+  let msgs = ''
+  redir => msgs
+  set verbose=13
+  try
+    echoerr 'foo'
+  catch
+    echo v:exception
+  endtry
+  set verbose=0
+  redir END
+  let expected =<< trim END
+    Exception thrown: Vim(echoerr):foo
+
+    Exception caught: Vim(echoerr):foo
+
+    Vim(echoerr):foo
+    Exception finished: Vim(echoerr):foo
+  END
+  call assert_equal(expected, msgs->split("\n"))
+endfunc
+
+" Test for trailing characters after a catch pattern {{{1
+func Test_catch_pattern_trailing_chars()
+  let lines =<< trim END
+    try
+      echoerr 'foo'
+    catch /foo/xxx
+      echo 'caught foo'
+    endtry
+  END
+
+  new
+  call setline(1, lines)
+  let caught_exception = v:false
+  try
+    source
+  catch /E488: Trailing characters: \/xxx/
+    let caught_exception = v:true
+  endtry
+  call assert_true(caught_exception)
+  bw!
+endfunc
+
 "-------------------------------------------------------------------------------
 " Modelines                                                                {{{1
 " vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker
index a28eef78fab75dea1f5e6a7ea198913f2b381b3e..0a90f015c2c675e745cd4e6e282994a5dfec542a 100644 (file)
@@ -724,6 +724,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1695,
 /**/
     1694,
 /**/