Skip to content

Commit 99dbe29

Browse files
committed
patch 7.4.1132
Problem: Old style tests for the argument list. Solution: Add more new style tests. (Yegappan Lakshmanan)
1 parent b20e334 commit 99dbe29

8 files changed

Lines changed: 204 additions & 97 deletions

File tree

src/Makefile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1933,8 +1933,6 @@ unittest unittests: $(UNITTEST_TARGETS)
19331933

19341934
# Run individual OLD style test, assuming that Vim was already compiled.
19351935
test1 \
1936-
test_argument_0count \
1937-
test_argument_count \
19381936
test_autocmd_option \
19391937
test_autoformat_join \
19401938
test_breakindent \
@@ -1997,6 +1995,7 @@ test_arglist \
19971995
test_sort \
19981996
test_undolevels \
19991997
test_unlet \
1998+
test_viminfo \
20001999
test_viml \
20012000
test_alot:
20022001
cd testdir; rm -f [email protected] test.log messages; $(MAKE) -f Makefile [email protected] VIMPROG=../$(VIMTARGET) $(GUI_TESTARG) SCRIPTSOURCE=../$(SCRIPTSOURCE)

src/testdir/Make_all.mak

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,6 @@ SCRIPTS_ALL = \
8989
test106.out \
9090
test107.out \
9191
test108.out \
92-
test_argument_0count.out \
93-
test_argument_count.out \
9492
test_autocmd_option.out \
9593
test_autoformat_join.out \
9694
test_breakindent.out \

src/testdir/test_arglist.vim

