mirror of
https://github.com/vim/vim.git
synced 2025-09-27 04:14:06 -04:00
patch 8.0.0890: still many old style tests
Problem: Still many old style tests. Solution: Convert several tests to new style. (Yegappan Lakshmanan)
This commit is contained in:
@@ -2169,6 +2169,7 @@ test_arglist \
|
||||
test_functions \
|
||||
test_ga \
|
||||
test_getcwd \
|
||||
test_getvar \
|
||||
test_gf \
|
||||
test_glob2regpat \
|
||||
test_global \
|
||||
@@ -2180,6 +2181,7 @@ test_arglist \
|
||||
test_help \
|
||||
test_help_tagjump \
|
||||
test_hide \
|
||||
test_highlight \
|
||||
test_history \
|
||||
test_hlsearch \
|
||||
test_increment \
|
||||
|
@@ -38,7 +38,6 @@ SCRIPTS_ALL = \
|
||||
test44.out \
|
||||
test45.out \
|
||||
test48.out \
|
||||
test51.out \
|
||||
test53.out \
|
||||
test55.out \
|
||||
test56.out \
|
||||
@@ -53,12 +52,9 @@ SCRIPTS_ALL = \
|
||||
test79.out \
|
||||
test80.out \
|
||||
test88.out \
|
||||
test91.out \
|
||||
test94.out \
|
||||
test95.out \
|
||||
test99.out \
|
||||
test103.out \
|
||||
test107.out \
|
||||
test108.out \
|
||||
test_autoformat_join.out \
|
||||
test_changelist.out \
|
||||
@@ -140,6 +136,7 @@ NEW_TESTS = test_arabic.res \
|
||||
test_file_size.res \
|
||||
test_fnameescape.res \
|
||||
test_fold.res \
|
||||
test_getvar.res \
|
||||
test_gf.res \
|
||||
test_gn.res \
|
||||
test_gui.res \
|
||||
@@ -147,6 +144,7 @@ NEW_TESTS = test_arabic.res \
|
||||
test_hardcopy.res \
|
||||
test_help.res \
|
||||
test_hide.res \
|
||||
test_highlight.res \
|
||||
test_history.res \
|
||||
test_hlsearch.res \
|
||||
test_increment.res \
|
||||
|
@@ -81,17 +81,16 @@ SCRIPT = test1.out test3.out test4.out test5.out \
|
||||
test33.out test34.out test36.out test37.out \
|
||||
test38.out test39.out test40.out test41.out test42.out \
|
||||
test43.out test44.out test45.out \
|
||||
test48.out test49.out test51.out test53.out test54.out \
|
||||
test48.out test49.out test53.out test54.out \
|
||||
test55.out test56.out test57.out test60.out \
|
||||
test64.out \
|
||||
test66.out test68.out test69.out \
|
||||
test72.out \
|
||||
test77a.out test78.out test79.out test80.out \
|
||||
test88.out \
|
||||
test91.out test94.out \
|
||||
test94.out \
|
||||
test95.out test99.out \
|
||||
test103.out \
|
||||
test107.out test108.out\
|
||||
test108.out\
|
||||
test_autocmd_option.out \
|
||||
test_autoformat_join.out \
|
||||
test_breakindent.out \
|
||||
|
@@ -1,38 +0,0 @@
|
||||
Test for visual mode not being reset causing E315 error.
|
||||
STARTTEST
|
||||
:so small.vim
|
||||
:set belloff=all
|
||||
:enew
|
||||
:let g:msg="Everything's fine."
|
||||
:function! TriggerTheProblem()
|
||||
: " At this point there is no visual selection because :call reset it.
|
||||
: " Let's restore the selection:
|
||||
: normal gv
|
||||
: '<,'>del _
|
||||
: try
|
||||
: exe "normal \<Esc>"
|
||||
: catch /^Vim\%((\a\+)\)\=:E315/
|
||||
: echom 'Snap! E315 error!'
|
||||
: let g:msg='Snap! E315 error!'
|
||||
: endtry
|
||||
:endfunction
|
||||
:enew
|
||||
:setl buftype=nofile
|
||||
:call append(line('$'), 'Delete this line.')
|
||||
:"
|
||||
:"
|
||||
:" NOTE: this has to be done by a call to a function because executing :del the
|
||||
:" ex-way will require the colon operator which resets the visual mode thus
|
||||
:" preventing the problem:
|
||||
:"
|
||||
GV:call TriggerTheProblem()
|
||||
:%del _
|
||||
:call append(line('$'), g:msg)
|
||||
:w! test.out
|
||||
:brewind
|
||||
ENDTEST
|
||||
|
||||
STARTTEST
|
||||
:qa!
|
||||
ENDTEST
|
||||
|
@@ -1,2 +0,0 @@
|
||||
|
||||
Everything's fine.
|
@@ -1,38 +0,0 @@
|
||||
Tests for adjusting window and contents vim: set ft=vim :
|
||||
|
||||
STARTTEST
|
||||
:so small.vim
|
||||
:new
|
||||
:call setline(1, range(1,256))
|
||||
:let r=[]
|
||||
:func! GetScreenStr(row)
|
||||
: let str = ""
|
||||
: for c in range(1,3)
|
||||
: let str .= nr2char(screenchar(a:row, c))
|
||||
: endfor
|
||||
: return str
|
||||
:endfunc
|
||||
:
|
||||
:exe ":norm! \<C-W>t\<C-W>=1Gzt\<C-W>w\<C-W>+"
|
||||
:let s3=GetScreenStr(1)
|
||||
:wincmd p
|
||||
:call add(r, [line("w0"), s3])
|
||||
:
|
||||
:exe ":norm! \<C-W>t\<C-W>=50Gzt\<C-W>w\<C-W>+"
|
||||
:let s3=GetScreenStr(1)
|
||||
:wincmd p
|
||||
:call add(r, [line("w0"), s3])
|
||||
:
|
||||
:exe ":norm! \<C-W>t\<C-W>=59Gzt\<C-W>w\<C-W>+"
|
||||
:let s3=GetScreenStr(1)
|
||||
::wincmd p
|
||||
:call add(r, [line("w0"), s3])
|
||||
:
|
||||
:bwipeout!
|
||||
:$put=r
|
||||
:call garbagecollect(1)
|
||||
:"
|
||||
:/^start:/,$wq! test.out
|
||||
ENDTEST
|
||||
|
||||
start:
|
@@ -1,4 +0,0 @@
|
||||
start:
|
||||
[1, '1 ']
|
||||
[50, '50 ']
|
||||
[59, '59 ']
|
@@ -1,36 +0,0 @@
|
||||
Tests for ":highlight". vim: set ft=vim :
|
||||
|
||||
STARTTEST
|
||||
:so small.vim
|
||||
:" basic test if ":highlight" doesn't crash
|
||||
:highlight
|
||||
:hi Search
|
||||
:" test setting colors.
|
||||
:" test clearing one color and all doesn't generate error or warning
|
||||
:hi NewGroup term=bold cterm=italic ctermfg=DarkBlue ctermbg=Grey gui= guifg=#00ff00 guibg=Cyan
|
||||
:hi Group2 term= cterm=
|
||||
:hi Group3 term=underline cterm=bold
|
||||
:redir! >test.out
|
||||
:hi NewGroup
|
||||
:hi Group2
|
||||
:hi Group3
|
||||
:hi clear NewGroup
|
||||
:hi NewGroup
|
||||
:hi Group2
|
||||
:hi Group2 NONE
|
||||
:hi Group2
|
||||
:hi clear
|
||||
:hi Group3
|
||||
:hi Crash term='asdf
|
||||
:redir END
|
||||
:" filter ctermfg and ctermbg, the numbers depend on the terminal
|
||||
:e! test.out
|
||||
:%s/ctermfg=\d*/ctermfg=2/
|
||||
:%s/ctermbg=\d*/ctermbg=3/
|
||||
:" filter out possibly translated error message
|
||||
:%s/E475: [^:]*:/E475:/
|
||||
:" fix the fileformat
|
||||
:set ff&
|
||||
:wq!
|
||||
ENDTEST
|
||||
|
@@ -1,20 +0,0 @@
|
||||
|
||||
|
||||
NewGroup xxx term=bold cterm=italic ctermfg=2 ctermbg=3
|
||||
|
||||
Group2 xxx cleared
|
||||
|
||||
Group3 xxx term=underline cterm=bold
|
||||
|
||||
|
||||
NewGroup xxx cleared
|
||||
|
||||
Group2 xxx cleared
|
||||
|
||||
|
||||
Group2 xxx cleared
|
||||
|
||||
|
||||
Group3 xxx cleared
|
||||
|
||||
E475: term='asdf
|
@@ -1,89 +0,0 @@
|
||||
Tests for getwinvar(), gettabvar() and gettabwinvar().
|
||||
vim: set ft=vim :
|
||||
|
||||
STARTTEST
|
||||
:so small.vim
|
||||
:so mbyte.vim
|
||||
:"
|
||||
:" Use strings to test for memory leaks.
|
||||
:" First, check that in an empty window, gettabvar() returns the correct value
|
||||
:let t:testvar='abcd'
|
||||
:$put =string(gettabvar(1,'testvar'))
|
||||
:$put =string(gettabvar(1,'testvar'))
|
||||
:"
|
||||
:" test for getwinvar()
|
||||
:let w:var_str = "Dance"
|
||||
:let def_str = "Chance"
|
||||
:$put =string(getwinvar(1, 'var_str'))
|
||||
:$put =string(getwinvar(1, 'var_str', def_str))
|
||||
:$put =string(getwinvar(1, ''))
|
||||
:$put =string(getwinvar(1, '', def_str))
|
||||
:unlet w:var_str
|
||||
:$put =string(getwinvar(1, 'var_str', def_str))
|
||||
:$put =string(getwinvar(1, ''))
|
||||
:$put =string(getwinvar(1, '', def_str))
|
||||
:$put =string(getwinvar(9, ''))
|
||||
:$put =string(getwinvar(9, '', def_str))
|
||||
:$put =string(getwinvar(1, '&nu'))
|
||||
:$put =string(getwinvar(1, '&nu', 1))
|
||||
:unlet def_str
|
||||
:"
|
||||
:" test for gettabvar()
|
||||
:tabnew
|
||||
:tabnew
|
||||
:let t:var_list = [1, 2, 3]
|
||||
:let t:other = 777
|
||||
:let def_list = [4, 5, 6, 7]
|
||||
:tabrewind
|
||||
:$put =string(gettabvar(3, 'var_list'))
|
||||
:$put =string(gettabvar(3, 'var_list', def_list))
|
||||
:$put =string(gettabvar(3, ''))
|
||||
:$put =string(gettabvar(3, '', def_list))
|
||||
:tablast
|
||||
:unlet t:var_list
|
||||
:tabrewind
|
||||
:$put =string(gettabvar(3, 'var_list', def_list))
|
||||
:$put =string(gettabvar(9, ''))
|
||||
:$put =string(gettabvar(9, '', def_list))
|
||||
:$put =string(gettabvar(3, '&nu'))
|
||||
:$put =string(gettabvar(3, '&nu', def_list))
|
||||
:unlet def_list
|
||||
:tabonly
|
||||
:"
|
||||
:" test for gettabwinvar()
|
||||
:tabnew
|
||||
:tabnew
|
||||
:tabprev
|
||||
:split
|
||||
:split
|
||||
:wincmd w
|
||||
:vert split
|
||||
:wincmd w
|
||||
:let w:var_dict = {'dict': 'tabwin'}
|
||||
:let def_dict = {'dict2': 'newval'}
|
||||
:wincmd b
|
||||
:tabrewind
|
||||
:$put =string(gettabwinvar(2, 3, 'var_dict'))
|
||||
:$put =string(gettabwinvar(2, 3, 'var_dict', def_dict))
|
||||
:$put =string(gettabwinvar(2, 3, ''))
|
||||
:$put =string(gettabwinvar(2, 3, '', def_dict))
|
||||
:tabnext
|
||||
:3wincmd w
|
||||
:unlet w:var_dict
|
||||
:tabrewind
|
||||
:$put =string(gettabwinvar(2, 3, 'var_dict', def_dict))
|
||||
:$put =string(gettabwinvar(2, 3, ''))
|
||||
:$put =string(gettabwinvar(2, 3, '', def_dict))
|
||||
:$put =string(gettabwinvar(2, 9, ''))
|
||||
:$put =string(gettabwinvar(2, 9, '', def_dict))
|
||||
:$put =string(gettabwinvar(9, 3, ''))
|
||||
:$put =string(gettabwinvar(9, 3, '', def_dict))
|
||||
:unlet def_dict
|
||||
:$put =string(gettabwinvar(2, 3, '&nux'))
|
||||
:$put =string(gettabwinvar(2, 3, '&nux', 1))
|
||||
:tabonly
|
||||
:"
|
||||
:/^start/,$wq! test.out
|
||||
ENDTEST
|
||||
|
||||
start:
|
@@ -1,36 +0,0 @@
|
||||
start:
|
||||
'abcd'
|
||||
'abcd'
|
||||
'Dance'
|
||||
'Dance'
|
||||
{'var_str': 'Dance'}
|
||||
{'var_str': 'Dance'}
|
||||
'Chance'
|
||||
{}
|
||||
{}
|
||||
''
|
||||
'Chance'
|
||||
0
|
||||
0
|
||||
[1, 2, 3]
|
||||
[1, 2, 3]
|
||||
{'var_list': [1, 2, 3], 'other': 777}
|
||||
{'var_list': [1, 2, 3], 'other': 777}
|
||||
[4, 5, 6, 7]
|
||||
''
|
||||
[4, 5, 6, 7]
|
||||
''
|
||||
[4, 5, 6, 7]
|
||||
{'dict': 'tabwin'}
|
||||
{'dict': 'tabwin'}
|
||||
{'var_dict': {'dict': 'tabwin'}}
|
||||
{'var_dict': {'dict': 'tabwin'}}
|
||||
{'dict2': 'newval'}
|
||||
{}
|
||||
{}
|
||||
''
|
||||
{'dict2': 'newval'}
|
||||
''
|
||||
{'dict2': 'newval'}
|
||||
''
|
||||
1
|
88
src/testdir/test_getvar.vim
Normal file
88
src/testdir/test_getvar.vim
Normal file
@@ -0,0 +1,88 @@
|
||||
" Tests for getwinvar(), gettabvar() and gettabwinvar().
|
||||
func Test_var()
|
||||
" Use strings to test for memory leaks. First, check that in an empty
|
||||
" window, gettabvar() returns the correct value
|
||||
let t:testvar='abcd'
|
||||
call assert_equal('abcd', gettabvar(1, 'testvar'))
|
||||
call assert_equal('abcd', gettabvar(1, 'testvar'))
|
||||
|
||||
" test for getwinvar()
|
||||
let w:var_str = "Dance"
|
||||
let def_str = "Chance"
|
||||
call assert_equal('Dance', getwinvar(1, 'var_str'))
|
||||
call assert_equal('Dance', getwinvar(1, 'var_str', def_str))
|
||||
call assert_equal({'var_str': 'Dance'}, getwinvar(1, ''))
|
||||
call assert_equal({'var_str': 'Dance'}, getwinvar(1, '', def_str))
|
||||
unlet w:var_str
|
||||
call assert_equal('Chance', getwinvar(1, 'var_str', def_str))
|
||||
call assert_equal({}, getwinvar(1, ''))
|
||||
call assert_equal({}, getwinvar(1, '', def_str))
|
||||
call assert_equal('', getwinvar(9, ''))
|
||||
call assert_equal('Chance', getwinvar(9, '', def_str))
|
||||
call assert_equal(0, getwinvar(1, '&nu'))
|
||||
call assert_equal(0, getwinvar(1, '&nu', 1))
|
||||
unlet def_str
|
||||
|
||||
" test for gettabvar()
|
||||
tabnew
|
||||
tabnew
|
||||
let t:var_list = [1, 2, 3]
|
||||
let t:other = 777
|
||||
let def_list = [4, 5, 6, 7]
|
||||
tabrewind
|
||||
call assert_equal([1, 2, 3], gettabvar(3, 'var_list'))
|
||||
call assert_equal([1, 2, 3], gettabvar(3, 'var_list', def_list))
|
||||
call assert_equal({'var_list': [1, 2, 3], 'other': 777}, gettabvar(3, ''))
|
||||
call assert_equal({'var_list': [1, 2, 3], 'other': 777},
|
||||
\ gettabvar(3, '', def_list))
|
||||
|
||||
tablast
|
||||
unlet t:var_list
|
||||
tabrewind
|
||||
call assert_equal([4, 5, 6, 7], gettabvar(3, 'var_list', def_list))
|
||||
call assert_equal('', gettabvar(9, ''))
|
||||
call assert_equal([4, 5, 6, 7], gettabvar(9, '', def_list))
|
||||
call assert_equal('', gettabvar(3, '&nu'))
|
||||
call assert_equal([4, 5, 6, 7], gettabvar(3, '&nu', def_list))
|
||||
unlet def_list
|
||||
tabonly
|
||||
|
||||
" test for gettabwinvar()
|
||||
tabnew
|
||||
tabnew
|
||||
tabprev
|
||||
split
|
||||
split
|
||||
wincmd w
|
||||
vert split
|
||||
wincmd w
|
||||
let w:var_dict = {'dict': 'tabwin'}
|
||||
let def_dict = {'dict2': 'newval'}
|
||||
wincmd b
|
||||
tabrewind
|
||||
call assert_equal({'dict': 'tabwin'}, gettabwinvar(2, 3, 'var_dict'))
|
||||
call assert_equal({'dict': 'tabwin'},
|
||||
\ gettabwinvar(2, 3, 'var_dict', def_dict))
|
||||
call assert_equal({'var_dict': {'dict': 'tabwin'}}, gettabwinvar(2, 3, ''))
|
||||
call assert_equal({'var_dict': {'dict': 'tabwin'}},
|
||||
\ gettabwinvar(2, 3, '', def_dict))
|
||||
|
||||
tabnext
|
||||
3wincmd w
|
||||
unlet w:var_dict
|
||||
tabrewind
|
||||
call assert_equal({'dict2': 'newval'},
|
||||
\ gettabwinvar(2, 3, 'var_dict', def_dict))
|
||||
call assert_equal({}, gettabwinvar(2, 3, ''))
|
||||
call assert_equal({}, gettabwinvar(2, 3, '', def_dict))
|
||||
call assert_equal("", gettabwinvar(2, 9, ''))
|
||||
call assert_equal({'dict2': 'newval'}, gettabwinvar(2, 9, '', def_dict))
|
||||
call assert_equal('', gettabwinvar(9, 3, ''))
|
||||
call assert_equal({'dict2': 'newval'}, gettabwinvar(9, 3, '', def_dict))
|
||||
|
||||
unlet def_dict
|
||||
|
||||
call assert_equal('', gettabwinvar(2, 3, '&nux'))
|
||||
call assert_equal(1, gettabwinvar(2, 3, '&nux', 1))
|
||||
tabonly
|
||||
endfunc
|
36
src/testdir/test_highlight.vim
Normal file
36
src/testdir/test_highlight.vim
Normal file
@@ -0,0 +1,36 @@
|
||||
" Tests for ":highlight".
|
||||
func Test_highlight()
|
||||
" basic test if ":highlight" doesn't crash
|
||||
highlight
|
||||
hi Search
|
||||
|
||||
" test setting colors.
|
||||
" test clearing one color and all doesn't generate error or warning
|
||||
silent! hi NewGroup term=bold cterm=italic ctermfg=DarkBlue ctermbg=Grey gui= guifg=#00ff00 guibg=Cyan
|
||||
silent! hi Group2 term= cterm=
|
||||
hi Group3 term=underline cterm=bold
|
||||
|
||||
let res = split(execute("hi NewGroup"), "\n")[0]
|
||||
" filter ctermfg and ctermbg, the numbers depend on the terminal
|
||||
let res = substitute(res, 'ctermfg=\d*', 'ctermfg=2', '')
|
||||
let res = substitute(res, 'ctermbg=\d*', 'ctermbg=3', '')
|
||||
call assert_equal("NewGroup xxx term=bold cterm=italic ctermfg=2 ctermbg=3",
|
||||
\ res)
|
||||
call assert_equal("Group2 xxx cleared",
|
||||
\ split(execute("hi Group2"), "\n")[0])
|
||||
call assert_equal("Group3 xxx term=underline cterm=bold",
|
||||
\ split(execute("hi Group3"), "\n")[0])
|
||||
|
||||
hi clear NewGroup
|
||||
call assert_equal("NewGroup xxx cleared",
|
||||
\ split(execute("hi NewGroup"), "\n")[0])
|
||||
call assert_equal("Group2 xxx cleared",
|
||||
\ split(execute("hi Group2"), "\n")[0])
|
||||
hi Group2 NONE
|
||||
call assert_equal("Group2 xxx cleared",
|
||||
\ split(execute("hi Group2"), "\n")[0])
|
||||
hi clear
|
||||
call assert_equal("Group3 xxx cleared",
|
||||
\ split(execute("hi Group3"), "\n")[0])
|
||||
call assert_fails("hi Crash term='asdf", "E475:")
|
||||
endfunc
|
@@ -60,3 +60,34 @@ func Test_Visual_inner_quote()
|
||||
normal vki'
|
||||
bwipe!
|
||||
endfunc
|
||||
|
||||
" Test for Visual mode not being reset causing E315 error.
|
||||
func TriggerTheProblem()
|
||||
" At this point there is no visual selection because :call reset it.
|
||||
" Let's restore the selection:
|
||||
normal gv
|
||||
'<,'>del _
|
||||
try
|
||||
exe "normal \<Esc>"
|
||||
catch /^Vim\%((\a\+)\)\=:E315/
|
||||
echom 'Snap! E315 error!'
|
||||
let g:msg='Snap! E315 error!'
|
||||
endtry
|
||||
endfunc
|
||||
|
||||
func Test_visual_mode_reset()
|
||||
set belloff=all
|
||||
enew
|
||||
let g:msg="Everything's fine."
|
||||
enew
|
||||
setl buftype=nofile
|
||||
call append(line('$'), 'Delete this line.')
|
||||
|
||||
" NOTE: this has to be done by a call to a function because executing :del
|
||||
" the ex-way will require the colon operator which resets the visual mode
|
||||
" thus preventing the problem:
|
||||
exe "normal! GV:call TriggerTheProblem()\<CR>"
|
||||
call assert_equal("Everything's fine.", g:msg)
|
||||
|
||||
set belloff&
|
||||
endfunc
|
||||
|
@@ -416,4 +416,42 @@ func Test_next_split_all()
|
||||
bwipe!
|
||||
endfunc
|
||||
|
||||
" Tests for adjusting window and contents
|
||||
func GetScreenStr(row)
|
||||
let str = ""
|
||||
for c in range(1,3)
|
||||
let str .= nr2char(screenchar(a:row, c))
|
||||
endfor
|
||||
return str
|
||||
endfunc
|
||||
|
||||
func Test_window_contents()
|
||||
enew! | only | new
|
||||
call setline(1, range(1,256))
|
||||
|
||||
exe "norm! \<C-W>t\<C-W>=1Gzt\<C-W>w\<C-W>+"
|
||||
redraw
|
||||
let s3=GetScreenStr(1)
|
||||
wincmd p
|
||||
call assert_equal(1, line("w0"))
|
||||
call assert_equal('1 ', s3)
|
||||
|
||||
exe "norm! \<C-W>t\<C-W>=50Gzt\<C-W>w\<C-W>+"
|
||||
redraw
|
||||
let s3=GetScreenStr(1)
|
||||
wincmd p
|
||||
call assert_equal(50, line("w0"))
|
||||
call assert_equal('50 ', s3)
|
||||
|
||||
exe "norm! \<C-W>t\<C-W>=59Gzt\<C-W>w\<C-W>+"
|
||||
redraw
|
||||
let s3=GetScreenStr(1)
|
||||
wincmd p
|
||||
call assert_equal(59, line("w0"))
|
||||
call assert_equal('59 ', s3)
|
||||
|
||||
bwipeout!
|
||||
call test_garbagecollect_now()
|
||||
endfunc
|
||||
|
||||
" vim: shiftwidth=2 sts=2 expandtab
|
||||
|
@@ -769,6 +769,8 @@ static char *(features[]) =
|
||||
|
||||
static int included_patches[] =
|
||||
{ /* Add new patch number below this line */
|
||||
/**/
|
||||
890,
|
||||
/**/
|
||||
889,
|
||||
/**/
|
||||
|
Reference in New Issue
Block a user