mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
vim-patch:8.2.2979: not all options code is covered by tests
Problem: Not all options code is covered by tests.
Solution: Add more tests for options. (Yegappan Lakshmanan, closes vim/vim#8369)
5958549760
This commit is contained in:
parent
5d1cb73e7f
commit
dd2b7586f3
@ -1927,4 +1927,28 @@ func Test_read_invalid()
|
|||||||
set encoding=utf-8
|
set encoding=utf-8
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
" Test for the 'revins' option
|
||||||
|
func Test_edit_revins()
|
||||||
|
CheckFeature rightleft
|
||||||
|
new
|
||||||
|
set revins
|
||||||
|
exe "normal! ione\ttwo three"
|
||||||
|
call assert_equal("eerht owt\teno", getline(1))
|
||||||
|
call setline(1, "one\ttwo three")
|
||||||
|
normal! gg$bi a
|
||||||
|
call assert_equal("one\ttwo a three", getline(1))
|
||||||
|
exe "normal! $bi\<BS>\<BS>"
|
||||||
|
call assert_equal("one\ttwo a ree", getline(1))
|
||||||
|
exe "normal! 0wi\<C-W>"
|
||||||
|
call assert_equal("one\t a ree", getline(1))
|
||||||
|
exe "normal! 0wi\<C-U>"
|
||||||
|
call assert_equal("one\t ", getline(1))
|
||||||
|
" newline in insert mode starts at the end of the line
|
||||||
|
call setline(1, 'one two three')
|
||||||
|
exe "normal! wi\nfour"
|
||||||
|
call assert_equal(['one two three', 'ruof'], getline(1, '$'))
|
||||||
|
set revins&
|
||||||
|
bw!
|
||||||
|
endfunc
|
||||||
|
|
||||||
" vim: shiftwidth=2 sts=2 expandtab
|
" vim: shiftwidth=2 sts=2 expandtab
|
||||||
|
@ -662,6 +662,12 @@ func Sandbox_tests()
|
|||||||
if has('unix')
|
if has('unix')
|
||||||
call assert_fails('cd `pwd`', 'E48:')
|
call assert_fails('cd `pwd`', 'E48:')
|
||||||
endif
|
endif
|
||||||
|
" some options cannot be changed in a sandbox
|
||||||
|
call assert_fails('set exrc', 'E48:')
|
||||||
|
call assert_fails('set cdpath', 'E48:')
|
||||||
|
if has('xim')
|
||||||
|
call assert_fails('set imstyle', 'E48:')
|
||||||
|
endif
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func Test_sandbox()
|
func Test_sandbox()
|
||||||
|
@ -141,6 +141,17 @@ func Test_helptag_cmd()
|
|||||||
call delete('Xdir', 'rf')
|
call delete('Xdir', 'rf')
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
" Test for setting the 'helpheight' option in the help window
|
||||||
|
func Test_help_window_height()
|
||||||
|
let &cmdheight = &lines - 24
|
||||||
|
set helpheight=10
|
||||||
|
help
|
||||||
|
set helpheight=14
|
||||||
|
call assert_equal(14, winheight(0))
|
||||||
|
set helpheight& cmdheight=1
|
||||||
|
close
|
||||||
|
endfunc
|
||||||
|
|
||||||
func Test_help_long_argument()
|
func Test_help_long_argument()
|
||||||
try
|
try
|
||||||
exe 'help \%' .. repeat('0', 1021)
|
exe 'help \%' .. repeat('0', 1021)
|
||||||
|
@ -942,6 +942,19 @@ func Test_mkvimrc()
|
|||||||
endfor
|
endfor
|
||||||
|
|
||||||
call s:ClearMappings()
|
call s:ClearMappings()
|
||||||
|
|
||||||
|
" the 'pastetoggle', 'wildchar' and 'wildcharm' option values should be
|
||||||
|
" stored as key names in the vimrc file
|
||||||
|
set pastetoggle=<F5>
|
||||||
|
set wildchar=<F6>
|
||||||
|
set wildcharm=<F7>
|
||||||
|
call assert_fails('mkvimrc Xtestvimrc')
|
||||||
|
mkvimrc! Xtestvimrc
|
||||||
|
call assert_notequal(-1, index(readfile('Xtestvimrc'), 'set pastetoggle=<F5>'))
|
||||||
|
call assert_notequal(-1, index(readfile('Xtestvimrc'), 'set wildchar=<F6>'))
|
||||||
|
call assert_notequal(-1, index(readfile('Xtestvimrc'), 'set wildcharm=<F7>'))
|
||||||
|
set pastetoggle& wildchar& wildcharm&
|
||||||
|
|
||||||
call delete('Xtestvimrc')
|
call delete('Xtestvimrc')
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
@ -418,6 +418,7 @@ func Test_set_errors()
|
|||||||
set nomodifiable
|
set nomodifiable
|
||||||
call assert_fails('set fileencoding=latin1', 'E21:')
|
call assert_fails('set fileencoding=latin1', 'E21:')
|
||||||
set modifiable&
|
set modifiable&
|
||||||
|
" call assert_fails('set t_#-&', 'E522:')
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func CheckWasSet(name)
|
func CheckWasSet(name)
|
||||||
@ -932,6 +933,18 @@ func Test_opt_local_to_global()
|
|||||||
call assert_equal('gnewprg', &l:equalprg)
|
call assert_equal('gnewprg', &l:equalprg)
|
||||||
call assert_equal('gnewprg', &equalprg)
|
call assert_equal('gnewprg', &equalprg)
|
||||||
set equalprg&
|
set equalprg&
|
||||||
|
|
||||||
|
" Test for setting the global/local value of a boolean option
|
||||||
|
setglobal autoread
|
||||||
|
setlocal noautoread
|
||||||
|
call assert_false(&autoread)
|
||||||
|
set autoread<
|
||||||
|
call assert_true(&autoread)
|
||||||
|
setglobal noautoread
|
||||||
|
setlocal autoread
|
||||||
|
setlocal autoread<
|
||||||
|
call assert_false(&autoread)
|
||||||
|
set autoread&
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
" Test for incrementing, decrementing and multiplying a number option value
|
" Test for incrementing, decrementing and multiplying a number option value
|
||||||
@ -1082,6 +1095,25 @@ func Test_opt_reset_scroll()
|
|||||||
call delete('Xscroll')
|
call delete('Xscroll')
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
" Test for setting an option to a Vi or Vim default
|
||||||
|
func Test_opt_default()
|
||||||
|
throw 'Skipped: Nvim has different defaults'
|
||||||
|
set formatoptions&vi
|
||||||
|
call assert_equal('vt', &formatoptions)
|
||||||
|
set formatoptions&vim
|
||||||
|
call assert_equal('tcq', &formatoptions)
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
" Test for the 'cmdheight' option
|
||||||
|
func Test_cmdheight()
|
||||||
|
%bw!
|
||||||
|
let ht = &lines
|
||||||
|
set cmdheight=9999
|
||||||
|
call assert_equal(1, winheight(0))
|
||||||
|
call assert_equal(ht - 1, &cmdheight)
|
||||||
|
set cmdheight&
|
||||||
|
endfunc
|
||||||
|
|
||||||
" Test for the 'cdhome' option
|
" Test for the 'cdhome' option
|
||||||
func Test_opt_cdhome()
|
func Test_opt_cdhome()
|
||||||
if has('unix') || has('vms')
|
if has('unix') || has('vms')
|
||||||
|
@ -429,4 +429,18 @@ func Test_varsofttabstop()
|
|||||||
close!
|
close!
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
" Setting 'shiftwidth' to a negative value, should set it to either the value
|
||||||
|
" of 'tabstop' (if 'vartabstop' is not set) or to the first value in
|
||||||
|
" 'vartabstop'
|
||||||
|
func Test_shiftwidth_vartabstop()
|
||||||
|
throw 'Skipped: Nvim removed this behavior in #6377'
|
||||||
|
setlocal tabstop=7 vartabstop=
|
||||||
|
call assert_fails('set shiftwidth=-1', 'E487:')
|
||||||
|
call assert_equal(7, &shiftwidth)
|
||||||
|
setlocal tabstop=7 vartabstop=5,7,10
|
||||||
|
call assert_fails('set shiftwidth=-1', 'E487:')
|
||||||
|
call assert_equal(5, &shiftwidth)
|
||||||
|
setlocal shiftwidth& vartabstop& tabstop&
|
||||||
|
endfunc
|
||||||
|
|
||||||
" vim: shiftwidth=2 sts=2 expandtab
|
" vim: shiftwidth=2 sts=2 expandtab
|
||||||
|
@ -433,7 +433,15 @@ func Test_window_width()
|
|||||||
call assert_inrange(ww1, ww1 + 1, ww2)
|
call assert_inrange(ww1, ww1 + 1, ww2)
|
||||||
call assert_inrange(ww3, ww3 + 1, ww2)
|
call assert_inrange(ww3, ww3 + 1, ww2)
|
||||||
|
|
||||||
bw Xa Xb Xc
|
" when the current window width is less than the new 'winwidth', the current
|
||||||
|
" window width should be increased.
|
||||||
|
enew | only
|
||||||
|
split
|
||||||
|
10vnew
|
||||||
|
set winwidth=15
|
||||||
|
call assert_equal(15, winwidth(0))
|
||||||
|
|
||||||
|
%bw!
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func Test_equalalways_on_close()
|
func Test_equalalways_on_close()
|
||||||
|
Loading…
Reference in New Issue
Block a user