To: vim_dev@googlegroups.com Subject: Patch 8.2.1786 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.1786 Problem: Various Normal mode commands not fully tested. Solution: Add more tests. (Yegappan Lakshmanan, closes #7059) Files: src/testdir/test_normal.vim, src/testdir/test_regexp_utf8.vim, src/testdir/test_registers.vim, src/testdir/test_spellfile.vim, src/testdir/test_tagjump.vim, src/testdir/test_visual.vim *** ../vim-8.2.1785/src/testdir/test_normal.vim 2020-09-04 21:18:40.484161926 +0200 --- src/testdir/test_normal.vim 2020-10-02 18:43:59.627077502 +0200 *************** *** 596,601 **** --- 596,614 ---- call assert_equal(21, winsaveview()['topline']) call assert_equal([0, 21, 2, 0, 9], getcurpos()) + " Test for z+ with [count] greater than buffer size + 1 + norm! 1000z+ + call assert_equal(' 100', getline('.')) + call assert_equal(100, winsaveview()['topline']) + call assert_equal([0, 100, 2, 0, 9], getcurpos()) + + " Test for z+ from the last buffer line + norm! Gz.z+ + call assert_equal(' 100', getline('.')) + call assert_equal(100, winsaveview()['topline']) + call assert_equal([0, 100, 2, 0, 9], getcurpos()) + " Test for z^ norm! 22z+0 norm! z^ *************** *** 603,608 **** --- 616,627 ---- call assert_equal(12, winsaveview()['topline']) call assert_equal([0, 21, 2, 0, 9], getcurpos()) + " Test for z^ from first buffer line + norm! ggz^ + call assert_equal('1', getline('.')) + call assert_equal(1, winsaveview()['topline']) + call assert_equal([0, 1, 1, 0, 1], getcurpos()) + " Test for [count]z^ 1 norm! 30z^ *************** *** 682,687 **** --- 701,719 ---- norm! yl call assert_equal('z', @0) + " Test for zs and ze with folds + %fold + norm! $zs + call assert_equal(26, col('.')) + call assert_equal(0, winsaveview()['leftcol']) + norm! yl + call assert_equal('z', @0) + norm! ze + call assert_equal(26, col('.')) + call assert_equal(0, winsaveview()['leftcol']) + norm! yl + call assert_equal('z', @0) + " cleanup set wrap listchars=eol:$ bw! *************** *** 775,780 **** --- 807,825 ---- normal! 4H call assert_equal(33, line('.')) + " Test for using a large count value + %d + call setline(1, range(1, 4)) + norm! 6H + call assert_equal(4, line('.')) + + " Test for 'M' with folded lines + %d + call setline(1, range(1, 20)) + 1,5fold + norm! LM + call assert_equal(12, line('.')) + " Test for the CTRL-E and CTRL-Y commands with folds %d call setline(1, range(1, 10)) *************** *** 1155,1160 **** --- 1200,1212 ---- norm! j call assert_equal('55', getline('.')) + " Test for zm with a count + 50 + set foldlevel=2 + norm! 3zm + call assert_equal(0, &foldlevel) + call assert_equal(49, foldclosed(line('.'))) + " Test for zM 48 set nofoldenable foldlevel=99 *************** *** 1355,1360 **** --- 1407,1420 ---- set iskeyword-=% set iskeyword-=\| + " Test for specifying a count to K + 1 + com! -nargs=* Kprog let g:Kprog_Args = + set keywordprg=:Kprog + norm! 3K + call assert_equal('3 version8', g:Kprog_Args) + delcom Kprog + " Only expect "man" to work on Unix if !has("unix") let &keywordprg = k *************** *** 1386,1391 **** --- 1446,1453 ---- call setline(1, ['abc', 'xyz']) call assert_fails("normal! gg2lv2h\", 'E433:') call assert_beeps("normal! ggVjK") + norm! V + call assert_beeps("norm! cK") " clean up let &keywordprg = k *************** *** 1770,1775 **** --- 1832,1861 ---- bw! endfunc + " Test for section movements + func Test_normal_section() + new + let lines =<< trim [END] + int foo() + { + if (1) + { + a = 1; + } + } + [END] + call setline(1, lines) + + " jumping to a folded line using [[ should open the fold + 2,3fold + call cursor(5, 1) + call feedkeys("[[", 'xt') + call assert_equal(2, line('.')) + call assert_equal(-1, foldclosedend(line('.'))) + + close! + endfunc + " Test for ~ command func Test_normal30_changecase() new *************** *** 2744,2768 **** call assert_beeps('normal! ]m') call assert_beeps('normal! [M') call assert_beeps('normal! ]M') ! a ! Piece of Java ! { ! tt m1 { ! t1; ! } e1 ! ! tt m2 { ! t2; ! } e2 ! ! tt m3 { ! if (x) ! { ! t3; ! } ! } e3 ! } ! . normal gg --- 2830,2855 ---- call assert_beeps('normal! ]m') call assert_beeps('normal! [M') call assert_beeps('normal! ]M') ! let lines =<< trim [CODE] ! Piece of Java ! { ! tt m1 { ! t1; ! } e1 ! ! tt m2 { ! t2; ! } e2 ! ! tt m3 { ! if (x) ! { ! t3; ! } ! } e3 ! } ! [CODE] ! call setline(1, lines) normal gg *************** *** 2815,2820 **** --- 2902,2916 ---- call assert_equal("{LF", getline('.')) call assert_equal([2, 2, 2], [line('.'), col('.'), virtcol('.')]) + call cursor(2, 1) + call assert_beeps('norm! 5]m') + + " jumping to a method in a fold should open the fold + 6,10fold + call feedkeys("gg3]m", 'xt') + call assert_equal([7, 8, 15], [line('.'), col('.'), virtcol('.')]) + call assert_equal(-1, foldclosedend(7)) + close! endfunc *************** *** 3005,3010 **** --- 3101,3127 ---- close! endfunc + " Test for deleting or changing characters across lines with 'whichwrap' + " containing 's'. Should count as one character. + func Test_normal_op_across_lines() + new + set whichwrap& + call setline(1, ['one two', 'three four']) + exe "norm! $3d\" + call assert_equal(['one twhree four'], getline(1, '$')) + + call setline(1, ['one two', 'three four']) + exe "norm! $3c\x" + call assert_equal(['one twxhree four'], getline(1, '$')) + + set whichwrap+=l + call setline(1, ['one two', 'three four']) + exe "norm! $3x" + call assert_equal(['one twhree four'], getline(1, '$')) + close! + set whichwrap& + endfunc + " Test for 'w' and 'b' commands func Test_normal_word_move() new *************** *** 3078,3081 **** --- 3195,3211 ---- close! endfunc + " Test for jumping in a file using % + func Test_normal_percent_jump() + new + call setline(1, range(1, 100)) + + " jumping to a folded line should open the fold + 25,75fold + call feedkeys('50%', 'xt') + call assert_equal(50, line('.')) + call assert_equal(-1, foldclosedend(50)) + close! + endfunc + " vim: shiftwidth=2 sts=2 expandtab *** ../vim-8.2.1785/src/testdir/test_regexp_utf8.vim 2020-07-26 12:52:53.556746191 +0200 --- src/testdir/test_regexp_utf8.vim 2020-10-02 18:43:59.627077502 +0200 *************** *** 495,502 **** func Test_search_with_end_offset() new call setline(1, ['', 'dog(a', 'cat(']) ! exe "normal /(/e+" .. "\" ! normal "ayn call assert_equal("a\ncat(", @a) close! endfunc --- 495,502 ---- func Test_search_with_end_offset() new call setline(1, ['', 'dog(a', 'cat(']) ! exe "normal /(/e+\" ! normal n"ayn call assert_equal("a\ncat(", @a) close! endfunc *** ../vim-8.2.1785/src/testdir/test_registers.vim 2020-08-12 18:50:31.883655785 +0200 --- src/testdir/test_registers.vim 2020-10-02 18:43:59.627077502 +0200 *************** *** 424,429 **** --- 424,435 ---- @ call assert_equal(3, i) + " try to execute expression register and use a backspace to cancel it + new + call feedkeys("@=\ax\y", 'xt') + call assert_equal(['x', 'y'], getline(1, '$')) + close! + " cannot execute a register in operator pending mode call assert_beeps('normal! c@r') endfunc *** ../vim-8.2.1785/src/testdir/test_spellfile.vim 2020-09-11 18:11:45.098325224 +0200 --- src/testdir/test_spellfile.vim 2020-10-02 18:43:59.627077502 +0200 *************** *** 25,30 **** --- 25,42 ---- let cnt=readfile('./Xspellfile.add') call assert_equal('goood', cnt[0]) + " zg should fail in operator-pending mode + call assert_beeps('norm! czg') + + " zg fails in visual mode when not able to get the visual text + call assert_beeps('norm! ggVjzg') + norm! V + + " zg fails for a non-identifier word + call append(line('$'), '###') + call assert_fails('norm! Gzg', 'E349:') + $d + " Test for zw 2 norm! $zw *** ../vim-8.2.1785/src/testdir/test_tagjump.vim 2020-09-23 22:38:01.507927503 +0200 --- src/testdir/test_tagjump.vim 2020-10-02 18:43:59.627077502 +0200 *************** *** 1133,1139 **** " Test for [i, ]i, [I, ]I, [ CTRL-I, ] CTRL-I and CTRL-W i commands func Test_inc_search() new ! call setline(1, ['1:foo', '2:foo', 'foo', '3:foo', '4:foo']) call cursor(3, 1) " Test for [i and ]i --- 1133,1139 ---- " Test for [i, ]i, [I, ]I, [ CTRL-I, ] CTRL-I and CTRL-W i commands func Test_inc_search() new ! call setline(1, ['1:foo', '2:foo', 'foo', '3:foo', '4:foo', '===']) call cursor(3, 1) " Test for [i and ]i *************** *** 1143,1148 **** --- 1143,1151 ---- call assert_equal('3:foo', execute('normal ]i')) call assert_equal('4:foo', execute('normal 2]i')) call assert_fails('normal 3]i', 'E389:') + call assert_fails('normal G]i', 'E349:') + call assert_fails('normal [i', 'E349:') + call cursor(3, 1) " Test for :isearch call assert_equal('1:foo', execute('isearch foo')) *************** *** 1163,1168 **** --- 1166,1174 ---- call assert_equal([ \ ' 1: 4 3:foo', \ ' 2: 5 4:foo'], split(execute('normal ]I'), "\n")) + call assert_fails('normal G]I', 'E349:') + call assert_fails('normal [I', 'E349:') + call cursor(3, 1) " Test for :ilist call assert_equal([ *************** *** 1188,1193 **** --- 1194,1202 ---- exe "normal k2]\t" call assert_equal([5, 3], [line('.'), col('.')]) call assert_fails("normal 2k3]\t", 'E389:') + call assert_fails("normal G[\t", 'E349:') + call assert_fails("normal ]\t", 'E349:') + call cursor(3, 1) " Test for :ijump call cursor(3, 1) *************** *** 1212,1217 **** --- 1221,1228 ---- close call assert_fails('3wincmd i', 'E387:') call assert_fails('6wincmd i', 'E389:') + call assert_fails("normal G\i", 'E349:') + call cursor(3, 1) " Test for :isplit isplit foo *** ../vim-8.2.1785/src/testdir/test_visual.vim 2020-08-22 21:08:40.756880896 +0200 --- src/testdir/test_visual.vim 2020-10-02 18:43:59.627077502 +0200 *************** *** 370,383 **** func Test_Visual_paragraph_textobject() new ! call setline(1, ['First line.', ! \ '', ! \ 'Second line.', ! \ 'Third line.', ! \ 'Fourth line.', ! \ 'Fifth line.', ! \ '', ! \ 'Sixth line.']) " When start and end of visual area are identical, 'ap' or 'ip' select " the whole paragraph. --- 370,386 ---- func Test_Visual_paragraph_textobject() new ! let lines =<< trim [END] ! First line. ! ! Second line. ! Third line. ! Fourth line. ! Fifth line. ! ! Sixth line. ! [END] ! call setline(1, lines) " When start and end of visual area are identical, 'ap' or 'ip' select " the whole paragraph. *************** *** 633,638 **** --- 636,655 ---- normal Gkvj$d call assert_equal(['', 'a', ''], getline(1, '$')) + " characterwise visual mode: use a count with the visual mode + %d _ + call setline(1, 'one two three') + norm! vy5vy + call assert_equal('one t', @") + + " characterwise visual mode: use a count with the visual mode from the last + " line in the buffer + %d _ + call setline(1, ['one', 'two', 'three', 'four']) + norm! vj$y + norm! G1vy + call assert_equal('four', @") + bwipe! endfunc *** ../vim-8.2.1785/src/version.c 2020-10-02 18:11:52.509992300 +0200 --- src/version.c 2020-10-02 18:45:11.202837278 +0200 *************** *** 752,753 **** --- 752,755 ---- { /* Add new patch number below this line */ + /**/ + 1786, /**/ -- How To Keep A Healthy Level Of Insanity: 11. Specify that your drive-through order is "to go". /// 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 ///