aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2023-05-06 08:17:14 +0800
committerGitHub <noreply@github.com>2023-05-06 08:17:14 +0800
commitb97d2abb216477dddfca9ce74077d157045f22cf (patch)
treee87e2da65fd5ea42a537d806c26dd7b15333b40d /test
parent22205f36a6213f51f211a67444b335f916a2fa9f (diff)
parent6b912dec8ef06535b164b0f4eb3d55775eb9f6a8 (diff)
downloadrneovim-b97d2abb216477dddfca9ce74077d157045f22cf.tar.gz
rneovim-b97d2abb216477dddfca9ce74077d157045f22cf.tar.bz2
rneovim-b97d2abb216477dddfca9ce74077d157045f22cf.zip
Merge pull request #23488 from zeertzjq/vim-8.2.2094
vim-patch:8.2.{2094,2141},9.0.1508
Diffstat (limited to 'test')
-rw-r--r--test/old/testdir/test_trycatch.vim55
1 files changed, 55 insertions, 0 deletions
diff --git a/test/old/testdir/test_trycatch.vim b/test/old/testdir/test_trycatch.vim
index ef20e03126..52a687ab4f 100644
--- a/test/old/testdir/test_trycatch.vim
+++ b/test/old/testdir/test_trycatch.vim
@@ -2220,6 +2220,61 @@ func Test_BufEnter_exception()
%bwipe!
endfunc
+" Test for using try/catch when lines are joined by "|" or "\n" {{{1
+func Test_try_catch_nextcmd()
+ func Throw()
+ throw "Failure"
+ endfunc
+
+ let lines =<< trim END
+ try
+ let s:x = Throw()
+ catch
+ let g:caught = 1
+ endtry
+ END
+
+ let g:caught = 0
+ call execute(lines)
+ call assert_equal(1, g:caught)
+
+ let g:caught = 0
+ call execute(join(lines, '|'))
+ call assert_equal(1, g:caught)
+
+ let g:caught = 0
+ call execute(join(lines, "\n"))
+ call assert_equal(1, g:caught)
+
+ unlet g:caught
+ delfunc Throw
+endfunc
+
+" Test for using try/catch in a user command with a failing expression {{{1
+func Test_user_command_try_catch()
+ let lines =<< trim END
+ function s:throw() abort
+ throw 'error'
+ endfunction
+
+ command! Execute
+ \ try
+ \ | let s:x = s:throw()
+ \ | catch
+ \ | let g:caught = 'caught'
+ \ | endtry
+
+ let g:caught = 'no'
+ Execute
+ call assert_equal('caught', g:caught)
+ END
+ call writefile(lines, 'XtestTryCatch')
+ source XtestTryCatch
+
+ call delete('XtestTryCatch')
+ unlet g:caught
+endfunc
+
" Test for using throw in a called function with following error {{{1
func Test_user_command_throw_in_function_call()
let lines =<< trim END