comparison src/testdir/test_autocmd.vim @ 16617:24233eeaadd0 v8.1.1311

patch 8.1.1311: aborting an autocmd with an exception is not tested commit https://github.com/vim/vim/commit/23b5139234a79567097ca73aba15ea134381b934 Author: Bram Moolenaar <Bram@vim.org> Date: Thu May 9 21:38:43 2019 +0200 patch 8.1.1311: aborting an autocmd with an exception is not tested Problem: Aborting an autocmd with an exception is not tested. Solution: Add a test. Also shows how to abort a command by throwing an exception.
author Bram Moolenaar <Bram@vim.org>
date Thu, 09 May 2019 21:45:05 +0200
parents 3b2db762a509
children ea0f9a2df961
comparison
equal deleted inserted replaced
16616:7fb7aeecdf75 16617:24233eeaadd0
1731 au! FileChangedShell 1731 au! FileChangedShell
1732 call delete('Xtestfile.gz') 1732 call delete('Xtestfile.gz')
1733 call delete('Xtest.c') 1733 call delete('Xtest.c')
1734 call delete('test.out') 1734 call delete('test.out')
1735 endfunc 1735 endfunc
1736
1737 func Test_throw_in_BufWritePre()
1738 new
1739 call setline(1, ['one', 'two', 'three'])
1740 call assert_false(filereadable('Xthefile'))
1741 augroup throwing
1742 au BufWritePre X* throw 'do not write'
1743 augroup END
1744 try
1745 w Xthefile
1746 catch
1747 let caught = 1
1748 endtry
1749 call assert_equal(1, caught)
1750 call assert_false(filereadable('Xthefile'))
1751
1752 bwipe!
1753 au! throwing
1754 endfunc