diff src/testdir/test_exit.vim @ 13442:94e638936d3e v8.0.1595

patch 8.0.1595: no autocommand triggered before exiting commit https://github.com/vim/vim/commit/12a96de430779b88795fac87a2be666d9f661d1e Author: Bram Moolenaar <Bram@vim.org> Date: Sun Mar 11 14:44:18 2018 +0100 patch 8.0.1595: no autocommand triggered before exiting Problem: No autocommand triggered before exiting. Solution: Add the ExitPre autocommand event.
author Christian Brabandt <cb@256bit.org>
date Sun, 11 Mar 2018 14:45:05 +0100
parents
children 9c90cf08cfa8
line wrap: on
line diff
new file mode 100644
--- /dev/null
+++ b/src/testdir/test_exit.vim
@@ -0,0 +1,57 @@
+" Tests for exiting Vim.
+
+source shared.vim
+
+func Test_exiting()
+  let after = [
+	\ 'au QuitPre * call writefile(["QuitPre"], "Xtestout")',
+	\ 'au ExitPre * call writefile(["ExitPre"], "Xtestout", "a")',
+	\ 'quit',
+	\ ]
+  if RunVim([], after, '')
+    call assert_equal(['QuitPre', 'ExitPre'], readfile('Xtestout'))
+  endif
+  call delete('Xtestout')
+
+  let after = [
+	\ 'au QuitPre * call writefile(["QuitPre"], "Xtestout")',
+	\ 'au ExitPre * call writefile(["ExitPre"], "Xtestout", "a")',
+	\ 'help',
+	\ 'wincmd w',
+	\ 'quit',
+	\ ]
+  if RunVim([], after, '')
+    call assert_equal(['QuitPre', 'ExitPre'], readfile('Xtestout'))
+  endif
+  call delete('Xtestout')
+
+  let after = [
+	\ 'au QuitPre * call writefile(["QuitPre"], "Xtestout")',
+	\ 'au ExitPre * call writefile(["ExitPre"], "Xtestout", "a")',
+	\ 'split',
+	\ 'new',
+	\ 'qall',
+	\ ]
+  if RunVim([], after, '')
+    call assert_equal(['QuitPre', 'ExitPre'], readfile('Xtestout'))
+  endif
+  call delete('Xtestout')
+
+  let after = [
+	\ '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',
+	\ ]
+  if RunVim([], after, '')
+    call assert_equal(['QuitPre', 'ExitPre', 'QuitPre', 'ExitPre'],
+	  \ readfile('Xtestout'))
+  endif
+  call delete('Xtestout')
+endfunc