diff options
author | Daniel Hahler <git@thequod.de> | 2019-06-11 13:56:16 +0200 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2019-06-11 13:56:15 +0200 |
commit | 432f69fc0985920ce0b06e28f4ca784499c943db (patch) | |
tree | bf067de36ab8a82d266dfc34c3f6b2c810cdd833 | |
parent | 6fe430f582f2297ca190d04639a885c789b532ae (diff) | |
download | rneovim-432f69fc0985920ce0b06e28f4ca784499c943db.tar.gz rneovim-432f69fc0985920ce0b06e28f4ca784499c943db.tar.bz2 rneovim-432f69fc0985920ce0b06e28f4ca784499c943db.zip |
vim-patch:8.1.1211: test user command code #10162
Problem: Not all user command code is tested.
Solution: Add more tests.
https://github.com/vim/vim/commit/e61e548dd6a20471fd81160b1c2a16089505ec8c
-rw-r--r-- | src/nvim/testdir/test_usercommands.vim | 95 |
1 files changed, 95 insertions, 0 deletions
diff --git a/src/nvim/testdir/test_usercommands.vim b/src/nvim/testdir/test_usercommands.vim index 1520c2f32a..b23a4aa62f 100644 --- a/src/nvim/testdir/test_usercommands.vim +++ b/src/nvim/testdir/test_usercommands.vim @@ -73,6 +73,97 @@ function Test_cmdmods() unlet g:mods endfunction +func SaveCmdArgs(...) + let g:args = a:000 +endfunc + +func Test_f_args() + command -nargs=* TestFArgs call SaveCmdArgs(<f-args>) + + TestFArgs + call assert_equal([], g:args) + + TestFArgs one two three + call assert_equal(['one', 'two', 'three'], g:args) + + TestFArgs one\\two three + call assert_equal(['one\two', 'three'], g:args) + + TestFArgs one\ two three + call assert_equal(['one two', 'three'], g:args) + + TestFArgs one\"two three + call assert_equal(['one\"two', 'three'], g:args) + + delcommand TestFArgs +endfunc + +func Test_q_args() + command -nargs=* TestQArgs call SaveCmdArgs(<q-args>) + + TestQArgs + call assert_equal([''], g:args) + + TestQArgs one two three + call assert_equal(['one two three'], g:args) + + TestQArgs one\\two three + call assert_equal(['one\\two three'], g:args) + + TestQArgs one\ two three + call assert_equal(['one\ two three'], g:args) + + TestQArgs one\"two three + call assert_equal(['one\"two three'], g:args) + + delcommand TestQArgs +endfunc + +func Test_reg_arg() + command -nargs=* -reg TestRegArg call SaveCmdArgs("<reg>", "<register>") + + TestRegArg + call assert_equal(['', ''], g:args) + + TestRegArg x + call assert_equal(['x', 'x'], g:args) + + delcommand TestRegArg +endfunc + +func Test_no_arg() + command -nargs=* TestNoArg call SaveCmdArgs("<args>", "<>", "<x>", "<lt>") + + TestNoArg + call assert_equal(['', '<>', '<x>', '<'], g:args) + + TestNoArg one + call assert_equal(['one', '<>', '<x>', '<'], g:args) + + delcommand TestNoArg +endfunc + +func Test_range_arg() + command -range TestRangeArg call SaveCmdArgs(<range>, <line1>, <line2>) + new + call setline(1, range(100)) + let lnum = line('.') + + TestRangeArg + call assert_equal([0, lnum, lnum], g:args) + + 99TestRangeArg + call assert_equal([1, 99, 99], g:args) + + 88,99TestRangeArg + call assert_equal([2, 88, 99], g:args) + + call assert_fails('102TestRangeArg', 'E16:') + + bwipe! + delcommand TestRangeArg +endfunc + func Test_Ambiguous() command Doit let g:didit = 'yes' command Dothat let g:didthat = 'also' @@ -88,6 +179,9 @@ func Test_Ambiguous() Do call assert_equal('also', g:didthat) delcommand Dothat + + " Nvim removed the ":Ni!" easter egg in 87e107d92. + call assert_fails("\x4ei\041", 'E492: Not an editor command: Ni!') endfunc func Test_CmdUndefined() @@ -111,6 +205,7 @@ func Test_CmdErrors() call assert_fails('com! - DoCmd :', 'E175:') call assert_fails('com! -xxx DoCmd :', 'E181:') call assert_fails('com! -addr DoCmd :', 'E179:') + call assert_fails('com! -addr=asdf DoCmd :', 'E180:') call assert_fails('com! -complete DoCmd :', 'E179:') call assert_fails('com! -complete=xxx DoCmd :', 'E180:') call assert_fails('com! -complete=custom DoCmd :', 'E467:') |