]> granicus.if.org Git - vim/commitdiff
patch 8.2.2979: not all options code is covered by tests v8.2.2979
authorYegappan Lakshmanan <yegappan@yahoo.com>
Sat, 12 Jun 2021 11:46:41 +0000 (13:46 +0200)
committerBram Moolenaar <Bram@vim.org>
Sat, 12 Jun 2021 11:46:41 +0000 (13:46 +0200)
Problem:    Not all options code is covered by tests.
Solution:   Add more tests for options. (Yegappan Lakshmanan, closes #8369)

src/testdir/test_edit.vim
src/testdir/test_excmd.vim
src/testdir/test_help.vim
src/testdir/test_mksession.vim
src/testdir/test_options.vim
src/testdir/test_vartabs.vim
src/testdir/test_window_cmd.vim
src/version.c

index 39cb6aa35065f7d397ffc933881587fabe988a99..3fcc11f2d80229e7b1604affffdc0c6c08450207 100644 (file)
@@ -1871,4 +1871,28 @@ func Test_read_invalid()
   set encoding=utf-8
 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
index 60753a6e82c7f21adc3d1751895f4bff2225588c..de82b5b77e95a10e1d502d6f6e8fa4f6370f726a 100644 (file)
@@ -593,6 +593,12 @@ func Sandbox_tests()
   if has('unix')
     call assert_fails('cd `pwd`', 'E48:')
   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
 
 func Test_sandbox()
index ff2bc41b7a023444c801045b654bfdbaa191e093..15cc642d1734d9a163e3a16fcbf42c87001eaddc 100644 (file)
@@ -123,5 +123,15 @@ func Test_helptag_cmd_readonly()
   call delete('Xdir', 'rf')
 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
 
 " vim: shiftwidth=2 sts=2 expandtab
index 66e6e292ac9d2340a6681b9801799386dcf7d424..a0a2cb461e6a3c5fc980f4519dc06f49d592e67e 100644 (file)
@@ -1019,6 +1019,19 @@ func Test_mkvimrc()
   endfor
 
   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')
 endfunc
 
index d789a461eaeba756701a52def2a55c9de994adca..d640426453b0acfac9c4aef9b8dd38bc82a53f7a 100644 (file)
@@ -434,6 +434,7 @@ func Test_set_errors()
   set nomodifiable
   call assert_fails('set fileencoding=latin1', 'E21:')
   set modifiable&
+  call assert_fails('set t_#-&', 'E522:')
 endfunc
 
 func CheckWasSet(name)
@@ -946,6 +947,18 @@ func Test_opt_local_to_global()
   call assert_equal('gnewprg', &l:equalprg)
   call assert_equal('gnewprg', &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
 
 " Test for incrementing, decrementing and multiplying a number option value
@@ -1121,4 +1134,22 @@ func Test_VIM_POSIX()
   call setenv('VIM_POSIX', saved_VIM_POSIX)
 endfunc
 
+" Test for setting an option to a Vi or Vim default
+func Test_opt_default()
+  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
+
 " vim: shiftwidth=2 sts=2 expandtab
index 0ff1ea8ac97ac9cd15deb6aa36bc3acbbdf06fb0..3b8a9ce0b1ab9ec4f076a31afb3a1bc731858c17 100644 (file)
@@ -419,4 +419,17 @@ func Test_varsofttabstop()
   close!
 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()
+  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
index fda34eb4635f9fd1769e387b7595a5c4c0f9c0ee..af7c63a19cc709d0a605cfba8b140534dbf442a2 100644 (file)
@@ -397,7 +397,15 @@ func Test_window_width()
   call assert_inrange(ww1, ww1 + 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
 
 func Test_equalalways_on_close()
index 6ae66ae28adeeda134403a1b9bf555124db5c47a..d55ab1a24485bfb526337a6cf329f64a3aa2aa3f 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    2979,
 /**/
     2978,
 /**/