comparison src/testdir/test_trycatch.vim @ 19471:cb73f4ae6b7c v8.2.0293

patch 8.2.0293: various Ex commands not sufficiently tested Commit: https://github.com/vim/vim/commit/818fc9ad143911b2faa0d7cee86724aa70a02080 Author: Bram Moolenaar <Bram@vim.org> Date: Fri Feb 21 17:54:45 2020 +0100 patch 8.2.0293: various Ex commands not sufficiently tested Problem: Various Ex commands not sufficiently tested. Solution: Add more test cases. (Yegappan Lakshmanan, closes https://github.com/vim/vim/issues/5673)
author Bram Moolenaar <Bram@vim.org>
date Fri, 21 Feb 2020 18:00:05 +0100
parents 050f5eaa9e50
children 0aba9ef12488
comparison
equal deleted inserted replaced
19470:ddc2e7caff46 19471:cb73f4ae6b7c
1994 set noautoread 1994 set noautoread
1995 bwipe! Xreload 1995 bwipe! Xreload
1996 call delete('Xreload') 1996 call delete('Xreload')
1997 endfunc 1997 endfunc
1998 1998
1999 " Test for errors with :catch, :throw, :finally {{{1
2000 func Test_try_catch_errors()
2001 call assert_fails('throw |', 'E471:')
2002 call assert_fails("throw \n ", 'E471:')
2003 call assert_fails('catch abc', 'E603:')
2004 call assert_fails('try | let i = 1| finally | catch | endtry', 'E604:')
2005 call assert_fails('finally', 'E606:')
2006 call assert_fails('try | finally | finally | endtry', 'E607:')
2007 call assert_fails('try | for i in range(5) | endif | endtry', 'E580:')
2008 call assert_fails('try | while v:true | endtry', 'E170:')
2009 call assert_fails('try | if v:true | endtry', 'E171:')
2010 endfunc
2011
2012 " Test for verbose messages with :try :catch, and :finally {{{1
2013 func Test_try_catch_verbose()
2014 " This test works only when the language is English
2015 if v:lang != "C" && v:lang !~ '^[Ee]n'
2016 return
2017 endif
2018
2019 set verbose=14
2020 redir => msg
2021 try
2022 echo i
2023 catch /E121:/
2024 finally
2025 endtry
2026 redir END
2027 let expected = [
2028 \ 'Exception thrown: Vim(echo):E121: Undefined variable: i',
2029 \ '',
2030 \ 'Exception caught: Vim(echo):E121: Undefined variable: i',
2031 \ '',
2032 \ 'Exception finished: Vim(echo):E121: Undefined variable: i'
2033 \ ]
2034 call assert_equal(expected, split(msg, "\n"))
2035 set verbose&
2036 endfunc
2037
1999 " Modeline {{{1 2038 " Modeline {{{1
2000 " vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker 2039 " vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker