xref: /vim-8.2.3635/src/testdir/test_exit.vim (revision 577fadfc)
1" Tests for exiting Vim.
2
3source shared.vim
4
5func Test_exiting()
6  let after = [
7	\ 'au QuitPre * call writefile(["QuitPre"], "Xtestout")',
8	\ 'au ExitPre * call writefile(["ExitPre"], "Xtestout", "a")',
9	\ 'quit',
10	\ ]
11  if RunVim([], after, '')
12    call assert_equal(['QuitPre', 'ExitPre'], readfile('Xtestout'))
13  endif
14  call delete('Xtestout')
15
16  let after = [
17	\ 'au QuitPre * call writefile(["QuitPre"], "Xtestout")',
18	\ 'au ExitPre * call writefile(["ExitPre"], "Xtestout", "a")',
19	\ 'help',
20	\ 'wincmd w',
21	\ 'quit',
22	\ ]
23  if RunVim([], after, '')
24    call assert_equal(['QuitPre', 'ExitPre'], readfile('Xtestout'))
25  endif
26  call delete('Xtestout')
27
28  let after = [
29	\ 'au QuitPre * call writefile(["QuitPre"], "Xtestout")',
30	\ 'au ExitPre * call writefile(["ExitPre"], "Xtestout", "a")',
31	\ 'split',
32	\ 'new',
33	\ 'qall',
34	\ ]
35  if RunVim([], after, '')
36    call assert_equal(['QuitPre', 'ExitPre'], readfile('Xtestout'))
37  endif
38  call delete('Xtestout')
39
40  let after = [
41	\ 'au QuitPre * call writefile(["QuitPre"], "Xtestout", "a")',
42	\ 'au ExitPre * call writefile(["ExitPre"], "Xtestout", "a")',
43	\ 'augroup nasty',
44	\ '  au ExitPre * split',
45	\ 'augroup END',
46	\ 'quit',
47	\ 'augroup nasty',
48	\ '  au! ExitPre',
49	\ 'augroup END',
50	\ 'quit',
51	\ ]
52  if RunVim([], after, '')
53    call assert_equal(['QuitPre', 'ExitPre', 'QuitPre', 'ExitPre'],
54	  \ readfile('Xtestout'))
55  endif
56  call delete('Xtestout')
57endfunc
58