diff options
author | zeertzjq <zeertzjq@outlook.com> | 2023-04-16 11:37:41 +0800 |
---|---|---|
committer | zeertzjq <zeertzjq@outlook.com> | 2023-04-16 15:04:41 +0800 |
commit | 7b05ddbb72717f995fedc81583d73f82c78c881d (patch) | |
tree | 0e09fc8651f9fabd194751f2b9fcd56c3c1118d8 /test | |
parent | 335bef0c211dc962499814d248670ff17758a642 (diff) | |
download | rneovim-7b05ddbb72717f995fedc81583d73f82c78c881d.tar.gz rneovim-7b05ddbb72717f995fedc81583d73f82c78c881d.tar.bz2 rneovim-7b05ddbb72717f995fedc81583d73f82c78c881d.zip |
vim-patch:9.0.0397: :defer not tested with exceptions and ":qa!"
Problem: :defer not tested with exceptions and ":qa!".
Solution: Test :defer works when exceptions are thrown and when ":qa!" is
used. Invoke the deferred calls on exit.
https://github.com/vim/vim/commit/58779858fb5a82a3233af5d4237a3cece88c10d4
Co-authored-by: Bram Moolenaar <Bram@vim.org>
Diffstat (limited to 'test')
-rw-r--r-- | test/old/testdir/test_user_func.vim | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/test/old/testdir/test_user_func.vim b/test/old/testdir/test_user_func.vim index fd70d1acb0..4bb4078a1c 100644 --- a/test/old/testdir/test_user_func.vim +++ b/test/old/testdir/test_user_func.vim @@ -584,5 +584,54 @@ func Test_defer() call assert_fails('defer Part("arg2")', 'E1300:') endfunc +func DeferLevelTwo() + call writefile(['text'], 'XDeleteTwo', 'D') + throw 'someerror' +endfunc + +" def DeferLevelOne() +func DeferLevelOne() + call writefile(['text'], 'XDeleteOne', 'D') + call g:DeferLevelTwo() +" enddef +endfunc + +func Test_defer_throw() + let caught = 'no' + try + call DeferLevelOne() + catch /someerror/ + let caught = 'yes' + endtry + call assert_equal('yes', caught) + call assert_false(filereadable('XDeleteOne')) + call assert_false(filereadable('XDeleteTwo')) +endfunc + +func Test_defer_quitall() + let lines =<< trim END + " vim9script + func DeferLevelTwo() + call writefile(['text'], 'XQuitallTwo', 'D') + qa! + endfunc + + " def DeferLevelOne() + func DeferLevelOne() + call writefile(['text'], 'XQuitallOne', 'D') + call DeferLevelTwo() + " enddef + endfunc + + " DeferLevelOne() + call DeferLevelOne() + END + call writefile(lines, 'XdeferQuitall', 'D') + let res = system(GetVimCommandClean() .. ' -X -S XdeferQuitall') + call assert_equal(0, v:shell_error) + call assert_false(filereadable('XQuitallOne')) + call assert_false(filereadable('XQuitallTwo')) +endfunc + " vim: shiftwidth=2 sts=2 expandtab |