1" Tests for exiting Vim. 2 3source shared.vim 4 5func Test_exiting() 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 12 if RunVim([], after, '') 13 call assert_equal(['QuitPre', 'ExitPre'], readfile('Xtestout')) 14 endif 15 call delete('Xtestout') 16 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 25 if RunVim([], after, '') 26 call assert_equal(['QuitPre', 'ExitPre'], readfile('Xtestout')) 27 endif 28 call delete('Xtestout') 29 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 38 if RunVim([], after, '') 39 call assert_equal(['QuitPre', 'ExitPre'], readfile('Xtestout')) 40 endif 41 call delete('Xtestout') 42 43 " ExitPre autocommand splits the window, so that it's no longer the last one. 44 let after =<< trim [CODE] 45 au QuitPre * call writefile(["QuitPre"], "Xtestout", "a") 46 au ExitPre * call writefile(["ExitPre"], "Xtestout", "a") 47 augroup nasty 48 au ExitPre * split 49 augroup END 50 quit 51 augroup nasty 52 au! ExitPre 53 augroup END 54 quit 55 [CODE] 56 57 if RunVim([], after, '') 58 call assert_equal(['QuitPre', 'ExitPre', 'QuitPre', 'ExitPre'], 59 \ readfile('Xtestout')) 60 endif 61 call delete('Xtestout') 62 63 " ExitPre autocommand splits and closes the window, so that there is still 64 " one window but it's a different one. 65 let after =<< trim [CODE] 66 au QuitPre * call writefile(["QuitPre"], "Xtestout", "a") 67 au ExitPre * call writefile(["ExitPre"], "Xtestout", "a") 68 augroup nasty 69 au ExitPre * split | only 70 augroup END 71 quit 72 augroup nasty 73 au! ExitPre 74 augroup END 75 quit 76 [CODE] 77 78 if RunVim([], after, '') 79 call assert_equal(['QuitPre', 'ExitPre', 'QuitPre', 'ExitPre'], 80 \ readfile('Xtestout')) 81 endif 82 call delete('Xtestout') 83endfunc 84 85" vim: shiftwidth=2 sts=2 expandtab 86