diff options
author | ZyX <kp-pav@yandex.ru> | 2017-11-19 22:05:22 +0300 |
---|---|---|
committer | ZyX <kp-pav@yandex.ru> | 2017-11-19 22:05:22 +0300 |
commit | 03a129aacf7e4b77ceaccc71251ecb5bf41d2a8f (patch) | |
tree | a3a05c99fe20de98aafbdea9314aa0d76f71aee9 /src/nvim/testdir | |
parent | 6ea3a08fdbb276fe64dda60c5fb934360327ed39 (diff) | |
parent | de8b1fd1dee5a91b2893fccc53cfd11631ccba38 (diff) | |
download | rneovim-03a129aacf7e4b77ceaccc71251ecb5bf41d2a8f.tar.gz rneovim-03a129aacf7e4b77ceaccc71251ecb5bf41d2a8f.tar.bz2 rneovim-03a129aacf7e4b77ceaccc71251ecb5bf41d2a8f.zip |
Merge branch 'master' into expression-parser
Diffstat (limited to 'src/nvim/testdir')
-rw-r--r-- | src/nvim/testdir/test_cmdline.vim | 38 | ||||
-rw-r--r-- | src/nvim/testdir/test_fileformat.vim | 16 | ||||
-rw-r--r-- | src/nvim/testdir/test_functions.vim | 85 | ||||
-rw-r--r-- | src/nvim/testdir/test_mapping.vim | 4 | ||||
-rw-r--r-- | src/nvim/testdir/test_unlet.vim | 2 | ||||
-rw-r--r-- | src/nvim/testdir/test_usercommands.vim | 104 |
6 files changed, 247 insertions, 2 deletions
diff --git a/src/nvim/testdir/test_cmdline.vim b/src/nvim/testdir/test_cmdline.vim index c0f04f4730..5fc519f822 100644 --- a/src/nvim/testdir/test_cmdline.vim +++ b/src/nvim/testdir/test_cmdline.vim @@ -25,6 +25,34 @@ func Test_complete_wildmenu() set nowildmenu endfunc +func Test_expr_completion() + if !(has('cmdline_compl') && has('eval')) + return + endif + for cmd in [ + \ 'let a = ', + \ 'if', + \ 'elseif', + \ 'while', + \ 'for', + \ 'echo', + \ 'echon', + \ 'execute', + \ 'echomsg', + \ 'echoerr', + \ 'call', + \ 'return', + \ 'cexpr', + \ 'caddexpr', + \ 'cgetexpr', + \ 'lexpr', + \ 'laddexpr', + \ 'lgetexpr'] + call feedkeys(":" . cmd . " getl\<Tab>\<Home>\"\<CR>", 'xt') + call assert_equal('"' . cmd . ' getline(', getreg(':')) + endfor +endfunc + func Test_getcompletion() if !has('cmdline_compl') return @@ -268,3 +296,13 @@ func Test_illegal_address2() call delete('Xtest.vim') endfunc +func Test_cmdline_complete_wildoptions() + help + call feedkeys(":tag /\<c-a>\<c-b>\"\<cr>", 'tx') + let a = join(sort(split(@:)),' ') + set wildoptions=tagfile + call feedkeys(":tag /\<c-a>\<c-b>\"\<cr>", 'tx') + let b = join(sort(split(@:)),' ') + call assert_equal(a, b) + bw! +endfunc diff --git a/src/nvim/testdir/test_fileformat.vim b/src/nvim/testdir/test_fileformat.vim index 584f20cdfc..8dc25f62b1 100644 --- a/src/nvim/testdir/test_fileformat.vim +++ b/src/nvim/testdir/test_fileformat.vim @@ -15,3 +15,19 @@ func Test_fileformat_after_bw() call assert_equal(test_fileformats, &fileformat) set fileformats& endfunc + +func Test_fileformat_autocommand() + let filecnt = ["", "foobar\<CR>", "eins\<CR>", "\<CR>", "zwei\<CR>", "drei", "vier", "fünf", ""] + let ffs = &ffs + call writefile(filecnt, 'Xfile', 'b') + au BufReadPre Xfile set ffs=dos ff=dos + new Xfile + call assert_equal('dos', &l:ff) + call assert_equal('dos', &ffs) + + " cleanup + call delete('Xfile') + let &ffs = ffs + au! BufReadPre Xfile + bw! +endfunc diff --git a/src/nvim/testdir/test_functions.vim b/src/nvim/testdir/test_functions.vim index 237a2dc820..59807ca946 100644 --- a/src/nvim/testdir/test_functions.vim +++ b/src/nvim/testdir/test_functions.vim @@ -191,4 +191,89 @@ func Test_toupper() call assert_equal("ⱥ ⱦ", tolower("Ⱥ Ⱦ")) endfunc +" Tests for the mode() function +let current_modes = '' +func! Save_mode() + let g:current_modes = mode(0) . '-' . mode(1) + return '' +endfunc + +func! Test_mode() + new + call append(0, ["Blue Ball Black", "Brown Band Bowl", ""]) + + inoremap <F2> <C-R>=Save_mode()<CR> + + normal! 3G + exe "normal i\<F2>\<Esc>" + call assert_equal('i-i', g:current_modes) + exe "normal i\<C-G>uBa\<C-P>\<F2>\<Esc>u" + call assert_equal('i-ic', g:current_modes) + exe "normal iBro\<C-P>\<F2>\<Esc>u" + call assert_equal('i-ic', g:current_modes) + exe "normal iBa\<C-X>\<F2>\<Esc>u" + call assert_equal('i-ix', g:current_modes) + exe "normal iBa\<C-X>\<C-P>\<F2>\<Esc>u" + call assert_equal('i-ic', g:current_modes) + exe "normal iBro\<C-X>\<C-P>\<F2>\<Esc>u" + call assert_equal('i-ic', g:current_modes) + exe "normal iBro\<C-X>\<C-P>\<C-P>\<F2>\<Esc>u" + call assert_equal('i-ic', g:current_modes) + exe "normal iCom\<C-P>\<F2>\<Esc>u" + call assert_equal('i-ic', g:current_modes) + exe "normal iCom\<C-X>\<C-P>\<F2>\<Esc>u" + call assert_equal('i-ic', g:current_modes) + + exe "normal RBa\<C-P>\<F2>\<Esc>u" + call assert_equal('R-Rc', g:current_modes) + exe "normal RBro\<C-P>\<F2>\<Esc>u" + call assert_equal('R-Rc', g:current_modes) + exe "normal RBa\<C-X>\<F2>\<Esc>u" + call assert_equal('R-Rx', g:current_modes) + exe "normal RBa\<C-X>\<C-P>\<F2>\<Esc>u" + call assert_equal('R-Rc', g:current_modes) + exe "normal RBro\<C-X>\<C-P>\<F2>\<Esc>u" + call assert_equal('R-Rc', g:current_modes) + exe "normal RBro\<C-X>\<C-P>\<C-P>\<F2>\<Esc>u" + call assert_equal('R-Rc', g:current_modes) + exe "normal RCom\<C-P>\<F2>\<Esc>u" + call assert_equal('R-Rc', g:current_modes) + exe "normal RCom\<C-X>\<C-P>\<F2>\<Esc>u" + call assert_equal('R-Rc', g:current_modes) + + call assert_equal('n', mode(0)) + call assert_equal('n', mode(1)) + " How to test operator-pending mode? + + call feedkeys("v", 'xt') + call assert_equal('v', mode()) + call assert_equal('v', mode(1)) + call feedkeys("\<Esc>V", 'xt') + call assert_equal('V', mode()) + call assert_equal('V', mode(1)) + call feedkeys("\<Esc>\<C-V>", 'xt') + call assert_equal("\<C-V>", mode()) + call assert_equal("\<C-V>", mode(1)) + call feedkeys("\<Esc>", 'xt') + + call feedkeys("gh", 'xt') + call assert_equal('s', mode()) + call assert_equal('s', mode(1)) + call feedkeys("\<Esc>gH", 'xt') + call assert_equal('S', mode()) + call assert_equal('S', mode(1)) + call feedkeys("\<Esc>g\<C-H>", 'xt') + call assert_equal("\<C-S>", mode()) + call assert_equal("\<C-S>", mode(1)) + call feedkeys("\<Esc>", 'xt') + + call feedkeys(":echo \<C-R>=Save_mode()\<C-U>\<CR>", 'xt') + call assert_equal('c-c', g:current_modes) + call feedkeys("gQecho \<C-R>=Save_mode()\<CR>\<CR>vi\<CR>", 'xt') + call assert_equal('c-cv', g:current_modes) + " How to test Ex mode? + + bwipe! + iunmap <F2> +endfunc diff --git a/src/nvim/testdir/test_mapping.vim b/src/nvim/testdir/test_mapping.vim index 7f93ddd56e..f5e4c4b90c 100644 --- a/src/nvim/testdir/test_mapping.vim +++ b/src/nvim/testdir/test_mapping.vim @@ -110,6 +110,8 @@ func Test_map_langmap() call feedkeys(":call append(line('$'), '+')\<CR>", "xt") call assert_equal('+', getline('$')) + iunmap a + iunmap c set nomodified endfunc @@ -120,7 +122,7 @@ func Test_map_feedkeys() $-1 call feedkeys("0qqdw.ifoo\<Esc>qj0@q\<Esc>", "xt") call assert_equal(['fooc d', 'fooc d'], getline(line('$') - 1, line('$'))) - unmap . + nunmap . set nomodified endfunc diff --git a/src/nvim/testdir/test_unlet.vim b/src/nvim/testdir/test_unlet.vim index f6705997a9..96ba752d9f 100644 --- a/src/nvim/testdir/test_unlet.vim +++ b/src/nvim/testdir/test_unlet.vim @@ -3,7 +3,7 @@ func Test_read_only() try " this caused a crash - unlet count + unlet v:count catch call assert_true(v:exception =~ ':E795:') endtry diff --git a/src/nvim/testdir/test_usercommands.vim b/src/nvim/testdir/test_usercommands.vim index d0864ec64c..db603610da 100644 --- a/src/nvim/testdir/test_usercommands.vim +++ b/src/nvim/testdir/test_usercommands.vim @@ -102,3 +102,107 @@ func Test_CmdUndefined() call assert_fails('Dothat', 'E492:') call assert_equal('yes', g:didnot) endfunc + +func Test_CmdErrors() + call assert_fails('com! docmd :', 'E183:') + call assert_fails('com! \<Tab> :', 'E182:') + call assert_fails('com! _ :', 'E182:') + call assert_fails('com! X :', 'E841:') + call assert_fails('com! - DoCmd :', 'E175:') + call assert_fails('com! -xxx DoCmd :', 'E181:') + call assert_fails('com! -addr DoCmd :', 'E179:') + call assert_fails('com! -complete DoCmd :', 'E179:') + call assert_fails('com! -complete=xxx DoCmd :', 'E180:') + call assert_fails('com! -complete=custom DoCmd :', 'E467:') + call assert_fails('com! -complete=customlist DoCmd :', 'E467:') + call assert_fails('com! -complete=behave,CustomComplete DoCmd :', 'E468:') + call assert_fails('com! -nargs=x DoCmd :', 'E176:') + call assert_fails('com! -count=1 -count=2 DoCmd :', 'E177:') + call assert_fails('com! -count=x DoCmd :', 'E178:') + call assert_fails('com! -range=x DoCmd :', 'E178:') + + com! -nargs=0 DoCmd : + call assert_fails('DoCmd x', 'E488:') + + com! -nargs=1 DoCmd : + call assert_fails('DoCmd', 'E471:') + + com! -nargs=+ DoCmd : + call assert_fails('DoCmd', 'E471:') + + call assert_fails('com DoCmd :', 'E174:') + comclear + call assert_fails('delcom DoCmd', 'E184:') +endfunc + +func CustomComplete(A, L, P) + return "January\nFebruary\nMars\n" +endfunc + +func CustomCompleteList(A, L, P) + return [ "Monday", "Tuesday", "Wednesday" ] +endfunc + +func Test_CmdCompletion() + call feedkeys(":com -\<C-A>\<C-B>\"\<CR>", 'tx') + call assert_equal('"com -addr bang bar buffer complete count nargs range register', @:) + + call feedkeys(":com -nargs=0 -\<C-A>\<C-B>\"\<CR>", 'tx') + call assert_equal('"com -nargs=0 -addr bang bar buffer complete count nargs range register', @:) + + call feedkeys(":com -nargs=\<C-A>\<C-B>\"\<CR>", 'tx') + call assert_equal('"com -nargs=* + 0 1 ?', @:) + + call feedkeys(":com -addr=\<C-A>\<C-B>\"\<CR>", 'tx') + call assert_equal('"com -addr=arguments buffers lines loaded_buffers quickfix tabs windows', @:) + + call feedkeys(":com -complete=co\<C-A>\<C-B>\"\<CR>", 'tx') + call assert_equal('"com -complete=color command compiler', @:) + + command! DoCmd1 : + command! DoCmd2 : + call feedkeys(":com \<C-A>\<C-B>\"\<CR>", 'tx') + call assert_equal('"com DoCmd1 DoCmd2', @:) + + call feedkeys(":DoC\<C-A>\<C-B>\"\<CR>", 'tx') + call assert_equal('"DoCmd1 DoCmd2', @:) + + call feedkeys(":delcom DoC\<C-A>\<C-B>\"\<CR>", 'tx') + call assert_equal('"delcom DoCmd1 DoCmd2', @:) + + delcom DoCmd1 + call feedkeys(":delcom DoC\<C-A>\<C-B>\"\<CR>", 'tx') + call assert_equal('"delcom DoCmd2', @:) + + call feedkeys(":com DoC\<C-A>\<C-B>\"\<CR>", 'tx') + call assert_equal('"com DoCmd2', @:) + + delcom DoCmd2 + call feedkeys(":delcom DoC\<C-A>\<C-B>\"\<CR>", 'tx') + call assert_equal('"delcom DoC', @:) + + call feedkeys(":com DoC\<C-A>\<C-B>\"\<CR>", 'tx') + call assert_equal('"com DoC', @:) + + com! -complete=behave DoCmd : + call feedkeys(":DoCmd \<C-A>\<C-B>\"\<CR>", 'tx') + call assert_equal('"DoCmd mswin xterm', @:) + + " This does not work. Why? + "call feedkeys(":DoCmd x\<C-A>\<C-B>\"\<CR>", 'tx') + "call assert_equal('"DoCmd xterm', @:) + + com! -complete=custom,CustomComplete DoCmd : + call feedkeys(":DoCmd \<C-A>\<C-B>\"\<CR>", 'tx') + call assert_equal('"DoCmd January February Mars', @:) + + com! -complete=customlist,CustomCompleteList DoCmd : + call feedkeys(":DoCmd \<C-A>\<C-B>\"\<CR>", 'tx') + call assert_equal('"DoCmd Monday Tuesday Wednesday', @:) + + com! -complete=custom,CustomCompleteList DoCmd : + call assert_fails("call feedkeys(':DoCmd \<C-D>', 'tx')", 'E730:') + + com! -complete=customlist,CustomComp DoCmd : + call assert_fails("call feedkeys(':DoCmd \<C-D>', 'tx')", 'E117:') +endfunc |