Patch 8.2.0092
Problem:    Tags functionality insufficiently tested.
Solution:   Add more tags tests. (Yegappan Lakshmanan, closes #5446)
Files:      src/testdir/test_tagjump.vim


*** ../vim-8.2.0091/src/testdir/test_tagjump.vim        2020-01-05 
20:35:39.967830421 +0100
--- src/testdir/test_tagjump.vim        2020-01-06 20:07:49.424973340 +0100
***************
*** 600,606 ****
  endfunc
  
  " Test for :ptag
! func Test_ptag()
    call writefile(["!_TAG_FILE_ENCODING\tutf-8\t//",
          \ "second\tXfile1\t2",
          \ "third\tXfile1\t3",],
--- 600,606 ----
  endfunc
  
  " Test for :ptag
! func Test_tag_preview()
    call writefile(["!_TAG_FILE_ENCODING\tutf-8\t//",
          \ "second\tXfile1\t2",
          \ "third\tXfile1\t3",],
***************
*** 614,624 ****
    call assert_equal(2, winnr('$'))
    call assert_equal(1, getwinvar(1, '&previewwindow'))
    call assert_equal(0, getwinvar(2, '&previewwindow'))
!   wincmd w
    call assert_equal(3, line('.'))
  
    " jump to the tag again
    ptag third
    call assert_equal(3, line('.'))
  
    " close the preview window
--- 614,632 ----
    call assert_equal(2, winnr('$'))
    call assert_equal(1, getwinvar(1, '&previewwindow'))
    call assert_equal(0, getwinvar(2, '&previewwindow'))
!   wincmd P
    call assert_equal(3, line('.'))
  
    " jump to the tag again
+   wincmd w
    ptag third
+   wincmd P
+   call assert_equal(3, line('.'))
+ 
+   " jump to the newer tag
+   wincmd w
+   ptag
+   wincmd P
    call assert_equal(3, line('.'))
  
    " close the preview window
***************
*** 787,794 ****
    %bwipe
  endfunc
  
! " Test for jumping to a tag when the tag stack is full
! func Test_tag_stack_full()
    let l = []
    for i in range(10, 31)
      let l += ["var" .. i .. "\tXfoo\t/^int var" .. i .. ";$/"]
--- 795,802 ----
    %bwipe
  endfunc
  
! " Tag stack tests
! func Test_tag_stack()
    let l = []
    for i in range(10, 31)
      let l += ["var" .. i .. "\tXfoo\t/^int var" .. i .. ";$/"]
***************
*** 802,807 ****
--- 810,816 ----
    endfor
    call writefile(l, 'Xfoo')
  
+   " Jump to a tag when the tag stack is full. Oldest entry should be removed.
    enew
    for i in range(10, 30)
      exe "tag var" .. i
***************
*** 814,822 ****
    call assert_equal('var12', l.items[0].tagname)
    call assert_equal('var31', l.items[19].tagname)
  
!   " Jump from the top of the stack
    call assert_fails('tag', 'E556:')
  
    " Pop from an unsaved buffer
    enew!
    call append(1, "sample text")
--- 823,837 ----
    call assert_equal('var12', l.items[0].tagname)
    call assert_equal('var31', l.items[19].tagname)
  
!   " Use tnext with a single match
!   call assert_fails('tnext', 'E427:')
! 
!   " Jump to newest entry from the top of the stack
    call assert_fails('tag', 'E556:')
  
+   " Pop with zero count from the top of the stack
+   call assert_fails('0pop', 'E556:')
+ 
    " Pop from an unsaved buffer
    enew!
    call append(1, "sample text")
***************
*** 827,832 ****
--- 842,854 ----
    " Pop all the entries in the tag stack
    call assert_fails('30pop', 'E555:')
  
+   " Pop with a count when already at the bottom of the stack
+   call assert_fails('exe "normal 4\<C-T>"', 'E555:')
+   call assert_equal(1, gettagstack().curidx)
+ 
+   " Jump to newest entry from the bottom of the stack with zero count
+   call assert_fails('0tag', 'E555:')
+ 
    " Pop the tag stack when it is empty
    call settagstack(1, {'items' : []})
    call assert_fails('pop', 'E73:')
***************
*** 853,858 ****
--- 875,881 ----
    [CODE]
    call writefile(code, 'Xfoo')
  
+   call settagstack(1, {'items' : []})
    tag first
    tlast
    call assert_equal(3, line('.'))
***************
*** 861,866 ****
--- 884,1034 ----
    call assert_equal(1, line('.'))
    call assert_fails('tprev', 'E425:')
  
+   tlast
+   call feedkeys("5\<CR>", 't')
+   tselect first
+   call assert_equal(2, gettagstack().curidx)
+ 
+   set ignorecase
+   tag FIRST
+   tnext
+   call assert_equal(2, line('.'))
+   set ignorecase&
+ 
+   call delete('Xtags')
+   call delete('Xfoo')
+   set tags&
+   %bwipe
+ endfunc
+ 
+ " Test for previewing multiple matching tags
+ func Test_preview_tag_multimatch()
+   call writefile([
+         \ "!_TAG_FILE_ENCODING\tutf-8\t//",
+         \ "first\tXfoo\t1",
+         \ "first\tXfoo\t2",
+         \ "first\tXfoo\t3"],
+         \ 'Xtags')
+   set tags=Xtags
+   let code =<< trim [CODE]
+     int first() {}
+     int first() {}
+     int first() {}
+   [CODE]
+   call writefile(code, 'Xfoo')
+ 
+   enew | only
+   ptag first
+   ptlast
+   wincmd P
+   call assert_equal(3, line('.'))
+   wincmd w
+   call assert_fails('ptnext', 'E428:')
+   ptprev
+   wincmd P
+   call assert_equal(2, line('.'))
+   wincmd w
+   ptfirst
+   wincmd P
+   call assert_equal(1, line('.'))
+   wincmd w
+   call assert_fails('ptprev', 'E425:')
+   ptnext
+   wincmd P
+   call assert_equal(2, line('.'))
+   wincmd w
+   ptlast
+   call feedkeys("5\<CR>", 't')
+   ptselect first
+   wincmd P
+   call assert_equal(3, line('.'))
+ 
+   pclose
+ 
+   call delete('Xtags')
+   call delete('Xfoo')
+   set tags&
+   %bwipe
+ endfunc
+ 
+ " Test for jumping to multiple matching tags across multiple :tags commands
+ func Test_tnext_multimatch()
+   call writefile([
+         \ "!_TAG_FILE_ENCODING\tutf-8\t//",
+         \ "first\tXfoo1\t1",
+         \ "first\tXfoo2\t1",
+         \ "first\tXfoo3\t1"],
+         \ 'Xtags')
+   set tags=Xtags
+   let code =<< trim [CODE]
+     int first() {}
+   [CODE]
+   call writefile(code, 'Xfoo1')
+   call writefile(code, 'Xfoo2')
+   call writefile(code, 'Xfoo3')
+ 
+   tag first
+   tag first
+   pop
+   tnext
+   tnext
+   call assert_fails('tnext', 'E428:')
+ 
+   call delete('Xtags')
+   call delete('Xfoo1')
+   call delete('Xfoo2')
+   call delete('Xfoo3')
+   set tags&
+   %bwipe
+ endfunc
+ 
+ " Test for jumping to multiple matching tags in non-existing files
+ func Test_multimatch_non_existing_files()
+   call writefile([
+         \ "!_TAG_FILE_ENCODING\tutf-8\t//",
+         \ "first\tXfoo1\t1",
+         \ "first\tXfoo2\t1",
+         \ "first\tXfoo3\t1"],
+         \ 'Xtags')
+   set tags=Xtags
+ 
+   call settagstack(1, {'items' : []})
+   call assert_fails('tag first', 'E429:')
+   call assert_equal(3, gettagstack().items[0].matchnr)
+ 
+   call delete('Xtags')
+   set tags&
+   %bwipe
+ endfunc
+ 
+ func Test_tselect_listing()
+   call writefile([
+         \ "!_TAG_FILE_ENCODING\tutf-8\t//",
+         \ "first\tXfoo\t1" .. ';"' .. "\tv\ttyperef:typename:int\tfile:",
+         \ "first\tXfoo\t2" .. ';"' .. "\tv\ttyperef:typename:char\tfile:"],
+         \ 'Xtags')
+   set tags=Xtags
+ 
+   let code =<< trim [CODE]
+     static int first;
+     static char first;
+   [CODE]
+   call writefile(code, 'Xfoo')
+ 
+   call feedkeys("\<CR>", "t")
+   let l = split(execute("tselect first"), "\n")
+   let expected =<< [DATA]
+   # pri kind tag               file
+   1 FS  v    first             Xfoo
+                typeref:typename:int 
+                1
+   2 FS  v    first             Xfoo
+                typeref:typename:char 
+                2
+ Type number and <Enter> (empty cancels): 
+ [DATA]
+   call assert_equal(expected, l)
+ 
    call delete('Xtags')
    call delete('Xfoo')
    set tags&
*** ../vim-8.2.0091/src/version.c       2020-01-06 19:53:38.882236516 +0100
--- src/version.c       2020-01-06 20:08:58.068630686 +0100
***************
*** 744,745 ****
--- 744,747 ----
  {   /* Add new patch number below this line */
+ /**/
+     92,
  /**/

-- 
BEDEVERE: How do you know so much about swallows?
ARTHUR:   Well you have to know these things when you're a king, you know.
                 "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

 /// 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/202001062004.006K4BmK014741%40masaka.moolenaar.net.

Raspunde prin e-mail lui