diff src/testdir/test_cmdline.vim @ 19517:738a4fe2c8c5 v8.2.0316

patch 8.2.0316: ex_getln.c code has insufficient test coverage Commit: https://github.com/vim/vim/commit/8d588ccee57390aa01c2395fc599bbe6506ee13a Author: Bram Moolenaar <Bram@vim.org> Date: Tue Feb 25 21:47:45 2020 +0100 patch 8.2.0316: ex_getln.c code has insufficient test coverage Problem: ex_getln.c code has insufficient test coverage. Solution: Add more tests. Fix a problem. (Yegappan Lakshmanan, closes https://github.com/vim/vim/issues/5693)
author Bram Moolenaar <Bram@vim.org>
date Tue, 25 Feb 2020 22:00:04 +0100
parents cb73f4ae6b7c
children bab20768e1fd
line wrap: on
line diff
--- a/src/testdir/test_cmdline.vim
+++ b/src/testdir/test_cmdline.vim
@@ -51,6 +51,12 @@ func Test_complete_wildmenu()
   call feedkeys(":e Xdir1/\<Tab>\<Down>\<Up>\<Right>\<CR>", 'tx')
   call assert_equal('testfile1', getline(1))
 
+  " Completion using a relative path
+  cd Xdir1/Xdir2
+  call feedkeys(":e ../\<Tab>\<Right>\<Down>\<C-A>\<C-B>\"\<CR>", 'tx')
+  call assert_equal('"e Xtestfile3 Xtestfile4', @:)
+  cd -
+
   " cleanup
   %bwipe
   call delete('Xdir1/Xdir2/Xtestfile4')
@@ -456,6 +462,10 @@ func Test_cmdline_paste()
     " ignore error E32
   endtry
   call assert_equal("Xtestfile", bufname("%"))
+
+  " Use an invalid expression for <C-\>e
+  call assert_beeps('call feedkeys(":\<C-\>einvalid\<CR>", "tx")')
+
   bwipe!
 endfunc
 
@@ -690,6 +700,8 @@ func Test_getcmdtype()
   cnoremap <expr> <F6> Check_cmdline('=')
   call feedkeys("a\<C-R>=MyCmd a\<F6>\<Esc>\<Esc>", "xt")
   cunmap <F6>
+
+  call assert_equal('', getcmdline())
 endfunc
 
 func Test_getcmdwintype()
@@ -930,6 +942,22 @@ func Test_cmdwin_cedit()
   delfunc CmdWinType
 endfunc
 
+" Test for CmdwinEnter autocmd
+func Test_cmdwin_autocmd()
+  augroup CmdWin
+    au!
+    autocmd CmdwinEnter * startinsert
+  augroup END
+
+  call assert_fails('call feedkeys("q:xyz\<CR>", "xt")', 'E492:')
+  call assert_equal('xyz', @:)
+
+  augroup CmdWin
+    au!
+  augroup END
+  augroup! CmdWin
+endfunc
+
 func Test_cmdlineclear_tabenter()
   CheckScreendump
 
@@ -967,6 +995,10 @@ func Test_cmdwin_jump_to_win()
   call assert_equal(1, winnr('$'))
   call feedkeys("q/:exit\<CR>", "xt")
   call assert_equal(1, winnr('$'))
+
+  " opening command window twice should fail
+  call assert_beeps('call feedkeys("q:q:\<CR>\<CR>", "xt")')
+  call assert_equal(1, winnr('$'))
 endfunc
 
 " Test for backtick expression in the command line
@@ -1006,4 +1038,19 @@ func Test_cmd_bang()
   call delete('Xresult')
 endfunc
 
+" Test for using ~ for home directory in cmdline completion matches
+func Test_cmdline_expand_home()
+  call mkdir('Xdir')
+  call writefile([], 'Xdir/Xfile1')
+  call writefile([], 'Xdir/Xfile2')
+  cd Xdir
+  let save_HOME = $HOME
+  let $HOME = getcwd()
+  call feedkeys(":e ~/\<C-A>\<C-B>\"\<CR>", 'xt')
+  call assert_equal('"e ~/Xfile1 ~/Xfile2', @:)
+  let $HOME = save_HOME
+  cd ..
+  call delete('Xdir', 'rf')
+endfunc
+
 " vim: shiftwidth=2 sts=2 expandtab