patch 8.2.0293: various Ex commands not sufficiently tested

Problem:    Various Ex commands not sufficiently tested.
Solution:   Add more test cases. (Yegappan Lakshmanan, closes #5673)
diff --git a/src/testdir/test_cmdline.vim b/src/testdir/test_cmdline.vim
index ff15cbb..545f09b 100644
--- a/src/testdir/test_cmdline.vim
+++ b/src/testdir/test_cmdline.vim
@@ -977,4 +977,33 @@
   %argd
 endfunc
 
+" Test for the :! command
+func Test_cmd_bang()
+  if !has('unix')
+    return
+  endif
+
+  let lines =<< trim [SCRIPT]
+    " Test for no previous command
+    call assert_fails('!!', 'E34:')
+    set nomore
+    " Test for cmdline expansion with :!
+    call setline(1, 'foo!')
+    silent !echo <cWORD> > Xfile.out
+    call assert_equal(['foo!'], readfile('Xfile.out'))
+    " Test for using previous command
+    silent !echo \! !
+    call assert_equal(['! echo foo!'], readfile('Xfile.out'))
+    call writefile(v:errors, 'Xresult')
+    call delete('Xfile.out')
+    qall!
+  [SCRIPT]
+  call writefile(lines, 'Xscript')
+  if RunVim([], [], '--clean -S Xscript')
+    call assert_equal([], readfile('Xresult'))
+  endif
+  call delete('Xscript')
+  call delete('Xresult')
+endfunc
+
 " vim: shiftwidth=2 sts=2 expandtab