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() |
Bram Moolenaar | c79745a | 2019-05-20 22:12:34 +0200 | [diff] [blame] | 6 | let after =<< trim [CODE] |
| 7 | au QuitPre * call writefile(["QuitPre"], "Xtestout") |
| 8 | au ExitPre * call writefile(["ExitPre"], "Xtestout", "a") |
| 9 | quit |
| 10 | [CODE] |
| 11 | |
Bram Moolenaar | 12a96de | 2018-03-11 14:44:18 +0100 | [diff] [blame] | 12 | if RunVim([], after, '') |
| 13 | call assert_equal(['QuitPre', 'ExitPre'], readfile('Xtestout')) |
| 14 | endif |
| 15 | call delete('Xtestout') |
| 16 | |
Bram Moolenaar | c79745a | 2019-05-20 22:12:34 +0200 | [diff] [blame] | 17 | let after =<< trim [CODE] |
| 18 | au QuitPre * call writefile(["QuitPre"], "Xtestout") |
| 19 | au ExitPre * call writefile(["ExitPre"], "Xtestout", "a") |
| 20 | help |
| 21 | wincmd w |
| 22 | quit |
| 23 | [CODE] |
| 24 | |
Bram Moolenaar | 12a96de | 2018-03-11 14:44:18 +0100 | [diff] [blame] | 25 | if RunVim([], after, '') |
| 26 | call assert_equal(['QuitPre', 'ExitPre'], readfile('Xtestout')) |
| 27 | endif |
| 28 | call delete('Xtestout') |
| 29 | |
Bram Moolenaar | c79745a | 2019-05-20 22:12:34 +0200 | [diff] [blame] | 30 | let after =<< trim [CODE] |
| 31 | au QuitPre * call writefile(["QuitPre"], "Xtestout") |
| 32 | au ExitPre * call writefile(["ExitPre"], "Xtestout", "a") |
| 33 | split |
| 34 | new |
| 35 | qall |
| 36 | [CODE] |
| 37 | |
Bram Moolenaar | 12a96de | 2018-03-11 14:44:18 +0100 | [diff] [blame] | 38 | if RunVim([], after, '') |
| 39 | call assert_equal(['QuitPre', 'ExitPre'], readfile('Xtestout')) |
| 40 | endif |
| 41 | call delete('Xtestout') |
| 42 | |
Bram Moolenaar | c79745a | 2019-05-20 22:12:34 +0200 | [diff] [blame] | 43 | let after =<< trim [CODE] |
| 44 | au QuitPre * call writefile(["QuitPre"], "Xtestout", "a") |
| 45 | au ExitPre * call writefile(["ExitPre"], "Xtestout", "a") |
| 46 | augroup nasty |
| 47 | au ExitPre * split |
| 48 | augroup END |
| 49 | quit |
| 50 | augroup nasty |
| 51 | au! ExitPre |
| 52 | augroup END |
| 53 | quit |
| 54 | [CODE] |
| 55 | |
Bram Moolenaar | 12a96de | 2018-03-11 14:44:18 +0100 | [diff] [blame] | 56 | if RunVim([], after, '') |
| 57 | call assert_equal(['QuitPre', 'ExitPre', 'QuitPre', 'ExitPre'], |
| 58 | \ readfile('Xtestout')) |
| 59 | endif |
| 60 | call delete('Xtestout') |
| 61 | endfunc |