blob: e6c31962dd7a7df0278d9f183e52db85a3659a33 [file] [log] [blame]
Bram Moolenaar63a60de2016-06-04 22:08:55 +02001" 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 belowright MyCmd
12 botright MyCmd
13 browse MyCmd
14 confirm MyCmd
15 hide MyCmd
16 keepalt MyCmd
17 keepjumps MyCmd
18 keepmarks MyCmd
19 keeppatterns MyCmd
20 lockmarks MyCmd
21 noswapfile MyCmd
22 silent MyCmd
23 tab MyCmd
24 topleft MyCmd
25 verbose MyCmd
26 vertical MyCmd
27
28 aboveleft belowright botright browse confirm hide keepalt keepjumps
29 \ keepmarks keeppatterns lockmarks noswapfile silent tab
30 \ topleft verbose vertical MyCmd
31
32 call assert_equal(' aboveleft belowright botright browse confirm ' .
33 \ 'hide keepalt keepjumps keepmarks keeppatterns lockmarks ' .
34 \ 'noswapfile silent tab topleft verbose vertical aboveleft ' .
35 \ 'belowright botright browse confirm hide keepalt keepjumps ' .
36 \ 'keepmarks keeppatterns lockmarks noswapfile silent tab topleft ' .
37 \ 'verbose vertical ', g:mods)
38
39 let g:mods = ''
40 command! -nargs=* MyQCmd let g:mods .= '<q-mods> '
41
42 vertical MyQCmd
43 call assert_equal('"vertical" ', g:mods)
44
45 delcommand MyCmd
46 delcommand MyQCmd
47 unlet g:mods
48endfunction
Bram Moolenaareac784e2016-07-28 22:08:24 +020049
50func Test_Ambiguous()
51 command Doit let g:didit = 'yes'
52 command Dothat let g:didthat = 'also'
53 call assert_fails('Do', 'E464:')
54 Doit
55 call assert_equal('yes', g:didit)
56 Dothat
57 call assert_equal('also', g:didthat)
58 unlet g:didit
59 unlet g:didthat
60
61 delcommand Doit
62 Do
63 call assert_equal('also', g:didthat)
64 delcommand Dothat
65endfunc
66
67func Test_CmdUndefined()
68 call assert_fails('Doit', 'E492:')
69 au CmdUndefined Doit :command Doit let g:didit = 'yes'
70 Doit
71 call assert_equal('yes', g:didit)
72 delcommand Doit
73
74 call assert_fails('Dothat', 'E492:')
75 au CmdUndefined * let g:didnot = 'yes'
76 call assert_fails('Dothat', 'E492:')
77 call assert_equal('yes', g:didnot)
78endfunc