2016-08-10 20:52:25 -07:00
|
|
|
" Tests for user defined commands
|
|
|
|
|
|
|
|
" Test for <mods> in user defined commands
|
|
|
|
function Test_cmdmods()
|
|
|
|
let g:mods = ''
|
|
|
|
|
|
|
|
command! -nargs=* MyCmd let g:mods .= '<mods> '
|
|
|
|
|
|
|
|
MyCmd
|
|
|
|
aboveleft MyCmd
|
2017-01-05 05:22:07 -07:00
|
|
|
abo MyCmd
|
2016-08-10 20:52:25 -07:00
|
|
|
belowright MyCmd
|
2017-01-05 05:22:07 -07:00
|
|
|
bel MyCmd
|
2016-08-10 20:52:25 -07:00
|
|
|
botright MyCmd
|
2017-01-05 05:22:07 -07:00
|
|
|
bo MyCmd
|
2016-08-10 20:52:25 -07:00
|
|
|
browse MyCmd
|
2017-01-05 05:22:07 -07:00
|
|
|
bro MyCmd
|
2016-08-10 20:52:25 -07:00
|
|
|
confirm MyCmd
|
2017-01-05 05:22:07 -07:00
|
|
|
conf MyCmd
|
2016-08-10 20:52:25 -07:00
|
|
|
hide MyCmd
|
2017-01-05 05:22:07 -07:00
|
|
|
hid MyCmd
|
2016-08-10 20:52:25 -07:00
|
|
|
keepalt MyCmd
|
2017-01-05 05:22:07 -07:00
|
|
|
keepa MyCmd
|
2016-08-10 20:52:25 -07:00
|
|
|
keepjumps MyCmd
|
2017-01-05 05:22:07 -07:00
|
|
|
keepj MyCmd
|
2016-08-10 20:52:25 -07:00
|
|
|
keepmarks MyCmd
|
2017-01-05 05:22:07 -07:00
|
|
|
kee MyCmd
|
2016-08-10 20:52:25 -07:00
|
|
|
keeppatterns MyCmd
|
2017-01-05 05:22:07 -07:00
|
|
|
keepp MyCmd
|
|
|
|
leftabove MyCmd " results in :aboveleft
|
|
|
|
lefta MyCmd
|
2016-08-10 20:52:25 -07:00
|
|
|
lockmarks MyCmd
|
2017-01-05 05:22:07 -07:00
|
|
|
loc MyCmd
|
|
|
|
" noautocmd MyCmd
|
2016-08-10 20:52:25 -07:00
|
|
|
noswapfile MyCmd
|
2017-01-05 05:22:07 -07:00
|
|
|
nos MyCmd
|
|
|
|
rightbelow MyCmd " results in :belowright
|
|
|
|
rightb MyCmd
|
|
|
|
" sandbox MyCmd
|
2016-08-10 20:52:25 -07:00
|
|
|
silent MyCmd
|
2017-01-05 05:22:07 -07:00
|
|
|
sil MyCmd
|
2016-08-10 20:52:25 -07:00
|
|
|
tab MyCmd
|
|
|
|
topleft MyCmd
|
2017-01-05 05:22:07 -07:00
|
|
|
to MyCmd
|
|
|
|
" unsilent MyCmd
|
2016-08-10 20:52:25 -07:00
|
|
|
verbose MyCmd
|
2017-01-05 05:22:07 -07:00
|
|
|
verb MyCmd
|
2016-08-10 20:52:25 -07:00
|
|
|
vertical MyCmd
|
2017-01-05 05:22:07 -07:00
|
|
|
vert MyCmd
|
2016-08-25 18:54:00 -07:00
|
|
|
|
2016-08-10 20:52:25 -07:00
|
|
|
aboveleft belowright botright browse confirm hide keepalt keepjumps
|
|
|
|
\ keepmarks keeppatterns lockmarks noswapfile silent tab
|
|
|
|
\ topleft verbose vertical MyCmd
|
2016-08-25 18:54:00 -07:00
|
|
|
|
2017-01-05 05:22:07 -07:00
|
|
|
call assert_equal(' aboveleft aboveleft belowright belowright botright ' .
|
|
|
|
\ 'botright browse browse confirm confirm hide hide ' .
|
|
|
|
\ 'keepalt keepalt keepjumps keepjumps keepmarks keepmarks ' .
|
|
|
|
\ 'keeppatterns keeppatterns aboveleft aboveleft lockmarks lockmarks noswapfile ' .
|
|
|
|
\ 'noswapfile belowright belowright silent silent tab topleft topleft verbose verbose ' .
|
|
|
|
\ 'vertical vertical ' .
|
|
|
|
\ 'aboveleft belowright botright browse confirm hide keepalt keepjumps ' .
|
2016-08-10 20:52:25 -07:00
|
|
|
\ 'keepmarks keeppatterns lockmarks noswapfile silent tab topleft ' .
|
|
|
|
\ 'verbose vertical ', g:mods)
|
|
|
|
|
2016-08-25 18:54:00 -07:00
|
|
|
let g:mods = ''
|
2016-08-10 20:52:25 -07:00
|
|
|
command! -nargs=* MyQCmd let g:mods .= '<q-mods> '
|
2016-08-25 18:54:00 -07:00
|
|
|
|
2016-08-10 20:52:25 -07:00
|
|
|
vertical MyQCmd
|
|
|
|
call assert_equal('"vertical" ', g:mods)
|
|
|
|
|
|
|
|
delcommand MyCmd
|
|
|
|
delcommand MyQCmd
|
|
|
|
unlet g:mods
|
|
|
|
endfunction
|
2017-01-05 05:55:32 -07:00
|
|
|
|
|
|
|
func Test_Ambiguous()
|
|
|
|
command Doit let g:didit = 'yes'
|
|
|
|
command Dothat let g:didthat = 'also'
|
|
|
|
call assert_fails('Do', 'E464:')
|
|
|
|
Doit
|
|
|
|
call assert_equal('yes', g:didit)
|
|
|
|
Dothat
|
|
|
|
call assert_equal('also', g:didthat)
|
|
|
|
unlet g:didit
|
|
|
|
unlet g:didthat
|
|
|
|
|
|
|
|
delcommand Doit
|
|
|
|
Do
|
|
|
|
call assert_equal('also', g:didthat)
|
|
|
|
delcommand Dothat
|
|
|
|
endfunc
|
|
|
|
|
|
|
|
func Test_CmdUndefined()
|
|
|
|
call assert_fails('Doit', 'E492:')
|
|
|
|
au CmdUndefined Doit :command Doit let g:didit = 'yes'
|
|
|
|
Doit
|
|
|
|
call assert_equal('yes', g:didit)
|
|
|
|
delcommand Doit
|
|
|
|
|
|
|
|
call assert_fails('Dothat', 'E492:')
|
|
|
|
au CmdUndefined * let g:didnot = 'yes'
|
|
|
|
call assert_fails('Dothat', 'E492:')
|
|
|
|
call assert_equal('yes', g:didnot)
|
|
|
|
endfunc
|