To: vim_dev@googlegroups.com Subject: Patch 8.2.1022 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.1022 Problem: Various parts of code not covered by tests. Solution: Add more tests. (Yegappan Lakshmanan, closes #6300) Files: src/testdir/test_blob.vim, src/testdir/test_cpoptions.vim, src/testdir/test_digraph.vim, src/testdir/test_edit.vim, src/testdir/test_iminsert.vim, src/testdir/test_paste.vim, src/testdir/test_prompt_buffer.vim, src/testdir/test_selectmode.vim, src/testdir/test_tabpage.vim, src/testdir/test_tagjump.vim, src/testdir/test_textformat.vim, src/testdir/test_viminfo.vim, src/testdir/test_virtualedit.vim, src/testdir/test_visual.vim *** ../vim-8.2.1021/src/testdir/test_blob.vim 2020-04-25 15:24:40.551354115 +0200 --- src/testdir/test_blob.vim 2020-06-20 16:03:11.440533949 +0200 *************** *** 254,259 **** --- 254,260 ---- call assert_fails("call remove(b, 3, 2)", 'E979:') call assert_fails("call remove(1, 0)", 'E896:') call assert_fails("call remove(b, b)", 'E974:') + call assert_fails("call remove(b, 1, [])", 'E745:') call assert_fails("call remove(test_null_blob(), 1, 2)", 'E979:') endfunc *** ../vim-8.2.1021/src/testdir/test_cpoptions.vim 2020-06-14 13:50:51.747717715 +0200 --- src/testdir/test_cpoptions.vim 2020-06-20 16:03:11.440533949 +0200 *************** *** 246,251 **** --- 246,252 ---- endfunc " TODO: Add a test for the 'i' flag in 'cpo' + " Interrupting the reading of a file will leave it modified. " Test for the 'I' flag in 'cpo' (deleting autoindent when using arrow keys) func Test_cpo_I() *************** *** 294,302 **** let &cpo = save_cpo endfunc ! " TODO: Add a test for the 'k' flag in 'cpo' ! " TODO: Add a test for the 'K' flag in 'cpo' " Test for the 'l' flag in 'cpo' (backslash in a [] range) func Test_cpo_l() --- 295,306 ---- let &cpo = save_cpo endfunc ! " TODO: Add a test for the 'k' flag in 'cpo'. ! " Disable the recognition of raw key codes in mappings, abbreviations, and the ! " "to" part of menu commands. ! " TODO: Add a test for the 'K' flag in 'cpo'. ! " Don't wait for a key code to complete when it is halfway a mapping. " Test for the 'l' flag in 'cpo' (backslash in a [] range) func Test_cpo_l() *************** *** 334,340 **** let &cpo = save_cpo endfunc ! " TODO: Add a test for the 'm' flag in 'cpo' " Test for the 'M' flag in 'cpo' (% with escape parenthesis) func Test_cpo_M() --- 338,346 ---- let &cpo = save_cpo endfunc ! " TODO: Add a test for the 'm' flag in 'cpo'. ! " When included, a showmatch will always wait half a second. When not ! " included, a showmatch will wait half a second or until a character is typed. " Test for the 'M' flag in 'cpo' (% with escape parenthesis) func Test_cpo_M() *************** *** 498,504 **** let &cpo = save_cpo endfunc ! " TODO: Add a test for the 's' flag in 'cpo' " Test for the 'S' flag in 'cpo' (copying buffer options) func Test_cpo_S() --- 504,512 ---- let &cpo = save_cpo endfunc ! " TODO: Add a test for the 's' flag in 'cpo'. ! " Set buffer options when entering the buffer for the first time. If not ! " present the options are set when the buffer is created. " Test for the 'S' flag in 'cpo' (copying buffer options) func Test_cpo_S() *************** *** 543,550 **** let &cpo = save_cpo endfunc ! " TODO: Add a test for the 'v' flag in 'cpo' (backspace doesn't remove ! " characters from the screen) " Test for the 'w' flag in 'cpo' ('cw' on a blank character changes only one " character) --- 551,558 ---- let &cpo = save_cpo endfunc ! " TODO: Add a test for the 'v' flag in 'cpo'. ! " Backspaced characters remain visible on the screen in Insert mode. " Test for the 'w' flag in 'cpo' ('cw' on a blank character changes only one " character) *** ../vim-8.2.1021/src/testdir/test_digraph.vim 2020-04-13 19:55:47.567369413 +0200 --- src/testdir/test_digraph.vim 2020-06-20 16:03:11.440533949 +0200 *************** *** 2,7 **** --- 2,8 ---- source check.vim CheckFeature digraphs + source term_util.vim func Put_Dig(chars) exe "norm! o\".a:chars *************** *** 502,505 **** --- 503,522 ---- call delete('Xkeymap') endfunc + " Test for the characters displayed one the screen when entering a digraph + func Test_entering_digraph() + CheckRunVimInTerminal + let buf = RunVimInTerminal('', {'rows': 6}) + call term_sendkeys(buf, "i\") + call term_wait(buf) + call assert_equal('?', term_getline(buf, 1)) + call term_sendkeys(buf, "1") + call term_wait(buf) + call assert_equal('1', term_getline(buf, 1)) + call term_sendkeys(buf, "2") + call term_wait(buf) + call assert_equal('½', term_getline(buf, 1)) + call StopVimInTerminal(buf) + endfunc + " vim: shiftwidth=2 sts=2 expandtab *** ../vim-8.2.1021/src/testdir/test_edit.vim 2020-06-15 19:51:52.637404472 +0200 --- src/testdir/test_edit.vim 2020-06-20 16:03:11.440533949 +0200 *************** *** 401,406 **** --- 401,414 ---- call assert_equal("", getline(2)) call assert_equal(" baz", getline(3)) set autoindent& + + " pressing to erase line should keep the indent with 'autoindent' + set backspace=2 autoindent + %d + exe "normal i\tone\three\two" + call assert_equal(["\tone", "\ttwo"], getline(1, '$')) + set backspace& autoindent& + bwipe! endfunc *************** *** 1301,1309 **** func Test_edit_rightleft() " Cursor in rightleft mode moves differently ! if !exists("+rightleft") ! return ! endif call NewWindow(10, 20) call setline(1, ['abc', 'def', 'ghi']) call cursor(1, 2) --- 1309,1315 ---- func Test_edit_rightleft() " Cursor in rightleft mode moves differently ! CheckFeature rightleft call NewWindow(10, 20) call setline(1, ['abc', 'def', 'ghi']) call cursor(1, 2) *************** *** 1348,1353 **** --- 1354,1366 ---- \" ihg", \" ~"] call assert_equal(join(expect, "\n"), join(lines, "\n")) + %d _ + call test_override('redraw_flag', 1) + call test_override('char_avail', 1) + call feedkeys("a\x41", "xt") + redraw! + call assert_equal(repeat(' ', 19) .. 'A', Screenline(1)) + call test_override('ALL', 0) set norightleft bw! endfunc *************** *** 1683,1686 **** --- 1696,1798 ---- call delete('Xfile') endfunc + " Pressing escape in 'insertmode' should beep + func Test_edit_insertmode_esc_beeps() + new + set insertmode + call assert_beeps("call feedkeys(\"one\\", 'xt')") + set insertmode& + " unsupported CTRL-G command should beep in insert mode. + call assert_beeps("normal i\l") + close! + endfunc + + " Test for 'hkmap' and 'hkmapp' + func Test_edit_hkmap() + CheckFeature rightleft + if has('win32') && !has('gui') + " Test fails on the MS-Windows terminal version + return + endif + new + + set revins hkmap + let str = 'abcdefghijklmnopqrstuvwxyz' + let str ..= 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' + let str ..= '`/'',.;' + call feedkeys('i' .. str, 'xt') + let expected = "óõú,.;" + let expected ..= "ZYXWVUTSRQPONMLKJIHGFEDCBA" + let expected ..= "æèñ'äåàãø/ôíîöêìçïéòë÷âáðù" + call assert_equal(expected, getline(1)) + + %d + set revins hkmap hkmapp + let str = 'abcdefghijklmnopqrstuvwxyz' + let str ..= 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' + call feedkeys('i' .. str, 'xt') + let expected = "õYXWVUTSRQóOïíLKJIHGFEDêBA" + let expected ..= "öòXùåèúæø'ôñðîì÷çéäâóǟãëáà" + call assert_equal(expected, getline(1)) + + set revins& hkmap& hkmapp& + close! + endfunc + + " Test for 'allowrevins' and using CTRL-_ in insert mode + func Test_edit_allowrevins() + CheckFeature rightleft + new + set allowrevins + call feedkeys("iABC\DEF\GHI", 'xt') + call assert_equal('ABCFEDGHI', getline(1)) + set allowrevins& + close! + endfunc + + " Test for inserting a register in insert mode using CTRL-R + func Test_edit_insert_reg() + new + let g:Line = '' + func SaveFirstLine() + let g:Line = Screenline(1) + return 'r' + endfunc + inoremap SaveFirstLine() + call test_override('redraw_flag', 1) + call test_override('char_avail', 1) + let @r = 'sample' + call feedkeys("a\=SaveFirstLine()\", "xt") + call assert_equal('"', g:Line) + call test_override('ALL', 0) + close! + endfunc + + " When a character is inserted at the last position of the last line in a + " window, the window contents should be scrolled one line up. If the top line + " is part of a fold, then the entire fold should be scrolled up. + func Test_edit_lastline_scroll() + new + let h = winheight(0) + let lines = ['one', 'two', 'three'] + let lines += repeat(['vim'], h - 4) + call setline(1, lines) + call setline(h, repeat('x', winwidth(0) - 1)) + call feedkeys("GAx", 'xt') + redraw! + call assert_equal(h - 1, winline()) + call assert_equal(2, line('w0')) + + " scroll with a fold + 1,2fold + normal gg + call setline(h + 1, repeat('x', winwidth(0) - 1)) + call feedkeys("GAx", 'xt') + redraw! + call assert_equal(h - 1, winline()) + call assert_equal(3, line('w0')) + + close! + endfunc + " vim: shiftwidth=2 sts=2 expandtab *** ../vim-8.2.1021/src/testdir/test_iminsert.vim 2020-03-10 07:48:06.571619551 +0100 --- src/testdir/test_iminsert.vim 2020-06-20 16:03:11.440533949 +0200 *************** *** 7,13 **** func IM_activatefunc(active) let s:imactivatefunc_called = 1 ! let s:imstatus_active = a:active endfunc func IM_statusfunc() --- 7,13 ---- func IM_activatefunc(active) let s:imactivatefunc_called = 1 ! let s:imstatus_active = a:active endfunc func IM_statusfunc() *************** *** 83,86 **** --- 83,112 ---- close! endfunc + " Test for using CTRL-^ to toggle iminsert in insert mode + func Test_iminsert_toggle() + CheckGui + if has('win32') + CheckFeature multi_byte_ime + elseif !has('gui_mac') + CheckFeature xim + endif + if has('gui_running') && !has('win32') + " this works only in Win32 GUI version (for some reason) + return + endif + new + let save_imdisable = &imdisable + let save_iminsert = &iminsert + set noimdisable + set iminsert=0 + exe "normal i\" + call assert_equal(2, &iminsert) + exe "normal i\" + call assert_equal(0, &iminsert) + let &iminsert = save_iminsert + let &imdisable = save_imdisable + close! + endfunc + " vim: shiftwidth=2 sts=2 expandtab *** ../vim-8.2.1021/src/testdir/test_paste.vim 2019-08-12 14:08:44.000000000 +0200 --- src/testdir/test_paste.vim 2020-06-20 16:03:11.440533949 +0200 *************** *** 79,89 **** --- 79,105 ---- bwipe! endfunc + " bracketed paste in command line func Test_paste_cmdline() call feedkeys(":a\[200~foo\bar\[201~b\\"\", 'xt') call assert_equal("\"afoo\barb", getreg(':')) endfunc + " bracketed paste in Ex-mode + func Test_paste_ex_mode() + unlet! foo + call feedkeys("Qlet foo=\"\[200~foo\bar\[201~\"\vi\", 'xt') + call assert_equal("foo\rbar", foo) + endfunc + + func Test_paste_onechar() + new + let @f='abc' + call feedkeys("i\\[200~foo\bar\[201~", 'xt') + call assert_equal("abc", getline(1)) + close! + endfunc + func Test_paste_visual_mode() new call setline(1, 'here are some words') *************** *** 134,136 **** --- 150,154 ---- bwipe! endfunc + + " vim: shiftwidth=2 sts=2 expandtab *** ../vim-8.2.1021/src/testdir/test_prompt_buffer.vim 2020-04-21 22:19:26.059486839 +0200 --- src/testdir/test_prompt_buffer.vim 2020-06-20 16:03:11.440533949 +0200 *************** *** 147,152 **** --- 147,157 ---- call assert_beeps('normal! S') call assert_beeps("normal! \") call assert_beeps("normal! \") + " pressing CTRL-W in the prompt buffer should trigger the window commands + call assert_equal(1, winnr()) + exe "normal A\\" + call assert_equal(2, winnr()) + wincmd w close! call assert_equal(0, prompt_setprompt([], '')) endfunc *** ../vim-8.2.1021/src/testdir/test_selectmode.vim 2020-03-22 14:08:27.321399669 +0100 --- src/testdir/test_selectmode.vim 2020-06-20 16:03:11.440533949 +0200 *************** *** 38,43 **** --- 38,46 ---- set selectmode=cmd call feedkeys('gvabc', 'xt') call assert_equal('abctdef', getline(1)) + " arrow keys without shift should not start selection + call feedkeys("A\\\ro", 'xt') + call assert_equal('roabctdef', getline(1)) set selectmode= keymodel= bw! endfunc *** ../vim-8.2.1021/src/testdir/test_tabpage.vim 2020-05-31 21:27:58.335221898 +0200 --- src/testdir/test_tabpage.vim 2020-06-20 16:03:11.440533949 +0200 *************** *** 623,626 **** --- 623,637 ---- tabonly endfunc + " Pressing in insert mode should go to the previous tab page + " and should go to the next tab page + func Test_tabpage_Ctrl_Pageup() + tabnew + call feedkeys("i\", 'xt') + call assert_equal(1, tabpagenr()) + call feedkeys("i\", 'xt') + call assert_equal(2, tabpagenr()) + %bw! + endfunc + " vim: shiftwidth=2 sts=2 expandtab *** ../vim-8.2.1021/src/testdir/test_tagjump.vim 2020-06-17 22:58:31.044411790 +0200 --- src/testdir/test_tagjump.vim 2020-06-20 16:03:11.440533949 +0200 *************** *** 240,245 **** --- 240,246 ---- call delete('Xtags1') endfunc + " Test for emacs-style tags file (TAGS) func Test_tagjump_etags() if !has('emacs_tags') return *************** *** 1055,1061 **** call writefile([ \ "!_TAG_FILE_ENCODING\tutf-8\t//", \ "first\tXfoo\t1" .. ';"' .. "\tv\ttyperef:typename:int\tfile:", ! \ "first\tXfoo\t2" .. ';"' .. "\tv\ttyperef:typename:char\tfile:"], \ 'Xtags') set tags=Xtags --- 1056,1062 ---- call writefile([ \ "!_TAG_FILE_ENCODING\tutf-8\t//", \ "first\tXfoo\t1" .. ';"' .. "\tv\ttyperef:typename:int\tfile:", ! \ "first\tXfoo\t2" .. ';"' .. "\tkind:v\ttyperef:typename:char\tfile:"], \ 'Xtags') set tags=Xtags *************** *** 1337,1340 **** --- 1338,1393 ---- set tags& taglength& endfunc + " Tests for errors in a tags file + func Test_tagfile_errors() + set tags=Xtags + + " missing search pattern or line number for a tag + call writefile(["!_TAG_FILE_ENCODING\tutf-8\t//", + \ "foo\tXfile\t"], 'Xtags', 'b') + call writefile(['foo'], 'Xfile') + + enew + tag foo + call assert_equal('', @%) + let caught_431 = v:false + try + eval taglist('.*') + catch /:E431:/ + let caught_431 = v:true + endtry + call assert_equal(v:true, caught_431) + + call delete('Xtags') + call delete('Xfile') + set tags& + endfunc + + " When :stag fails to open the file, should close the new window + func Test_stag_close_window_on_error() + new | only + set tags=Xtags + call writefile(["!_TAG_FILE_ENCODING\tutf-8\t//", + \ "foo\tXfile\t1"], 'Xtags') + call writefile(['foo'], 'Xfile') + call writefile([], '.Xfile.swp') + " Remove the catch-all that runtest.vim adds + au! SwapExists + augroup StagTest + au! + autocmd SwapExists Xfile let v:swapchoice='q' + augroup END + + stag foo + call assert_equal(1, winnr('$')) + call assert_equal('', @%) + + augroup StagTest + au! + augroup END + call delete('Xfile') + call delete('.Xfile.swp') + set tags& + endfunc + " vim: shiftwidth=2 sts=2 expandtab *** ../vim-8.2.1021/src/testdir/test_textformat.vim 2020-05-05 19:57:15.075406752 +0200 --- src/testdir/test_textformat.vim 2020-06-20 16:03:11.440533949 +0200 *************** *** 1116,1121 **** --- 1116,1135 ---- call feedkeys("iabc abc a abc\k0weade", 'xt') call assert_equal(['abc abcde ', 'a abc'], getline(1, '$')) + " when a line ends with space, it is not broken up. + %d + call feedkeys("ione two to ", 'xt') + call assert_equal('one two to ', getline(1)) + + " when a line ends with spaces and backspace is used in the next line, the + " last space in the previous line should be removed. + %d + set backspace=indent,eol,start + call setline(1, ['one ', 'two']) + exe "normal 2Gi\" + call assert_equal(['one two'], getline(1, '$')) + set backspace& + " Test for 'a', 'w' and '1' options. setlocal textwidth=0 setlocal fo=1aw *** ../vim-8.2.1021/src/testdir/test_viminfo.vim 2020-06-07 16:08:03.656925994 +0200 --- src/testdir/test_viminfo.vim 2020-06-20 16:03:11.440533949 +0200 *************** *** 87,92 **** --- 87,114 ---- call assert_equal(test_null, g:MY_GLOBAL_NULL) call assert_equal(test_none, g:MY_GLOBAL_NONE) + " Test for invalid values for a blob, list, dict in a viminfo file + call writefile([ + \ "!GLOB_BLOB_1\tBLO\t123", + \ "!GLOB_BLOB_2\tBLO\t012", + \ "!GLOB_BLOB_3\tBLO\t0z1x", + \ "!GLOB_BLOB_4\tBLO\t0z12 ab", + \ "!GLOB_LIST_1\tLIS\t1 2", + \ "!GLOB_DICT_1\tDIC\t1 2"], 'Xviminfo') + call assert_fails('rv! Xviminfo', 'E15:') + call assert_equal('123', g:GLOB_BLOB_1) + call assert_equal(1, type(g:GLOB_BLOB_1)) + call assert_equal('012', g:GLOB_BLOB_2) + call assert_equal(1, type(g:GLOB_BLOB_2)) + call assert_equal('0z1x', g:GLOB_BLOB_3) + call assert_equal(1, type(g:GLOB_BLOB_3)) + call assert_equal('0z12 ab', g:GLOB_BLOB_4) + call assert_equal(1, type(g:GLOB_BLOB_4)) + call assert_equal('1 2', g:GLOB_LIST_1) + call assert_equal(1, type(g:GLOB_LIST_1)) + call assert_equal('1 2', g:GLOB_DICT_1) + call assert_equal(1, type(g:GLOB_DICT_1)) + call delete('Xviminfo') set viminfo-=! endfunc *** ../vim-8.2.1021/src/testdir/test_virtualedit.vim 2020-04-11 17:09:28.324426586 +0200 --- src/testdir/test_virtualedit.vim 2020-06-20 16:03:11.440533949 +0200 *************** *** 357,360 **** --- 357,378 ---- close! endfunc + " Test for using , and in virtual edit mode + " to erase character, word and line. + func Test_ve_backspace() + new + call setline(1, 'sample') + set virtualedit=all + set backspace=indent,eol,start + exe "normal 15|i\\" + call assert_equal([0, 1, 7, 5], getpos('.')) + exe "normal 15|i\" + call assert_equal([0, 1, 6, 0], getpos('.')) + exe "normal 15|i\" + call assert_equal([0, 1, 1, 0], getpos('.')) + set backspace& + set virtualedit& + close! + endfunc + " vim: shiftwidth=2 sts=2 expandtab *** ../vim-8.2.1021/src/testdir/test_visual.vim 2020-04-28 20:29:04.241851561 +0200 --- src/testdir/test_visual.vim 2020-06-20 16:03:11.440533949 +0200 *************** *** 208,213 **** --- 208,222 ---- exe "normal iabcdefghijklmnopqrst\0gRAB\tIJKLMNO\tQR" call assert_equal(['AB......CDEFGHI.Jkl', \ 'AB IJKLMNO QRst'], getline(12, 13)) + + " Test inserting Tab with 'noexpandtab' and 'softabstop' set to 4 + %d + call setline(1, 'aaaaaaaaaaaaa') + set softtabstop=4 + exe "normal gggR\\x" + call assert_equal("\txaaaa", getline(1)) + set softtabstop& + enew! set noai bs&vim if exists('save_t_kD') *** ../vim-8.2.1021/src/version.c 2020-06-20 16:00:22.744950878 +0200 --- src/version.c 2020-06-20 16:04:25.036348218 +0200 *************** *** 756,757 **** --- 756,759 ---- { /* Add new patch number below this line */ + /**/ + 1022, /**/ -- ARTHUR: Charge! [They all charge with swords drawn towards the RABBIT. A tremendous twenty second fight with Peckinpahish shots and borrowing heavily also on the Kung Fu and karate-type films ensues, in which some four KNIGHTS are comprehensively killed.] ARTHUR: Run away! Run away! "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/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///