mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
vim-patch:8.0.0890: still many old style tests
Problem: Still many old style tests.
Solution: Convert several tests to new style. (Yegappan Lakshmanan)
75373f3808
This commit is contained in:
parent
1593ee7cf2
commit
d671168574
@ -60,12 +60,14 @@ NEW_TESTS ?= \
|
||||
test_fnameescape.res \
|
||||
test_fold.res \
|
||||
test_ga.res \
|
||||
test_getvar.res \
|
||||
test_glob2regpat.res \
|
||||
test_gf.res \
|
||||
test_gn.res \
|
||||
test_hardcopy.res \
|
||||
test_help_tagjump.res \
|
||||
test_hide.res \
|
||||
test_highlight.res \
|
||||
test_history.res \
|
||||
test_hlsearch.res \
|
||||
test_increment.res \
|
||||
|
88
src/nvim/testdir/test_getvar.vim
Normal file
88
src/nvim/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/nvim/testdir/test_highlight.vim
Normal file
36
src/nvim/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 cterm=italic ctermfg=2 ctermbg=3",
|
||||
\ res)
|
||||
call assert_equal("Group2 xxx cleared",
|
||||
\ split(execute("hi Group2"), "\n")[0])
|
||||
call assert_equal("Group3 xxx 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
|
@ -152,3 +152,34 @@ func Test_virtual_replace()
|
||||
\ 'AB IJKLMNO QRst'], getline(12, 13))
|
||||
enew!
|
||||
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
|
||||
|
@ -417,4 +417,42 @@ func Test_window_newtab()
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user