To: vim_dev@googlegroups.com Subject: Patch 8.2.0325 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.0325 Problem: Ex_getln.c code not covered by tests. Solution: Add a few more tests. (Yegappan Lakshmanan, closes #5702) Files: src/testdir/test_cmdline.vim, src/testdir/test_ex_mode.vim, src/testdir/test_functions.vim, src/testdir/test_history.vim, src/testdir/test_options.vim *** ../vim-8.2.0324/src/testdir/test_cmdline.vim 2020-02-25 21:47:42.299474625 +0100 --- src/testdir/test_cmdline.vim 2020-02-27 21:30:40.221350163 +0100 *************** *** 14,19 **** --- 14,24 ---- " We can't see the output, but at least we check the code runs properly. call feedkeys(":e test\\r", "tx") call assert_equal('test', expand('%:t')) + + " If a command doesn't support completion, then CTRL-D should be literally + " used. + call feedkeys(":chistory \\\"\", 'xt') + call assert_equal("\"chistory \", @:) endfunc func Test_complete_wildmenu() *************** *** 51,56 **** --- 56,66 ---- call feedkeys(":e Xdir1/\\\\\", 'tx') call assert_equal('testfile1', getline(1)) + " Test for canceling the wild menu by adding a character + redrawstatus + call feedkeys(":e Xdir1/\x\\"\", 'xt') + call assert_equal('"e Xdir1/Xdir2/x', @:) + " Completion using a relative path cd Xdir1/Xdir2 call feedkeys(":e ../\\\\\\"\", 'tx') *************** *** 466,471 **** --- 476,493 ---- " Use an invalid expression for e call assert_beeps('call feedkeys(":\einvalid\", "tx")') + " Try to paste an invalid register using + call feedkeys(":\"one\\two\", 'xt') + call assert_equal('"onetwo', @:) + + let @a = "xy\z" + call feedkeys(":\"\a\", 'xt') + call assert_equal('"xz', @:) + call feedkeys(":\"\\a\", 'xt') + call assert_equal("\"xy\z", @:) + + call assert_beeps('call feedkeys(":\=\=\", "xt")') + bwipe! endfunc *************** *** 1053,1056 **** --- 1075,1184 ---- call delete('Xdir', 'rf') endfunc + " Test for using CTRL-\ CTRL-G in the command line to go back to normal mode + " or insert mode (when 'insertmode' is set) + func Test_cmdline_ctrl_g() + new + call setline(1, 'abc') + call cursor(1, 3) + " If command line is entered from insert mode, using C-\ C-G should back to + " insert mode + call feedkeys("i\:\\xy", 'xt') + call assert_equal('abxyc', getline(1)) + call assert_equal(4, col('.')) + + " If command line is entered in 'insertmode', using C-\ C-G should back to + " 'insertmode' + call feedkeys(":set im\\:\\12\:set noim\", 'xt') + call assert_equal('ab12xyc', getline(1)) + close! + endfunc + + " Return the 'len' characters in screen starting from (row,col) + func s:ScreenLine(row, col, len) + let s = '' + for i in range(a:len) + let s .= nr2char(screenchar(a:row, a:col + i)) + endfor + return s + endfunc + + " Test for 'wildmode' + func Test_wildmode() + func T(a, c, p) + return "oneA\noneB\noneC" + endfunc + command -nargs=1 -complete=custom,T MyCmd + + func SaveScreenLine() + let g:Sline = s:ScreenLine(&lines - 1, 1, 20) + return '' + endfunc + cnoremap SaveScreenLine() + + set nowildmenu + set wildmode=full,list + let g:Sline = '' + call feedkeys(":MyCmd \t\t\\\"\", 'xt') + call assert_equal('oneA oneB oneC ', g:Sline) + call assert_equal('"MyCmd oneA', @:) + + set wildmode=longest,full + call feedkeys(":MyCmd o\t\\"\", 'xt') + call assert_equal('"MyCmd one', @:) + call feedkeys(":MyCmd o\t\t\t\t\\"\", 'xt') + call assert_equal('"MyCmd oneC', @:) + + set wildmode=longest + call feedkeys(":MyCmd one\t\t\\"\", 'xt') + call assert_equal('"MyCmd one', @:) + + set wildmode=list:longest + let g:Sline = '' + call feedkeys(":MyCmd \t\\\"\", 'xt') + call assert_equal('oneA oneB oneC ', g:Sline) + call assert_equal('"MyCmd one', @:) + + set wildmode="" + call feedkeys(":MyCmd \t\t\\"\", 'xt') + call assert_equal('"MyCmd oneA', @:) + + delcommand MyCmd + delfunc T + delfunc SaveScreenLine + cunmap + set wildmode& + endfunc + + " Test for interrupting the command-line completion + func Test_interrupt_compl() + func F(lead, cmdl, p) + if a:lead =~ 'tw' + call interrupt() + return + endif + return "one\ntwo\nthree" + endfunc + command -nargs=1 -complete=custom,F Tcmd + + set nowildmenu + set wildmode=full + let interrupted = 0 + try + call feedkeys(":Tcmd tw\\\"\", 'xt') + catch /^Vim:Interrupt$/ + let interrupted = 1 + endtry + call assert_equal(1, interrupted) + + delcommand Tcmd + delfunc F + set wildmode& + endfunc + + func Test_cmdline_edit() + call feedkeys(":\"buffer\\\\", 'xt') + call assert_equal("\"buffer", @:) + endfunc + " vim: shiftwidth=2 sts=2 expandtab *** ../vim-8.2.0324/src/testdir/test_ex_mode.vim 2020-02-21 17:54:41.830235712 +0100 --- src/testdir/test_ex_mode.vim 2020-02-27 21:30:40.221350163 +0100 *************** *** 116,125 **** 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: shiftwidth=2 sts=2 expandtab --- 116,131 ---- func Test_Ex_global() new call setline(1, ['', 'foo', 'bar', 'foo', 'bar', 'foo']) ! call feedkeys("Q\g/bar/visual\$rxQ$ryQvisual\j", "xt") call assert_equal('bax', getline(3)) call assert_equal('bay', getline(5)) bwipe! endfunc + " In Ex-mode, a backslash escapes a newline + func Test_Ex_escape_enter() + call feedkeys("gQlet l = \"a\\\b\"\vi\", 'xt') + call assert_equal("a\rb", l) + endfunc + " vim: shiftwidth=2 sts=2 expandtab *** ../vim-8.2.0324/src/testdir/test_functions.vim 2020-02-25 21:47:42.303474610 +0100 --- src/testdir/test_functions.vim 2020-02-27 21:30:40.221350163 +0100 *************** *** 1162,1167 **** --- 1162,1180 ---- \ .. "\\", 'xt') delfunc Tcomplete call assert_equal('item1 item2 item3', c) + + call assert_fails("call input('F:', '', 'invalid')", 'E180:') + call assert_fails("call input('F:', '', [])", 'E730:') + endfunc + + " Test for the inputdialog() function + func Test_inputdialog() + CheckNotGui + + call feedkeys(":let v=inputdialog('Q:', 'xx', 'yy')\\", 'xt') + call assert_equal('xx', v) + call feedkeys(":let v=inputdialog('Q:', 'xx', 'yy')\\", 'xt') + call assert_equal('yy', v) endfunc " Test for inputlist() *** ../vim-8.2.0324/src/testdir/test_history.vim 2020-02-25 21:47:42.303474610 +0100 --- src/testdir/test_history.vim 2020-02-27 21:30:40.221350163 +0100 *************** *** 70,75 **** --- 70,83 ---- call assert_equal('', histget(a:hist, i)) call assert_equal('', histget(a:hist, i - 7 - 1)) endfor + + " Test for freeing an entry at the beginning of the history list + for i in range(1, 4) + call histadd(a:hist, 'text_' . i) + endfor + call histdel(a:hist, 1) + call assert_equal('', histget(a:hist, 1)) + call assert_equal('text_4', histget(a:hist, 4)) endfunction function Test_History() *************** *** 115,128 **** func Test_history_size() let save_histsz = &history call histdel(':') ! set history=5 for i in range(1, 5) call histadd(':', 'cmd' .. i) endfor call assert_equal(5, histnr(':')) call assert_equal('cmd5', histget(':', -1)) ! set history=10 for i in range(6, 10) call histadd(':', 'cmd' .. i) endfor --- 123,136 ---- func Test_history_size() let save_histsz = &history call histdel(':') ! set history=10 for i in range(1, 5) call histadd(':', 'cmd' .. i) endfor call assert_equal(5, histnr(':')) call assert_equal('cmd5', histget(':', -1)) ! set history=15 for i in range(6, 10) call histadd(':', 'cmd' .. i) endfor *************** *** 137,142 **** --- 145,159 ---- call assert_equal('cmd7', histget(':', 7)) call assert_equal('abc', histget(':', -1)) + " This test works only when the language is English + if v:lang == "C" || v:lang =~ '^[Ee]n' + set history=0 + redir => v + call feedkeys(":history\", 'xt') + redir END + call assert_equal(["'history' option is zero"], split(v, "\n")) + endif + let &history=save_histsz endfunc *************** *** 158,161 **** --- 175,186 ---- delfunc SavePat endfunc + " Test for making sure the key value is not stored in history + func Test_history_crypt_key() + CheckFeature cryptv + call feedkeys(":set bs=2 key=abc ts=8\", 'xt') + call assert_equal('set bs=2 key= ts=8', histget(':')) + set key& bs& ts& + endfunc + " vim: shiftwidth=2 sts=2 expandtab *** ../vim-8.2.0324/src/testdir/test_options.vim 2020-02-02 15:32:09.967762406 +0100 --- src/testdir/test_options.vim 2020-02-27 21:30:40.221350163 +0100 *************** *** 672,675 **** --- 672,698 ---- call assert_match(': "#echo Hello#"', v) endfunc + " Test for the 'rightleftcmd' option + func Test_rightleftcmd() + CheckFeature rightleft + set rightleft + set rightleftcmd + + let g:l = [] + func AddPos() + call add(g:l, screencol()) + return '' + endfunc + cmap AddPos() + + call feedkeys("/\abc\\\\\" .. + \ "\\\", 'xt') + call assert_equal([&co - 1, &co - 4, &co - 2, &co - 3], g:l) + + cunmap + unlet g:l + set rightleftcmd& + set rightleft& + endfunc + " vim: shiftwidth=2 sts=2 expandtab *** ../vim-8.2.0324/src/version.c 2020-02-26 22:05:57.094386589 +0100 --- src/version.c 2020-02-27 21:31:45.533265560 +0100 *************** *** 740,741 **** --- 740,743 ---- { /* Add new patch number below this line */ + /**/ + 325, /**/ -- Statistics say that you can have a baby per month on average: Just get nine women pregnant. /// 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 ///