Mercurial > vim
view src/testdir/test_cmdline.vim @ 9604:a16f2505a6b3
Added tag v7.4.2079 for changeset 20e7be5d99ac2299ab98660f8bf6d710da2087ac
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Wed, 20 Jul 2016 00:15:06 +0200 |
parents | e3b6a4a87684 |
children | af0d98d8836e |
line wrap: on
line source
" Tests for editing the command line. func Test_complete_tab() call writefile(['testfile'], 'Xtestfile') call feedkeys(":e Xtest\t\r", "tx") call assert_equal('testfile', getline(1)) call delete('Xtestfile') endfunc func Test_complete_list() " We can't see the output, but at least we check the code runs properly. call feedkeys(":e test\<C-D>\r", "tx") call assert_equal('test', expand('%:t')) endfunc func Test_complete_wildmenu() call writefile(['testfile1'], 'Xtestfile1') call writefile(['testfile2'], 'Xtestfile2') set wildmenu call feedkeys(":e Xtest\t\t\r", "tx") call assert_equal('testfile2', getline(1)) call delete('Xtestfile1') call delete('Xtestfile2') set nowildmenu endfunc func Test_getcompletion() if !has('cmdline_compl') return endif let groupcount = len(getcompletion('', 'event')) call assert_true(groupcount > 0) let matchcount = len(getcompletion('File', 'event')) call assert_true(matchcount > 0) call assert_true(groupcount > matchcount) if has('menu') source $VIMRUNTIME/menu.vim let matchcount = len(getcompletion('', 'menu')) call assert_true(matchcount > 0) call assert_equal(['File.'], getcompletion('File', 'menu')) call assert_true(matchcount > 0) let matchcount = len(getcompletion('File.', 'menu')) call assert_true(matchcount > 0) endif let l = getcompletion('v:n', 'var') call assert_true(index(l, 'v:null') >= 0) let l = getcompletion('', 'augroup') call assert_true(index(l, 'END') >= 0) let l = getcompletion('', 'behave') call assert_true(index(l, 'mswin') >= 0) let l = getcompletion('', 'color') call assert_true(index(l, 'default') >= 0) let l = getcompletion('', 'command') call assert_true(index(l, 'sleep') >= 0) let l = getcompletion('', 'dir') call assert_true(index(l, 'samples') >= 0) let l = getcompletion('exe', 'expression') call assert_true(index(l, 'executable(') >= 0) let l = getcompletion('tag', 'function') call assert_true(index(l, 'taglist(') >= 0) let l = getcompletion('run', 'file') call assert_true(index(l, 'runtest.vim') >= 0) let l = getcompletion('ha', 'filetype') call assert_true(index(l, 'hamster') >= 0) let l = getcompletion('z', 'syntax') call assert_true(index(l, 'zimbu') >= 0) let l = getcompletion('jikes', 'compiler') call assert_true(index(l, 'jikes') >= 0) let l = getcompletion('last', 'help') call assert_true(index(l, ':tablast') >= 0) let l = getcompletion('time', 'option') call assert_true(index(l, 'timeoutlen') >= 0) let l = getcompletion('er', 'highlight') call assert_true(index(l, 'ErrorMsg') >= 0) " For others test if the name is recognized. let names = ['buffer', 'environment', 'file_in_path', \ 'mapping', 'shellcmd', 'tag', 'tag_listfiles', 'user'] if has('cscope') call add(names, 'cscope') endif if has('cmdline_hist') call add(names, 'history') endif if has('gettext') call add(names, 'locale') endif if has('profile') call add(names, 'syntime') endif if has('signs') call add(names, 'sign') endif set tags=Xtags call writefile(["!_TAG_FILE_ENCODING\tutf-8\t//", "word\tfile\tcmd"], 'Xtags') for name in names let matchcount = len(getcompletion('', name)) call assert_true(matchcount >= 0, 'No matches for ' . name) endfor call delete('Xtags') call assert_fails('call getcompletion("", "burp")', 'E475:') endfunc