vim-patch:8.1.1311: test: abort autocmd with exception #10692

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.
23b5139234
This commit is contained in:
Jan Edmund Lazo 2019-08-04 19:54:17 -04:00 committed by Justin M. Keyes
parent a724209b5a
commit 01ddb39699

View File

@ -1673,6 +1673,25 @@ func Test_ReadWrite_Autocmds()
call delete('test.out')
endfunc
func Test_throw_in_BufWritePre()
new
call setline(1, ['one', 'two', 'three'])
call assert_false(filereadable('Xthefile'))
augroup throwing
au BufWritePre X* throw 'do not write'
augroup END
try
w Xthefile
catch
let caught = 1
endtry
call assert_equal(1, caught)
call assert_false(filereadable('Xthefile'))
bwipe!
au! throwing
endfunc
func Test_FileChangedShell_reload()
if !has('unix')
return