To: vim_dev@googlegroups.com Subject: Patch 8.2.0363 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.0363 Problem: Some Normal mode commands not tested. Solution: Add more tests. (Yegappan Lakshmanan, closes #5746) Files: src/testdir/test_cindent.vim, src/testdir/test_cmdline.vim, src/testdir/test_edit.vim, src/testdir/test_indent.vim, src/testdir/test_normal.vim, src/testdir/test_prompt_buffer.vim, src/testdir/test_virtualedit.vim, src/testdir/test_visual.vim *** ../vim-8.2.0362/src/testdir/test_cindent.vim 2020-01-26 21:59:25.632718110 +0100 --- src/testdir/test_cindent.vim 2020-03-08 05:02:45.706619068 +0100 *************** *** 5258,5266 **** set cindent norm! f:a: call assert_equal('case x:: // x', getline(1)) - set cindent& bwipe! endfunc " vim: shiftwidth=2 sts=2 expandtab --- 5258,5275 ---- set cindent norm! f:a: call assert_equal('case x:: // x', getline(1)) set cindent& bwipe! endfunc + " Test for changing multiple lines (using c) with cindent + func Test_cindent_change_multline() + new + setlocal cindent + call setline(1, ['if (a)', '{', ' i = 1;', '}']) + normal! jc3jm = 2; + call assert_equal("\tm = 2;", getline(2)) + close! + endfunc + " vim: shiftwidth=2 sts=2 expandtab *** ../vim-8.2.0362/src/testdir/test_cmdline.vim 2020-03-02 20:54:19.323757498 +0100 --- src/testdir/test_cmdline.vim 2020-03-08 05:02:45.706619068 +0100 *************** *** 1316,1319 **** --- 1316,1329 ---- call assert_equal('"ゔ', @:) endfunc + " Test for normal mode commands not supported in the cmd window + func Test_cmdwin_blocked_commands() + call assert_fails('call feedkeys("q:\\", "xt")', 'E11:') + call assert_fails('call feedkeys("q:\\", "xt")', 'E11:') + call assert_fails('call feedkeys("q:\\", "xt")', 'E11:') + call assert_fails('call feedkeys("q:Q\", "xt")', 'E11:') + call assert_fails('call feedkeys("q:Z\", "xt")', 'E11:') + call assert_fails('call feedkeys("q:\\", "xt")', 'E11:') + endfunc + " vim: shiftwidth=2 sts=2 expandtab *** ../vim-8.2.0362/src/testdir/test_edit.vim 2020-02-17 21:33:26.266098800 +0100 --- src/testdir/test_edit.vim 2020-03-08 05:02:45.706619068 +0100 *************** *** 265,270 **** --- 265,274 ---- call cursor(1, 4) call feedkeys("A\start\", 'txin') call assert_equal(['startdef', 'ghi'], getline(1, '$')) + " start select mode again with gv + set selectmode=cmd + call feedkeys('gvabc', 'xt') + call assert_equal('abctdef', getline(1)) set selectmode= keymodel= bw! endfunc *************** *** 1263,1268 **** --- 1267,1282 ---- catch /^Vim\%((\a\+)\)\=:E117/ " catch E117: unknown function endtry au! InsertCharPre + " Not allowed to enter ex mode when text is locked + au InsertCharPre :normal! gQ + let caught_e523 = 0 + try + call feedkeys("ix\", 'xt') + catch /^Vim\%((\a\+)\)\=:E523/ " catch E523 + let caught_e523 = 1 + endtry + call assert_equal(1, caught_e523) + au! InsertCharPre " 3) edit when completion is shown fun! Complete(findstart, base) if a:findstart *** ../vim-8.2.0362/src/testdir/test_indent.vim 2020-03-06 20:35:46.120669845 +0100 --- src/testdir/test_indent.vim 2020-03-08 05:02:45.706619068 +0100 *************** *** 98,101 **** --- 98,143 ---- close! endfunc + " Test for changing multiple lines with lisp indent + func Test_lisp_indent_change_multiline() + new + setlocal lisp autoindent + call setline(1, ['(if a', ' (if b', ' (return 5)))']) + normal! jc2j(return 4)) + call assert_equal(' (return 4))', getline(2)) + close! + endfunc + + func Test_lisp_indent() + new + setlocal lisp autoindent + call setline(1, ['(if a', ' ;; comment', ' \ abc', '', ' " str1\', ' " st\b', ' (return 5)']) + normal! jo;; comment + normal! jo\ abc + normal! jo;; ret + normal! jostr1" + normal! jostr2" + call assert_equal([' ;; comment', ' ;; comment', ' \ abc', ' \ abc', '', ' ;; ret', ' " str1\', ' str1"', ' " st\b', ' str2"'], getline(2, 11)) + close! + endfunc + + " Test for setting the 'indentexpr' from a modeline + func Test_modeline_indent_expr() + let modeline = &modeline + set modeline + func GetIndent() + return line('.') * 2 + endfunc + call writefile(['# vim: indentexpr=GetIndent()'], 'Xfile.txt') + set modelineexpr + new Xfile.txt + call assert_equal('GetIndent()', &indentexpr) + exe "normal Oa\nb\n" + call assert_equal([' a', ' b'], getline(1, 2)) + set modelineexpr& + delfunc GetIndent + let &modeline = modeline + close! + endfunc + " vim: shiftwidth=2 sts=2 expandtab *** ../vim-8.2.0362/src/testdir/test_normal.vim 2020-02-21 17:54:41.830235712 +0100 --- src/testdir/test_normal.vim 2020-03-08 05:02:45.706619068 +0100 *************** *** 115,122 **** bw! endfunc func Test_normal02_selectmode() - " some basic select mode tests call Setup_NewWindow() 50 norm! gHy --- 115,122 ---- bw! endfunc + " Test for select mode func Test_normal02_selectmode() call Setup_NewWindow() 50 norm! gHy *************** *** 439,446 **** 10new call setline(1, range(1,5)) " should not do anything, just beep ! exe "norm! " call assert_equal(map(range(1,5), 'string(v:val)'), getline(1,'$')) bw! endfunc --- 439,450 ---- 10new call setline(1, range(1,5)) " should not do anything, just beep ! call assert_beeps('exe "norm! "') call assert_equal(map(range(1,5), 'string(v:val)'), getline(1,'$')) + call assert_beeps('normal! G2dd') + call assert_beeps("normal! g\") + call assert_beeps("normal! g\") + call assert_beeps("normal! g\") bw! endfunc *************** *** 1628,1633 **** --- 1632,1645 ---- throw 'Skipped: Turkish locale not available' endtry + call setline(1, ['aaaaaa', 'aaaaaa']) + normal! gg10~ + call assert_equal(['AAAAAA', 'aaaaaa'], getline(1, 2)) + set whichwrap+=~ + normal! gg10~ + call assert_equal(['aaaaaa', 'AAAAaa'], getline(1, 2)) + set whichwrap& + " clean up bw! endfunc *************** *** 1657,1664 **** bw! endfunc func Test_normal32_g_cmd1() - " Test for g*, g# new call append(0, ['abc.x_foo', 'x_foobar.abc']) 1 --- 1669,1676 ---- bw! endfunc + " Test for g*, g# func Test_normal32_g_cmd1() new call append(0, ['abc.x_foo', 'x_foobar.abc']) 1 *************** *** 1673,1683 **** bw! endfunc fun! Test_normal33_g_cmd2() if !has("jumplist") return endif - " Tests for g cmds call Setup_NewWindow() " Test for g` clearjumps --- 1685,1696 ---- bw! endfunc + " Test for g`, g;, g,, g&, gv, gk, gj, gJ, g0, g^, g_, gm, g$, gM, g CTRL-G, + " gi and gI commands fun! Test_normal33_g_cmd2() if !has("jumplist") return endif call Setup_NewWindow() " Test for g` clearjumps *************** *** 1689,1694 **** --- 1702,1711 ---- call assert_equal('>', a[-1:]) call assert_equal(1, line('.')) call assert_equal('1', getline('.')) + call cursor(10, 1) + norm! g'a + call assert_equal('>', a[-1:]) + call assert_equal(1, line('.')) " Test for g; and g, norm! g; *************** *** 1730,1735 **** --- 1747,1758 ---- exe "norm! G0\4k4ly" exe "norm! gvood" call assert_equal(['', 'abfgh', 'abfgh', 'abfgh', 'fgh', 'fgh', 'fgh', 'fgh', 'fgh'], getline(1,'$')) + " gv cannot be used in operator pending mode + call assert_beeps('normal! cgv') + " gv should beep without a previously selected visual area + new + call assert_beeps('normal! gv') + close " Test for gk/gj %d *************** *** 1770,1777 **** norm! g^yl call assert_equal(15, col('.')) call assert_equal('l', getreg(0)) ! norm! 2ggdd $put =lineC " Test for gM --- 1793,1809 ---- norm! g^yl call assert_equal(15, col('.')) call assert_equal('l', getreg(0)) + call assert_beeps('normal 5g$') + + " Test for g_ + call assert_beeps('normal! 100g_') + call setline(2, [' foo ', ' foobar ']) + normal! 2ggg_ + call assert_equal(5, col('.')) + normal! 2g_ + call assert_equal(8, col('.')) ! norm! 2ggdG $put =lineC " Test for gM *************** *** 1805,1815 **** --- 1837,1859 ---- $put ='third line' norm! gi another word call assert_equal(['foobar next word another word', 'new line', 'third line'], getline(1,'$')) + call setline(1, 'foobar') + normal! Ggifirst line + call assert_equal('foobarfirst line', getline(1)) + " Test gi in 'virtualedit' mode with cursor after the end of the line + set virtualedit=all + call setline(1, 'foo') + exe "normal! Abar\\\\" + call setline(1, 'foo') + normal! Ggifirst line + call assert_equal('foo first line', getline(1)) + set virtualedit& " clean up bw! endfunc + " Test for g CTRL-G func Test_g_ctrl_g() new *************** *** 1883,1890 **** bwipe! endfunc fun! Test_normal34_g_cmd3() - " Test for g8 new let a=execute(':norm! 1G0g8') call assert_equal("\nNUL", a) --- 1927,1934 ---- bwipe! endfunc + " Test for g8 fun! Test_normal34_g_cmd3() new let a=execute(':norm! 1G0g8') call assert_equal("\nNUL", a) *************** *** 1901,1911 **** bw! endfunc func Test_normal_8g8() new - " Test 8g8 which finds invalid utf8 at or after the cursor. - " With invalid byte. call setline(1, "___\xff___") norm! 1G08g8g --- 1945,1954 ---- bw! endfunc + " Test 8g8 which finds invalid utf8 at or after the cursor. func Test_normal_8g8() new " With invalid byte. call setline(1, "___\xff___") norm! 1G08g8g *************** *** 1934,1941 **** bw! endfunc fun! Test_normal35_g_cmd4() - " Test for g< " Cannot capture its output, " probably a bug, therefore, test disabled: throw "Skipped: output of g< can't be tested currently" --- 1977,1984 ---- bw! endfunc + " Test for g< fun! Test_normal35_g_cmd4() " Cannot capture its output, " probably a bug, therefore, test disabled: throw "Skipped: output of g< can't be tested currently" *************** *** 1944,1949 **** --- 1987,1993 ---- call assert_true(!empty(b), 'failed `execute(g<)`') endfunc + " Test for gp gP go fun! Test_normal36_g_cmd5() new call append(0, 'abcdefghijklmnopqrstuvwxyz') *************** *** 1982,1989 **** bw! endfunc fun! Test_normal37_g_cmd6() - " basic test for gt and gT tabnew 1.txt tabnew 2.txt tabnew 3.txt --- 2026,2033 ---- bw! endfunc + " Test for gt and gT fun! Test_normal37_g_cmd6() tabnew 1.txt tabnew 2.txt tabnew 3.txt *************** *** 2009,2016 **** call assert_fails(':tabclose', 'E784:') endfunc fun! Test_normal38_nvhome() - " Test for and key new call setline(1, range(10)) $ --- 2053,2060 ---- call assert_fails(':tabclose', 'E784:') endfunc + " Test for and key fun! Test_normal38_nvhome() new call setline(1, range(10)) $ *************** *** 2025,2035 **** --- 2069,2082 ---- call assert_equal([0, 5, 1, 0, 1], getcurpos()) exe "norm! \" call assert_equal([0, 1, 1, 0, 1], getcurpos()) + exe "norm! G\" + call assert_equal([0, 1, 1, 0, 1], getcurpos()) " clean up bw! endfunc + " Test for cw cW ce fun! Test_normal39_cw() " Test for cw and cW on whitespace " and cpo+=w setting *************** *** 2050,2061 **** norm! 2gg0cwfoo call assert_equal('foo', getline('.')) " clean up bw! endfunc fun! Test_normal40_ctrl_bsl() - " Basic test for CTRL-\ commands new call append(0, 'here are some words') exe "norm! 1gg0a\\" --- 2097,2123 ---- norm! 2gg0cwfoo call assert_equal('foo', getline('.')) + call setline(1, 'one; two') + call cursor(1, 1) + call feedkeys('cwvim', 'xt') + call assert_equal('vim; two', getline(1)) + call feedkeys('0cWone', 'xt') + call assert_equal('one two', getline(1)) + "When cursor is at the end of a word 'ce' will change until the end of the + "next word, but 'cw' will change only one character + call setline(1, 'one two') + call feedkeys('0ecwce', 'xt') + call assert_equal('once two', getline(1)) + call setline(1, 'one two') + call feedkeys('0ecely', 'xt') + call assert_equal('only', getline(1)) + " clean up bw! endfunc + " Test for CTRL-\ commands fun! Test_normal40_ctrl_bsl() new call append(0, 'here are some words') exe "norm! 1gg0a\\" *************** *** 2079,2087 **** bw! endfunc fun! Test_normal41_insert_reg() - " Test for =, = and = - " in insert mode new set sts=2 sw=2 ts=8 tw=0 call append(0, ["aaa\tbbb\tccc", '', '', '']) --- 2141,2148 ---- bw! endfunc + " Test for =, = and = in insert mode fun! Test_normal41_insert_reg() new set sts=2 sw=2 ts=8 tw=0 call append(0, ["aaa\tbbb\tccc", '', '', '']) *************** *** 2099,2106 **** bw! endfunc func Test_normal42_halfpage() - " basic test for Ctrl-D and Ctrl-U call Setup_NewWindow() call assert_equal(5, &scroll) exe "norm! \" --- 2160,2167 ---- bw! endfunc + " Test for Ctrl-D and Ctrl-U func Test_normal42_halfpage() call Setup_NewWindow() call assert_equal(5, &scroll) exe "norm! \" *************** *** 2136,2143 **** bw! endfunc fun! Test_normal43_textobject1() - " basic tests for text object aw new call append(0, ['foobar,eins,foobar', 'foo,zwei,foo ']) " diw --- 2197,2204 ---- bw! endfunc + " Tests for text object aw fun! Test_normal43_textobject1() new call append(0, ['foobar,eins,foobar', 'foo,zwei,foo ']) " diw *************** *** 2167,2174 **** bw! endfunc func Test_normal44_textobjects2() - " basic testing for is and as text objects new call append(0, ['This is a test. With some sentences!', '', 'Even with a question? And one more. And no sentence here']) " Test for dis - does not remove trailing whitespace --- 2228,2235 ---- bw! endfunc + " Test for is and as text objects func Test_normal44_textobjects2() new call append(0, ['This is a test. With some sentences!', '', 'Even with a question? And one more. And no sentence here']) " Test for dis - does not remove trailing whitespace *************** *** 2462,2467 **** --- 2523,2540 ---- normal 4gro call assert_equal('ooooecond line', getline(2)) let &cpo = save_cpo + normal! ggvegrx + call assert_equal('xxxxx line', getline(1)) + exe "normal! gggr\122" + call assert_equal('zxxxx line', getline(1)) + set virtualedit=all + normal! 15|grl + call assert_equal('zxxxx line l', getline(1)) + set virtualedit& + set nomodifiable + call assert_fails('normal! grx', 'E21:') + call assert_fails('normal! gRx', 'E21:') + set modifiable& enew! endfunc *************** *** 2659,2668 **** bw! endfunc ! func Test_normal_gk() " needs 80 column new window new vert 80new put =[repeat('x',90)..' {{{1', 'x {{{1'] norm! gk " In a 80 column wide terminal the window will be only 78 char --- 2732,2742 ---- bw! endfunc ! func Test_normal_gk_gj() " needs 80 column new window new vert 80new + call assert_beeps('normal gk') put =[repeat('x',90)..' {{{1', 'x {{{1'] norm! gk " In a 80 column wide terminal the window will be only 78 char *************** *** 2677,2688 **** norm! gk call assert_equal(95, col('.')) call assert_equal(95, virtcol('.')) ! bw! ! bw! " needs 80 column new window new vert 80new set number set numberwidth=10 set cpoptions+=n --- 2751,2762 ---- norm! gk call assert_equal(95, col('.')) call assert_equal(95, virtcol('.')) ! %bw! " needs 80 column new window new vert 80new + call assert_beeps('normal gj') set number set numberwidth=10 set cpoptions+=n *************** *** 2701,2709 **** call assert_equal(1, col('.')) norm! gj call assert_equal(76, col('.')) ! bw! ! bw! ! set cpoptions& number& numberwidth& endfunc " Test for cursor movement with '-' in 'cpoptions' --- 2775,2788 ---- call assert_equal(1, col('.')) norm! gj call assert_equal(76, col('.')) ! " When 'nowrap' is set, gk and gj behave like k and j ! set nowrap ! normal! gk ! call assert_equal([2, 76], [line('.'), col('.')]) ! normal! gj ! call assert_equal([3, 76], [line('.'), col('.')]) ! %bw! ! set cpoptions& number& numberwidth& wrap& endfunc " Test for cursor movement with '-' in 'cpoptions' *************** *** 2731,2733 **** --- 2810,2851 ---- call assert_equal('f', @a) close! endfunc + + " Test for supplying a count to a normal-mode command across a cursorhold call + func Test_normal_cursorhold_with_count() + func s:cHold() + let g:cHold_Called += 1 + endfunc + new + augroup normalcHoldTest + au! + au CursorHold call s:cHold() + augroup END + let g:cHold_Called = 0 + call feedkeys("3\2ix", 'xt') + call assert_equal(1, g:cHold_Called) + call assert_equal(repeat('x', 32), getline(1)) + augroup normalcHoldTest + au! + augroup END + au! normalcHoldTest + close! + delfunc s:cHold + endfunc + + " Test for using a count and a command with CTRL-W + func Test_wincmd_with_count() + call feedkeys("\12n", 'xt') + call assert_equal(12, winheight(0)) + endfunc + + " Test for 'b', 'B' 'ge' and 'gE' commands + func Test_backward_motion() + normal! gg + call assert_beeps('normal! b') + call assert_beeps('normal! B') + call assert_beeps('normal! gE') + call assert_beeps('normal! ge') + endfunc + + " vim: shiftwidth=2 sts=2 expandtab *** ../vim-8.2.0362/src/testdir/test_prompt_buffer.vim 2019-09-04 20:00:18.000000000 +0200 --- src/testdir/test_prompt_buffer.vim 2020-03-08 05:02:45.706619068 +0100 *************** *** 124,126 **** --- 124,138 ---- delfunc MyPromptCallback bwipe! endfunc + + " Test for editing the prompt buffer + func Test_prompt_buffer_edit() + new + set buftype=prompt + normal! i + call assert_beeps('normal! dd') + call assert_beeps('normal! ~') + close! + endfunc + + " vim: shiftwidth=2 sts=2 expandtab *** ../vim-8.2.0362/src/testdir/test_virtualedit.vim 2019-12-03 22:56:07.000000000 +0100 --- src/testdir/test_virtualedit.vim 2020-03-08 05:02:45.706619068 +0100 *************** *** 301,306 **** --- 301,309 ---- call append(0, "'r'\t") normal gg^5lrxAy call assert_equal("'r' x y", getline(1)) + call setline(1, 'aaaaaaaaaaaa') + exe "normal! gg2lgR\" + call assert_equal("aa\taaaa", getline(1)) bwipe! set virtualedit= endfunc *** ../vim-8.2.0362/src/testdir/test_visual.vim 2020-02-17 21:33:26.270098788 +0100 --- src/testdir/test_visual.vim 2020-03-08 05:02:45.706619068 +0100 *************** *** 659,665 **** exe "normal GkkgH\" call assert_equal(['', 'b', 'c'], getline(1, '$')) - " linewise select mode: delete middle two lines call deletebufline('', 1, '$') call append('$', ['a', 'b', 'c']) --- 659,664 ---- *************** *** 681,686 **** --- 680,694 ---- bwipe! endfunc + " Test for blockwise select mode (g CTRL-H) + func Test_blockwise_select_mode() + new + call setline(1, ['foo', 'bar']) + call feedkeys("g\\\mm", 'xt') + call assert_equal(['mmo', 'mmr'], getline(1, '$')) + close! + endfunc + func Test_visual_mode_put() new *************** *** 908,911 **** --- 916,972 ---- close! endfunc + " Test for using visual mode maps in select mode + func Test_select_mode_map() + new + vmap 3l + call setline(1, 'Test line') + call feedkeys("gh\map", 'xt') + call assert_equal('map line', getline(1)) + + vmap ygV + call feedkeys("0gh\\\cwabc", 'xt') + call assert_equal('abc line', getline(1)) + + vmap :let v=100 + call feedkeys("gggh\\\foo", 'xt') + call assert_equal('foo line', getline(1)) + + " reselect the select mode using gv from a visual mode map + vmap gv + set selectmode=cmd + call feedkeys("0gh\map", 'xt') + call assert_equal('map line', getline(1)) + set selectmode& + + close! + endfunc + + " Test for changing text in visual mode with 'exclusive' selection + func Test_exclusive_selection() + new + call setline(1, ['one', 'two']) + set selection=exclusive + call feedkeys("vwcabc", 'xt') + call assert_equal('abctwo', getline(1)) + call setline(1, ["\tone"]) + set virtualedit=all + call feedkeys('0v2lcl', 'xt') + call assert_equal('l one', getline(1)) + set virtualedit& + set selection& + close! + endfunc + + " Test for starting visual mode with a count + " This test should be run withou any previous visual modes. So this should be + " run as a first test. + func Test_AAA_start_visual_mode_with_count() + new + call setline(1, ['aaaaaaa', 'aaaaaaa', 'aaaaaaa', 'aaaaaaa']) + normal! gg2Vy + call assert_equal("aaaaaaa\naaaaaaa\n", @") + close! + endfunc + " vim: shiftwidth=2 sts=2 expandtab *** ../vim-8.2.0362/src/version.c 2020-03-07 17:24:54.876029102 +0100 --- src/version.c 2020-03-08 05:13:00.831581966 +0100 *************** *** 740,741 **** --- 740,743 ---- { /* Add new patch number below this line */ + /**/ + 363, /**/ -- hundred-and-one symptoms of being an internet addict: 192. Your boss asks you to "go fer" coffee and you come up with 235 FTP sites. /// 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 ///