Bram Moolenaar | 12a96de | 2018-03-11 14:44:18 +0100 | [diff] [blame] | 1 | " Tests for exiting Vim. |
| 2 | |
| 3 | source shared.vim |
| 4 | |
| 5 | func 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') |
| 57 | endfunc |