To: vim_dev@googlegroups.com Subject: Patch 7.4.2353 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 7.4.2353 Problem: Not enough test coverage for Normal mode commands. Solution: Add more tests. (Christian Brabandt) Files: src/testdir/test_normal.vim *** ../vim-7.4.2352/src/testdir/test_normal.vim 2016-09-08 23:35:27.022913833 +0200 --- src/testdir/test_normal.vim 2016-09-09 16:54:46.336785660 +0200 *************** *** 13,21 **** call setline(ln, substitute(line, '\s\+$', '', '') . '->$') endif endfor ! endfu ! function! CountSpaces(type, ...) " for testing operatorfunc " will count the number of spaces " and return the result in g:a --- 13,21 ---- call setline(ln, substitute(line, '\s\+$', '', '') . '->$') endif endfor ! endfunc ! func! CountSpaces(type, ...) " for testing operatorfunc " will count the number of spaces " and return the result in g:a *************** *** 33,39 **** let g:a=strlen(substitute(@@, '[^ ]', '', 'g')) let &selection = sel_save let @@ = reg_save ! endfunction fun! Test_normal00_optrans() new --- 33,43 ---- let g:a=strlen(substitute(@@, '[^ ]', '', 'g')) let &selection = sel_save let @@ = reg_save ! endfunc ! ! func! IsWindows() ! return has("win32") || has("win64") || has("win95") ! endfunc fun! Test_normal00_optrans() new *************** *** 60,86 **** " clean up set cpo-=# bw! ! endfu func! Test_normal01_keymodel() call Setup_NewWindow() " Test 1: depending on 'keymodel' does something different ! :50 call feedkeys("V\y", 'tx') call assert_equal(['47', '48', '49', '50'], getline("'<", "'>")) ! :set keymodel=startsel ! :50 call feedkeys("V\y", 'tx') call assert_equal(['49', '50'], getline("'<", "'>")) " Start visual mode when keymodel = startsel ! :50 call feedkeys("\y", 'tx') call assert_equal(['49', '5'], getreg(0, 0, 1)) " Do not start visual mode when keymodel= ! :set keymodel= ! :50 call feedkeys("\y$", 'tx') call assert_equal(['42'], getreg(0, 0, 1)) " clean up bw! --- 64,100 ---- " clean up set cpo-=# bw! ! endfunc func! Test_normal01_keymodel() call Setup_NewWindow() " Test 1: depending on 'keymodel' does something different ! 50 call feedkeys("V\y", 'tx') call assert_equal(['47', '48', '49', '50'], getline("'<", "'>")) ! set keymodel=startsel ! 50 call feedkeys("V\y", 'tx') call assert_equal(['49', '50'], getline("'<", "'>")) " Start visual mode when keymodel = startsel ! 50 call feedkeys("\y", 'tx') call assert_equal(['49', '5'], getreg(0, 0, 1)) " Do not start visual mode when keymodel= ! set keymodel= ! 50 call feedkeys("\y$", 'tx') call assert_equal(['42'], getreg(0, 0, 1)) + " Stop visual mode when keymodel=stopsel + set keymodel=stopsel + 50 + call feedkeys("Vkk\yy", 'tx') + call assert_equal(['47'], getreg(0, 0, 1)) + + set keymodel= + 50 + call feedkeys("Vkk\yy", 'tx') + call assert_equal(['47', '48', '49', '50'], getreg(0, 0, 1)) " clean up bw! *************** *** 98,104 **** call assert_equal('y60', getline('.')) " clean up bw! ! endfu func! Test_normal03_join() " basic join test --- 112,128 ---- call assert_equal('y60', getline('.')) " clean up bw! ! endfunc ! ! func! Test_normal02_selectmode2() ! " some basic select mode tests ! call Setup_NewWindow() ! 50 ! call feedkeys(":set im\n\gHc\:set noim\n", 'tx') ! call assert_equal('c51', getline('.')) ! " clean up ! bw! ! endfunc func! Test_normal03_join() " basic join test *************** *** 118,129 **** call assert_equal('100', getline('.')) " clean up bw! ! endfu func! Test_normal04_filter() " basic filter test " only test on non windows platform ! if has("win32") || has("win64") || has("win95") return endif call Setup_NewWindow() --- 142,153 ---- call assert_equal('100', getline('.')) " clean up bw! ! endfunc func! Test_normal04_filter() " basic filter test " only test on non windows platform ! if IsWindows() return endif call Setup_NewWindow() *************** *** 144,150 **** call assert_equal('one', getline('.')) set cpo-=! bw! ! endfu func! Test_normal05_formatexpr() " basic formatexpr test --- 168,174 ---- call assert_equal('one', getline('.')) set cpo-=! bw! ! endfunc func! Test_normal05_formatexpr() " basic formatexpr test *************** *** 157,163 **** call assert_equal(['here: 1->$', '2', 'here: 3->$', '4', 'not here: '], getline(1,'$')) set formatexpr= bw! ! endfu func Test_normal05_formatexpr_newbuf() " Edit another buffer in the 'formatexpr' function --- 181,187 ---- call assert_equal(['here: 1->$', '2', 'here: 3->$', '4', 'not here: '], getline(1,'$')) set formatexpr= bw! ! endfunc func Test_normal05_formatexpr_newbuf() " Edit another buffer in the 'formatexpr' function *************** *** 186,192 **** func! Test_normal06_formatprg() " basic test for formatprg " only test on non windows platform ! if has("win32") || has("win64") || has("win95") return else " uses sed to number non-empty lines --- 210,216 ---- func! Test_normal06_formatprg() " basic test for formatprg " only test on non windows platform ! if IsWindows() return else " uses sed to number non-empty lines *************** *** 203,209 **** set formatprg= call delete('Xsed_format.sh') bw! ! endfu func! Test_normal07_internalfmt() " basic test for internal formmatter to textwidth of 12 --- 227,233 ---- set formatprg= call delete('Xsed_format.sh') bw! ! endfunc func! Test_normal07_internalfmt() " basic test for internal formmatter to textwidth of 12 *************** *** 217,223 **** " clean up set formatprg= tw=0 bw! ! endfu func! Test_normal08_fold() " basic tests for foldopen/folddelete --- 241,247 ---- " clean up set formatprg= tw=0 bw! ! endfunc func! Test_normal08_fold() " basic tests for foldopen/folddelete *************** *** 276,282 **** " clean up setl nofoldenable fdm=marker bw! ! endfu func! Test_normal09_operatorfunc() " Test operatorfunc --- 300,306 ---- " clean up setl nofoldenable fdm=marker bw! ! endfunc func! Test_normal09_operatorfunc() " Test operatorfunc *************** *** 305,311 **** unmap ,, set opfunc= bw! ! endfu func! Test_normal10_expand() " Test for expand() --- 329,335 ---- unmap ,, set opfunc= bw! ! endfunc func! Test_normal10_expand() " Test for expand() *************** *** 319,325 **** call assert_equal('ifooar,,cbar', b) " clean up bw! ! endfu func! Test_normal11_showcmd() " test for 'showcmd' --- 343,349 ---- call assert_equal('ifooar,,cbar', b) " clean up bw! ! endfunc func! Test_normal11_showcmd() " test for 'showcmd' *************** *** 334,340 **** exe "norm! 0d3\2l" call assert_equal('obar2foobar3', getline('.')) bw! ! endfu func! Test_normal12_nv_error() " Test for nv_error --- 358,364 ---- exe "norm! 0d3\2l" call assert_equal('obar2foobar3', getline('.')) bw! ! endfunc func! Test_normal12_nv_error() " Test for nv_error *************** *** 344,350 **** exe "norm! " call assert_equal(map(range(1,5), 'string(v:val)'), getline(1,'$')) bw! ! endfu func! Test_normal13_help() " Test for F1 --- 368,374 ---- exe "norm! " call assert_equal(map(range(1,5), 'string(v:val)'), getline(1,'$')) bw! ! endfunc func! Test_normal13_help() " Test for F1 *************** *** 353,359 **** call assert_match('help\.txt', bufname('%')) call assert_equal(2, winnr('$')) bw! ! endfu func! Test_normal14_page() " basic test for Ctrl-F and Ctrl-B --- 377,383 ---- call assert_match('help\.txt', bufname('%')) call assert_equal(2, winnr('$')) bw! ! endfunc func! Test_normal14_page() " basic test for Ctrl-F and Ctrl-B *************** *** 387,393 **** " cleanup set startofline bw! ! endfu func! Test_normal14_page_eol() 10new --- 411,417 ---- " cleanup set startofline bw! ! endfunc func! Test_normal14_page_eol() 10new *************** *** 485,491 **** " cleanup bw! ! endfu func! Test_normal16_z_scroll_hor() " basic test for z commands that scroll the window --- 509,515 ---- " cleanup bw! ! endfunc func! Test_normal16_z_scroll_hor() " basic test for z commands that scroll the window *************** *** 551,557 **** " cleanup set wrap listchars=eol:$ bw! ! endfu func! Test_normal17_z_scroll_hor2() " basic test for z commands that scroll the window --- 575,581 ---- " cleanup set wrap listchars=eol:$ bw! ! endfunc func! Test_normal17_z_scroll_hor2() " basic test for z commands that scroll the window *************** *** 618,624 **** " cleanup set wrap listchars=eol:$ sidescrolloff=0 bw! ! endfu func! Test_normal18_z_fold() " basic tests for foldopen/folddelete --- 642,648 ---- " cleanup set wrap listchars=eol:$ sidescrolloff=0 bw! ! endfunc func! Test_normal18_z_fold() " basic tests for foldopen/folddelete *************** *** 989,995 **** " clean up setl nofoldenable fdm=marker foldlevel=0 bw! ! endfu func! Test_normal19_z_spell() if !has("spell") || !has('syntax') --- 1013,1019 ---- " clean up setl nofoldenable fdm=marker foldlevel=0 bw! ! endfunc func! Test_normal19_z_spell() if !has("spell") || !has('syntax') *************** *** 1136,1142 **** set spellfile= bw! ! endfu func! Test_normal20_exmode() if !has("unix") --- 1160,1166 ---- set spellfile= bw! ! endfunc func! Test_normal20_exmode() if !has("unix") *************** *** 1154,1163 **** call delete(file) endfor bw! ! endfu func! Test_normal21_nv_hat() set hidden e Xfoobar e Xfile2 call feedkeys("\", 't') --- 1178,1191 ---- call delete(file) endfor bw! ! endfunc func! Test_normal21_nv_hat() set hidden + new + " to many buffers opened already, will not work + "call assert_fails(":b#", 'E23') + "call assert_equal('', @#) e Xfoobar e Xfile2 call feedkeys("\", 't') *************** *** 1167,1173 **** " clean up set nohidden bw! ! endfu func! Test_normal22_zet() " Test for ZZ --- 1195,1201 ---- " clean up set nohidden bw! ! endfunc func! Test_normal22_zet() " Test for ZZ *************** *** 1189,1195 **** call delete(file) endfor " let &shell = shell ! endfu func! Test_normal23_K() " Test for K command --- 1217,1223 ---- call delete(file) endfor " let &shell = shell ! endfunc func! Test_normal23_K() " Test for K command *************** *** 1224,1230 **** " clean up let &keywordprg = k bw! ! endfu func! Test_normal24_rot13() " This test uses multi byte characters --- 1252,1258 ---- " clean up let &keywordprg = k bw! ! endfunc func! Test_normal24_rot13() " This test uses multi byte characters *************** *** 1242,1248 **** " clean up bw! ! endfu func! Test_normal25_tag() " Testing for CTRL-] g CTRL-] g] --- 1270,1276 ---- " clean up bw! ! endfunc func! Test_normal25_tag() " Testing for CTRL-] g CTRL-] g] *************** *** 1309,1315 **** " clean up helpclose ! endfu func! Test_normal26_put() " Test for ]p ]P [p and [P --- 1337,1343 ---- " clean up helpclose ! endfunc func! Test_normal26_put() " Test for ]p ]P [p and [P *************** *** 1328,1334 **** " clean up bw! ! endfu func! Test_normal27_bracket() " Test for [' [` ]' ]` --- 1356,1362 ---- " clean up bw! ! endfunc func! Test_normal27_bracket() " Test for [' [` ]' ]` *************** *** 1379,1385 **** " clean up bw! ! endfu func! Test_normal28_parenthesis() " basic testing for ( and ) --- 1407,1413 ---- " clean up bw! ! endfunc func! Test_normal28_parenthesis() " basic testing for ( and ) *************** *** 1402,1408 **** " clean up bw! ! endfu fun! Test_normal29_brace() " basic test for { and } movements --- 1430,1436 ---- " clean up bw! ! endfunc fun! Test_normal29_brace() " basic test for { and } movements *************** *** 1477,1483 **** " clean up set cpo-={ bw! ! endfu fun! Test_normal30_changecase() " This test uses multi byte characters --- 1505,1511 ---- " clean up set cpo-={ bw! ! endfunc fun! Test_normal30_changecase() " This test uses multi byte characters *************** *** 1505,1511 **** " clean up bw! ! endfu fun! Test_normal31_r_cmd() " Test for r command --- 1533,1539 ---- " clean up bw! ! endfunc fun! Test_normal31_r_cmd() " Test for r command *************** *** 1530,1536 **** " clean up set noautoindent bw! ! endfu func! Test_normal32_g_cmd1() " Test for g*, g# --- 1558,1564 ---- " clean up set noautoindent bw! ! endfunc func! Test_normal32_g_cmd1() " Test for g*, g# *************** *** 1546,1552 **** " clean up bw! ! endfu fun! Test_normal33_g_cmd2() if !has("jumplist") --- 1574,1580 ---- " clean up bw! ! endfunc fun! Test_normal33_g_cmd2() if !has("jumplist") *************** *** 1666,1672 **** " clean up bw! ! endfu fun! Test_normal34_g_cmd3() if !has("multi_byte") --- 1694,1700 ---- " clean up bw! ! endfunc fun! Test_normal34_g_cmd3() if !has("multi_byte") *************** *** 1682,1688 **** call append(1, range(1,10)) " clean up bw! ! endfu fun! Test_normal35_g_cmd4() " Test for g< --- 1710,1716 ---- call append(1, range(1,10)) " clean up bw! ! endfunc fun! Test_normal35_g_cmd4() " Test for g< *************** *** 1692,1698 **** echo "a\nb\nc\nd" let b=execute(':norm! g<') call assert_true(!empty(b), 'failed `execute(g<)`') ! endfu fun! Test_normal36_g_cmd5() new --- 1720,1726 ---- echo "a\nb\nc\nd" let b=execute(':norm! g<') call assert_true(!empty(b), 'failed `execute(g<)`') ! endfunc fun! Test_normal36_g_cmd5() new *************** *** 1730,1736 **** call assert_equal([0, 14, 1, 0, 2147483647], getcurpos()) " clean up bw! ! endfu fun! Test_normal37_g_cmd6() " basic test for gt and gT --- 1758,1764 ---- call assert_equal([0, 14, 1, 0, 2147483647], getcurpos()) " clean up bw! ! endfunc fun! Test_normal37_g_cmd6() " basic test for gt and gT *************** *** 1757,1763 **** endfor " clean up call assert_fails(':tabclose', 'E784') ! endfu fun! Test_normal38_nvhome() " Test for and key --- 1785,1791 ---- endfor " clean up call assert_fails(':tabclose', 'E784') ! endfunc fun! Test_normal38_nvhome() " Test for and key *************** *** 1778,1784 **** " clean up bw! ! endfu fun! Test_normal39_cw() " Test for cw and cW on whitespace --- 1806,1812 ---- " clean up bw! ! endfunc fun! Test_normal39_cw() " Test for cw and cW on whitespace *************** *** 1802,1808 **** " clean up bw! ! endfu fun! Test_normal40_ctrl_bsl() " Basic test for CTRL-\ commands --- 1830,1836 ---- " clean up bw! ! endfunc fun! Test_normal40_ctrl_bsl() " Basic test for CTRL-\ commands *************** *** 1827,1833 **** " clean up bw! ! endfu fun! Test_normal41_insert_reg() " Test for =, = and = --- 1855,1861 ---- " clean up bw! ! endfunc fun! Test_normal41_insert_reg() " Test for =, = and = *************** *** 1847,1853 **** " clean up set sts=0 sw=8 ts=8 bw! ! endfu func! Test_normal42_halfpage() " basic test for Ctrl-D and Ctrl-U --- 1875,1881 ---- " clean up set sts=0 sw=8 ts=8 bw! ! endfunc func! Test_normal42_halfpage() " basic test for Ctrl-D and Ctrl-U *************** *** 1884,1890 **** " cleanup set startofline bw! ! endfu fun! Test_normal43_textobject1() " basic tests for text object aw --- 1912,1918 ---- " cleanup set startofline bw! ! endfunc fun! Test_normal43_textobject1() " basic tests for text object aw *************** *** 1915,1921 **** " clean up bw! ! endfu func! Test_normal44_textobjects2() " basic testing for is and as text objects --- 1943,1949 ---- " clean up bw! ! endfunc func! Test_normal44_textobjects2() " basic testing for is and as text objects *************** *** 1970,1976 **** " clean up bw! ! endfu func! Test_normal45_drop() if !has("dnd") --- 1998,2004 ---- " clean up bw! ! endfunc func! Test_normal45_drop() if !has("dnd") *************** *** 1985,1993 **** " the ~ register is read only call assert_fails(':let @~="1"', 'E354') bw! ! endfu func! Test_normal46_ignore() new " How to test this? " let's just for now test, that the buffer --- 2013,2026 ---- " the ~ register is read only call assert_fails(':let @~="1"', 'E354') bw! ! endfunc func! Test_normal46_ignore() + " This test uses multi byte characters + if !has("multi_byte") + return + endif + new " How to test this? " let's just for now test, that the buffer *************** *** 1995,2003 **** call feedkeys("\", 't') call assert_equal([''], getline(1,'$')) " clean up bw! ! endfu func! Test_normal47_visual_buf_wipe() " This was causing a crash or ml_get error. --- 2028,2043 ---- call feedkeys("\", 't') call assert_equal([''], getline(1,'$')) + " no valid commands + exe "norm! \" + call assert_equal([''], getline(1,'$')) + + exe "norm! ä" + call assert_equal([''], getline(1,'$')) + " clean up bw! ! endfunc func! Test_normal47_visual_buf_wipe() " This was causing a crash or ml_get error. *************** *** 2011,2014 **** bw! norm yp set nomodified ! endfu --- 2051,2209 ---- bw! norm yp set nomodified ! endfunc ! ! func! Test_normal47_autocmd() ! " disabled, does not seem to be possible currently ! throw "Skipped: not possible to test cursorhold autocmd while waiting for input in normal_cmd" ! new ! call append(0, repeat('-',20)) ! au CursorHold * call feedkeys('2l', '') ! 1 ! set updatetime=20 ! " should delete 12 chars (d12l) ! call feedkeys('d1', '!') ! call assert_equal('--------', getline(1)) ! ! " clean up ! au! CursorHold ! set updatetime=4000 ! bw! ! endfunc ! ! func! Test_normal48_wincmd() ! new ! exe "norm! \c" ! call assert_equal(1, winnr('$')) ! call assert_fails(":norm! \c", "E444") ! endfunc ! ! func! Test_normal49_counts() ! new ! call setline(1, 'one two three four five six seven eight nine ten') ! 1 ! norm! 3d2w ! call assert_equal('seven eight nine ten', getline(1)) ! bw! ! endfunc ! ! func! Test_normal50_commandline() ! if !has("timers") || !has("cmdline_hist") || !has("vertsplit") ! return ! endif ! func! DoTimerWork(id) ! call assert_equal('[Command Line]', bufname('')) ! " should fail, with E11, but does fail with E23? ! "call feedkeys("\", 'tm') ! ! " should also fail with E11 ! call assert_fails(":wincmd p", 'E11') ! " return from commandline window ! call feedkeys("\") ! endfunc ! ! let oldlang=v:lang ! lang C ! set updatetime=20 ! call timer_start(100, 'DoTimerWork') ! try ! " throws E23, for whatever reason... ! call feedkeys('q:', 'x!') ! catch /E23/ ! " no-op ! endtry ! " clean up ! set updatetime=4000 ! exe "lang" oldlang ! bw! ! endfunc ! ! func! Test_normal51_FileChangedRO() ! if !has("autocmd") ! return ! endif ! call writefile(['foo'], 'Xreadonly.log') ! new Xreadonly.log ! setl ro ! au FileChangedRO :call feedkeys("\", 'tix') ! call assert_fails(":norm! Af", 'E788') ! call assert_equal(['foo'], getline(1,'$')) ! call assert_equal('Xreadonly.log', bufname('')) ! ! " cleanup ! bw! ! call delete("Xreadonly.log") ! endfunc ! ! func! Test_normal52_rl() ! if !has("rightleft") ! return ! endif ! new ! call setline(1, 'abcde fghij klmnopq') ! norm! 1gg$ ! set rl ! call assert_equal(19, col('.')) ! call feedkeys('l', 'tx') ! call assert_equal(18, col('.')) ! call feedkeys('h', 'tx') ! call assert_equal(19, col('.')) ! call feedkeys("\", 'tx') ! call assert_equal(18, col('.')) ! call feedkeys("\", 'tx') ! call assert_equal(13, col('.')) ! call feedkeys("\", 'tx') ! call assert_equal(7, col('.')) ! call feedkeys("\", 'tx') ! call assert_equal(13, col('.')) ! call feedkeys("\", 'tx') ! call assert_equal(19, col('.')) ! call feedkeys("<<", 'tx') ! call assert_equal(' abcde fghij klmnopq',getline(1)) ! call feedkeys(">>", 'tx') ! call assert_equal('abcde fghij klmnopq',getline(1)) ! ! " cleanup ! set norl ! bw! ! endfunc ! ! func! Test_normal53_digraph() ! if !has('digraphs') ! return ! endif ! new ! call setline(1, 'abcdefgh|') ! exe "norm! 1gg0f\!!" ! call assert_equal(9, col('.')) ! set cpo+=D ! exe "norm! 1gg0f\!!" ! call assert_equal(1, col('.')) ! ! set cpo-=D ! bw! ! endfunc ! ! func! Test_normal54_Ctrl_bsl() ! new ! call setline(1, 'abcdefghijklmn') ! exe "norm! df\\" ! call assert_equal(['abcdefghijklmn'], getline(1,'$')) ! exe "norm! df\\" ! call assert_equal(['abcdefghijklmn'], getline(1,'$')) ! exe "norm! df\m" ! call assert_equal(['abcdefghijklmn'], getline(1,'$')) ! if !has("multi_byte") ! return ! endif ! call setline(2, 'abcdefghijklmnāf') ! norm! 2gg0 ! exe "norm! df\" ! call assert_equal(['abcdefghijklmn', 'f'], getline(1,'$')) ! norm! 1gg0 ! exe "norm! df\" ! call assert_equal(['abcdefghijklmn', 'f'], getline(1,'$')) ! ! " clean up ! bw! ! endfunc *** ../vim-7.4.2352/src/version.c 2016-09-09 16:03:45.171139515 +0200 --- src/version.c 2016-09-09 16:58:13.565870096 +0200 *************** *** 765,766 **** --- 765,768 ---- { /* Add new patch number below this line */ + /**/ + 2353, /**/ -- hundred-and-one symptoms of being an internet addict: 216. Your pet rock leaves home. /// 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 ///