Lines changed: 201 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,3 +72,204 @@ func Assert_argc(l)
7272
let i += 1
7373
endwhile
7474
endfunc
75+
76+
" Test for [count]argument and [count]argdelete commands
77+
" Ported from the test_argument_count.in test script
78+
function Test_argument()
79+
" Clean the argument list
80+
arga a | %argd
81+
82+
let save_hidden = &hidden
83+
set hidden
84+
85+
let g:buffers = []
86+
augroup TEST
87+
au BufEnter * call add(buffers, expand('%:t'))
88+
augroup END
89+
90+
argadd a b c d
91+
$argu
92+
$-argu
93+
-argu
94+
1argu
95+
+2argu
96+
97+
augroup TEST
98+
au!
99+
augroup END
100+
101+
call assert_equal(['d', 'c', 'b', 'a', 'c'], g:buffers)
102+
103+
redir => result
104+
ar
105+
redir END
106+
call assert_true(result =~# 'a b \[c] d')
107+
108+
.argd
109+
call assert_equal(['a', 'b', 'd'], argv())
110+
111+
-argd
112+
call assert_equal(['a', 'd'], argv())
113+
114+
$argd
115+
call assert_equal(['a'], argv())
116+
117+
1arga c
118+
1arga b
119+
$argu
120+
$arga x
121+
call assert_equal(['a', 'b', 'c', 'x'], argv())
122+
123+
0arga Y
124+
call assert_equal(['Y', 'a', 'b', 'c', 'x'], argv())
125+
126+
%argd
127+
call assert_equal([], argv())
128+
129+
arga a b c d e f
130+
2,$-argd
131+
call assert_equal(['a', 'f'], argv())
132+
133+
let &hidden = save_hidden
134+
135+
" Setting argument list should fail when the current buffer has unsaved
136+
" changes
137+
%argd
138+
enew!
139+
set modified
140+
call assert_fails('args x y z', 'E37:')
141+
args! x y z
142+
call assert_equal(['x', 'y', 'z'], argv())
143+
call assert_equal('x', expand('%:t'))
144+
145+
last | enew | argu
146+
call assert_equal('z', expand('%:t'))
147+
148+
%argdelete
149+
call assert_fails('argument', 'E163:')
150+
endfunction
151+
152+
" Test for 0argadd and 0argedit
153+
" Ported from the test_argument_0count.in test script
154+
function Test_zero_argadd()
155+
" Clean the argument list
156+
arga a | %argd
157+
158+
arga a b c d
159+
2argu
160+
0arga added
161+
call assert_equal(['added', 'a', 'b', 'c', 'd'], argv())
162+
163+
2argu
164+
arga third
165+
call assert_equal(['added', 'a', 'third', 'b', 'c', 'd'], argv())
166+
167+
%argd
168+
arga a b c d
169+
2argu
170+
0arge edited
171+
call assert_equal(['edited', 'a', 'b', 'c', 'd'], argv())
172+
173+
2argu
174+
arga third
175+
call assert_equal(['edited', 'a', 'third', 'b', 'c', 'd'], argv())
176+
endfunction
177+
178+
function Reset_arglist()
179+
args a | %argd
180+
endfunction
181+
182+
" Test for argc()
183+
function Test_argc()
184+
call Reset_arglist()
185+
call assert_equal(0, argc())
186+
argadd a b
187+
call assert_equal(2, argc())
188+
endfunction
189+
190+
" Test for arglistid()
191+
function Test_arglistid()
192+
call Reset_arglist()
193+
arga a b
194+
call assert_equal(0, arglistid())
195+
split
196+
arglocal
197+
call assert_equal(1, arglistid())
198+
tabnew | tabfirst
199+
call assert_equal(0, arglistid(2))
200+
call assert_equal(1, arglistid(1, 1))
201+
call assert_equal(0, arglistid(2, 1))
202+
call assert_equal(1, arglistid(1, 2))
203+
tabonly | only | enew!
204+
argglobal
205+
call assert_equal(0, arglistid())
206+
endfunction
207+
208+
" Test for argv()
209+
function Test_argv()
210+
call Reset_arglist()
211+
call assert_equal([], argv())
212+
call assert_equal("", argv(2))
213+
argadd a b c d
214+
call assert_equal('c', argv(2))
215+
endfunction
216+
217+
" Test for the :argedit command
218+
function Test_argedit()
219+
call Reset_arglist()
220+
argedit a
221+
call assert_equal(['a'], argv())
222+
call assert_equal('a', expand('%:t'))
223+
argedit b
224+
call assert_equal(['a', 'b'], argv())
225+
call assert_equal('b', expand('%:t'))
226+
argedit a
227+
call assert_equal(['a', 'b'], argv())
228+
call assert_equal('a', expand('%:t'))
229+
call assert_fails('argedit a b', 'E172:')
230+
argedit c
231+
call assert_equal(['a', 'c', 'b'], argv())
232+
0argedit x
233+
call assert_equal(['x', 'a', 'c', 'b'], argv())
234+
enew! | set modified
235+
call assert_fails('argedit y', 'E37:')
236+
argedit! y
237+
call assert_equal(['x', 'y', 'a', 'c', 'b'], argv())
238+
%argd
239+
endfunction
240+
241+
" Test for the :argdelete command
242+
function Test_argdelete()
243+
call Reset_arglist()
244+
args aa a aaa b bb
245+
argdelete a*
246+
call assert_equal(['b', 'bb'], argv())
247+
call assert_equal('aa', expand('%:t'))
248+
last
249+
argdelete %
250+
call assert_equal(['b'], argv())
251+
call assert_fails('argdelete', 'E471:')
252+
call assert_fails('1,100argdelete', 'E16:')
253+
%argd
254+
endfunction
255+
256+
" Tests for the :next, :prev, :first, :last, :rewind commands
257+
function Test_argpos()
258+
call Reset_arglist()
259+
args a b c d
260+
last
261+
call assert_equal(3, argidx())
262+
call assert_fails('next', 'E165:')
263+
prev
264+
call assert_equal(2, argidx())
265+
Next
266+
call assert_equal(1, argidx())
267+
first
268+
call assert_equal(0, argidx())
269+
call assert_fails('prev', 'E164:')
270+
3next
271+
call assert_equal(3, argidx())
272+
rewind
273+
call assert_equal(0, argidx())
274+
%argd
275+
endfunction

src/testdir/test_argument_0count.in

Lines changed: 0 additions & 28 deletions
This file was deleted.

src/testdir/test_argument_0count.ok

Lines changed: 0 additions & 5 deletions
This file was deleted.

src/testdir/test_argument_count.in

Lines changed: 0 additions & 47 deletions
This file was deleted.

src/testdir/test_argument_count.ok

Lines changed: 0 additions & 13 deletions
This file was deleted.

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -741,6 +741,8 @@ static char *(features[]) =
741741

742742
static int included_patches[] =
743743
{ /* Add new patch number below this line */
744+
/**/
745+
1132,
744746
/**/
745747
1131,
746748
/**/

0 commit comments

Comments
 (0)