2018-03-11 14:44:18 +01:00
|
|
|
" Tests for exiting Vim.
|
|
|
|
|
|
|
|
|
|
source shared.vim
|
|
|
|
|
|
|
|
|
|
func Test_exiting()
|
2019-05-20 22:12:34 +02:00
|
|
|
let after =<< trim [CODE]
|
|
|
|
|
au QuitPre * call writefile(["QuitPre"], "Xtestout")
|
|
|
|
|
au ExitPre * call writefile(["ExitPre"], "Xtestout", "a")
|
|
|
|
|
quit
|
|
|
|
|
[CODE]
|
|
|
|
|
|
2018-03-11 14:44:18 +01:00
|
|
|
if RunVim([], after, '')
|
|
|
|
|
call assert_equal(['QuitPre', 'ExitPre'], readfile('Xtestout'))
|
|
|
|
|
endif
|
|
|
|
|
call delete('Xtestout')
|
|
|
|
|
|
2019-05-20 22:12:34 +02:00
|
|
|
let after =<< trim [CODE]
|
|
|
|
|
au QuitPre * call writefile(["QuitPre"], "Xtestout")
|
|
|
|
|
au ExitPre * call writefile(["ExitPre"], "Xtestout", "a")
|
|
|
|
|
help
|
|
|
|
|
wincmd w
|
|
|
|
|
quit
|
|
|
|
|
[CODE]
|
|
|
|
|
|
2018-03-11 14:44:18 +01:00
|
|
|
if RunVim([], after, '')
|
|
|
|
|
call assert_equal(['QuitPre', 'ExitPre'], readfile('Xtestout'))
|
|
|
|
|
endif
|
|
|
|
|
call delete('Xtestout')
|
|
|
|
|
|
2019-05-20 22:12:34 +02:00
|
|
|
let after =<< trim [CODE]
|
|
|
|
|
au QuitPre * call writefile(["QuitPre"], "Xtestout")
|
|
|
|
|
au ExitPre * call writefile(["ExitPre"], "Xtestout", "a")
|
|
|
|
|
split
|
|
|
|
|
new
|
|
|
|
|
qall
|
|
|
|
|
[CODE]
|
|
|
|
|
|
2018-03-11 14:44:18 +01:00
|
|
|
if RunVim([], after, '')
|
|
|
|
|
call assert_equal(['QuitPre', 'ExitPre'], readfile('Xtestout'))
|
|
|
|
|
endif
|
|
|
|
|
call delete('Xtestout')
|
|
|
|
|
|
2019-10-20 22:27:10 +02:00
|
|
|
" ExitPre autocommand splits the window, so that it's no longer the last one.
|
2019-05-20 22:12:34 +02:00
|
|
|
let after =<< trim [CODE]
|
|
|
|
|
au QuitPre * call writefile(["QuitPre"], "Xtestout", "a")
|
|
|
|
|
au ExitPre * call writefile(["ExitPre"], "Xtestout", "a")
|
|
|
|
|
augroup nasty
|
|
|
|
|
au ExitPre * split
|
|
|
|
|
augroup END
|
|
|
|
|
quit
|
|
|
|
|
augroup nasty
|
|
|
|
|
au! ExitPre
|
|
|
|
|
augroup END
|
|
|
|
|
quit
|
|
|
|
|
[CODE]
|
|
|
|
|
|
2018-03-11 14:44:18 +01:00
|
|
|
if RunVim([], after, '')
|
|
|
|
|
call assert_equal(['QuitPre', 'ExitPre', 'QuitPre', 'ExitPre'],
|
|
|
|
|
\ readfile('Xtestout'))
|
|
|
|
|
endif
|
|
|
|
|
call delete('Xtestout')
|
2019-10-20 22:27:10 +02:00
|
|
|
|
|
|
|
|
" ExitPre autocommand splits and closes the window, so that there is still
|
|
|
|
|
" one window but it's a different one.
|
|
|
|
|
let after =<< trim [CODE]
|
|
|
|
|
au QuitPre * call writefile(["QuitPre"], "Xtestout", "a")
|
|
|
|
|
au ExitPre * call writefile(["ExitPre"], "Xtestout", "a")
|
|
|
|
|
augroup nasty
|
|
|
|
|
au ExitPre * split | only
|
|
|
|
|
augroup END
|
|
|
|
|
quit
|
|
|
|
|
augroup nasty
|
|
|
|
|
au! ExitPre
|
|
|
|
|
augroup END
|
|
|
|
|
quit
|
|
|
|
|
[CODE]
|
|
|
|
|
|
|
|
|
|
if RunVim([], after, '')
|
|
|
|
|
call assert_equal(['QuitPre', 'ExitPre', 'QuitPre', 'ExitPre'],
|
|
|
|
|
\ readfile('Xtestout'))
|
|
|
|
|
endif
|
|
|
|
|
call delete('Xtestout')
|
2018-03-11 14:44:18 +01:00
|
|
|
endfunc
|