To: vim_dev@googlegroups.com Subject: Patch 8.2.2979 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.2979 Problem: Not all options code is covered by tests. Solution: Add more tests for options. (Yegappan Lakshmanan, closes #8369) Files: 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 *** ../vim-8.2.2978/src/testdir/test_edit.vim 2021-03-22 19:37:02.545019774 +0100 --- src/testdir/test_edit.vim 2021-06-12 13:39:27.876986606 +0200 *************** *** 1871,1874 **** --- 1871,1898 ---- 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\\" + call assert_equal("one\ttwo a ree", getline(1)) + exe "normal! 0wi\" + call assert_equal("one\t a ree", getline(1)) + exe "normal! 0wi\" + 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-8.2.2978/src/testdir/test_excmd.vim 2021-06-05 20:59:18.619771748 +0200 --- src/testdir/test_excmd.vim 2021-06-12 13:39:27.876986606 +0200 *************** *** 593,598 **** --- 593,604 ---- 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() *** ../vim-8.2.2978/src/testdir/test_help.vim 2021-03-20 12:49:12.078222904 +0100 --- src/testdir/test_help.vim 2021-06-12 13:45:05.768103069 +0200 *************** *** 123,127 **** --- 123,137 ---- 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 *** ../vim-8.2.2978/src/testdir/test_mksession.vim 2021-05-03 19:08:33.482050717 +0200 --- src/testdir/test_mksession.vim 2021-06-12 13:39:27.876986606 +0200 *************** *** 1019,1024 **** --- 1019,1037 ---- endfor call s:ClearMappings() + + " the 'pastetoggle', 'wildchar' and 'wildcharm' option values should be + " stored as key names in the vimrc file + set pastetoggle= + set wildchar= + set wildcharm= + call assert_fails('mkvimrc Xtestvimrc') + mkvimrc! Xtestvimrc + call assert_notequal(-1, index(readfile('Xtestvimrc'), 'set pastetoggle=')) + call assert_notequal(-1, index(readfile('Xtestvimrc'), 'set wildchar=')) + call assert_notequal(-1, index(readfile('Xtestvimrc'), 'set wildcharm=')) + set pastetoggle& wildchar& wildcharm& + call delete('Xtestvimrc') endfunc *** ../vim-8.2.2978/src/testdir/test_options.vim 2021-05-06 17:36:50.988003911 +0200 --- src/testdir/test_options.vim 2021-06-12 13:39:27.876986606 +0200 *************** *** 434,439 **** --- 434,440 ---- set nomodifiable call assert_fails('set fileencoding=latin1', 'E21:') set modifiable& + call assert_fails('set t_#-&', 'E522:') endfunc func CheckWasSet(name) *************** *** 946,951 **** --- 947,964 ---- 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,1124 **** --- 1134,1155 ---- 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 *** ../vim-8.2.2978/src/testdir/test_vartabs.vim 2020-12-18 19:49:52.349571840 +0100 --- src/testdir/test_vartabs.vim 2021-06-12 13:39:27.876986606 +0200 *************** *** 419,422 **** --- 419,435 ---- 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 *** ../vim-8.2.2978/src/testdir/test_window_cmd.vim 2021-03-20 19:55:31.660402769 +0100 --- src/testdir/test_window_cmd.vim 2021-06-12 13:39:27.876986606 +0200 *************** *** 397,403 **** call assert_inrange(ww1, ww1 + 1, ww2) call assert_inrange(ww3, ww3 + 1, ww2) ! bw Xa Xb Xc endfunc func Test_equalalways_on_close() --- 397,411 ---- call assert_inrange(ww1, ww1 + 1, ww2) call assert_inrange(ww3, ww3 + 1, ww2) ! " 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() *** ../vim-8.2.2978/src/version.c 2021-06-12 12:33:46.415692289 +0200 --- src/version.c 2021-06-12 13:40:41.512798233 +0200 *************** *** 752,753 **** --- 752,755 ---- { /* Add new patch number below this line */ + /**/ + 2979, /**/ -- DENNIS: You can't expect to wield supreme executive power just 'cause some watery tart threw a sword at you! "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// \\\ \\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///