# HG changeset patch # User Bram Moolenaar # Date 1556370907 -7200 # Node ID 4734d601ebdd210c1b93e405f81167594d26d987 # Parent e7c242103171434a040255cb7e652c9910c520df patch 8.1.1211: not all user command code is tested commit https://github.com/vim/vim/commit/e61e548dd6a20471fd81160b1c2a16089505ec8c Author: Bram Moolenaar Date: Sat Apr 27 15:05:12 2019 +0200 patch 8.1.1211: not all user command code is tested Problem: Not all user command code is tested. Solution: Add more tests. diff --git a/src/testdir/test_usercommands.vim b/src/testdir/test_usercommands.vim --- a/src/testdir/test_usercommands.vim +++ b/src/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() + + 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() + + 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("", "") + + 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("", "<>", "", "") + + TestNoArg + call assert_equal(['', '<>', '', '<'], g:args) + + TestNoArg one + call assert_equal(['one', '<>', '', '<'], g:args) + + delcommand TestNoArg +endfunc + +func Test_range_arg() + command -range TestRangeArg call SaveCmdArgs(, , ) + 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,8 @@ func Test_Ambiguous() Do call assert_equal('also', g:didthat) delcommand Dothat + + call assert_fails("\x4ei\041", ' you demand a ') endfunc func Test_redefine_on_reload() @@ -139,6 +232,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:') diff --git a/src/version.c b/src/version.c --- a/src/version.c +++ b/src/version.c @@ -768,6 +768,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 1211, +/**/ 1210, /**/ 1209,