To: vim_dev@googlegroups.com Subject: Patch 8.2.0551 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.0551 Problem: Not all code for options is tested. Solution: Add more tests. (Yegappan Lakshmanan, closes #5913) Files: src/testdir/test_options.vim, src/testdir/test_python3.vim, src/testdir/test_undo.vim, src/testdir/test_vimscript.vim *** ../vim-8.2.0550/src/testdir/test_options.vim 2020-04-11 17:09:28.324426586 +0200 --- src/testdir/test_options.vim 2020-04-12 13:47:09.264623171 +0200 *************** *** 269,276 **** call feedkeys(":set tags=./\\\\ dif\\\"\", 'tx') call assert_equal('"set tags=./\\ diff diffexpr diffopt', @:) - set tags& endfunc func Test_set_errors() --- 269,321 ---- call feedkeys(":set tags=./\\\\ dif\\\"\", 'tx') call assert_equal('"set tags=./\\ diff diffexpr diffopt', @:) set tags& + + " Expanding the option names + call feedkeys(":set \\\"\", 'xt') + call assert_equal('"set all', @:) + + " Expanding a second set of option names + call feedkeys(":set wrapscan \\\"\", 'xt') + call assert_equal('"set wrapscan all', @:) + + " Expanding a special keycode + call feedkeys(":set \\\"\", 'xt') + call assert_equal('"set ', @:) + + " Expanding an invalid special keycode + call feedkeys(":set \\\"\", 'xt') + call assert_equal("\"set \", @:) + + " Expanding a terminal keycode + call feedkeys(":set t_AB\\\"\", 'xt') + call assert_equal("\"set t_AB", @:) + + " Expanding an invalid option name + call feedkeys(":set abcde=\\\"\", 'xt') + call assert_equal("\"set abcde=\", @:) + + " Expanding after a = for a boolean option + call feedkeys(":set wrapscan=\\\"\", 'xt') + call assert_equal("\"set wrapscan=\", @:) + + " Expanding a numeric option + call feedkeys(":set tabstop+=\\\"\", 'xt') + call assert_equal("\"set tabstop+=" .. &tabstop, @:) + + " Expanding a non-boolean option + call feedkeys(":set invtabstop=\\\"\", 'xt') + call assert_equal("\"set invtabstop=", @:) + + " Expand options for 'spellsuggest' + call feedkeys(":set spellsuggest=best,file:xyz\\\"\", 'xt') + call assert_equal("\"set spellsuggest=best,file:xyz", @:) + + " Expand value for 'key' + set key=abcd + call feedkeys(":set key=\\\"\", 'xt') + call assert_equal('"set key=*****', @:) + set key= endfunc func Test_set_errors() *************** *** 327,333 **** --- 372,385 ---- endif call assert_fails('set backupext=~ patchmode=~', 'E589:') call assert_fails('set winminheight=10 winheight=9', 'E591:') + set winminheight& winheight& + set winheight=10 winminheight=10 + call assert_fails('set winheight=9', 'E591:') + set winminheight& winheight& call assert_fails('set winminwidth=10 winwidth=9', 'E592:') + set winminwidth& winwidth& + call assert_fails('set winwidth=9 winminwidth=10', 'E592:') + set winwidth& winminwidth& call assert_fails("set showbreak=\x01", 'E595:') call assert_fails('set t_foo=', 'E846:') call assert_fails('set tabstop??', 'E488:') *************** *** 338,346 **** --- 390,400 ---- call assert_fails('set autoindent@', 'E488:') call assert_fails('set wildchar=', 'E474:') call assert_fails('set cmdheight=1a', 'E521:') + call assert_fails('set invcmdheight', 'E474:') if has('python') && has('python3') call assert_fails('set pyxversion=6', 'E474:') endif + call assert_fails("let &tabstop='ab'", 'E521:') endfunc func CheckWasSet(name) *************** *** 798,804 **** --- 852,860 ---- func Test_opt_sandbox() for opt in ['backupdir', 'cdpath', 'exrc'] call assert_fails('sandbox set ' .. opt .. '?', 'E48:') + call assert_fails('sandbox let &' .. opt .. ' = 1', 'E48:') endfor + call assert_fails('sandbox let &modelineexpr = 1', 'E48:') endfunc " Test for setting an option with local value to global value *** ../vim-8.2.0550/src/testdir/test_python3.vim 2020-02-23 15:10:13.569404928 +0100 --- src/testdir/test_python3.vim 2020-04-12 13:47:09.264623171 +0200 *************** *** 259,261 **** --- 259,334 ---- bwipe! endfunc + + " Test for resetting options with local values to global values + func Test_python3_opt_reset_local_to_global() + new + + py3 curbuf = vim.current.buffer + py3 curwin = vim.current.window + + " List of buffer-local options. Each list item has [option name, global + " value, buffer-local value, buffer-local value after reset] to use in the + " test. + let bopts = [ + \ ['autoread', 1, 0, -1], + \ ['equalprg', 'geprg', 'leprg', ''], + \ ['keywordprg', 'gkprg', 'lkprg', ''], + \ ['path', 'gpath', 'lpath', ''], + \ ['backupcopy', 'yes', 'no', ''], + \ ['tags', 'gtags', 'ltags', ''], + \ ['tagcase', 'ignore', 'match', ''], + \ ['define', 'gdef', 'ldef', ''], + \ ['include', 'ginc', 'linc', ''], + \ ['dict', 'gdict', 'ldict', ''], + \ ['thesaurus', 'gtsr', 'ltsr', ''], + \ ['formatprg', 'gfprg', 'lfprg', ''], + \ ['errorformat', '%f:%l:%m', '%s-%l-%m', ''], + \ ['grepprg', 'ggprg', 'lgprg', ''], + \ ['makeprg', 'gmprg', 'lmprg', ''], + \ ['balloonexpr', 'gbexpr', 'lbexpr', ''], + \ ['cryptmethod', 'blowfish2', 'zip', ''], + \ ['lispwords', 'abc', 'xyz', ''], + \ ['makeencoding', 'utf-8', 'latin1', ''], + \ ['undolevels', 100, 200, -123456]] + + " Set the global and buffer-local option values and then clear the + " buffer-local option value. + for opt in bopts + py3 pyopt = vim.bindeval("opt") + py3 vim.options[pyopt[0]] = pyopt[1] + py3 curbuf.options[pyopt[0]] = pyopt[2] + exe "call assert_equal(opt[2], &" .. opt[0] .. ")" + exe "call assert_equal(opt[1], &g:" .. opt[0] .. ")" + exe "call assert_equal(opt[2], &l:" .. opt[0] .. ")" + py3 del curbuf.options[pyopt[0]] + exe "call assert_equal(opt[1], &" .. opt[0] .. ")" + exe "call assert_equal(opt[1], &g:" .. opt[0] .. ")" + exe "call assert_equal(opt[3], &l:" .. opt[0] .. ")" + exe "set " .. opt[0] .. "&" + endfor + + " Set the global and window-local option values and then clear the + " window-local option value. + let wopts = [ + \ ['scrolloff', 5, 10, -1], + \ ['sidescrolloff', 6, 12, -1], + \ ['statusline', '%<%f', '%<%F', '']] + for opt in wopts + py3 pyopt = vim.bindeval("opt") + py3 vim.options[pyopt[0]] = pyopt[1] + py3 curwin.options[pyopt[0]] = pyopt[2] + exe "call assert_equal(opt[2], &" .. opt[0] .. ")" + exe "call assert_equal(opt[1], &g:" .. opt[0] .. ")" + exe "call assert_equal(opt[2], &l:" .. opt[0] .. ")" + py3 del curwin.options[pyopt[0]] + exe "call assert_equal(opt[1], &" .. opt[0] .. ")" + exe "call assert_equal(opt[1], &g:" .. opt[0] .. ")" + exe "call assert_equal(opt[3], &l:" .. opt[0] .. ")" + exe "set " .. opt[0] .. "&" + endfor + + close! + endfunc + + " vim: shiftwidth=2 sts=2 expandtab *** ../vim-8.2.0550/src/testdir/test_undo.vim 2020-02-11 22:03:43.042846213 +0100 --- src/testdir/test_undo.vim 2020-04-12 13:47:09.264623171 +0200 *************** *** 123,128 **** --- 123,133 ---- call assert_equal(50, &g:undolevels) call assert_equal(-123456, &l:undolevels) + " Resetting the local 'undolevels' value to use the global value + setlocal undolevels=5 + setlocal undolevels< + call assert_equal(-123456, &l:undolevels) + " Drop created windows set ul& new *** ../vim-8.2.0550/src/testdir/test_vimscript.vim 2020-04-08 21:50:18.880619637 +0200 --- src/testdir/test_vimscript.vim 2020-04-12 13:47:09.264623171 +0200 *************** *** 1411,1416 **** --- 1411,1420 ---- call assert_equal(["{'a': [1, 2, 3], 'b': [...]}", \ "{'a': [1, 2, 3], 'b': [1, 2, 3]}"], l) + call assert_fails('echo &:', 'E112:') + call assert_fails('echo &g:', 'E112:') + call assert_fails('echo &l:', 'E112:') + endfunc "------------------------------------------------------------------------------- *** ../vim-8.2.0550/src/version.c 2020-04-12 13:38:49.405711500 +0200 --- src/version.c 2020-04-12 13:50:04.944213995 +0200 *************** *** 740,741 **** --- 740,743 ---- { /* Add new patch number below this line */ + /**/ + 551, /**/ -- God made machine language; all the rest is the work of man. /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///