annotate src/testdir/test_usercommands.vim @ 16403:250420b35b10 v8.1.1206

patch 8.1.1206: user command parsing and listing not properly tested commit https://github.com/vim/vim/commit/d1f90bbcab0ad934d3f48a717a916807b57269ab Author: Bram Moolenaar <Bram@vim.org> Date: Thu Apr 25 22:42:07 2019 +0200 patch 8.1.1206: user command parsing and listing not properly tested Problem: User command parsing and listing not properly tested. Solution: Add more tests. (Dominique Pelle, closes https://github.com/vim/vim/issues/4296)
author Bram Moolenaar <Bram@vim.org>
date Thu, 25 Apr 2019 22:45:05 +0200
parents b101b193d5ff
children 4734d601ebdd
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
9230
f7fb117883ba commit https://github.com/vim/vim/commit/63a60ded3fd584847a05dccf058026e682abad90
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1 " Tests for user defined commands
f7fb117883ba commit https://github.com/vim/vim/commit/63a60ded3fd584847a05dccf058026e682abad90
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2
f7fb117883ba commit https://github.com/vim/vim/commit/63a60ded3fd584847a05dccf058026e682abad90
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3 " Test for <mods> in user defined commands
f7fb117883ba commit https://github.com/vim/vim/commit/63a60ded3fd584847a05dccf058026e682abad90
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4 function Test_cmdmods()
f7fb117883ba commit https://github.com/vim/vim/commit/63a60ded3fd584847a05dccf058026e682abad90
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5 let g:mods = ''
f7fb117883ba commit https://github.com/vim/vim/commit/63a60ded3fd584847a05dccf058026e682abad90
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6
f7fb117883ba commit https://github.com/vim/vim/commit/63a60ded3fd584847a05dccf058026e682abad90
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7 command! -nargs=* MyCmd let g:mods .= '<mods> '
f7fb117883ba commit https://github.com/vim/vim/commit/63a60ded3fd584847a05dccf058026e682abad90
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8
f7fb117883ba commit https://github.com/vim/vim/commit/63a60ded3fd584847a05dccf058026e682abad90
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9 MyCmd
f7fb117883ba commit https://github.com/vim/vim/commit/63a60ded3fd584847a05dccf058026e682abad90
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10 aboveleft MyCmd
9703
1f33aece8e55 commit https://github.com/vim/vim/commit/3bcfca3ab4db415d0e750e00204dd25a91fcee77
Christian Brabandt <cb@256bit.org>
parents: 9667
diff changeset
11 abo MyCmd
9230
f7fb117883ba commit https://github.com/vim/vim/commit/63a60ded3fd584847a05dccf058026e682abad90
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
12 belowright MyCmd
9703
1f33aece8e55 commit https://github.com/vim/vim/commit/3bcfca3ab4db415d0e750e00204dd25a91fcee77
Christian Brabandt <cb@256bit.org>
parents: 9667
diff changeset
13 bel MyCmd
9230
f7fb117883ba commit https://github.com/vim/vim/commit/63a60ded3fd584847a05dccf058026e682abad90
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
14 botright MyCmd
9703
1f33aece8e55 commit https://github.com/vim/vim/commit/3bcfca3ab4db415d0e750e00204dd25a91fcee77
Christian Brabandt <cb@256bit.org>
parents: 9667
diff changeset
15 bo MyCmd
9230
f7fb117883ba commit https://github.com/vim/vim/commit/63a60ded3fd584847a05dccf058026e682abad90
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
16 browse MyCmd
9703
1f33aece8e55 commit https://github.com/vim/vim/commit/3bcfca3ab4db415d0e750e00204dd25a91fcee77
Christian Brabandt <cb@256bit.org>
parents: 9667
diff changeset
17 bro MyCmd
9230
f7fb117883ba commit https://github.com/vim/vim/commit/63a60ded3fd584847a05dccf058026e682abad90
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
18 confirm MyCmd
9703
1f33aece8e55 commit https://github.com/vim/vim/commit/3bcfca3ab4db415d0e750e00204dd25a91fcee77
Christian Brabandt <cb@256bit.org>
parents: 9667
diff changeset
19 conf MyCmd
9230
f7fb117883ba commit https://github.com/vim/vim/commit/63a60ded3fd584847a05dccf058026e682abad90
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
20 hide MyCmd
9703
1f33aece8e55 commit https://github.com/vim/vim/commit/3bcfca3ab4db415d0e750e00204dd25a91fcee77
Christian Brabandt <cb@256bit.org>
parents: 9667
diff changeset
21 hid MyCmd
9230
f7fb117883ba commit https://github.com/vim/vim/commit/63a60ded3fd584847a05dccf058026e682abad90
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
22 keepalt MyCmd
9703
1f33aece8e55 commit https://github.com/vim/vim/commit/3bcfca3ab4db415d0e750e00204dd25a91fcee77
Christian Brabandt <cb@256bit.org>
parents: 9667
diff changeset
23 keepa MyCmd
9230
f7fb117883ba commit https://github.com/vim/vim/commit/63a60ded3fd584847a05dccf058026e682abad90
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
24 keepjumps MyCmd
9703
1f33aece8e55 commit https://github.com/vim/vim/commit/3bcfca3ab4db415d0e750e00204dd25a91fcee77
Christian Brabandt <cb@256bit.org>
parents: 9667
diff changeset
25 keepj MyCmd
9230
f7fb117883ba commit https://github.com/vim/vim/commit/63a60ded3fd584847a05dccf058026e682abad90
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
26 keepmarks MyCmd
9703
1f33aece8e55 commit https://github.com/vim/vim/commit/3bcfca3ab4db415d0e750e00204dd25a91fcee77
Christian Brabandt <cb@256bit.org>
parents: 9667
diff changeset
27 kee MyCmd
9230
f7fb117883ba commit https://github.com/vim/vim/commit/63a60ded3fd584847a05dccf058026e682abad90
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
28 keeppatterns MyCmd
9703
1f33aece8e55 commit https://github.com/vim/vim/commit/3bcfca3ab4db415d0e750e00204dd25a91fcee77
Christian Brabandt <cb@256bit.org>
parents: 9667
diff changeset
29 keepp MyCmd
1f33aece8e55 commit https://github.com/vim/vim/commit/3bcfca3ab4db415d0e750e00204dd25a91fcee77
Christian Brabandt <cb@256bit.org>
parents: 9667
diff changeset
30 leftabove MyCmd " results in :aboveleft
1f33aece8e55 commit https://github.com/vim/vim/commit/3bcfca3ab4db415d0e750e00204dd25a91fcee77
Christian Brabandt <cb@256bit.org>
parents: 9667
diff changeset
31 lefta MyCmd
9230
f7fb117883ba commit https://github.com/vim/vim/commit/63a60ded3fd584847a05dccf058026e682abad90
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
32 lockmarks MyCmd
9703
1f33aece8e55 commit https://github.com/vim/vim/commit/3bcfca3ab4db415d0e750e00204dd25a91fcee77
Christian Brabandt <cb@256bit.org>
parents: 9667
diff changeset
33 loc MyCmd
1f33aece8e55 commit https://github.com/vim/vim/commit/3bcfca3ab4db415d0e750e00204dd25a91fcee77
Christian Brabandt <cb@256bit.org>
parents: 9667
diff changeset
34 " noautocmd MyCmd
9230
f7fb117883ba commit https://github.com/vim/vim/commit/63a60ded3fd584847a05dccf058026e682abad90
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
35 noswapfile MyCmd
9703
1f33aece8e55 commit https://github.com/vim/vim/commit/3bcfca3ab4db415d0e750e00204dd25a91fcee77
Christian Brabandt <cb@256bit.org>
parents: 9667
diff changeset
36 nos MyCmd
1f33aece8e55 commit https://github.com/vim/vim/commit/3bcfca3ab4db415d0e750e00204dd25a91fcee77
Christian Brabandt <cb@256bit.org>
parents: 9667
diff changeset
37 rightbelow MyCmd " results in :belowright
1f33aece8e55 commit https://github.com/vim/vim/commit/3bcfca3ab4db415d0e750e00204dd25a91fcee77
Christian Brabandt <cb@256bit.org>
parents: 9667
diff changeset
38 rightb MyCmd
1f33aece8e55 commit https://github.com/vim/vim/commit/3bcfca3ab4db415d0e750e00204dd25a91fcee77
Christian Brabandt <cb@256bit.org>
parents: 9667
diff changeset
39 " sandbox MyCmd
9230
f7fb117883ba commit https://github.com/vim/vim/commit/63a60ded3fd584847a05dccf058026e682abad90
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
40 silent MyCmd
9703
1f33aece8e55 commit https://github.com/vim/vim/commit/3bcfca3ab4db415d0e750e00204dd25a91fcee77
Christian Brabandt <cb@256bit.org>
parents: 9667
diff changeset
41 sil MyCmd
9230
f7fb117883ba commit https://github.com/vim/vim/commit/63a60ded3fd584847a05dccf058026e682abad90
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
42 tab MyCmd
f7fb117883ba commit https://github.com/vim/vim/commit/63a60ded3fd584847a05dccf058026e682abad90
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
43 topleft MyCmd
9703
1f33aece8e55 commit https://github.com/vim/vim/commit/3bcfca3ab4db415d0e750e00204dd25a91fcee77
Christian Brabandt <cb@256bit.org>
parents: 9667
diff changeset
44 to MyCmd
1f33aece8e55 commit https://github.com/vim/vim/commit/3bcfca3ab4db415d0e750e00204dd25a91fcee77
Christian Brabandt <cb@256bit.org>
parents: 9667
diff changeset
45 " unsilent MyCmd
9230
f7fb117883ba commit https://github.com/vim/vim/commit/63a60ded3fd584847a05dccf058026e682abad90
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
46 verbose MyCmd
9703
1f33aece8e55 commit https://github.com/vim/vim/commit/3bcfca3ab4db415d0e750e00204dd25a91fcee77
Christian Brabandt <cb@256bit.org>
parents: 9667
diff changeset
47 verb MyCmd
9230
f7fb117883ba commit https://github.com/vim/vim/commit/63a60ded3fd584847a05dccf058026e682abad90
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
48 vertical MyCmd
9703
1f33aece8e55 commit https://github.com/vim/vim/commit/3bcfca3ab4db415d0e750e00204dd25a91fcee77
Christian Brabandt <cb@256bit.org>
parents: 9667
diff changeset
49 vert MyCmd
9230
f7fb117883ba commit https://github.com/vim/vim/commit/63a60ded3fd584847a05dccf058026e682abad90
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
50
f7fb117883ba commit https://github.com/vim/vim/commit/63a60ded3fd584847a05dccf058026e682abad90
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
51 aboveleft belowright botright browse confirm hide keepalt keepjumps
f7fb117883ba commit https://github.com/vim/vim/commit/63a60ded3fd584847a05dccf058026e682abad90
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
52 \ keepmarks keeppatterns lockmarks noswapfile silent tab
f7fb117883ba commit https://github.com/vim/vim/commit/63a60ded3fd584847a05dccf058026e682abad90
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
53 \ topleft verbose vertical MyCmd
f7fb117883ba commit https://github.com/vim/vim/commit/63a60ded3fd584847a05dccf058026e682abad90
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
54
9703
1f33aece8e55 commit https://github.com/vim/vim/commit/3bcfca3ab4db415d0e750e00204dd25a91fcee77
Christian Brabandt <cb@256bit.org>
parents: 9667
diff changeset
55 call assert_equal(' aboveleft aboveleft belowright belowright botright ' .
1f33aece8e55 commit https://github.com/vim/vim/commit/3bcfca3ab4db415d0e750e00204dd25a91fcee77
Christian Brabandt <cb@256bit.org>
parents: 9667
diff changeset
56 \ 'botright browse browse confirm confirm hide hide ' .
1f33aece8e55 commit https://github.com/vim/vim/commit/3bcfca3ab4db415d0e750e00204dd25a91fcee77
Christian Brabandt <cb@256bit.org>
parents: 9667
diff changeset
57 \ 'keepalt keepalt keepjumps keepjumps keepmarks keepmarks ' .
1f33aece8e55 commit https://github.com/vim/vim/commit/3bcfca3ab4db415d0e750e00204dd25a91fcee77
Christian Brabandt <cb@256bit.org>
parents: 9667
diff changeset
58 \ 'keeppatterns keeppatterns aboveleft aboveleft lockmarks lockmarks noswapfile ' .
1f33aece8e55 commit https://github.com/vim/vim/commit/3bcfca3ab4db415d0e750e00204dd25a91fcee77
Christian Brabandt <cb@256bit.org>
parents: 9667
diff changeset
59 \ 'noswapfile belowright belowright silent silent tab topleft topleft verbose verbose ' .
1f33aece8e55 commit https://github.com/vim/vim/commit/3bcfca3ab4db415d0e750e00204dd25a91fcee77
Christian Brabandt <cb@256bit.org>
parents: 9667
diff changeset
60 \ 'vertical vertical ' .
1f33aece8e55 commit https://github.com/vim/vim/commit/3bcfca3ab4db415d0e750e00204dd25a91fcee77
Christian Brabandt <cb@256bit.org>
parents: 9667
diff changeset
61 \ 'aboveleft belowright botright browse confirm hide keepalt keepjumps ' .
9230
f7fb117883ba commit https://github.com/vim/vim/commit/63a60ded3fd584847a05dccf058026e682abad90
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
62 \ 'keepmarks keeppatterns lockmarks noswapfile silent tab topleft ' .
f7fb117883ba commit https://github.com/vim/vim/commit/63a60ded3fd584847a05dccf058026e682abad90
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
63 \ 'verbose vertical ', g:mods)
f7fb117883ba commit https://github.com/vim/vim/commit/63a60ded3fd584847a05dccf058026e682abad90
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
64
f7fb117883ba commit https://github.com/vim/vim/commit/63a60ded3fd584847a05dccf058026e682abad90
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
65 let g:mods = ''
f7fb117883ba commit https://github.com/vim/vim/commit/63a60ded3fd584847a05dccf058026e682abad90
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
66 command! -nargs=* MyQCmd let g:mods .= '<q-mods> '
f7fb117883ba commit https://github.com/vim/vim/commit/63a60ded3fd584847a05dccf058026e682abad90
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
67
f7fb117883ba commit https://github.com/vim/vim/commit/63a60ded3fd584847a05dccf058026e682abad90
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
68 vertical MyQCmd
f7fb117883ba commit https://github.com/vim/vim/commit/63a60ded3fd584847a05dccf058026e682abad90
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
69 call assert_equal('"vertical" ', g:mods)
f7fb117883ba commit https://github.com/vim/vim/commit/63a60ded3fd584847a05dccf058026e682abad90
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
70
f7fb117883ba commit https://github.com/vim/vim/commit/63a60ded3fd584847a05dccf058026e682abad90
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
71 delcommand MyCmd
f7fb117883ba commit https://github.com/vim/vim/commit/63a60ded3fd584847a05dccf058026e682abad90
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
72 delcommand MyQCmd
f7fb117883ba commit https://github.com/vim/vim/commit/63a60ded3fd584847a05dccf058026e682abad90
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
73 unlet g:mods
f7fb117883ba commit https://github.com/vim/vim/commit/63a60ded3fd584847a05dccf058026e682abad90
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
74 endfunction
9667
c27052511998 commit https://github.com/vim/vim/commit/eac784eced501c54d2c99e18a1af96cd996f3a6c
Christian Brabandt <cb@256bit.org>
parents: 9230
diff changeset
75
c27052511998 commit https://github.com/vim/vim/commit/eac784eced501c54d2c99e18a1af96cd996f3a6c
Christian Brabandt <cb@256bit.org>
parents: 9230
diff changeset
76 func Test_Ambiguous()
c27052511998 commit https://github.com/vim/vim/commit/eac784eced501c54d2c99e18a1af96cd996f3a6c
Christian Brabandt <cb@256bit.org>
parents: 9230
diff changeset
77 command Doit let g:didit = 'yes'
c27052511998 commit https://github.com/vim/vim/commit/eac784eced501c54d2c99e18a1af96cd996f3a6c
Christian Brabandt <cb@256bit.org>
parents: 9230
diff changeset
78 command Dothat let g:didthat = 'also'
c27052511998 commit https://github.com/vim/vim/commit/eac784eced501c54d2c99e18a1af96cd996f3a6c
Christian Brabandt <cb@256bit.org>
parents: 9230
diff changeset
79 call assert_fails('Do', 'E464:')
c27052511998 commit https://github.com/vim/vim/commit/eac784eced501c54d2c99e18a1af96cd996f3a6c
Christian Brabandt <cb@256bit.org>
parents: 9230
diff changeset
80 Doit
c27052511998 commit https://github.com/vim/vim/commit/eac784eced501c54d2c99e18a1af96cd996f3a6c
Christian Brabandt <cb@256bit.org>
parents: 9230
diff changeset
81 call assert_equal('yes', g:didit)
c27052511998 commit https://github.com/vim/vim/commit/eac784eced501c54d2c99e18a1af96cd996f3a6c
Christian Brabandt <cb@256bit.org>
parents: 9230
diff changeset
82 Dothat
c27052511998 commit https://github.com/vim/vim/commit/eac784eced501c54d2c99e18a1af96cd996f3a6c
Christian Brabandt <cb@256bit.org>
parents: 9230
diff changeset
83 call assert_equal('also', g:didthat)
c27052511998 commit https://github.com/vim/vim/commit/eac784eced501c54d2c99e18a1af96cd996f3a6c
Christian Brabandt <cb@256bit.org>
parents: 9230
diff changeset
84 unlet g:didit
c27052511998 commit https://github.com/vim/vim/commit/eac784eced501c54d2c99e18a1af96cd996f3a6c
Christian Brabandt <cb@256bit.org>
parents: 9230
diff changeset
85 unlet g:didthat
c27052511998 commit https://github.com/vim/vim/commit/eac784eced501c54d2c99e18a1af96cd996f3a6c
Christian Brabandt <cb@256bit.org>
parents: 9230
diff changeset
86
c27052511998 commit https://github.com/vim/vim/commit/eac784eced501c54d2c99e18a1af96cd996f3a6c
Christian Brabandt <cb@256bit.org>
parents: 9230
diff changeset
87 delcommand Doit
c27052511998 commit https://github.com/vim/vim/commit/eac784eced501c54d2c99e18a1af96cd996f3a6c
Christian Brabandt <cb@256bit.org>
parents: 9230
diff changeset
88 Do
c27052511998 commit https://github.com/vim/vim/commit/eac784eced501c54d2c99e18a1af96cd996f3a6c
Christian Brabandt <cb@256bit.org>
parents: 9230
diff changeset
89 call assert_equal('also', g:didthat)
c27052511998 commit https://github.com/vim/vim/commit/eac784eced501c54d2c99e18a1af96cd996f3a6c
Christian Brabandt <cb@256bit.org>
parents: 9230
diff changeset
90 delcommand Dothat
c27052511998 commit https://github.com/vim/vim/commit/eac784eced501c54d2c99e18a1af96cd996f3a6c
Christian Brabandt <cb@256bit.org>
parents: 9230
diff changeset
91 endfunc
c27052511998 commit https://github.com/vim/vim/commit/eac784eced501c54d2c99e18a1af96cd996f3a6c
Christian Brabandt <cb@256bit.org>
parents: 9230
diff changeset
92
15125
b101b193d5ff patch 8.1.0573: cannot redefine user command without ! in same script
Bram Moolenaar <Bram@vim.org>
parents: 15099
diff changeset
93 func Test_redefine_on_reload()
b101b193d5ff patch 8.1.0573: cannot redefine user command without ! in same script
Bram Moolenaar <Bram@vim.org>
parents: 15099
diff changeset
94 call writefile(['command ExistingCommand echo "yes"'], 'Xcommandexists')
b101b193d5ff patch 8.1.0573: cannot redefine user command without ! in same script
Bram Moolenaar <Bram@vim.org>
parents: 15099
diff changeset
95 call assert_equal(0, exists(':ExistingCommand'))
b101b193d5ff patch 8.1.0573: cannot redefine user command without ! in same script
Bram Moolenaar <Bram@vim.org>
parents: 15099
diff changeset
96 source Xcommandexists
b101b193d5ff patch 8.1.0573: cannot redefine user command without ! in same script
Bram Moolenaar <Bram@vim.org>
parents: 15099
diff changeset
97 call assert_equal(2, exists(':ExistingCommand'))
b101b193d5ff patch 8.1.0573: cannot redefine user command without ! in same script
Bram Moolenaar <Bram@vim.org>
parents: 15099
diff changeset
98 " Redefining a command when reloading a script is OK.
b101b193d5ff patch 8.1.0573: cannot redefine user command without ! in same script
Bram Moolenaar <Bram@vim.org>
parents: 15099
diff changeset
99 source Xcommandexists
b101b193d5ff patch 8.1.0573: cannot redefine user command without ! in same script
Bram Moolenaar <Bram@vim.org>
parents: 15099
diff changeset
100 call assert_equal(2, exists(':ExistingCommand'))
b101b193d5ff patch 8.1.0573: cannot redefine user command without ! in same script
Bram Moolenaar <Bram@vim.org>
parents: 15099
diff changeset
101
b101b193d5ff patch 8.1.0573: cannot redefine user command without ! in same script
Bram Moolenaar <Bram@vim.org>
parents: 15099
diff changeset
102 " But redefining in another script is not OK.
b101b193d5ff patch 8.1.0573: cannot redefine user command without ! in same script
Bram Moolenaar <Bram@vim.org>
parents: 15099
diff changeset
103 call writefile(['command ExistingCommand echo "yes"'], 'Xcommandexists2')
b101b193d5ff patch 8.1.0573: cannot redefine user command without ! in same script
Bram Moolenaar <Bram@vim.org>
parents: 15099
diff changeset
104 call assert_fails('source Xcommandexists2', 'E174:')
b101b193d5ff patch 8.1.0573: cannot redefine user command without ! in same script
Bram Moolenaar <Bram@vim.org>
parents: 15099
diff changeset
105 call delete('Xcommandexists2')
b101b193d5ff patch 8.1.0573: cannot redefine user command without ! in same script
Bram Moolenaar <Bram@vim.org>
parents: 15099
diff changeset
106
b101b193d5ff patch 8.1.0573: cannot redefine user command without ! in same script
Bram Moolenaar <Bram@vim.org>
parents: 15099
diff changeset
107 " And defining twice in one script is not OK.
b101b193d5ff patch 8.1.0573: cannot redefine user command without ! in same script
Bram Moolenaar <Bram@vim.org>
parents: 15099
diff changeset
108 delcommand ExistingCommand
b101b193d5ff patch 8.1.0573: cannot redefine user command without ! in same script
Bram Moolenaar <Bram@vim.org>
parents: 15099
diff changeset
109 call assert_equal(0, exists(':ExistingCommand'))
b101b193d5ff patch 8.1.0573: cannot redefine user command without ! in same script
Bram Moolenaar <Bram@vim.org>
parents: 15099
diff changeset
110 call writefile([
b101b193d5ff patch 8.1.0573: cannot redefine user command without ! in same script
Bram Moolenaar <Bram@vim.org>
parents: 15099
diff changeset
111 \ 'command ExistingCommand echo "yes"',
b101b193d5ff patch 8.1.0573: cannot redefine user command without ! in same script
Bram Moolenaar <Bram@vim.org>
parents: 15099
diff changeset
112 \ 'command ExistingCommand echo "no"',
b101b193d5ff patch 8.1.0573: cannot redefine user command without ! in same script
Bram Moolenaar <Bram@vim.org>
parents: 15099
diff changeset
113 \ ], 'Xcommandexists')
b101b193d5ff patch 8.1.0573: cannot redefine user command without ! in same script
Bram Moolenaar <Bram@vim.org>
parents: 15099
diff changeset
114 call assert_fails('source Xcommandexists', 'E174:')
b101b193d5ff patch 8.1.0573: cannot redefine user command without ! in same script
Bram Moolenaar <Bram@vim.org>
parents: 15099
diff changeset
115 call assert_equal(2, exists(':ExistingCommand'))
b101b193d5ff patch 8.1.0573: cannot redefine user command without ! in same script
Bram Moolenaar <Bram@vim.org>
parents: 15099
diff changeset
116
b101b193d5ff patch 8.1.0573: cannot redefine user command without ! in same script
Bram Moolenaar <Bram@vim.org>
parents: 15099
diff changeset
117 call delete('Xcommandexists')
b101b193d5ff patch 8.1.0573: cannot redefine user command without ! in same script
Bram Moolenaar <Bram@vim.org>
parents: 15099
diff changeset
118 delcommand ExistingCommand
b101b193d5ff patch 8.1.0573: cannot redefine user command without ! in same script
Bram Moolenaar <Bram@vim.org>
parents: 15099
diff changeset
119 endfunc
b101b193d5ff patch 8.1.0573: cannot redefine user command without ! in same script
Bram Moolenaar <Bram@vim.org>
parents: 15099
diff changeset
120
9667
c27052511998 commit https://github.com/vim/vim/commit/eac784eced501c54d2c99e18a1af96cd996f3a6c
Christian Brabandt <cb@256bit.org>
parents: 9230
diff changeset
121 func Test_CmdUndefined()
c27052511998 commit https://github.com/vim/vim/commit/eac784eced501c54d2c99e18a1af96cd996f3a6c
Christian Brabandt <cb@256bit.org>
parents: 9230
diff changeset
122 call assert_fails('Doit', 'E492:')
c27052511998 commit https://github.com/vim/vim/commit/eac784eced501c54d2c99e18a1af96cd996f3a6c
Christian Brabandt <cb@256bit.org>
parents: 9230
diff changeset
123 au CmdUndefined Doit :command Doit let g:didit = 'yes'
c27052511998 commit https://github.com/vim/vim/commit/eac784eced501c54d2c99e18a1af96cd996f3a6c
Christian Brabandt <cb@256bit.org>
parents: 9230
diff changeset
124 Doit
c27052511998 commit https://github.com/vim/vim/commit/eac784eced501c54d2c99e18a1af96cd996f3a6c
Christian Brabandt <cb@256bit.org>
parents: 9230
diff changeset
125 call assert_equal('yes', g:didit)
c27052511998 commit https://github.com/vim/vim/commit/eac784eced501c54d2c99e18a1af96cd996f3a6c
Christian Brabandt <cb@256bit.org>
parents: 9230
diff changeset
126 delcommand Doit
c27052511998 commit https://github.com/vim/vim/commit/eac784eced501c54d2c99e18a1af96cd996f3a6c
Christian Brabandt <cb@256bit.org>
parents: 9230
diff changeset
127
c27052511998 commit https://github.com/vim/vim/commit/eac784eced501c54d2c99e18a1af96cd996f3a6c
Christian Brabandt <cb@256bit.org>
parents: 9230
diff changeset
128 call assert_fails('Dothat', 'E492:')
c27052511998 commit https://github.com/vim/vim/commit/eac784eced501c54d2c99e18a1af96cd996f3a6c
Christian Brabandt <cb@256bit.org>
parents: 9230
diff changeset
129 au CmdUndefined * let g:didnot = 'yes'
c27052511998 commit https://github.com/vim/vim/commit/eac784eced501c54d2c99e18a1af96cd996f3a6c
Christian Brabandt <cb@256bit.org>
parents: 9230
diff changeset
130 call assert_fails('Dothat', 'E492:')
c27052511998 commit https://github.com/vim/vim/commit/eac784eced501c54d2c99e18a1af96cd996f3a6c
Christian Brabandt <cb@256bit.org>
parents: 9230
diff changeset
131 call assert_equal('yes', g:didnot)
c27052511998 commit https://github.com/vim/vim/commit/eac784eced501c54d2c99e18a1af96cd996f3a6c
Christian Brabandt <cb@256bit.org>
parents: 9230
diff changeset
132 endfunc
10704
6736cb425720 patch 8.0.0242: no tests for user command completion
Christian Brabandt <cb@256bit.org>
parents: 9703
diff changeset
133
6736cb425720 patch 8.0.0242: no tests for user command completion
Christian Brabandt <cb@256bit.org>
parents: 9703
diff changeset
134 func Test_CmdErrors()
6736cb425720 patch 8.0.0242: no tests for user command completion
Christian Brabandt <cb@256bit.org>
parents: 9703
diff changeset
135 call assert_fails('com! docmd :', 'E183:')
6736cb425720 patch 8.0.0242: no tests for user command completion
Christian Brabandt <cb@256bit.org>
parents: 9703
diff changeset
136 call assert_fails('com! \<Tab> :', 'E182:')
6736cb425720 patch 8.0.0242: no tests for user command completion
Christian Brabandt <cb@256bit.org>
parents: 9703
diff changeset
137 call assert_fails('com! _ :', 'E182:')
6736cb425720 patch 8.0.0242: no tests for user command completion
Christian Brabandt <cb@256bit.org>
parents: 9703
diff changeset
138 call assert_fails('com! X :', 'E841:')
6736cb425720 patch 8.0.0242: no tests for user command completion
Christian Brabandt <cb@256bit.org>
parents: 9703
diff changeset
139 call assert_fails('com! - DoCmd :', 'E175:')
6736cb425720 patch 8.0.0242: no tests for user command completion
Christian Brabandt <cb@256bit.org>
parents: 9703
diff changeset
140 call assert_fails('com! -xxx DoCmd :', 'E181:')
6736cb425720 patch 8.0.0242: no tests for user command completion
Christian Brabandt <cb@256bit.org>
parents: 9703
diff changeset
141 call assert_fails('com! -addr DoCmd :', 'E179:')
6736cb425720 patch 8.0.0242: no tests for user command completion
Christian Brabandt <cb@256bit.org>
parents: 9703
diff changeset
142 call assert_fails('com! -complete DoCmd :', 'E179:')
6736cb425720 patch 8.0.0242: no tests for user command completion
Christian Brabandt <cb@256bit.org>
parents: 9703
diff changeset
143 call assert_fails('com! -complete=xxx DoCmd :', 'E180:')
6736cb425720 patch 8.0.0242: no tests for user command completion
Christian Brabandt <cb@256bit.org>
parents: 9703
diff changeset
144 call assert_fails('com! -complete=custom DoCmd :', 'E467:')
6736cb425720 patch 8.0.0242: no tests for user command completion
Christian Brabandt <cb@256bit.org>
parents: 9703
diff changeset
145 call assert_fails('com! -complete=customlist DoCmd :', 'E467:')
6736cb425720 patch 8.0.0242: no tests for user command completion
Christian Brabandt <cb@256bit.org>
parents: 9703
diff changeset
146 call assert_fails('com! -complete=behave,CustomComplete DoCmd :', 'E468:')
6736cb425720 patch 8.0.0242: no tests for user command completion
Christian Brabandt <cb@256bit.org>
parents: 9703
diff changeset
147 call assert_fails('com! -nargs=x DoCmd :', 'E176:')
6736cb425720 patch 8.0.0242: no tests for user command completion
Christian Brabandt <cb@256bit.org>
parents: 9703
diff changeset
148 call assert_fails('com! -count=1 -count=2 DoCmd :', 'E177:')
6736cb425720 patch 8.0.0242: no tests for user command completion
Christian Brabandt <cb@256bit.org>
parents: 9703
diff changeset
149 call assert_fails('com! -count=x DoCmd :', 'E178:')
6736cb425720 patch 8.0.0242: no tests for user command completion
Christian Brabandt <cb@256bit.org>
parents: 9703
diff changeset
150 call assert_fails('com! -range=x DoCmd :', 'E178:')
6736cb425720 patch 8.0.0242: no tests for user command completion
Christian Brabandt <cb@256bit.org>
parents: 9703
diff changeset
151
6736cb425720 patch 8.0.0242: no tests for user command completion
Christian Brabandt <cb@256bit.org>
parents: 9703
diff changeset
152 com! -nargs=0 DoCmd :
6736cb425720 patch 8.0.0242: no tests for user command completion
Christian Brabandt <cb@256bit.org>
parents: 9703
diff changeset
153 call assert_fails('DoCmd x', 'E488:')
6736cb425720 patch 8.0.0242: no tests for user command completion
Christian Brabandt <cb@256bit.org>
parents: 9703
diff changeset
154
6736cb425720 patch 8.0.0242: no tests for user command completion
Christian Brabandt <cb@256bit.org>
parents: 9703
diff changeset
155 com! -nargs=1 DoCmd :
6736cb425720 patch 8.0.0242: no tests for user command completion
Christian Brabandt <cb@256bit.org>
parents: 9703
diff changeset
156 call assert_fails('DoCmd', 'E471:')
6736cb425720 patch 8.0.0242: no tests for user command completion
Christian Brabandt <cb@256bit.org>
parents: 9703
diff changeset
157
6736cb425720 patch 8.0.0242: no tests for user command completion
Christian Brabandt <cb@256bit.org>
parents: 9703
diff changeset
158 com! -nargs=+ DoCmd :
6736cb425720 patch 8.0.0242: no tests for user command completion
Christian Brabandt <cb@256bit.org>
parents: 9703
diff changeset
159 call assert_fails('DoCmd', 'E471:')
6736cb425720 patch 8.0.0242: no tests for user command completion
Christian Brabandt <cb@256bit.org>
parents: 9703
diff changeset
160
6736cb425720 patch 8.0.0242: no tests for user command completion
Christian Brabandt <cb@256bit.org>
parents: 9703
diff changeset
161 call assert_fails('com DoCmd :', 'E174:')
6736cb425720 patch 8.0.0242: no tests for user command completion
Christian Brabandt <cb@256bit.org>
parents: 9703
diff changeset
162 comclear
6736cb425720 patch 8.0.0242: no tests for user command completion
Christian Brabandt <cb@256bit.org>
parents: 9703
diff changeset
163 call assert_fails('delcom DoCmd', 'E184:')
6736cb425720 patch 8.0.0242: no tests for user command completion
Christian Brabandt <cb@256bit.org>
parents: 9703
diff changeset
164 endfunc
6736cb425720 patch 8.0.0242: no tests for user command completion
Christian Brabandt <cb@256bit.org>
parents: 9703
diff changeset
165
6736cb425720 patch 8.0.0242: no tests for user command completion
Christian Brabandt <cb@256bit.org>
parents: 9703
diff changeset
166 func CustomComplete(A, L, P)
6736cb425720 patch 8.0.0242: no tests for user command completion
Christian Brabandt <cb@256bit.org>
parents: 9703
diff changeset
167 return "January\nFebruary\nMars\n"
6736cb425720 patch 8.0.0242: no tests for user command completion
Christian Brabandt <cb@256bit.org>
parents: 9703
diff changeset
168 endfunc
6736cb425720 patch 8.0.0242: no tests for user command completion
Christian Brabandt <cb@256bit.org>
parents: 9703
diff changeset
169
6736cb425720 patch 8.0.0242: no tests for user command completion
Christian Brabandt <cb@256bit.org>
parents: 9703
diff changeset
170 func CustomCompleteList(A, L, P)
6736cb425720 patch 8.0.0242: no tests for user command completion
Christian Brabandt <cb@256bit.org>
parents: 9703
diff changeset
171 return [ "Monday", "Tuesday", "Wednesday" ]
6736cb425720 patch 8.0.0242: no tests for user command completion
Christian Brabandt <cb@256bit.org>
parents: 9703
diff changeset
172 endfunc
6736cb425720 patch 8.0.0242: no tests for user command completion
Christian Brabandt <cb@256bit.org>
parents: 9703
diff changeset
173
6736cb425720 patch 8.0.0242: no tests for user command completion
Christian Brabandt <cb@256bit.org>
parents: 9703
diff changeset
174 func Test_CmdCompletion()
6736cb425720 patch 8.0.0242: no tests for user command completion
Christian Brabandt <cb@256bit.org>
parents: 9703
diff changeset
175 call feedkeys(":com -\<C-A>\<C-B>\"\<CR>", 'tx')
6736cb425720 patch 8.0.0242: no tests for user command completion
Christian Brabandt <cb@256bit.org>
parents: 9703
diff changeset
176 call assert_equal('"com -addr bang bar buffer complete count nargs range register', @:)
6736cb425720 patch 8.0.0242: no tests for user command completion
Christian Brabandt <cb@256bit.org>
parents: 9703
diff changeset
177
6736cb425720 patch 8.0.0242: no tests for user command completion
Christian Brabandt <cb@256bit.org>
parents: 9703
diff changeset
178 call feedkeys(":com -nargs=0 -\<C-A>\<C-B>\"\<CR>", 'tx')
6736cb425720 patch 8.0.0242: no tests for user command completion
Christian Brabandt <cb@256bit.org>
parents: 9703
diff changeset
179 call assert_equal('"com -nargs=0 -addr bang bar buffer complete count nargs range register', @:)
6736cb425720 patch 8.0.0242: no tests for user command completion
Christian Brabandt <cb@256bit.org>
parents: 9703
diff changeset
180
6736cb425720 patch 8.0.0242: no tests for user command completion
Christian Brabandt <cb@256bit.org>
parents: 9703
diff changeset
181 call feedkeys(":com -nargs=\<C-A>\<C-B>\"\<CR>", 'tx')
6736cb425720 patch 8.0.0242: no tests for user command completion
Christian Brabandt <cb@256bit.org>
parents: 9703
diff changeset
182 call assert_equal('"com -nargs=* + 0 1 ?', @:)
6736cb425720 patch 8.0.0242: no tests for user command completion
Christian Brabandt <cb@256bit.org>
parents: 9703
diff changeset
183
6736cb425720 patch 8.0.0242: no tests for user command completion
Christian Brabandt <cb@256bit.org>
parents: 9703
diff changeset
184 call feedkeys(":com -addr=\<C-A>\<C-B>\"\<CR>", 'tx')
15099
39728d503e47 patch 8.1.0560: cannot use address type "other" with with user command
Bram Moolenaar <Bram@vim.org>
parents: 13101
diff changeset
185 call assert_equal('"com -addr=arguments buffers lines loaded_buffers other quickfix tabs windows', @:)
10704
6736cb425720 patch 8.0.0242: no tests for user command completion
Christian Brabandt <cb@256bit.org>
parents: 9703
diff changeset
186
6736cb425720 patch 8.0.0242: no tests for user command completion
Christian Brabandt <cb@256bit.org>
parents: 9703
diff changeset
187 call feedkeys(":com -complete=co\<C-A>\<C-B>\"\<CR>", 'tx')
6736cb425720 patch 8.0.0242: no tests for user command completion
Christian Brabandt <cb@256bit.org>
parents: 9703
diff changeset
188 call assert_equal('"com -complete=color command compiler', @:)
6736cb425720 patch 8.0.0242: no tests for user command completion
Christian Brabandt <cb@256bit.org>
parents: 9703
diff changeset
189
6736cb425720 patch 8.0.0242: no tests for user command completion
Christian Brabandt <cb@256bit.org>
parents: 9703
diff changeset
190 command! DoCmd1 :
6736cb425720 patch 8.0.0242: no tests for user command completion
Christian Brabandt <cb@256bit.org>
parents: 9703
diff changeset
191 command! DoCmd2 :
6736cb425720 patch 8.0.0242: no tests for user command completion
Christian Brabandt <cb@256bit.org>
parents: 9703
diff changeset
192 call feedkeys(":com \<C-A>\<C-B>\"\<CR>", 'tx')
6736cb425720 patch 8.0.0242: no tests for user command completion
Christian Brabandt <cb@256bit.org>
parents: 9703
diff changeset
193 call assert_equal('"com DoCmd1 DoCmd2', @:)
6736cb425720 patch 8.0.0242: no tests for user command completion
Christian Brabandt <cb@256bit.org>
parents: 9703
diff changeset
194
6736cb425720 patch 8.0.0242: no tests for user command completion
Christian Brabandt <cb@256bit.org>
parents: 9703
diff changeset
195 call feedkeys(":DoC\<C-A>\<C-B>\"\<CR>", 'tx')
6736cb425720 patch 8.0.0242: no tests for user command completion
Christian Brabandt <cb@256bit.org>
parents: 9703
diff changeset
196 call assert_equal('"DoCmd1 DoCmd2', @:)
6736cb425720 patch 8.0.0242: no tests for user command completion
Christian Brabandt <cb@256bit.org>
parents: 9703
diff changeset
197
6736cb425720 patch 8.0.0242: no tests for user command completion
Christian Brabandt <cb@256bit.org>
parents: 9703
diff changeset
198 call feedkeys(":delcom DoC\<C-A>\<C-B>\"\<CR>", 'tx')
6736cb425720 patch 8.0.0242: no tests for user command completion
Christian Brabandt <cb@256bit.org>
parents: 9703
diff changeset
199 call assert_equal('"delcom DoCmd1 DoCmd2', @:)
6736cb425720 patch 8.0.0242: no tests for user command completion
Christian Brabandt <cb@256bit.org>
parents: 9703
diff changeset
200
6736cb425720 patch 8.0.0242: no tests for user command completion
Christian Brabandt <cb@256bit.org>
parents: 9703
diff changeset
201 delcom DoCmd1
6736cb425720 patch 8.0.0242: no tests for user command completion
Christian Brabandt <cb@256bit.org>
parents: 9703
diff changeset
202 call feedkeys(":delcom DoC\<C-A>\<C-B>\"\<CR>", 'tx')
6736cb425720 patch 8.0.0242: no tests for user command completion
Christian Brabandt <cb@256bit.org>
parents: 9703
diff changeset
203 call assert_equal('"delcom DoCmd2', @:)
6736cb425720 patch 8.0.0242: no tests for user command completion
Christian Brabandt <cb@256bit.org>
parents: 9703
diff changeset
204
6736cb425720 patch 8.0.0242: no tests for user command completion
Christian Brabandt <cb@256bit.org>
parents: 9703
diff changeset
205 call feedkeys(":com DoC\<C-A>\<C-B>\"\<CR>", 'tx')
6736cb425720 patch 8.0.0242: no tests for user command completion
Christian Brabandt <cb@256bit.org>
parents: 9703
diff changeset
206 call assert_equal('"com DoCmd2', @:)
6736cb425720 patch 8.0.0242: no tests for user command completion
Christian Brabandt <cb@256bit.org>
parents: 9703
diff changeset
207
6736cb425720 patch 8.0.0242: no tests for user command completion
Christian Brabandt <cb@256bit.org>
parents: 9703
diff changeset
208 delcom DoCmd2
6736cb425720 patch 8.0.0242: no tests for user command completion
Christian Brabandt <cb@256bit.org>
parents: 9703
diff changeset
209 call feedkeys(":delcom DoC\<C-A>\<C-B>\"\<CR>", 'tx')
6736cb425720 patch 8.0.0242: no tests for user command completion
Christian Brabandt <cb@256bit.org>
parents: 9703
diff changeset
210 call assert_equal('"delcom DoC', @:)
6736cb425720 patch 8.0.0242: no tests for user command completion
Christian Brabandt <cb@256bit.org>
parents: 9703
diff changeset
211
6736cb425720 patch 8.0.0242: no tests for user command completion
Christian Brabandt <cb@256bit.org>
parents: 9703
diff changeset
212 call feedkeys(":com DoC\<C-A>\<C-B>\"\<CR>", 'tx')
6736cb425720 patch 8.0.0242: no tests for user command completion
Christian Brabandt <cb@256bit.org>
parents: 9703
diff changeset
213 call assert_equal('"com DoC', @:)
6736cb425720 patch 8.0.0242: no tests for user command completion
Christian Brabandt <cb@256bit.org>
parents: 9703
diff changeset
214
6736cb425720 patch 8.0.0242: no tests for user command completion
Christian Brabandt <cb@256bit.org>
parents: 9703
diff changeset
215 com! -complete=behave DoCmd :
6736cb425720 patch 8.0.0242: no tests for user command completion
Christian Brabandt <cb@256bit.org>
parents: 9703
diff changeset
216 call feedkeys(":DoCmd \<C-A>\<C-B>\"\<CR>", 'tx')
6736cb425720 patch 8.0.0242: no tests for user command completion
Christian Brabandt <cb@256bit.org>
parents: 9703
diff changeset
217 call assert_equal('"DoCmd mswin xterm', @:)
6736cb425720 patch 8.0.0242: no tests for user command completion
Christian Brabandt <cb@256bit.org>
parents: 9703
diff changeset
218
6736cb425720 patch 8.0.0242: no tests for user command completion
Christian Brabandt <cb@256bit.org>
parents: 9703
diff changeset
219 " This does not work. Why?
6736cb425720 patch 8.0.0242: no tests for user command completion
Christian Brabandt <cb@256bit.org>
parents: 9703
diff changeset
220 "call feedkeys(":DoCmd x\<C-A>\<C-B>\"\<CR>", 'tx')
6736cb425720 patch 8.0.0242: no tests for user command completion
Christian Brabandt <cb@256bit.org>
parents: 9703
diff changeset
221 "call assert_equal('"DoCmd xterm', @:)
6736cb425720 patch 8.0.0242: no tests for user command completion
Christian Brabandt <cb@256bit.org>
parents: 9703
diff changeset
222
6736cb425720 patch 8.0.0242: no tests for user command completion
Christian Brabandt <cb@256bit.org>
parents: 9703
diff changeset
223 com! -complete=custom,CustomComplete DoCmd :
6736cb425720 patch 8.0.0242: no tests for user command completion
Christian Brabandt <cb@256bit.org>
parents: 9703
diff changeset
224 call feedkeys(":DoCmd \<C-A>\<C-B>\"\<CR>", 'tx')
6736cb425720 patch 8.0.0242: no tests for user command completion
Christian Brabandt <cb@256bit.org>
parents: 9703
diff changeset
225 call assert_equal('"DoCmd January February Mars', @:)
6736cb425720 patch 8.0.0242: no tests for user command completion
Christian Brabandt <cb@256bit.org>
parents: 9703
diff changeset
226
6736cb425720 patch 8.0.0242: no tests for user command completion
Christian Brabandt <cb@256bit.org>
parents: 9703
diff changeset
227 com! -complete=customlist,CustomCompleteList DoCmd :
6736cb425720 patch 8.0.0242: no tests for user command completion
Christian Brabandt <cb@256bit.org>
parents: 9703
diff changeset
228 call feedkeys(":DoCmd \<C-A>\<C-B>\"\<CR>", 'tx')
6736cb425720 patch 8.0.0242: no tests for user command completion
Christian Brabandt <cb@256bit.org>
parents: 9703
diff changeset
229 call assert_equal('"DoCmd Monday Tuesday Wednesday', @:)
6736cb425720 patch 8.0.0242: no tests for user command completion
Christian Brabandt <cb@256bit.org>
parents: 9703
diff changeset
230
6736cb425720 patch 8.0.0242: no tests for user command completion
Christian Brabandt <cb@256bit.org>
parents: 9703
diff changeset
231 com! -complete=custom,CustomCompleteList DoCmd :
6736cb425720 patch 8.0.0242: no tests for user command completion
Christian Brabandt <cb@256bit.org>
parents: 9703
diff changeset
232 call assert_fails("call feedkeys(':DoCmd \<C-D>', 'tx')", 'E730:')
6736cb425720 patch 8.0.0242: no tests for user command completion
Christian Brabandt <cb@256bit.org>
parents: 9703
diff changeset
233
6736cb425720 patch 8.0.0242: no tests for user command completion
Christian Brabandt <cb@256bit.org>
parents: 9703
diff changeset
234 com! -complete=customlist,CustomComp DoCmd :
6736cb425720 patch 8.0.0242: no tests for user command completion
Christian Brabandt <cb@256bit.org>
parents: 9703
diff changeset
235 call assert_fails("call feedkeys(':DoCmd \<C-D>', 'tx')", 'E117:')
6736cb425720 patch 8.0.0242: no tests for user command completion
Christian Brabandt <cb@256bit.org>
parents: 9703
diff changeset
236 endfunc
13101
9b3f8029a326 patch 8.0.1425: execute() does not work in completion of user command
Christian Brabandt <cb@256bit.org>
parents: 12644
diff changeset
237
9b3f8029a326 patch 8.0.1425: execute() does not work in completion of user command
Christian Brabandt <cb@256bit.org>
parents: 12644
diff changeset
238 func CallExecute(A, L, P)
9b3f8029a326 patch 8.0.1425: execute() does not work in completion of user command
Christian Brabandt <cb@256bit.org>
parents: 12644
diff changeset
239 " Drop first '\n'
9b3f8029a326 patch 8.0.1425: execute() does not work in completion of user command
Christian Brabandt <cb@256bit.org>
parents: 12644
diff changeset
240 return execute('echo "hi"')[1:]
9b3f8029a326 patch 8.0.1425: execute() does not work in completion of user command
Christian Brabandt <cb@256bit.org>
parents: 12644
diff changeset
241 endfunc
9b3f8029a326 patch 8.0.1425: execute() does not work in completion of user command
Christian Brabandt <cb@256bit.org>
parents: 12644
diff changeset
242
9b3f8029a326 patch 8.0.1425: execute() does not work in completion of user command
Christian Brabandt <cb@256bit.org>
parents: 12644
diff changeset
243 func Test_use_execute_in_completion()
9b3f8029a326 patch 8.0.1425: execute() does not work in completion of user command
Christian Brabandt <cb@256bit.org>
parents: 12644
diff changeset
244 command! -nargs=* -complete=custom,CallExecute DoExec :
9b3f8029a326 patch 8.0.1425: execute() does not work in completion of user command
Christian Brabandt <cb@256bit.org>
parents: 12644
diff changeset
245 call feedkeys(":DoExec \<C-A>\<C-B>\"\<CR>", 'tx')
9b3f8029a326 patch 8.0.1425: execute() does not work in completion of user command
Christian Brabandt <cb@256bit.org>
parents: 12644
diff changeset
246 call assert_equal('"DoExec hi', @:)
9b3f8029a326 patch 8.0.1425: execute() does not work in completion of user command
Christian Brabandt <cb@256bit.org>
parents: 12644
diff changeset
247 delcommand DoExec
9b3f8029a326 patch 8.0.1425: execute() does not work in completion of user command
Christian Brabandt <cb@256bit.org>
parents: 12644
diff changeset
248 endfunc
15099
39728d503e47 patch 8.1.0560: cannot use address type "other" with with user command
Bram Moolenaar <Bram@vim.org>
parents: 13101
diff changeset
249
39728d503e47 patch 8.1.0560: cannot use address type "other" with with user command
Bram Moolenaar <Bram@vim.org>
parents: 13101
diff changeset
250 func Test_addr_all()
39728d503e47 patch 8.1.0560: cannot use address type "other" with with user command
Bram Moolenaar <Bram@vim.org>
parents: 13101
diff changeset
251 command! -addr=lines DoSomething let g:a1 = <line1> | let g:a2 = <line2>
39728d503e47 patch 8.1.0560: cannot use address type "other" with with user command
Bram Moolenaar <Bram@vim.org>
parents: 13101
diff changeset
252 %DoSomething
39728d503e47 patch 8.1.0560: cannot use address type "other" with with user command
Bram Moolenaar <Bram@vim.org>
parents: 13101
diff changeset
253 call assert_equal(1, g:a1)
39728d503e47 patch 8.1.0560: cannot use address type "other" with with user command
Bram Moolenaar <Bram@vim.org>
parents: 13101
diff changeset
254 call assert_equal(line('$'), g:a2)
39728d503e47 patch 8.1.0560: cannot use address type "other" with with user command
Bram Moolenaar <Bram@vim.org>
parents: 13101
diff changeset
255
39728d503e47 patch 8.1.0560: cannot use address type "other" with with user command
Bram Moolenaar <Bram@vim.org>
parents: 13101
diff changeset
256 command! -addr=arguments DoSomething let g:a1 = <line1> | let g:a2 = <line2>
39728d503e47 patch 8.1.0560: cannot use address type "other" with with user command
Bram Moolenaar <Bram@vim.org>
parents: 13101
diff changeset
257 args one two three
39728d503e47 patch 8.1.0560: cannot use address type "other" with with user command
Bram Moolenaar <Bram@vim.org>
parents: 13101
diff changeset
258 %DoSomething
39728d503e47 patch 8.1.0560: cannot use address type "other" with with user command
Bram Moolenaar <Bram@vim.org>
parents: 13101
diff changeset
259 call assert_equal(1, g:a1)
39728d503e47 patch 8.1.0560: cannot use address type "other" with with user command
Bram Moolenaar <Bram@vim.org>
parents: 13101
diff changeset
260 call assert_equal(3, g:a2)
39728d503e47 patch 8.1.0560: cannot use address type "other" with with user command
Bram Moolenaar <Bram@vim.org>
parents: 13101
diff changeset
261
39728d503e47 patch 8.1.0560: cannot use address type "other" with with user command
Bram Moolenaar <Bram@vim.org>
parents: 13101
diff changeset
262 command! -addr=buffers DoSomething let g:a1 = <line1> | let g:a2 = <line2>
39728d503e47 patch 8.1.0560: cannot use address type "other" with with user command
Bram Moolenaar <Bram@vim.org>
parents: 13101
diff changeset
263 %DoSomething
39728d503e47 patch 8.1.0560: cannot use address type "other" with with user command
Bram Moolenaar <Bram@vim.org>
parents: 13101
diff changeset
264 for low in range(1, bufnr('$'))
39728d503e47 patch 8.1.0560: cannot use address type "other" with with user command
Bram Moolenaar <Bram@vim.org>
parents: 13101
diff changeset
265 if buflisted(low)
39728d503e47 patch 8.1.0560: cannot use address type "other" with with user command
Bram Moolenaar <Bram@vim.org>
parents: 13101
diff changeset
266 break
39728d503e47 patch 8.1.0560: cannot use address type "other" with with user command
Bram Moolenaar <Bram@vim.org>
parents: 13101
diff changeset
267 endif
39728d503e47 patch 8.1.0560: cannot use address type "other" with with user command
Bram Moolenaar <Bram@vim.org>
parents: 13101
diff changeset
268 endfor
39728d503e47 patch 8.1.0560: cannot use address type "other" with with user command
Bram Moolenaar <Bram@vim.org>
parents: 13101
diff changeset
269 call assert_equal(low, g:a1)
39728d503e47 patch 8.1.0560: cannot use address type "other" with with user command
Bram Moolenaar <Bram@vim.org>
parents: 13101
diff changeset
270 call assert_equal(bufnr('$'), g:a2)
39728d503e47 patch 8.1.0560: cannot use address type "other" with with user command
Bram Moolenaar <Bram@vim.org>
parents: 13101
diff changeset
271
39728d503e47 patch 8.1.0560: cannot use address type "other" with with user command
Bram Moolenaar <Bram@vim.org>
parents: 13101
diff changeset
272 command! -addr=loaded_buffers DoSomething let g:a1 = <line1> | let g:a2 = <line2>
39728d503e47 patch 8.1.0560: cannot use address type "other" with with user command
Bram Moolenaar <Bram@vim.org>
parents: 13101
diff changeset
273 %DoSomething
39728d503e47 patch 8.1.0560: cannot use address type "other" with with user command
Bram Moolenaar <Bram@vim.org>
parents: 13101
diff changeset
274 for low in range(1, bufnr('$'))
39728d503e47 patch 8.1.0560: cannot use address type "other" with with user command
Bram Moolenaar <Bram@vim.org>
parents: 13101
diff changeset
275 if bufloaded(low)
39728d503e47 patch 8.1.0560: cannot use address type "other" with with user command
Bram Moolenaar <Bram@vim.org>
parents: 13101
diff changeset
276 break
39728d503e47 patch 8.1.0560: cannot use address type "other" with with user command
Bram Moolenaar <Bram@vim.org>
parents: 13101
diff changeset
277 endif
39728d503e47 patch 8.1.0560: cannot use address type "other" with with user command
Bram Moolenaar <Bram@vim.org>
parents: 13101
diff changeset
278 endfor
39728d503e47 patch 8.1.0560: cannot use address type "other" with with user command
Bram Moolenaar <Bram@vim.org>
parents: 13101
diff changeset
279 call assert_equal(low, g:a1)
39728d503e47 patch 8.1.0560: cannot use address type "other" with with user command
Bram Moolenaar <Bram@vim.org>
parents: 13101
diff changeset
280 for up in range(bufnr('$'), 1, -1)
39728d503e47 patch 8.1.0560: cannot use address type "other" with with user command
Bram Moolenaar <Bram@vim.org>
parents: 13101
diff changeset
281 if bufloaded(up)
39728d503e47 patch 8.1.0560: cannot use address type "other" with with user command
Bram Moolenaar <Bram@vim.org>
parents: 13101
diff changeset
282 break
39728d503e47 patch 8.1.0560: cannot use address type "other" with with user command
Bram Moolenaar <Bram@vim.org>
parents: 13101
diff changeset
283 endif
39728d503e47 patch 8.1.0560: cannot use address type "other" with with user command
Bram Moolenaar <Bram@vim.org>
parents: 13101
diff changeset
284 endfor
39728d503e47 patch 8.1.0560: cannot use address type "other" with with user command
Bram Moolenaar <Bram@vim.org>
parents: 13101
diff changeset
285 call assert_equal(up, g:a2)
39728d503e47 patch 8.1.0560: cannot use address type "other" with with user command
Bram Moolenaar <Bram@vim.org>
parents: 13101
diff changeset
286
39728d503e47 patch 8.1.0560: cannot use address type "other" with with user command
Bram Moolenaar <Bram@vim.org>
parents: 13101
diff changeset
287 command! -addr=windows DoSomething let g:a1 = <line1> | let g:a2 = <line2>
39728d503e47 patch 8.1.0560: cannot use address type "other" with with user command
Bram Moolenaar <Bram@vim.org>
parents: 13101
diff changeset
288 new
39728d503e47 patch 8.1.0560: cannot use address type "other" with with user command
Bram Moolenaar <Bram@vim.org>
parents: 13101
diff changeset
289 %DoSomething
39728d503e47 patch 8.1.0560: cannot use address type "other" with with user command
Bram Moolenaar <Bram@vim.org>
parents: 13101
diff changeset
290 call assert_equal(1, g:a1)
39728d503e47 patch 8.1.0560: cannot use address type "other" with with user command
Bram Moolenaar <Bram@vim.org>
parents: 13101
diff changeset
291 call assert_equal(winnr('$'), g:a2)
39728d503e47 patch 8.1.0560: cannot use address type "other" with with user command
Bram Moolenaar <Bram@vim.org>
parents: 13101
diff changeset
292 bwipe
39728d503e47 patch 8.1.0560: cannot use address type "other" with with user command
Bram Moolenaar <Bram@vim.org>
parents: 13101
diff changeset
293
39728d503e47 patch 8.1.0560: cannot use address type "other" with with user command
Bram Moolenaar <Bram@vim.org>
parents: 13101
diff changeset
294 command! -addr=tabs DoSomething let g:a1 = <line1> | let g:a2 = <line2>
39728d503e47 patch 8.1.0560: cannot use address type "other" with with user command
Bram Moolenaar <Bram@vim.org>
parents: 13101
diff changeset
295 tabnew
39728d503e47 patch 8.1.0560: cannot use address type "other" with with user command
Bram Moolenaar <Bram@vim.org>
parents: 13101
diff changeset
296 %DoSomething
39728d503e47 patch 8.1.0560: cannot use address type "other" with with user command
Bram Moolenaar <Bram@vim.org>
parents: 13101
diff changeset
297 call assert_equal(1, g:a1)
39728d503e47 patch 8.1.0560: cannot use address type "other" with with user command
Bram Moolenaar <Bram@vim.org>
parents: 13101
diff changeset
298 call assert_equal(len(gettabinfo()), g:a2)
39728d503e47 patch 8.1.0560: cannot use address type "other" with with user command
Bram Moolenaar <Bram@vim.org>
parents: 13101
diff changeset
299 bwipe
39728d503e47 patch 8.1.0560: cannot use address type "other" with with user command
Bram Moolenaar <Bram@vim.org>
parents: 13101
diff changeset
300
39728d503e47 patch 8.1.0560: cannot use address type "other" with with user command
Bram Moolenaar <Bram@vim.org>
parents: 13101
diff changeset
301 command! -addr=other DoSomething echo 'nothing'
39728d503e47 patch 8.1.0560: cannot use address type "other" with with user command
Bram Moolenaar <Bram@vim.org>
parents: 13101
diff changeset
302 DoSomething
39728d503e47 patch 8.1.0560: cannot use address type "other" with with user command
Bram Moolenaar <Bram@vim.org>
parents: 13101
diff changeset
303 call assert_fails('%DoSomething')
39728d503e47 patch 8.1.0560: cannot use address type "other" with with user command
Bram Moolenaar <Bram@vim.org>
parents: 13101
diff changeset
304
39728d503e47 patch 8.1.0560: cannot use address type "other" with with user command
Bram Moolenaar <Bram@vim.org>
parents: 13101
diff changeset
305 delcommand DoSomething
39728d503e47 patch 8.1.0560: cannot use address type "other" with with user command
Bram Moolenaar <Bram@vim.org>
parents: 13101
diff changeset
306 endfunc
16403
250420b35b10 patch 8.1.1206: user command parsing and listing not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 15125
diff changeset
307
250420b35b10 patch 8.1.1206: user command parsing and listing not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 15125
diff changeset
308 func Test_command_list()
250420b35b10 patch 8.1.1206: user command parsing and listing not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 15125
diff changeset
309 command! DoCmd :
250420b35b10 patch 8.1.1206: user command parsing and listing not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 15125
diff changeset
310 call assert_equal("\n Name Args Address Complete Definition"
250420b35b10 patch 8.1.1206: user command parsing and listing not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 15125
diff changeset
311 \ .. "\n DoCmd 0 :",
250420b35b10 patch 8.1.1206: user command parsing and listing not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 15125
diff changeset
312 \ execute('command DoCmd'))
250420b35b10 patch 8.1.1206: user command parsing and listing not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 15125
diff changeset
313
250420b35b10 patch 8.1.1206: user command parsing and listing not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 15125
diff changeset
314 " Test with various -range= and -count= argument values.
250420b35b10 patch 8.1.1206: user command parsing and listing not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 15125
diff changeset
315 command! -range DoCmd :
250420b35b10 patch 8.1.1206: user command parsing and listing not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 15125
diff changeset
316 call assert_equal("\n Name Args Address Complete Definition"
250420b35b10 patch 8.1.1206: user command parsing and listing not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 15125
diff changeset
317 \ .. "\n DoCmd 0 . :",
250420b35b10 patch 8.1.1206: user command parsing and listing not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 15125
diff changeset
318 \ execute('command DoCmd'))
250420b35b10 patch 8.1.1206: user command parsing and listing not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 15125
diff changeset
319 command! -range=% DoCmd :
250420b35b10 patch 8.1.1206: user command parsing and listing not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 15125
diff changeset
320 call assert_equal("\n Name Args Address Complete Definition"
250420b35b10 patch 8.1.1206: user command parsing and listing not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 15125
diff changeset
321 \ .. "\n DoCmd 0 % :",
250420b35b10 patch 8.1.1206: user command parsing and listing not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 15125
diff changeset
322 \ execute('command! DoCmd'))
250420b35b10 patch 8.1.1206: user command parsing and listing not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 15125
diff changeset
323 command! -range=2 DoCmd :
250420b35b10 patch 8.1.1206: user command parsing and listing not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 15125
diff changeset
324 call assert_equal("\n Name Args Address Complete Definition"
250420b35b10 patch 8.1.1206: user command parsing and listing not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 15125
diff changeset
325 \ .. "\n DoCmd 0 2 :",
250420b35b10 patch 8.1.1206: user command parsing and listing not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 15125
diff changeset
326 \ execute('command DoCmd'))
250420b35b10 patch 8.1.1206: user command parsing and listing not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 15125
diff changeset
327 command! -count=2 DoCmd :
250420b35b10 patch 8.1.1206: user command parsing and listing not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 15125
diff changeset
328 call assert_equal("\n Name Args Address Complete Definition"
250420b35b10 patch 8.1.1206: user command parsing and listing not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 15125
diff changeset
329 \ .. "\n DoCmd 0 2c :",
250420b35b10 patch 8.1.1206: user command parsing and listing not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 15125
diff changeset
330 \ execute('command DoCmd'))
250420b35b10 patch 8.1.1206: user command parsing and listing not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 15125
diff changeset
331
250420b35b10 patch 8.1.1206: user command parsing and listing not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 15125
diff changeset
332 " Test with various -addr= argument values.
250420b35b10 patch 8.1.1206: user command parsing and listing not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 15125
diff changeset
333 command! -addr=lines DoCmd :
250420b35b10 patch 8.1.1206: user command parsing and listing not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 15125
diff changeset
334 call assert_equal("\n Name Args Address Complete Definition"
250420b35b10 patch 8.1.1206: user command parsing and listing not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 15125
diff changeset
335 \ .. "\n DoCmd 0 . :",
250420b35b10 patch 8.1.1206: user command parsing and listing not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 15125
diff changeset
336 \ execute('command DoCmd'))
250420b35b10 patch 8.1.1206: user command parsing and listing not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 15125
diff changeset
337 command! -addr=arguments DoCmd :
250420b35b10 patch 8.1.1206: user command parsing and listing not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 15125
diff changeset
338 call assert_equal("\n Name Args Address Complete Definition"
250420b35b10 patch 8.1.1206: user command parsing and listing not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 15125
diff changeset
339 \ .. "\n DoCmd 0 . arg :",
250420b35b10 patch 8.1.1206: user command parsing and listing not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 15125
diff changeset
340 \ execute('command DoCmd'))
250420b35b10 patch 8.1.1206: user command parsing and listing not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 15125
diff changeset
341 command! -addr=buffers DoCmd :
250420b35b10 patch 8.1.1206: user command parsing and listing not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 15125
diff changeset
342 call assert_equal("\n Name Args Address Complete Definition"
250420b35b10 patch 8.1.1206: user command parsing and listing not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 15125
diff changeset
343 \ .. "\n DoCmd 0 . buf :",
250420b35b10 patch 8.1.1206: user command parsing and listing not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 15125
diff changeset
344 \ execute('command DoCmd'))
250420b35b10 patch 8.1.1206: user command parsing and listing not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 15125
diff changeset
345 command! -addr=loaded_buffers DoCmd :
250420b35b10 patch 8.1.1206: user command parsing and listing not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 15125
diff changeset
346 call assert_equal("\n Name Args Address Complete Definition"
250420b35b10 patch 8.1.1206: user command parsing and listing not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 15125
diff changeset
347 \ .. "\n DoCmd 0 . load :",
250420b35b10 patch 8.1.1206: user command parsing and listing not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 15125
diff changeset
348 \ execute('command DoCmd'))
250420b35b10 patch 8.1.1206: user command parsing and listing not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 15125
diff changeset
349 command! -addr=windows DoCmd :
250420b35b10 patch 8.1.1206: user command parsing and listing not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 15125
diff changeset
350 call assert_equal("\n Name Args Address Complete Definition"
250420b35b10 patch 8.1.1206: user command parsing and listing not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 15125
diff changeset
351 \ .. "\n DoCmd 0 . win :",
250420b35b10 patch 8.1.1206: user command parsing and listing not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 15125
diff changeset
352 \ execute('command DoCmd'))
250420b35b10 patch 8.1.1206: user command parsing and listing not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 15125
diff changeset
353 command! -addr=tabs DoCmd :
250420b35b10 patch 8.1.1206: user command parsing and listing not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 15125
diff changeset
354 call assert_equal("\n Name Args Address Complete Definition"
250420b35b10 patch 8.1.1206: user command parsing and listing not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 15125
diff changeset
355 \ .. "\n DoCmd 0 . tab :",
250420b35b10 patch 8.1.1206: user command parsing and listing not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 15125
diff changeset
356 \ execute('command DoCmd'))
250420b35b10 patch 8.1.1206: user command parsing and listing not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 15125
diff changeset
357 command! -addr=other DoCmd :
250420b35b10 patch 8.1.1206: user command parsing and listing not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 15125
diff changeset
358 call assert_equal("\n Name Args Address Complete Definition"
250420b35b10 patch 8.1.1206: user command parsing and listing not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 15125
diff changeset
359 \ .. "\n DoCmd 0 . ? :",
250420b35b10 patch 8.1.1206: user command parsing and listing not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 15125
diff changeset
360 \ execute('command DoCmd'))
250420b35b10 patch 8.1.1206: user command parsing and listing not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 15125
diff changeset
361
250420b35b10 patch 8.1.1206: user command parsing and listing not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 15125
diff changeset
362 " Test with various -complete= argument values (non-exhaustive list)
250420b35b10 patch 8.1.1206: user command parsing and listing not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 15125
diff changeset
363 command! -complete=arglist DoCmd :
250420b35b10 patch 8.1.1206: user command parsing and listing not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 15125
diff changeset
364 call assert_equal("\n Name Args Address Complete Definition"
250420b35b10 patch 8.1.1206: user command parsing and listing not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 15125
diff changeset
365 \ .. "\n DoCmd 0 arglist :",
250420b35b10 patch 8.1.1206: user command parsing and listing not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 15125
diff changeset
366 \ execute('command DoCmd'))
250420b35b10 patch 8.1.1206: user command parsing and listing not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 15125
diff changeset
367 command! -complete=augroup DoCmd :
250420b35b10 patch 8.1.1206: user command parsing and listing not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 15125
diff changeset
368 call assert_equal("\n Name Args Address Complete Definition"
250420b35b10 patch 8.1.1206: user command parsing and listing not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 15125
diff changeset
369 \ .. "\n DoCmd 0 augroup :",
250420b35b10 patch 8.1.1206: user command parsing and listing not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 15125
diff changeset
370 \ execute('command DoCmd'))
250420b35b10 patch 8.1.1206: user command parsing and listing not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 15125
diff changeset
371 command! -complete=custom,CustomComplete DoCmd :
250420b35b10 patch 8.1.1206: user command parsing and listing not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 15125
diff changeset
372 call assert_equal("\n Name Args Address Complete Definition"
250420b35b10 patch 8.1.1206: user command parsing and listing not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 15125
diff changeset
373 \ .. "\n DoCmd 0 custom :",
250420b35b10 patch 8.1.1206: user command parsing and listing not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 15125
diff changeset
374 \ execute('command DoCmd'))
250420b35b10 patch 8.1.1206: user command parsing and listing not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 15125
diff changeset
375 command! -complete=customlist,CustomComplete DoCmd :
250420b35b10 patch 8.1.1206: user command parsing and listing not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 15125
diff changeset
376 call assert_equal("\n Name Args Address Complete Definition"
250420b35b10 patch 8.1.1206: user command parsing and listing not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 15125
diff changeset
377 \ .. "\n DoCmd 0 customlist :",
250420b35b10 patch 8.1.1206: user command parsing and listing not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 15125
diff changeset
378 \ execute('command DoCmd'))
250420b35b10 patch 8.1.1206: user command parsing and listing not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 15125
diff changeset
379
250420b35b10 patch 8.1.1206: user command parsing and listing not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 15125
diff changeset
380 " Test with various -narg= argument values.
250420b35b10 patch 8.1.1206: user command parsing and listing not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 15125
diff changeset
381 command! -nargs=0 DoCmd :
250420b35b10 patch 8.1.1206: user command parsing and listing not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 15125
diff changeset
382 call assert_equal("\n Name Args Address Complete Definition"
250420b35b10 patch 8.1.1206: user command parsing and listing not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 15125
diff changeset
383 \ .. "\n DoCmd 0 :",
250420b35b10 patch 8.1.1206: user command parsing and listing not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 15125
diff changeset
384 \ execute('command DoCmd'))
250420b35b10 patch 8.1.1206: user command parsing and listing not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 15125
diff changeset
385 command! -nargs=1 DoCmd :
250420b35b10 patch 8.1.1206: user command parsing and listing not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 15125
diff changeset
386 call assert_equal("\n Name Args Address Complete Definition"
250420b35b10 patch 8.1.1206: user command parsing and listing not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 15125
diff changeset
387 \ .. "\n DoCmd 1 :",
250420b35b10 patch 8.1.1206: user command parsing and listing not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 15125
diff changeset
388 \ execute('command DoCmd'))
250420b35b10 patch 8.1.1206: user command parsing and listing not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 15125
diff changeset
389 command! -nargs=* DoCmd :
250420b35b10 patch 8.1.1206: user command parsing and listing not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 15125
diff changeset
390 call assert_equal("\n Name Args Address Complete Definition"
250420b35b10 patch 8.1.1206: user command parsing and listing not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 15125
diff changeset
391 \ .. "\n DoCmd * :",
250420b35b10 patch 8.1.1206: user command parsing and listing not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 15125
diff changeset
392 \ execute('command DoCmd'))
250420b35b10 patch 8.1.1206: user command parsing and listing not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 15125
diff changeset
393 command! -nargs=? DoCmd :
250420b35b10 patch 8.1.1206: user command parsing and listing not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 15125
diff changeset
394 call assert_equal("\n Name Args Address Complete Definition"
250420b35b10 patch 8.1.1206: user command parsing and listing not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 15125
diff changeset
395 \ .. "\n DoCmd ? :",
250420b35b10 patch 8.1.1206: user command parsing and listing not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 15125
diff changeset
396 \ execute('command DoCmd'))
250420b35b10 patch 8.1.1206: user command parsing and listing not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 15125
diff changeset
397 command! -nargs=+ DoCmd :
250420b35b10 patch 8.1.1206: user command parsing and listing not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 15125
diff changeset
398 call assert_equal("\n Name Args Address Complete Definition"
250420b35b10 patch 8.1.1206: user command parsing and listing not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 15125
diff changeset
399 \ .. "\n DoCmd + :",
250420b35b10 patch 8.1.1206: user command parsing and listing not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 15125
diff changeset
400 \ execute('command DoCmd'))
250420b35b10 patch 8.1.1206: user command parsing and listing not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 15125
diff changeset
401
250420b35b10 patch 8.1.1206: user command parsing and listing not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 15125
diff changeset
402 " Test with other arguments.
250420b35b10 patch 8.1.1206: user command parsing and listing not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 15125
diff changeset
403 command! -bang DoCmd :
250420b35b10 patch 8.1.1206: user command parsing and listing not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 15125
diff changeset
404 call assert_equal("\n Name Args Address Complete Definition"
250420b35b10 patch 8.1.1206: user command parsing and listing not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 15125
diff changeset
405 \ .. "\n! DoCmd 0 :",
250420b35b10 patch 8.1.1206: user command parsing and listing not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 15125
diff changeset
406 \ execute('command DoCmd'))
250420b35b10 patch 8.1.1206: user command parsing and listing not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 15125
diff changeset
407 command! -bar DoCmd :
250420b35b10 patch 8.1.1206: user command parsing and listing not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 15125
diff changeset
408 call assert_equal("\n Name Args Address Complete Definition"
250420b35b10 patch 8.1.1206: user command parsing and listing not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 15125
diff changeset
409 \ .. "\n| DoCmd 0 :",
250420b35b10 patch 8.1.1206: user command parsing and listing not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 15125
diff changeset
410 \ execute('command DoCmd'))
250420b35b10 patch 8.1.1206: user command parsing and listing not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 15125
diff changeset
411 command! -register DoCmd :
250420b35b10 patch 8.1.1206: user command parsing and listing not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 15125
diff changeset
412 call assert_equal("\n Name Args Address Complete Definition"
250420b35b10 patch 8.1.1206: user command parsing and listing not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 15125
diff changeset
413 \ .. "\n\" DoCmd 0 :",
250420b35b10 patch 8.1.1206: user command parsing and listing not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 15125
diff changeset
414 \ execute('command DoCmd'))
250420b35b10 patch 8.1.1206: user command parsing and listing not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 15125
diff changeset
415 command! -buffer DoCmd :
250420b35b10 patch 8.1.1206: user command parsing and listing not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 15125
diff changeset
416 call assert_equal("\n Name Args Address Complete Definition"
250420b35b10 patch 8.1.1206: user command parsing and listing not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 15125
diff changeset
417 \ .. "\nb DoCmd 0 :"
250420b35b10 patch 8.1.1206: user command parsing and listing not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 15125
diff changeset
418 \ .. "\n\" DoCmd 0 :",
250420b35b10 patch 8.1.1206: user command parsing and listing not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 15125
diff changeset
419 \ execute('command DoCmd'))
250420b35b10 patch 8.1.1206: user command parsing and listing not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 15125
diff changeset
420 comclear
250420b35b10 patch 8.1.1206: user command parsing and listing not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 15125
diff changeset
421
250420b35b10 patch 8.1.1206: user command parsing and listing not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 15125
diff changeset
422 " Test with many args.
250420b35b10 patch 8.1.1206: user command parsing and listing not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 15125
diff changeset
423 command! -bang -bar -register -buffer -nargs=+ -complete=environment -addr=windows -count=3 DoCmd :
250420b35b10 patch 8.1.1206: user command parsing and listing not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 15125
diff changeset
424 call assert_equal("\n Name Args Address Complete Definition"
250420b35b10 patch 8.1.1206: user command parsing and listing not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 15125
diff changeset
425 \ .. "\n!\"b|DoCmd + 3c win environment :",
250420b35b10 patch 8.1.1206: user command parsing and listing not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 15125
diff changeset
426 \ execute('command DoCmd'))
250420b35b10 patch 8.1.1206: user command parsing and listing not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 15125
diff changeset
427 comclear
250420b35b10 patch 8.1.1206: user command parsing and listing not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 15125
diff changeset
428
250420b35b10 patch 8.1.1206: user command parsing and listing not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 15125
diff changeset
429 " Test with special characters in command definition.
250420b35b10 patch 8.1.1206: user command parsing and listing not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 15125
diff changeset
430 command! DoCmd :<cr><tab><c-d>
250420b35b10 patch 8.1.1206: user command parsing and listing not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 15125
diff changeset
431 call assert_equal("\n Name Args Address Complete Definition"
250420b35b10 patch 8.1.1206: user command parsing and listing not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 15125
diff changeset
432 \ .. "\n DoCmd 0 :<CR><Tab><C-D>",
250420b35b10 patch 8.1.1206: user command parsing and listing not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 15125
diff changeset
433 \ execute('command DoCmd'))
250420b35b10 patch 8.1.1206: user command parsing and listing not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 15125
diff changeset
434
250420b35b10 patch 8.1.1206: user command parsing and listing not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 15125
diff changeset
435 " Test output in verbose mode.
250420b35b10 patch 8.1.1206: user command parsing and listing not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 15125
diff changeset
436 command! DoCmd :
250420b35b10 patch 8.1.1206: user command parsing and listing not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 15125
diff changeset
437 call assert_match("^\n"
250420b35b10 patch 8.1.1206: user command parsing and listing not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 15125
diff changeset
438 \ .. " Name Args Address Complete Definition\n"
250420b35b10 patch 8.1.1206: user command parsing and listing not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 15125
diff changeset
439 \ .. " DoCmd 0 :\n"
250420b35b10 patch 8.1.1206: user command parsing and listing not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 15125
diff changeset
440 \ .. "\tLast set from .*/test_usercommands.vim line \\d\\+$",
250420b35b10 patch 8.1.1206: user command parsing and listing not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 15125
diff changeset
441 \ execute('verbose command DoCmd'))
250420b35b10 patch 8.1.1206: user command parsing and listing not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 15125
diff changeset
442
250420b35b10 patch 8.1.1206: user command parsing and listing not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 15125
diff changeset
443 comclear
250420b35b10 patch 8.1.1206: user command parsing and listing not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 15125
diff changeset
444 call assert_equal("\nNo user-defined commands found", execute(':command Xxx'))
250420b35b10 patch 8.1.1206: user command parsing and listing not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 15125
diff changeset
445 call assert_equal("\nNo user-defined commands found", execute('command'))
250420b35b10 patch 8.1.1206: user command parsing and listing not properly tested
Bram Moolenaar <Bram@vim.org>
parents: 15125
diff changeset
446 endfunc