diff options
Diffstat (limited to 'test/old/testdir/test_cmdline.vim')
-rw-r--r-- | test/old/testdir/test_cmdline.vim | 93 |
1 files changed, 58 insertions, 35 deletions
diff --git a/test/old/testdir/test_cmdline.vim b/test/old/testdir/test_cmdline.vim index 49c14c9c74..3f13218c5b 100644 --- a/test/old/testdir/test_cmdline.vim +++ b/test/old/testdir/test_cmdline.vim @@ -1126,14 +1126,14 @@ func Test_cmdline_complete_various() call assert_equal("\"sI \<C-A>", @:) " completion for :write command - call mkdir('Xdir') - call writefile(['one'], 'Xdir/Xfile1') + call mkdir('Xcwdir') + call writefile(['one'], 'Xcwdir/Xfile1') let save_cwd = getcwd() - cd Xdir + cd Xcwdir call feedkeys(":w >> \<C-A>\<C-B>\"\<CR>", 'xt') call assert_equal("\"w >> Xfile1", @:) call chdir(save_cwd) - call delete('Xdir', 'rf') + call delete('Xcwdir', 'rf') " completion for :w ! and :r ! commands call feedkeys(":w !invalid_xyz_cmd\<C-A>\<C-B>\"\<CR>", 'xt') @@ -1190,12 +1190,12 @@ func Test_cmdline_complete_various() call assert_equal("\"doautocmd BufNew,BufEnter", @:) " completion of file name in :doautocmd - call writefile([], 'Xfile1') - call writefile([], 'Xfile2') - call feedkeys(":doautocmd BufEnter Xfi\<C-A>\<C-B>\"\<CR>", 'xt') - call assert_equal("\"doautocmd BufEnter Xfile1 Xfile2", @:) - call delete('Xfile1') - call delete('Xfile2') + call writefile([], 'Xvarfile1') + call writefile([], 'Xvarfile2') + call feedkeys(":doautocmd BufEnter Xvarfi\<C-A>\<C-B>\"\<CR>", 'xt') + call assert_equal("\"doautocmd BufEnter Xvarfile1 Xvarfile2", @:) + call delete('Xvarfile1') + call delete('Xvarfile2') " completion for the :augroup command augroup XTest.test @@ -2010,17 +2010,17 @@ 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 + call mkdir('Xexpdir') + call writefile([], 'Xexpdir/Xfile1') + call writefile([], 'Xexpdir/Xfile2') + cd Xexpdir 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') + call delete('Xexpdir', 'rf') endfunc " Test for using CTRL-\ CTRL-G in the command line to go back to normal mode @@ -2140,6 +2140,29 @@ func Test_wildmode() let &encoding = save_encoding endfunc +func Test_custom_complete_autoload() + call mkdir('Xcustdir/autoload', 'p') + let save_rtp = &rtp + exe 'set rtp=' .. getcwd() .. '/Xcustdir' + let lines =<< trim END + func vim8#Complete(a, c, p) + return "oneA\noneB\noneC" + endfunc + END + call writefile(lines, 'Xcustdir/autoload/vim8.vim') + + command -nargs=1 -complete=custom,vim8#Complete MyCmd + set nowildmenu + set wildmode=full,list + call feedkeys(":MyCmd \<C-A>\<C-B>\"\<CR>", 'xt') + call assert_equal('"MyCmd oneA oneB oneC', @:) + + let &rtp = save_rtp + set wildmode& wildmenu& + delcommand MyCmd + call delete('Xcustdir', 'rf') +endfunc + " Test for interrupting the command-line completion func Test_interrupt_compl() func F(lead, cmdl, p) @@ -2470,31 +2493,31 @@ endfunc " Test for the 'suffixes' option func Test_suffixes_opt() - call writefile([], 'Xfile') - call writefile([], 'Xfile.c') - call writefile([], 'Xfile.o') + call writefile([], 'Xsuffile') + call writefile([], 'Xsuffile.c') + call writefile([], 'Xsuffile.o') set suffixes= - call feedkeys(":e Xfi*\<C-A>\<C-B>\"\<CR>", 'xt') - call assert_equal('"e Xfile Xfile.c Xfile.o', @:) - call feedkeys(":e Xfi*\<Tab>\<Tab>\<C-B>\"\<CR>", 'xt') - call assert_equal('"e Xfile.c', @:) + call feedkeys(":e Xsuffi*\<C-A>\<C-B>\"\<CR>", 'xt') + call assert_equal('"e Xsuffile Xsuffile.c Xsuffile.o', @:) + call feedkeys(":e Xsuffi*\<Tab>\<Tab>\<C-B>\"\<CR>", 'xt') + call assert_equal('"e Xsuffile.c', @:) set suffixes=.c - call feedkeys(":e Xfi*\<C-A>\<C-B>\"\<CR>", 'xt') - call assert_equal('"e Xfile Xfile.o Xfile.c', @:) - call feedkeys(":e Xfi*\<Tab>\<Tab>\<C-B>\"\<CR>", 'xt') - call assert_equal('"e Xfile.o', @:) + call feedkeys(":e Xsuffi*\<C-A>\<C-B>\"\<CR>", 'xt') + call assert_equal('"e Xsuffile Xsuffile.o Xsuffile.c', @:) + call feedkeys(":e Xsuffi*\<Tab>\<Tab>\<C-B>\"\<CR>", 'xt') + call assert_equal('"e Xsuffile.o', @:) set suffixes=,, - call feedkeys(":e Xfi*\<C-A>\<C-B>\"\<CR>", 'xt') - call assert_equal('"e Xfile.c Xfile.o Xfile', @:) - call feedkeys(":e Xfi*\<Tab>\<Tab>\<C-B>\"\<CR>", 'xt') - call assert_equal('"e Xfile.o', @:) + call feedkeys(":e Xsuffi*\<C-A>\<C-B>\"\<CR>", 'xt') + call assert_equal('"e Xsuffile.c Xsuffile.o Xsuffile', @:) + call feedkeys(":e Xsuffi*\<Tab>\<Tab>\<C-B>\"\<CR>", 'xt') + call assert_equal('"e Xsuffile.o', @:) set suffixes& " Test for getcompletion() with different patterns - call assert_equal(['Xfile', 'Xfile.c', 'Xfile.o'], getcompletion('Xfile', 'file')) - call assert_equal(['Xfile'], getcompletion('Xfile$', 'file')) - call delete('Xfile') - call delete('Xfile.c') - call delete('Xfile.o') + call assert_equal(['Xsuffile', 'Xsuffile.c', 'Xsuffile.o'], getcompletion('Xsuffile', 'file')) + call assert_equal(['Xsuffile'], getcompletion('Xsuffile$', 'file')) + call delete('Xsuffile') + call delete('Xsuffile.c') + call delete('Xsuffile.o') endfunc " Test for using a popup menu for the command line completion matches |