forked from aniani/vim
patch 7.4.1132
Problem: Old style tests for the argument list. Solution: Add more new style tests. (Yegappan Lakshmanan)
This commit is contained in:
@@ -1933,8 +1933,6 @@ unittest unittests: $(UNITTEST_TARGETS)
|
|||||||
|
|
||||||
# Run individual OLD style test, assuming that Vim was already compiled.
|
# Run individual OLD style test, assuming that Vim was already compiled.
|
||||||
test1 \
|
test1 \
|
||||||
test_argument_0count \
|
|
||||||
test_argument_count \
|
|
||||||
test_autocmd_option \
|
test_autocmd_option \
|
||||||
test_autoformat_join \
|
test_autoformat_join \
|
||||||
test_breakindent \
|
test_breakindent \
|
||||||
@@ -1997,6 +1995,7 @@ test_arglist \
|
|||||||
test_sort \
|
test_sort \
|
||||||
test_undolevels \
|
test_undolevels \
|
||||||
test_unlet \
|
test_unlet \
|
||||||
|
test_viminfo \
|
||||||
test_viml \
|
test_viml \
|
||||||
test_alot:
|
test_alot:
|
||||||
cd testdir; rm -f $@.res test.log messages; $(MAKE) -f Makefile $@.res VIMPROG=../$(VIMTARGET) $(GUI_TESTARG) SCRIPTSOURCE=../$(SCRIPTSOURCE)
|
cd testdir; rm -f $@.res test.log messages; $(MAKE) -f Makefile $@.res VIMPROG=../$(VIMTARGET) $(GUI_TESTARG) SCRIPTSOURCE=../$(SCRIPTSOURCE)
|
||||||
|
|||||||
@@ -89,8 +89,6 @@ SCRIPTS_ALL = \
|
|||||||
test106.out \
|
test106.out \
|
||||||
test107.out \
|
test107.out \
|
||||||
test108.out \
|
test108.out \
|
||||||
test_argument_0count.out \
|
|
||||||
test_argument_count.out \
|
|
||||||
test_autocmd_option.out \
|
test_autocmd_option.out \
|
||||||
test_autoformat_join.out \
|
test_autoformat_join.out \
|
||||||
test_breakindent.out \
|
test_breakindent.out \
|
||||||
|
|||||||
@@ -72,3 +72,204 @@ func Assert_argc(l)
|
|||||||
let i += 1
|
let i += 1
|
||||||
endwhile
|
endwhile
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
" Test for [count]argument and [count]argdelete commands
|
||||||
|
" Ported from the test_argument_count.in test script
|
||||||
|
function Test_argument()
|
||||||
|
" Clean the argument list
|
||||||
|
arga a | %argd
|
||||||
|
|
||||||
|
let save_hidden = &hidden
|
||||||
|
set hidden
|
||||||
|
|
||||||
|
let g:buffers = []
|
||||||
|
augroup TEST
|
||||||
|
au BufEnter * call add(buffers, expand('%:t'))
|
||||||
|
augroup END
|
||||||
|
|
||||||
|
argadd a b c d
|
||||||
|
$argu
|
||||||
|
$-argu
|
||||||
|
-argu
|
||||||
|
1argu
|
||||||
|
+2argu
|
||||||
|
|
||||||
|
augroup TEST
|
||||||
|
au!
|
||||||
|
augroup END
|
||||||
|
|
||||||
|
call assert_equal(['d', 'c', 'b', 'a', 'c'], g:buffers)
|
||||||
|
|
||||||
|
redir => result
|
||||||
|
ar
|
||||||
|
redir END
|
||||||
|
call assert_true(result =~# 'a b \[c] d')
|
||||||
|
|
||||||
|
.argd
|
||||||
|
call assert_equal(['a', 'b', 'd'], argv())
|
||||||
|
|
||||||
|
-argd
|
||||||
|
call assert_equal(['a', 'd'], argv())
|
||||||
|
|
||||||
|
$argd
|
||||||
|
call assert_equal(['a'], argv())
|
||||||
|
|
||||||
|
1arga c
|
||||||
|
1arga b
|
||||||
|
$argu
|
||||||
|
$arga x
|
||||||
|
call assert_equal(['a', 'b', 'c', 'x'], argv())
|
||||||
|
|
||||||
|
0arga Y
|
||||||
|
call assert_equal(['Y', 'a', 'b', 'c', 'x'], argv())
|
||||||
|
|
||||||
|
%argd
|
||||||
|
call assert_equal([], argv())
|
||||||
|
|
||||||
|
arga a b c d e f
|
||||||
|
2,$-argd
|
||||||
|
call assert_equal(['a', 'f'], argv())
|
||||||
|
|
||||||
|
let &hidden = save_hidden
|
||||||
|
|
||||||
|
" Setting argument list should fail when the current buffer has unsaved
|
||||||
|
" changes
|
||||||
|
%argd
|
||||||
|
enew!
|
||||||
|
set modified
|
||||||
|
call assert_fails('args x y z', 'E37:')
|
||||||
|
args! x y z
|
||||||
|
call assert_equal(['x', 'y', 'z'], argv())
|
||||||
|
call assert_equal('x', expand('%:t'))
|
||||||
|
|
||||||
|
last | enew | argu
|
||||||
|
call assert_equal('z', expand('%:t'))
|
||||||
|
|
||||||
|
%argdelete
|
||||||
|
call assert_fails('argument', 'E163:')
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
" Test for 0argadd and 0argedit
|
||||||
|
" Ported from the test_argument_0count.in test script
|
||||||
|
function Test_zero_argadd()
|
||||||
|
" Clean the argument list
|
||||||
|
arga a | %argd
|
||||||
|
|
||||||
|
arga a b c d
|
||||||
|
2argu
|
||||||
|
0arga added
|
||||||
|
call assert_equal(['added', 'a', 'b', 'c', 'd'], argv())
|
||||||
|
|
||||||
|
2argu
|
||||||
|
arga third
|
||||||
|
call assert_equal(['added', 'a', 'third', 'b', 'c', 'd'], argv())
|
||||||
|
|
||||||
|
%argd
|
||||||
|
arga a b c d
|
||||||
|
2argu
|
||||||
|
0arge edited
|
||||||
|
call assert_equal(['edited', 'a', 'b', 'c', 'd'], argv())
|
||||||
|
|
||||||
|
2argu
|
||||||
|
arga third
|
||||||
|
call assert_equal(['edited', 'a', 'third', 'b', 'c', 'd'], argv())
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function Reset_arglist()
|
||||||
|
args a | %argd
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
" Test for argc()
|
||||||
|
function Test_argc()
|
||||||
|
call Reset_arglist()
|
||||||
|
call assert_equal(0, argc())
|
||||||
|
argadd a b
|
||||||
|
call assert_equal(2, argc())
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
" Test for arglistid()
|
||||||
|
function Test_arglistid()
|
||||||
|
call Reset_arglist()
|
||||||
|
arga a b
|
||||||
|
call assert_equal(0, arglistid())
|
||||||
|
split
|
||||||
|
arglocal
|
||||||
|
call assert_equal(1, arglistid())
|
||||||
|
tabnew | tabfirst
|
||||||
|
call assert_equal(0, arglistid(2))
|
||||||
|
call assert_equal(1, arglistid(1, 1))
|
||||||
|
call assert_equal(0, arglistid(2, 1))
|
||||||
|
call assert_equal(1, arglistid(1, 2))
|
||||||
|
tabonly | only | enew!
|
||||||
|
argglobal
|
||||||
|
call assert_equal(0, arglistid())
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
" Test for argv()
|
||||||
|
function Test_argv()
|
||||||
|
call Reset_arglist()
|
||||||
|
call assert_equal([], argv())
|
||||||
|
call assert_equal("", argv(2))
|
||||||
|
argadd a b c d
|
||||||
|
call assert_equal('c', argv(2))
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
" Test for the :argedit command
|
||||||
|
function Test_argedit()
|
||||||
|
call Reset_arglist()
|
||||||
|
argedit a
|
||||||
|
call assert_equal(['a'], argv())
|
||||||
|
call assert_equal('a', expand('%:t'))
|
||||||
|
argedit b
|
||||||
|
call assert_equal(['a', 'b'], argv())
|
||||||
|
call assert_equal('b', expand('%:t'))
|
||||||
|
argedit a
|
||||||
|
call assert_equal(['a', 'b'], argv())
|
||||||
|
call assert_equal('a', expand('%:t'))
|
||||||
|
call assert_fails('argedit a b', 'E172:')
|
||||||
|
argedit c
|
||||||
|
call assert_equal(['a', 'c', 'b'], argv())
|
||||||
|
0argedit x
|
||||||
|
call assert_equal(['x', 'a', 'c', 'b'], argv())
|
||||||
|
enew! | set modified
|
||||||
|
call assert_fails('argedit y', 'E37:')
|
||||||
|
argedit! y
|
||||||
|
call assert_equal(['x', 'y', 'a', 'c', 'b'], argv())
|
||||||
|
%argd
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
" Test for the :argdelete command
|
||||||
|
function Test_argdelete()
|
||||||
|
call Reset_arglist()
|
||||||
|
args aa a aaa b bb
|
||||||
|
argdelete a*
|
||||||
|
call assert_equal(['b', 'bb'], argv())
|
||||||
|
call assert_equal('aa', expand('%:t'))
|
||||||
|
last
|
||||||
|
argdelete %
|
||||||
|
call assert_equal(['b'], argv())
|
||||||
|
call assert_fails('argdelete', 'E471:')
|
||||||
|
call assert_fails('1,100argdelete', 'E16:')
|
||||||
|
%argd
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
" Tests for the :next, :prev, :first, :last, :rewind commands
|
||||||
|
function Test_argpos()
|
||||||
|
call Reset_arglist()
|
||||||
|
args a b c d
|
||||||
|
last
|
||||||
|
call assert_equal(3, argidx())
|
||||||
|
call assert_fails('next', 'E165:')
|
||||||
|
prev
|
||||||
|
call assert_equal(2, argidx())
|
||||||
|
Next
|
||||||
|
call assert_equal(1, argidx())
|
||||||
|
first
|
||||||
|
call assert_equal(0, argidx())
|
||||||
|
call assert_fails('prev', 'E164:')
|
||||||
|
3next
|
||||||
|
call assert_equal(3, argidx())
|
||||||
|
rewind
|
||||||
|
call assert_equal(0, argidx())
|
||||||
|
%argd
|
||||||
|
endfunction
|
||||||
|
|||||||
@@ -1,28 +0,0 @@
|
|||||||
Tests for :0argadd and :0argedit vim: set ft=vim :
|
|
||||||
|
|
||||||
STARTTEST
|
|
||||||
:so small.vim
|
|
||||||
:let arglists = []
|
|
||||||
:%argd
|
|
||||||
:arga a b c d
|
|
||||||
:2argu
|
|
||||||
:0arga added
|
|
||||||
:call add(arglists, argv())
|
|
||||||
:2argu
|
|
||||||
:arga third
|
|
||||||
:call add(arglists, argv())
|
|
||||||
:%argd
|
|
||||||
:arga a b c d
|
|
||||||
:2argu
|
|
||||||
:0arge edited
|
|
||||||
:call add(arglists, argv())
|
|
||||||
:2argu
|
|
||||||
:arga third
|
|
||||||
:call add(arglists, argv())
|
|
||||||
:e! test.out
|
|
||||||
:call append(0, map(copy(arglists), 'join(v:val, " ")'))
|
|
||||||
:w
|
|
||||||
:qa!
|
|
||||||
ENDTEST
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
added a b c d
|
|
||||||
added a third b c d
|
|
||||||
edited a b c d
|
|
||||||
edited a third b c d
|
|
||||||
|
|
||||||
@@ -1,47 +0,0 @@
|
|||||||
Tests for :[count]argument! and :[count]argdelete vim: set ft=vim :
|
|
||||||
|
|
||||||
STARTTEST
|
|
||||||
:so small.vim
|
|
||||||
:%argd
|
|
||||||
:argadd a b c d
|
|
||||||
:set hidden
|
|
||||||
:let buffers = []
|
|
||||||
:augroup TEST
|
|
||||||
:au BufEnter * call add(buffers, expand('%:t'))
|
|
||||||
:augroup END
|
|
||||||
:$argu
|
|
||||||
:$-argu
|
|
||||||
:-argu
|
|
||||||
:1argu
|
|
||||||
:+2argu
|
|
||||||
:augroup TEST
|
|
||||||
:au!
|
|
||||||
:augroup END
|
|
||||||
:let arglists = []
|
|
||||||
:.argd
|
|
||||||
:call add(arglists, argv())
|
|
||||||
:-argd
|
|
||||||
:call add(arglists, argv())
|
|
||||||
:$argd
|
|
||||||
:call add(arglists, argv())
|
|
||||||
:1arga c
|
|
||||||
:1arga b
|
|
||||||
:$argu
|
|
||||||
:$arga x
|
|
||||||
:call add(arglists, argv())
|
|
||||||
:0arga Y
|
|
||||||
:call add(arglists, argv())
|
|
||||||
:%argd
|
|
||||||
:call add(arglists, argv())
|
|
||||||
:arga a b c d e f
|
|
||||||
:2,$-argd
|
|
||||||
:call add(arglists, argv())
|
|
||||||
:e! test.out
|
|
||||||
:call append(0, buffers)
|
|
||||||
:let lnr = line('$')
|
|
||||||
:call append(lnr, map(copy(arglists), 'join(v:val, " ")'))
|
|
||||||
:w
|
|
||||||
:qa!
|
|
||||||
ENDTEST
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
d
|
|
||||||
c
|
|
||||||
b
|
|
||||||
a
|
|
||||||
c
|
|
||||||
|
|
||||||
a b d
|
|
||||||
a d
|
|
||||||
a
|
|
||||||
a b c x
|
|
||||||
Y a b c x
|
|
||||||
|
|
||||||
a f
|
|
||||||
@@ -741,6 +741,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
1132,
|
||||||
/**/
|
/**/
|
||||||
1131,
|
1131,
|
||||||
/**/
|
/**/
|
||||||
|
|||||||
Reference in New Issue
Block a user