1" Tests for user defined commands
2
3" Test for <mods> in user defined commands
4function Test_cmdmods()
5  let g:mods = ''
6
7  command! -nargs=* MyCmd let g:mods .= '<mods> '
8
9  MyCmd
10  aboveleft MyCmd
11  abo MyCmd
12  belowright MyCmd
13  bel MyCmd
14  botright MyCmd
15  bo MyCmd
16  browse MyCmd
17  bro MyCmd
18  confirm MyCmd
19  conf MyCmd
20  hide MyCmd
21  hid MyCmd
22  keepalt MyCmd
23  keepa MyCmd
24  keepjumps MyCmd
25  keepj MyCmd
26  keepmarks MyCmd
27  kee MyCmd
28  keeppatterns MyCmd
29  keepp MyCmd
30  leftabove MyCmd  " results in :aboveleft
31  lefta MyCmd
32  lockmarks MyCmd
33  loc MyCmd
34  " noautocmd MyCmd
35  noswapfile MyCmd
36  nos MyCmd
37  rightbelow MyCmd " results in :belowright
38  rightb MyCmd
39  " sandbox MyCmd
40  silent MyCmd
41  sil MyCmd
42  tab MyCmd
43  topleft MyCmd
44  to MyCmd
45  " unsilent MyCmd
46  verbose MyCmd
47  verb MyCmd
48  vertical MyCmd
49  vert MyCmd
50
51  aboveleft belowright botright browse confirm hide keepalt keepjumps
52	      \ keepmarks keeppatterns lockmarks noswapfile silent tab
53	      \ topleft verbose vertical MyCmd
54
55  call assert_equal(' aboveleft aboveleft belowright belowright botright ' .
56      \ 'botright browse browse confirm confirm hide hide ' .
57      \ 'keepalt keepalt keepjumps keepjumps keepmarks keepmarks ' .
58      \ 'keeppatterns keeppatterns aboveleft aboveleft lockmarks lockmarks noswapfile ' .
59      \ 'noswapfile belowright belowright silent silent tab topleft topleft verbose verbose ' .
60      \ 'vertical vertical ' .
61      \ 'aboveleft belowright botright browse confirm hide keepalt keepjumps ' .
62      \ 'keepmarks keeppatterns lockmarks noswapfile silent tab topleft ' .
63      \ 'verbose vertical ', g:mods)
64
65  let g:mods = ''
66  command! -nargs=* MyQCmd let g:mods .= '<q-mods> '
67
68  vertical MyQCmd
69  call assert_equal('"vertical" ', g:mods)
70
71  delcommand MyCmd
72  delcommand MyQCmd
73  unlet g:mods
74endfunction
75
76func Test_Ambiguous()
77  command Doit let g:didit = 'yes'
78  command Dothat let g:didthat = 'also'
79  call assert_fails('Do', 'E464:')
80  Doit
81  call assert_equal('yes', g:didit)
82  Dothat
83  call assert_equal('also', g:didthat)
84  unlet g:didit
85  unlet g:didthat
86
87  delcommand Doit
88  Do
89  call assert_equal('also', g:didthat)
90  delcommand Dothat
91endfunc
92
93func Test_CmdUndefined()
94  call assert_fails('Doit', 'E492:')
95  au CmdUndefined Doit :command Doit let g:didit = 'yes'
96  Doit
97  call assert_equal('yes', g:didit)
98  delcommand Doit
99
100  call assert_fails('Dothat', 'E492:')
101  au CmdUndefined * let g:didnot = 'yes'
102  call assert_fails('Dothat', 'E492:')
103  call assert_equal('yes', g:didnot)
104endfunc
105