patch 8.2.2070: can't get the exit value in VimLeave(Pre) autocommands

Problem:    Can't get the exit value in VimLeave or VimLeavePre autocommands.
Solution:   Add v:exiting like in Neovim. (Yegappan Lakshmanan, closes #7395)
diff --git a/src/testdir/test_exit.vim b/src/testdir/test_exit.vim
index 2b29c37..93b8f51 100644
--- a/src/testdir/test_exit.vim
+++ b/src/testdir/test_exit.vim
@@ -82,4 +82,31 @@
   call delete('Xtestout')
 endfunc
 
+" Test for getting the Vim exit code from v:exiting
+func Test_exit_code()
+  call assert_equal(v:null, v:exiting)
+
+  let before =<< trim [CODE]
+    au QuitPre * call writefile(['qp = ' .. v:exiting], 'Xtestout', 'a')
+    au ExitPre * call writefile(['ep = ' .. v:exiting], 'Xtestout', 'a')
+    au VimLeavePre * call writefile(['lp = ' .. v:exiting], 'Xtestout', 'a')
+    au VimLeave * call writefile(['l = ' .. v:exiting], 'Xtestout', 'a')
+  [CODE]
+
+  if RunVim(before, ['quit'], '')
+    call assert_equal(['qp = v:null', 'ep = v:null', 'lp = 0', 'l = 0'], readfile('Xtestout'))
+  endif
+  call delete('Xtestout')
+
+  if RunVim(before, ['cquit'], '')
+    call assert_equal(['lp = 1', 'l = 1'], readfile('Xtestout'))
+  endif
+  call delete('Xtestout')
+
+  if RunVim(before, ['cquit 4'], '')
+    call assert_equal(['lp = 4', 'l = 4'], readfile('Xtestout'))
+  endif
+  call delete('Xtestout')
+endfunc
+
 " vim: shiftwidth=2 sts=2 expandtab