Patch 8.2.0316
Problem:    ex_getln.c code has insufficient test coverage.
Solution:   Add more tests. Fix a problem. (Yegappan Lakshmanan, closes #5693)
Files:      src/cmdhist.c, src/testdir/test_cmdline.vim,
            src/testdir/test_functions.vim, src/testdir/test_history.vim,
            src/testdir/test_menu.vim


*** ../vim-8.2.0315/src/cmdhist.c       2019-08-18 22:08:54.000000000 +0200
--- src/cmdhist.c       2020-02-25 21:46:23.679739798 +0100
***************
*** 389,395 ****
                i += hislen;
                wrapped = TRUE;
            }
!       if (hist[i].hisnum == num && hist[i].hisstr != NULL)
            return i;
      }
      else if (-num <= hislen)
--- 389,395 ----
                i += hislen;
                wrapped = TRUE;
            }
!       if (i >= 0 && hist[i].hisnum == num && hist[i].hisstr != NULL)
            return i;
      }
      else if (-num <= hislen)
*** ../vim-8.2.0315/src/testdir/test_cmdline.vim        2020-02-21 
17:54:41.830235712 +0100
--- src/testdir/test_cmdline.vim        2020-02-25 21:46:23.679739798 +0100
***************
*** 51,56 ****
--- 51,62 ----
    call feedkeys(":e Xdir1/\<Tab>\<Down>\<Up>\<Right>\<CR>", 'tx')
    call assert_equal('testfile1', getline(1))
  
+   " Completion using a relative path
+   cd Xdir1/Xdir2
+   call feedkeys(":e ../\<Tab>\<Right>\<Down>\<C-A>\<C-B>\"\<CR>", 'tx')
+   call assert_equal('"e Xtestfile3 Xtestfile4', @:)
+   cd -
+ 
    " cleanup
    %bwipe
    call delete('Xdir1/Xdir2/Xtestfile4')
***************
*** 456,461 ****
--- 462,471 ----
      " ignore error E32
    endtry
    call assert_equal("Xtestfile", bufname("%"))
+ 
+   " Use an invalid expression for <C-\>e
+   call assert_beeps('call feedkeys(":\<C-\>einvalid\<CR>", "tx")')
+ 
    bwipe!
  endfunc
  
***************
*** 690,695 ****
--- 700,707 ----
    cnoremap <expr> <F6> Check_cmdline('=')
    call feedkeys("a\<C-R>=MyCmd a\<F6>\<Esc>\<Esc>", "xt")
    cunmap <F6>
+ 
+   call assert_equal('', getcmdline())
  endfunc
  
  func Test_getcmdwintype()
***************
*** 930,935 ****
--- 942,963 ----
    delfunc CmdWinType
  endfunc
  
+ " Test for CmdwinEnter autocmd
+ func Test_cmdwin_autocmd()
+   augroup CmdWin
+     au!
+     autocmd CmdwinEnter * startinsert
+   augroup END
+ 
+   call assert_fails('call feedkeys("q:xyz\<CR>", "xt")', 'E492:')
+   call assert_equal('xyz', @:)
+ 
+   augroup CmdWin
+     au!
+   augroup END
+   augroup! CmdWin
+ endfunc
+ 
  func Test_cmdlineclear_tabenter()
    CheckScreendump
  
***************
*** 967,972 ****
--- 995,1004 ----
    call assert_equal(1, winnr('$'))
    call feedkeys("q/:exit\<CR>", "xt")
    call assert_equal(1, winnr('$'))
+ 
+   " opening command window twice should fail
+   call assert_beeps('call feedkeys("q:q:\<CR>\<CR>", "xt")')
+   call assert_equal(1, winnr('$'))
  endfunc
  
  " Test for backtick expression in the command line
***************
*** 1006,1009 ****
--- 1038,1056 ----
    call delete('Xresult')
  endfunc
  
+ " Test for using ~ for home directory in cmdline completion matches
+ func Test_cmdline_expand_home()
+   call mkdir('Xdir')
+   call writefile([], 'Xdir/Xfile1')
+   call writefile([], 'Xdir/Xfile2')
+   cd Xdir
+   let save_HOME = $HOME
+   let $HOME = getcwd()
+   call feedkeys(":e ~/\<C-A>\<C-B>\"\<CR>", 'xt')
+   call assert_equal('"e ~/Xfile1 ~/Xfile2', @:)
+   let $HOME = save_HOME
+   cd ..
+   call delete('Xdir', 'rf')
+ endfunc
+ 
  " vim: shiftwidth=2 sts=2 expandtab
*** ../vim-8.2.0315/src/testdir/test_functions.vim      2020-02-14 
16:52:08.319436425 +0100
--- src/testdir/test_functions.vim      2020-02-25 21:46:23.679739798 +0100
***************
*** 1141,1146 ****
--- 1141,1170 ----
    bw!
  endfunc
  
+ " Test for input()
+ func Test_input_func()
+   " Test for prompt with multiple lines
+   redir => v
+   call feedkeys(":let c = input(\"A\\nB\\nC\\n? \")\<CR>B\<CR>", 'xt')
+   redir END
+   call assert_equal("B", c)
+   call assert_equal(['A', 'B', 'C'], split(v, "\n"))
+ 
+   " Test for default value
+   call feedkeys(":let c = input('color? ', 'red')\<CR>\<CR>", 'xt')
+   call assert_equal('red', c)
+ 
+   " Test for completion at the input prompt
+   func! Tcomplete(arglead, cmdline, pos)
+     return "item1\nitem2\nitem3"
+   endfunc
+   call feedkeys(":let c = input('Q? ', '' , 'custom,Tcomplete')\<CR>"
+         \ .. "\<C-A>\<CR>", 'xt')
+   delfunc Tcomplete
+   call assert_equal('item1 item2 item3', c)
+ endfunc
+ 
+ " Test for inputlist()
  func Test_inputlist()
    call feedkeys(":let c = inputlist(['Select color:', '1. red', '2. green', 
'3. blue'])\<cr>1\<cr>", 'tx')
    call assert_equal(1, c)
