To: vim_dev@googlegroups.com Subject: Patch 8.2.0293 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.0293 Problem: Various Ex commands not sufficiently tested. Solution: Add more test cases. (Yegappan Lakshmanan, closes #5673) Files: src/testdir/test_arglist.vim, src/testdir/test_cmdline.vim, src/testdir/test_ex_mode.vim, src/testdir/test_excmd.vim, src/testdir/test_expand.vim, src/testdir/test_filetype.vim, src/testdir/test_filter_cmd.vim, src/testdir/test_global.vim, src/testdir/test_normal.vim, src/testdir/test_plus_arg_edit.vim, src/testdir/test_quickfix.vim, src/testdir/test_trycatch.vim, src/testdir/test_vimscript.vim *** ../vim-8.2.0292/src/testdir/test_arglist.vim 2020-02-18 21:54:36.982093690 +0100 --- src/testdir/test_arglist.vim 2020-02-21 17:47:46.076012854 +0100 *************** *** 515,522 **** --- 515,524 ---- throw 'Skipped: cannot run vim in terminal' endif let buf = RunVimInTerminal('', {'rows': 6}) + call term_sendkeys(buf, ":set nomore\n") call term_sendkeys(buf, ":args a b c\n") call term_sendkeys(buf, ":quit\n") + call term_wait(buf) call WaitForAssert({-> assert_match('^E173:', term_getline(buf, 6))}) call StopVimInTerminal(buf) *************** *** 525,538 **** call term_sendkeys(buf, ":set nomore\n") call term_sendkeys(buf, ":args a b c\n") call term_sendkeys(buf, ":confirm quit\n") call WaitForAssert({-> assert_match('^\[Y\]es, (N)o: *$', \ term_getline(buf, 6))}) call term_sendkeys(buf, "N") call term_sendkeys(buf, ":confirm quit\n") call WaitForAssert({-> assert_match('^\[Y\]es, (N)o: *$', \ term_getline(buf, 6))}) call term_sendkeys(buf, "Y") ! call StopVimInTerminal(buf) endfunc " vim: shiftwidth=2 sts=2 expandtab --- 527,544 ---- call term_sendkeys(buf, ":set nomore\n") call term_sendkeys(buf, ":args a b c\n") call term_sendkeys(buf, ":confirm quit\n") + call term_wait(buf) call WaitForAssert({-> assert_match('^\[Y\]es, (N)o: *$', \ term_getline(buf, 6))}) call term_sendkeys(buf, "N") + call term_wait(buf) call term_sendkeys(buf, ":confirm quit\n") call WaitForAssert({-> assert_match('^\[Y\]es, (N)o: *$', \ term_getline(buf, 6))}) call term_sendkeys(buf, "Y") ! call term_wait(buf) ! call WaitForAssert({-> assert_equal("finished", term_getstatus(buf))}) ! only! endfunc " vim: shiftwidth=2 sts=2 expandtab *** ../vim-8.2.0292/src/testdir/test_cmdline.vim 2020-02-16 13:33:52.047371845 +0100 --- src/testdir/test_cmdline.vim 2020-02-21 17:47:46.076012854 +0100 *************** *** 977,980 **** --- 977,1009 ---- %argd endfunc + " Test for the :! command + func Test_cmd_bang() + if !has('unix') + return + endif + + let lines =<< trim [SCRIPT] + " Test for no previous command + call assert_fails('!!', 'E34:') + set nomore + " Test for cmdline expansion with :! + call setline(1, 'foo!') + silent !echo > Xfile.out + call assert_equal(['foo!'], readfile('Xfile.out')) + " Test for using previous command + silent !echo \! ! + call assert_equal(['! echo foo!'], readfile('Xfile.out')) + call writefile(v:errors, 'Xresult') + call delete('Xfile.out') + qall! + [SCRIPT] + call writefile(lines, 'Xscript') + if RunVim([], [], '--clean -S Xscript') + call assert_equal([], readfile('Xresult')) + endif + call delete('Xscript') + call delete('Xresult') + endfunc + " vim: shiftwidth=2 sts=2 expandtab *** ../vim-8.2.0292/src/testdir/test_ex_mode.vim 2020-02-18 21:32:55.854340478 +0100 --- src/testdir/test_ex_mode.vim 2020-02-21 17:47:46.076012854 +0100 *************** *** 111,121 **** close! endfunc ! func Test_Ex_feedkeys() ! " this doesn't do anything useful, just check it doesn't hang new ! call setline(1, ["foo"]) ! call feedkeys("Qg/foo/visual\", "xt") bwipe! endfunc --- 111,124 ---- close! endfunc ! " Test for :g/pat/visual to run vi commands in Ex mode ! " This used to hang Vim before 8.2.0274. ! func Test_Ex_global() new ! call setline(1, ['', 'foo', 'bar', 'foo', 'bar', 'foo']) ! call feedkeys("Qg/bar/visual\$rxQ$ryQvisual\j", "xt") ! call assert_equal('bax', getline(3)) ! call assert_equal('bay', getline(5)) bwipe! endfunc *** ../vim-8.2.0292/src/testdir/test_excmd.vim 2020-02-18 21:54:36.982093690 +0100 --- src/testdir/test_excmd.vim 2020-02-21 17:47:46.076012854 +0100 *************** *** 349,354 **** --- 349,392 ---- let cmd = ":\eexecute('close')\\" call assert_equal(2, winnr('$')) close + + call assert_fails("call feedkeys(\":\=execute('bnext')\\", 'xt')", 'E523:') + endfunc + + " Test for the :verbose command + func Test_verbose_cmd() + call assert_equal([' verbose=1'], split(execute('verbose set vbs'), "\n")) + call assert_equal([' verbose=0'], split(execute('0verbose set vbs'), "\n")) + let l = execute("4verbose set verbose | set verbose") + call assert_equal([' verbose=4', ' verbose=0'], split(l, "\n")) + endfunc + + " Test for the :delete command and the related abbreviated commands + func Test_excmd_delete() + new + call setline(1, ['foo', "\tbar"]) + call assert_equal(['^Ibar$'], split(execute('dl'), "\n")) + call setline(1, ['foo', "\tbar"]) + call assert_equal(['^Ibar$'], split(execute('dell'), "\n")) + call setline(1, ['foo', "\tbar"]) + call assert_equal(['^Ibar$'], split(execute('delel'), "\n")) + call setline(1, ['foo', "\tbar"]) + call assert_equal(['^Ibar$'], split(execute('deletl'), "\n")) + call setline(1, ['foo', "\tbar"]) + call assert_equal(['^Ibar$'], split(execute('deletel'), "\n")) + call setline(1, ['foo', "\tbar"]) + call assert_equal([' bar'], split(execute('dp'), "\n")) + call setline(1, ['foo', "\tbar"]) + call assert_equal([' bar'], split(execute('dep'), "\n")) + call setline(1, ['foo', "\tbar"]) + call assert_equal([' bar'], split(execute('delp'), "\n")) + call setline(1, ['foo', "\tbar"]) + call assert_equal([' bar'], split(execute('delep'), "\n")) + call setline(1, ['foo', "\tbar"]) + call assert_equal([' bar'], split(execute('deletp'), "\n")) + call setline(1, ['foo', "\tbar"]) + call assert_equal([' bar'], split(execute('deletep'), "\n")) + close! endfunc " vim: shiftwidth=2 sts=2 expandtab *** ../vim-8.2.0292/src/testdir/test_expand.vim 2020-02-17 21:33:26.266098800 +0100 --- src/testdir/test_expand.vim 2020-02-21 17:47:46.076012854 +0100 *************** *** 81,87 **** call assert_fails('call expandcmd("make ")', 'E495:') enew call assert_fails('call expandcmd("make %")', 'E499:') ! close endfunc " Test for expanding , and outside of sourcing a script --- 81,91 ---- call assert_fails('call expandcmd("make ")', 'E495:') enew call assert_fails('call expandcmd("make %")', 'E499:') ! let $FOO="blue\tsky" ! call setline(1, "$FOO") ! call assert_equal("grep pat blue\tsky", expandcmd('grep pat ')) ! unlet $FOO ! close! endfunc " Test for expanding , and outside of sourcing a script *************** *** 108,112 **** --- 112,128 ---- call delete('Xresult') endfunc + " Test for expanding filenames multiple times in a command line + func Test_expand_filename_multicmd() + edit foo + call setline(1, 'foo!') + new + call setline(1, 'foo!') + new | new + call assert_equal(4, winnr('$')) + call assert_equal('foo!', bufname(winbufnr(1))) + call assert_equal('foo', bufname(winbufnr(2))) + %bwipe! + endfunc " vim: shiftwidth=2 sts=2 expandtab *** ../vim-8.2.0292/src/testdir/test_filetype.vim 2020-02-17 21:33:26.266098800 +0100 --- src/testdir/test_filetype.vim 2020-02-21 17:47:46.076012854 +0100 *************** *** 637,644 **** --- 637,648 ---- new Xtest.vim filetype indent on call assert_equal(1, g:did_indent_on) + call assert_equal(['filetype detection:ON plugin:OFF indent:ON'], + \ execute('filetype')->split("\n")) filetype indent off call assert_equal(0, exists('g:did_indent_on')) + call assert_equal(['filetype detection:ON plugin:OFF indent:OFF'], + \ execute('filetype')->split("\n")) close endfunc *** ../vim-8.2.0292/src/testdir/test_filter_cmd.vim 2019-12-01 14:52:23.000000000 +0100 --- src/testdir/test_filter_cmd.vim 2020-02-21 17:47:46.076012854 +0100 *************** *** 47,52 **** --- 47,60 ---- call assert_fails('filter /pat', 'E476:') call assert_fails('filter /pat/', 'E476:') call assert_fails('filter /pat/ asdf', 'E492:') + " Using assert_fails() causes E476 instead of E866. So use a try-catch. + let caught_e866 = 0 + try + filter /\@>b/ ls + catch /E866:/ + let caught_e866 = 1 + endtry + call assert_equal(1, caught_e866) call assert_fails('filter!', 'E471:') call assert_fails('filter! pat', 'E476:') *** ../vim-8.2.0292/src/testdir/test_global.vim 2020-02-02 15:32:09.967762406 +0100 --- src/testdir/test_global.vim 2020-02-21 17:47:46.076012854 +0100 *************** *** 55,58 **** --- 55,70 ---- close! endfunc + " Test for global command with newline character + func Test_global_newline() + new + call setline(1, ['foo']) + exe "g/foo/s/f/h/\s/o$/w/" + call assert_equal('how', getline(1)) + call setline(1, ["foo\bar"]) + exe "g/foo/s/foo\\\bar/xyz/" + call assert_equal('xyz', getline(1)) + close! + endfunc + " vim: shiftwidth=2 sts=2 expandtab *** ../vim-8.2.0292/src/testdir/test_normal.vim 2020-02-17 21:33:26.270098788 +0100 --- src/testdir/test_normal.vim 2020-02-21 17:47:46.076012854 +0100 *************** *** 2721,2723 **** --- 2721,2733 ---- let &cpo = save_cpo close! endfunc + + " Test for using : to run a multi-line Ex command in operator pending mode + func Test_normal_yank_with_excmd() + new + call setline(1, ['foo', 'bar', 'baz']) + let @a = '' + call feedkeys("\"ay:if v:true\normal l\endif\", 'xt') + call assert_equal('f', @a) + close! + endfunc *** ../vim-8.2.0292/src/testdir/test_plus_arg_edit.vim 2020-02-16 13:33:52.047371845 +0100 --- src/testdir/test_plus_arg_edit.vim 2020-02-21 17:47:46.076012854 +0100 *************** *** 18,24 **** e! ++enc=utf8 Xfile call assert_equal('[?][?][???][??]', getline(1)) ! e! ++enc=utf8 ++bad=_ Xfile call assert_equal('[_][_][___][__]', getline(1)) e! ++enc=utf8 ++bad=drop Xfile --- 18,24 ---- e! ++enc=utf8 Xfile call assert_equal('[?][?][???][??]', getline(1)) ! e! ++encoding=utf8 ++bad=_ Xfile call assert_equal('[_][_][___][__]', getline(1)) e! ++enc=utf8 ++bad=drop Xfile *** ../vim-8.2.0292/src/testdir/test_quickfix.vim 2020-02-18 21:54:36.982093690 +0100 --- src/testdir/test_quickfix.vim 2020-02-21 17:47:46.076012854 +0100 *************** *** 484,489 **** --- 484,490 ---- \ 'RegularLine2'] Xfirst + call assert_fails('-5Xcc', 'E16:') call assert_fails('Xprev', 'E553') call assert_fails('Xpfile', 'E553') Xnfile *** ../vim-8.2.0292/src/testdir/test_trycatch.vim 2019-12-14 16:18:11.574458417 +0100 --- src/testdir/test_trycatch.vim 2020-02-21 17:47:46.076012854 +0100 *************** *** 1996,2000 **** --- 1996,2039 ---- call delete('Xreload') endfunc + " Test for errors with :catch, :throw, :finally {{{1 + func Test_try_catch_errors() + call assert_fails('throw |', 'E471:') + call assert_fails("throw \n ", 'E471:') + call assert_fails('catch abc', 'E603:') + call assert_fails('try | let i = 1| finally | catch | endtry', 'E604:') + call assert_fails('finally', 'E606:') + call assert_fails('try | finally | finally | endtry', 'E607:') + call assert_fails('try | for i in range(5) | endif | endtry', 'E580:') + call assert_fails('try | while v:true | endtry', 'E170:') + call assert_fails('try | if v:true | endtry', 'E171:') + endfunc + + " Test for verbose messages with :try :catch, and :finally {{{1 + func Test_try_catch_verbose() + " This test works only when the language is English + if v:lang != "C" && v:lang !~ '^[Ee]n' + return + endif + + set verbose=14 + redir => msg + try + echo i + catch /E121:/ + finally + endtry + redir END + let expected = [ + \ 'Exception thrown: Vim(echo):E121: Undefined variable: i', + \ '', + \ 'Exception caught: Vim(echo):E121: Undefined variable: i', + \ '', + \ 'Exception finished: Vim(echo):E121: Undefined variable: i' + \ ] + call assert_equal(expected, split(msg, "\n")) + set verbose& + endfunc + " Modeline {{{1 " vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker *** ../vim-8.2.0292/src/testdir/test_vimscript.vim 2020-02-17 22:11:39.670644186 +0100 --- src/testdir/test_vimscript.vim 2020-02-21 17:47:46.076012854 +0100 *************** *** 1970,1975 **** --- 1970,1998 ---- call writefile(['try', 'echo "."'], 'Xscript') call assert_fails('source Xscript', 'E600:') call delete('Xscript') + + " Using endfor with :while + let caught_e732 = 0 + try + while v:true + endfor + catch /E732:/ + let caught_e732 = 1 + endtry + call assert_equal(1, caught_e732) + + " Using endwhile with :for + let caught_e733 = 0 + try + for i in range(1) + endwhile + catch /E733:/ + let caught_e733 = 1 + endtry + call assert_equal(1, caught_e733) + + " Missing 'in' in a :for statement + call assert_fails('for i range(1) | endfor', 'E690:') endfunc " Test for deep nesting of if/for/while/try statements {{{1 *** ../vim-8.2.0292/src/version.c 2020-02-20 23:08:30.746951116 +0100 --- src/version.c 2020-02-21 17:48:57.619707374 +0100 *************** *** 740,741 **** --- 740,743 ---- { /* Add new patch number below this line */ + /**/ + 293, /**/ -- A fool learns from his mistakes, a wise man from someone else's. /// 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 ///