To: vim_dev@googlegroups.com Subject: Patch 8.2.0197 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.0197 Problem: Some Ex commands not sufficiently tested. Solution: Add more tests. (Yegappan Lakshmanan, closes #5565) Files: src/testdir/test_global.vim, src/testdir/test_help.vim, src/testdir/test_help_tagjump.vim, src/testdir/test_options.vim, src/testdir/test_substitute.vim, src/testdir/test_textformat.vim, src/testdir/test_writefile.vim *** ../vim-8.2.0196/src/testdir/test_global.vim 2020-01-29 21:57:28.745607653 +0100 --- src/testdir/test_global.vim 2020-02-02 15:29:06.237111621 +0100 *************** *** 25,28 **** --- 25,58 ---- call assert_fails('g/\(/y', 'E476:') endfunc + " Test for printing lines using :g with different search patterns + func Test_global_print() + new + call setline(1, ['foo', 'bar', 'foo', 'foo']) + let @/ = 'foo' + let t = execute("g/")->trim()->split("\n") + call assert_equal(['foo', 'foo', 'foo'], t) + + " Test for Vi compatible patterns + let @/ = 'bar' + let t = execute('g\/')->trim()->split("\n") + call assert_equal(['bar'], t) + + normal gg + s/foo/foo/ + let t = execute('g\&')->trim()->split("\n") + call assert_equal(['foo', 'foo', 'foo'], t) + + let @/ = 'bar' + let t = execute('g?')->trim()->split("\n") + call assert_equal(['bar'], t) + + " Test for the 'Pattern found in every line' message + let v:statusmsg = '' + v/foo\|bar/p + call assert_notequal('', v:statusmsg) + + close! + endfunc + " vim: shiftwidth=2 sts=2 expandtab *** ../vim-8.2.0196/src/testdir/test_help.vim 2019-12-27 17:20:51.533918083 +0100 --- src/testdir/test_help.vim 2020-02-02 15:29:06.237111621 +0100 *************** *** 12,17 **** --- 12,29 ---- func Test_help_errors() call assert_fails('help doesnotexist', 'E149:') call assert_fails('help!', 'E478:') + if has('multi_lang') + call assert_fails('help help@xy', 'E661:') + endif + + let save_hf = &helpfile + set helpfile=help_missing + help + call assert_equal(1, winnr('$')) + call assert_notequal('help', &buftype) + let &helpfile = save_hf + + call assert_fails('help ' . repeat('a', 1048), 'E149:') new set keywordprg=:help *** ../vim-8.2.0196/src/testdir/test_help_tagjump.vim 2018-08-02 22:16:50.000000000 +0200 --- src/testdir/test_help_tagjump.vim 2020-02-02 15:29:06.237111621 +0100 *************** *** 11,16 **** --- 11,21 ---- call assert_true(getline('.') =~ '\*bar\*') helpclose + help " + call assert_equal("help", &filetype) + call assert_true(getline('.') =~ '\*quote\*') + helpclose + help "* call assert_equal("help", &filetype) call assert_true(getline('.') =~ '\*quotestar\*') *************** *** 74,84 **** --- 79,118 ---- call assert_true(getline('.') =~ '\*i_^_CTRL-D\*') helpclose + help i^x^y + call assert_equal("help", &filetype) + call assert_true(getline('.') =~ '\*i_CTRL-X_CTRL-Y\*') + helpclose + + exe "help i\\" + call assert_equal("help", &filetype) + call assert_true(getline('.') =~ '\*i_CTRL-\\_CTRL-G\*') + helpclose + exec "help \" call assert_equal("help", &filetype) call assert_true(getline('.') =~ '\*CTRL-V\*') helpclose + help /\| + call assert_equal("help", &filetype) + call assert_true(getline('.') =~ '\*/\\bar\*') + helpclose + + help CTRL-\_CTRL-N + call assert_equal("help", &filetype) + call assert_true(getline('.') =~ '\*CTRL-\\_CTRL-N\*') + helpclose + + help `:pwd`, + call assert_equal("help", &filetype) + call assert_true(getline('.') =~ '\*:pwd\*') + helpclose + + help `:ls`. + call assert_equal("help", &filetype) + call assert_true(getline('.') =~ '\*:ls\*') + helpclose exec "help! ('textwidth'" call assert_equal("help", &filetype) *************** *** 110,115 **** --- 144,158 ---- call assert_true(getline('.') =~ '\*{address}\*') helpclose + " Use special patterns in the help tag + for h in ['/\w', '/\%^', '/\%(', '/\zs', '/\@<=', '/\_$', '[++opt]', '/\{'] + exec "help! " . h + call assert_equal("help", &filetype) + let pat = '\*' . escape(h, '\$[') . '\*' + call assert_true(getline('.') =~ pat, pat) + helpclose + endfor + exusage call assert_equal("help", &filetype) call assert_true(getline('.') =~ '\*:index\*') *** ../vim-8.2.0196/src/testdir/test_options.vim 2020-01-30 18:24:47.001204003 +0100 --- src/testdir/test_options.vim 2020-02-02 15:29:06.237111621 +0100 *************** *** 659,662 **** --- 659,675 ---- close! endfunc + " Test for the 'shellquote' option + func Test_shellquote() + CheckUnix + set shellquote=# + set verbose=20 + redir => v + silent! !echo Hello + redir END + set verbose& + set shellquote& + call assert_match(': "#echo Hello#"', v) + endfunc + " vim: shiftwidth=2 sts=2 expandtab *** ../vim-8.2.0196/src/testdir/test_substitute.vim 2020-01-29 21:57:28.745607653 +0100 --- src/testdir/test_substitute.vim 2020-02-02 15:29:06.237111621 +0100 *************** *** 51,60 **** --- 51,62 ---- \ { 'cmd': ':s/t/r/cg', 'exp': 'Tesring srring', 'prompt': 'a' }, \ { 'cmd': ':s/t/r/ci', 'exp': 'resting string', 'prompt': 'y' }, \ { 'cmd': ':s/t/r/cI', 'exp': 'Tesring string', 'prompt': 'y' }, + \ { 'cmd': ':s/t/r/c', 'exp': 'Testing string', 'prompt': 'n' }, \ { 'cmd': ':s/t/r/cn', 'exp': ln }, \ { 'cmd': ':s/t/r/cp', 'exp': 'Tesring string', 'prompt': 'y' }, \ { 'cmd': ':s/t/r/cl', 'exp': 'Tesring string', 'prompt': 'y' }, \ { 'cmd': ':s/t/r/gc', 'exp': 'Tesring srring', 'prompt': 'a' }, + \ { 'cmd': ':s/i/I/gc', 'exp': 'TestIng string', 'prompt': 'l' }, \ { 'cmd': ':s/foo/bar/ge', 'exp': ln }, \ { 'cmd': ':s/t/r/g', 'exp': 'Tesring srring' }, \ { 'cmd': ':s/t/r/gi', 'exp': 'resring srring' }, *************** *** 86,91 **** --- 88,94 ---- \ { 'cmd': ':s//r/rp', 'exp': 'Testr string' }, \ { 'cmd': ':s//r/rl', 'exp': 'Testr string' }, \ { 'cmd': ':s//r/r', 'exp': 'Testr string' }, + \ { 'cmd': ':s/i/I/gc', 'exp': 'Testing string', 'prompt': 'q' }, \] for var in variants *************** *** 176,181 **** --- 179,188 ---- call assert_equal(["foo\tbarbar\foo"], getline(1, '$')) call assert_equal('\n', histget("search", -1)) + call setline(1, ['foo', 'bar', 'baz', 'qux']) + call execute('1,2s/\n//') + call assert_equal(['foobarbaz', 'qux'], getline(1, '$')) + bwipe! endfunc *************** *** 190,195 **** --- 197,207 ---- call assert_fails('s/foo/bar/0', 'E939:') + call setline(1, ['foo foo', 'foo foo', 'foo foo', 'foo foo', 'foo foo']) + 2,4s/foo/bar/ 10 + call assert_equal(['foo foo', 'foo foo', 'foo foo', 'bar foo', 'bar foo'], + \ getline(1, '$')) + bwipe! endfunc *************** *** 208,213 **** --- 220,229 ---- " No substitution should have been done. call assert_equal(lines, getline(1, '$')) + %delete _ + call setline(1, ['A', 'Bar', 'Baz']) + call assert_equal("\n1 match on 1 line", execute('s/\nB\@=//gn')) + bwipe! endfunc *************** *** 748,751 **** --- 764,806 ---- bwipe! endfunc + " Test for repeating last substitution using :~ and :&r + func Test_repeat_last_sub() + new + call setline(1, ['blue green yellow orange white']) + s/blue/red/ + let @/ = 'yellow' + ~ + let @/ = 'white' + :&r + let @/ = 'green' + s//gray + call assert_equal('red gray red orange red', getline(1)) + close! + endfunc + + " Test for Vi compatible substitution: + " \/{string}/, \?{string}? and \&{string}& + func Test_sub_vi_compatibility() + new + call setline(1, ['blue green yellow orange blue']) + let @/ = 'orange' + s\/white/ + let @/ = 'blue' + s\?amber? + let @/ = 'white' + s\&green& + call assert_equal('amber green yellow white green', getline(1)) + close! + endfunc + + " Test for substitute with the new text longer than the original text + func Test_sub_expand_text() + new + call setline(1, 'abcabcabcabcabcabcabcabc') + s/b/\=repeat('B', 10)/g + call assert_equal(repeat('aBBBBBBBBBBc', 8), getline(1)) + close! + endfunc + " vim: shiftwidth=2 sts=2 expandtab *** ../vim-8.2.0196/src/testdir/test_textformat.vim 2020-01-30 16:09:18.460743760 +0100 --- src/testdir/test_textformat.vim 2020-02-02 15:29:06.237111621 +0100 *************** *** 433,438 **** --- 433,453 ---- call assert_equal("\t\t Vim", getline(1)) q! + " align text with 'rightleft' + if has('rightleft') + new + call setline(1, 'Vim') + setlocal rightleft + left 20 + setlocal norightleft + call assert_equal("\t\t Vim", getline(1)) + setlocal rightleft + right + setlocal norightleft + call assert_equal("Vim", getline(1)) + close! + endif + set tw& endfunc *** ../vim-8.2.0196/src/testdir/test_writefile.vim 2020-01-29 21:57:28.745607653 +0100 --- src/testdir/test_writefile.vim 2020-02-02 15:29:06.237111621 +0100 *************** *** 1,5 **** --- 1,7 ---- " Tests for the writefile() function and some :write commands. + source check.vim + func Test_writefile() let f = tempname() call writefile(["over","written"], f, "b") *************** *** 183,191 **** " Test for ':w !' to pipe lines from the current buffer to an external " command. func Test_write_pipe_to_cmd() ! if !has('unix') ! return ! endif new call setline(1, ['L1', 'L2', 'L3', 'L4']) 2,3w !cat > Xfile --- 185,191 ---- " Test for ':w !' to pipe lines from the current buffer to an external " command. func Test_write_pipe_to_cmd() ! CheckUnix new call setline(1, ['L1', 'L2', 'L3', 'L4']) 2,3w !cat > Xfile *** ../vim-8.2.0196/src/version.c 2020-02-02 15:25:10.097976117 +0100 --- src/version.c 2020-02-02 15:30:37.520413928 +0100 *************** *** 744,745 **** --- 744,747 ---- { /* Add new patch number below this line */ + /**/ + 197, /**/ -- How To Keep A Healthy Level Of Insanity: 2. Page yourself over the intercom. Don't disguise your voice. /// 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 ///