Mercurial > vim
comparison src/testdir/test_trycatch.vim @ 25826:5040fae521f6 v8.2.3448
patch 8.2.3448: :endtry after function call that throws not found
Commit: https://github.com/vim/vim/commit/1d34189ecb99fa76363c06e1aa815c1075675a1c
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Sep 18 15:25:52 2021 +0200
patch 8.2.3448: :endtry after function call that throws not found
Problem: :endtry after function call that throws not found.
Solution: Do check for following :endtry if an exception is being thrown.
(closes #8889)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 18 Sep 2021 15:30:04 +0200 |
parents | e855eba4ac39 |
children | a58520ab7c3b |
comparison
equal
deleted
inserted
replaced
25825:9b12bc041450 | 25826:5040fae521f6 |
---|---|
2234 try | 2234 try |
2235 call s:get_dict().foo() | 2235 call s:get_dict().foo() |
2236 catch /my_error/ | 2236 catch /my_error/ |
2237 let caught = 'yes' | 2237 let caught = 'yes' |
2238 catch | 2238 catch |
2239 let caught = 'no' | 2239 let caught = v:exception |
2240 endtry | 2240 endtry |
2241 call assert_equal('yes', caught) | 2241 call assert_equal('yes', caught) |
2242 END | 2242 END |
2243 call writefile(lines, 'XtestThrow') | 2243 call writefile(lines, 'XtestThrow') |
2244 source XtestThrow | 2244 source XtestThrow |
2245 | 2245 |
2246 call delete('XtestThrow') | 2246 call delete('XtestThrow') |
2247 unlet g:caught | 2247 unlet g:caught |
2248 endfunc | 2248 endfunc |
2249 | 2249 |
2250 " Test for using throw in a called function with following endtry {{{1 | |
2251 func Test_user_command_function_call_with_endtry() | |
2252 let lines =<< trim END | |
2253 funct s:throw(msg) abort | |
2254 throw a:msg | |
2255 endfunc | |
2256 func s:main() abort | |
2257 try | |
2258 try | |
2259 throw 'err1' | |
2260 catch | |
2261 call s:throw('err2') | endtry | |
2262 catch | |
2263 let s:caught = 'yes' | |
2264 endtry | |
2265 endfunc | |
2266 | |
2267 call s:main() | |
2268 call assert_equal('yes', s:caught) | |
2269 END | |
2270 call writefile(lines, 'XtestThrow') | |
2271 source XtestThrow | |
2272 | |
2273 call delete('XtestThrow') | |
2274 endfunc | |
2275 | |
2250 | 2276 |
2251 " Modeline {{{1 | 2277 " Modeline {{{1 |
2252 " vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker | 2278 " vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker |