aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/testdir
diff options
context:
space:
mode:
authorShougo Matsushita <Shougo.Matsu@gmail.com>2016-07-23 11:33:38 +0900
committerJustin M. Keyes <justinkz@gmail.com>2016-08-01 03:33:38 -0400
commit23f591dba078fee16ab6e4debfcd051e799ca4f8 (patch)
tree0a469e39398562b3145821b8b9b1ed124e9b48a1 /src/nvim/testdir
parent70ae6ac344472e51ac75316992e2c03464b4f6ad (diff)
downloadrneovim-23f591dba078fee16ab6e4debfcd051e799ca4f8.tar.gz
rneovim-23f591dba078fee16ab6e4debfcd051e799ca4f8.tar.bz2
rneovim-23f591dba078fee16ab6e4debfcd051e799ca4f8.zip
[RFC] vim-patch:7.4.2011, vim-patch:7.4.2012, vim-patch:7.4.2066 #5106
vim-patch:7.4.2011 Problem: It is not easy to get a list of command arguments. Solution: Add getcompletion(). (Yegappan Lakshmanan) https://github.com/vim/vim/commit/aa4d73235bf4deee167aa5314b89ae3d3db334b7 vim-patch:7.4.2012 Problem: Test for getcompletion() does not pass on all systems. Solution: Only test what is supported. https://github.com/vim/vim/commit/0d3e24be5686c0710aa3c6671e4c626d6cb21a5f vim-patch:7.4.2066 Problem: getcompletion() not well tested. Solution: Add more testing. https://github.com/vim/vim/commit/c1fb763184c8ae82300357867fa2070aa94366e9
Diffstat (limited to 'src/nvim/testdir')
-rw-r--r--src/nvim/testdir/test_alot.vim1
-rw-r--r--src/nvim/testdir/test_cmdline.vim120
2 files changed, 121 insertions, 0 deletions
diff --git a/src/nvim/testdir/test_alot.vim b/src/nvim/testdir/test_alot.vim
index 14ea73818a..30b8a9ceb8 100644
--- a/src/nvim/testdir/test_alot.vim
+++ b/src/nvim/testdir/test_alot.vim
@@ -3,6 +3,7 @@
source test_assign.vim
source test_cursor_func.vim
+source test_cmdline.vim
source test_menu.vim
source test_popup.vim
source test_unlet.vim
diff --git a/src/nvim/testdir/test_cmdline.vim b/src/nvim/testdir/test_cmdline.vim
new file mode 100644
index 0000000000..438b20cc5e
--- /dev/null
+++ b/src/nvim/testdir/test_cmdline.vim
@@ -0,0 +1,120 @@
+" 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, 'sautest') >= 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('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