***************
*** 2034,2036 ****
--- 2058,2062 ----
    call StopVimInTerminal(buf)
    call delete('XTest_echoraw')
  endfunc
+ 
+ " vim: shiftwidth=2 sts=2 expandtab
*** ../vim-8.2.0315/src/testdir/test_history.vim        2019-08-31 
20:36:27.000000000 +0200
--- src/testdir/test_history.vim        2020-02-25 21:46:23.679739798 +0100
***************
*** 85,90 ****
--- 85,92 ----
    call assert_fails('call histget([])', 'E730:')
    call assert_equal(-1, histnr('abc'))
    call assert_fails('call histnr([])', 'E730:')
+   call assert_fails('history xyz', 'E488:')
+   call assert_fails('history ,abc', 'E488:')
  endfunction
  
  function Test_Search_history_window()
***************
*** 108,110 ****
--- 110,161 ----
    call feedkeys(":history \<C-A>\<C-B>\"\<CR>", 'tx')
    call assert_equal('"history / : = > ? @ all cmd debug expr input search', 
@:)
  endfunc
+ 
+ " Test for increasing the 'history' option value
+ 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
+   call assert_equal(10, histnr(':'))
+   call assert_equal('cmd1', histget(':', 1))
+   call assert_equal('cmd10', histget(':', -1))
+ 
+   set history=5
+   call histadd(':', 'abc')
+   call assert_equal('', histget(':', 6))
+   call assert_equal('', histget(':', 12))
+   call assert_equal('cmd7', histget(':', 7))
+   call assert_equal('abc', histget(':', -1))
+ 
+   let &history=save_histsz
+ endfunc
+ 
+ " Test for recalling old search patterns in /
+ func Test_history_search()
+   call histdel('/')
+   let g:pat = []
+   func SavePat()
+     call add(g:pat, getcmdline())
+     return ''
+   endfunc
+   cnoremap <F2> <C-\>eSavePat()<CR>
+   call histadd('/', 'pat1')
+   call histadd('/', 'pat2')
+   let @/ = ''
+   call feedkeys("/\<Up>\<F2>\<Up>\<F2>\<Down>\<Down>\<F2>\<Esc>", 'xt')
+   call assert_equal(['pat2', 'pat1', ''], g:pat)
+   cunmap <F2>
+   delfunc SavePat
+ endfunc
+ 
+ " vim: shiftwidth=2 sts=2 expandtab
*** ../vim-8.2.0315/src/testdir/test_menu.vim   2019-12-27 17:20:51.533918083 
+0100
--- src/testdir/test_menu.vim   2020-02-25 21:46:23.679739798 +0100
***************
*** 88,90 ****
--- 88,126 ----
  
    unlet g:did_menu
  endfun
+ 
+ " Test for menu item completion in command line
+ func Test_menu_expand()
+   " Create the menu itmes for test
+   for i in range(1, 4)
+     let m = 'menu Xmenu.A' .. i .. '.A' .. i
+     for j in range(1, 4)
+       exe m .. 'B' .. j .. ' :echo "A' .. i .. 'B' .. j .. '"' .. "<CR>"
+     endfor
+   endfor
+   set wildmenu
+ 
+   " Test for <CR> selecting a submenu
+   call feedkeys(":emenu Xmenu.A\<Tab>\<CR>\<Right>x\<BS>\<C-B>\"\<CR>", 'xt')
+   call assert_equal('"emenu Xmenu.A1.A1B2', @:)
+ 
+   " Test for <Down> selecting a submenu
+   call feedkeys(":emenu Xmenu.A\<Tab>\<Right>\<Right>\<Down>" ..
+         \ "\<C-A>\<C-B>\"\<CR>", 'xt')
+   call assert_equal('"emenu Xmenu.A3.A3B1 A3B2 A3B3 A3B4', @:)
+ 
+   " Test for <Up> to go up a submenu
+   call feedkeys(":emenu Xmenu.A\<Tab>\<Down>\<Up>\<Right>\<Right>" ..
+         \ "\<Left>\<Down>\<C-A>\<C-B>\"\<CR>", 'xt')
+   call assert_equal('"emenu Xmenu.A2.A2B1 A2B2 A2B3 A2B4', @:)
+ 
+   " Test for <Up> to go up a menu
+   call feedkeys(":emenu Xmenu.A\<Tab>\<Down>\<Up>\<Up>\<Up>" ..
+         \ "\<C-A>\<C-B>\"\<CR>", 'xt')
+   call assert_equal('"emenu Buffers. Xmenu.', @:)
+ 
+   set wildmenu&
+   unmenu Xmenu
+ endfunc
+ 
+ " vim: shiftwidth=2 sts=2 expandtab
*** ../vim-8.2.0315/src/version.c       2020-02-25 21:26:46.275580512 +0100
--- src/version.c       2020-02-25 21:47:23.343538819 +0100
***************
*** 740,741 ****
--- 740,743 ----
  {   /* Add new patch number below this line */
+ /**/
+     316,
  /**/

-- 
hundred-and-one symptoms of being an internet addict:
118. You are on a first-name basis with your ISP's staff.

 /// Bram Moolenaar -- [email protected] -- 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    ///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/202002252048.01PKmY76011418%40masaka.moolenaar.net.

Raspunde prin e-mail lui