@@ -73,6 +73,97 @@ function Test_cmdmods()
7373 unlet g: mods
7474endfunction
7575
76+ func SaveCmdArgs (... )
77+ let g: args = a: 000
78+ endfunc
79+
80+ func Test_f_args ()
81+ command -nargs =* TestFArgs call SaveCmdArgs (<f-args> )
82+
83+ TestFArgs
84+ call assert_equal ([], g: args )
85+
86+ TestFArgs one two three
87+ call assert_equal ([' one' , ' two' , ' three' ], g: args )
88+
89+ TestFArgs one\\ two three
90+ call assert_equal ([' one\two' , ' three' ], g: args )
91+
92+ TestFArgs one\ two three
93+ call assert_equal ([' one two' , ' three' ], g: args )
94+
95+ TestFArgs one\" two three
96+ call assert_equal ([' one\"two' , ' three' ], g: args )
97+
98+ delcommand TestFArgs
99+ endfunc
100+
101+ func Test_q_args ()
102+ command -nargs =* TestQArgs call SaveCmdArgs (<q-args> )
103+
104+ TestQArgs
105+ call assert_equal ([' ' ], g: args )
106+
107+ TestQArgs one two three
108+ call assert_equal ([' one two three' ], g: args )
109+
110+ TestQArgs one\\ two three
111+ call assert_equal ([' one\\two three' ], g: args )
112+
113+ TestQArgs one\ two three
114+ call assert_equal ([' one\ two three' ], g: args )
115+
116+ TestQArgs one\" two three
117+ call assert_equal ([' one\"two three' ], g: args )
118+
119+ delcommand TestQArgs
120+ endfunc
121+
122+ func Test_reg_arg ()
123+ command -nargs =* - reg TestRegArg call SaveCmdArgs (" <reg>" , " <register>" )
124+
125+ TestRegArg
126+ call assert_equal ([' ' , ' ' ], g: args )
127+
128+ TestRegArg x
129+ call assert_equal ([' x' , ' x' ], g: args )
130+
131+ delcommand TestRegArg
132+ endfunc
133+
134+ func Test_no_arg ()
135+ command -nargs =* TestNoArg call SaveCmdArgs (" <args>" , " <>" , " <x>" , " <lt>" )
136+
137+ TestNoArg
138+ call assert_equal ([' ' , ' <>' , ' <x>' , ' <' ], g: args )
139+
140+ TestNoArg one
141+ call assert_equal ([' one' , ' <>' , ' <x>' , ' <' ], g: args )
142+
143+ delcommand TestNoArg
144+ endfunc
145+
146+ func Test_range_arg ()
147+ command - range TestRangeArg call SaveCmdArgs (<range> , <line1> , <line2> )
148+ new
149+ call setline (1 , range (100 ))
150+ let lnum = line (' .' )
151+
152+ TestRangeArg
153+ call assert_equal ([0 , lnum, lnum], g: args )
154+
155+ 99 TestRangeArg
156+ call assert_equal ([1 , 99 , 99 ], g: args )
157+
158+ 88 ,99 TestRangeArg
159+ call assert_equal ([2 , 88 , 99 ], g: args )
160+
161+ call assert_fails (' 102TestRangeArg' , ' E16:' )
162+
163+ bwipe!
164+ delcommand TestRangeArg
165+ endfunc
166+
76167func Test_Ambiguous ()
77168 command Doit let g: didit = ' yes'
78169 command Dothat let g: didthat = ' also'
@@ -88,6 +179,8 @@ func Test_Ambiguous()
88179 Do
89180 call assert_equal (' also' , g: didthat )
90181 delcommand Dothat
182+
183+ call assert_fails (" \x4e i\041 " , ' you demand a ' )
91184endfunc
92185
93186func Test_redefine_on_reload ()
@@ -139,6 +232,7 @@ func Test_CmdErrors()
139232 call assert_fails (' com! - DoCmd :' , ' E175:' )
140233 call assert_fails (' com! -xxx DoCmd :' , ' E181:' )
141234 call assert_fails (' com! -addr DoCmd :' , ' E179:' )
235+ call assert_fails (' com! -addr=asdf DoCmd :' , ' E180:' )
142236 call assert_fails (' com! -complete DoCmd :' , ' E179:' )
143237 call assert_fails (' com! -complete=xxx DoCmd :' , ' E180:' )
144238 call assert_fails (' com! -complete=custom DoCmd :' , ' E467:' )
0 commit comments