Skip to content

Commit 391b1dd

Browse files
committed
patch 8.0.0404: not enough testing for quickfix
Problem: Not enough testing for quickfix. Solution: Add some more tests. (Yegappan Lakshmanan)
1 parent 24d7636 commit 391b1dd

File tree

2 files changed

+85
-0
lines changed

2 files changed

+85
-0
lines changed

src/testdir/test_quickfix.vim

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,14 @@ func XlistTests(cchar)
128128
let l = split(result, "\n")
129129
call assert_equal([' 2 Xtestfile1:1 col 3: Line1',
130130
\ ' 3: non-error 2', ' 4 Xtestfile2:2 col 2: Line2'], l)
131+
132+
" Test for '+'
133+
redir => result
134+
Xlist! +2
135+
redir END
136+
let l = split(result, "\n")
137+
call assert_equal([' 2 Xtestfile1:1 col 3: Line1',
138+
\ ' 3: non-error 2', ' 4 Xtestfile2:2 col 2: Line2'], l)
131139
endfunc
132140

133141
func Test_clist()
@@ -925,6 +933,11 @@ func Test_efm2()
925933
\ "(67,3) warning: 's' already defined"
926934
\]
927935
set efm=%+P[%f],(%l\\,%c)%*[\ ]%t%*[^:]:\ %m,%-Q
936+
" To exercise the push/pop file functionality in quickfix, the test files
937+
" need to be created.
938+
call writefile(['Line1'], 'Xtestfile1')
939+
call writefile(['Line2'], 'Xtestfile2')
940+
call writefile(['Line3'], 'Xtestfile3')
928941
cexpr ""
929942
for l in lines
930943
caddexpr l
@@ -935,6 +948,9 @@ func Test_efm2()
935948
call assert_equal(2, l[2].col)
936949
call assert_equal('w', l[2].type)
937950
call assert_equal('e', l[3].type)
951+
call delete('Xtestfile1')
952+
call delete('Xtestfile2')
953+
call delete('Xtestfile3')
938954

939955
" Tests for %E, %C and %Z format specifiers
940956
let lines = ["Error 275",
@@ -1369,11 +1385,25 @@ func Test_switchbuf()
13691385
call assert_equal(2, winnr('$'))
13701386
call assert_equal(1, bufwinnr('Xqftestfile3'))
13711387

1388+
" If only quickfix window is open in the current tabpage, jumping to an
1389+
" entry with 'switchubf' set to 'usetab' should search in other tabpages.
13721390
enew | only
1391+
set switchbuf=usetab
1392+
tabedit Xqftestfile1
1393+
tabedit Xqftestfile2
1394+
tabedit Xqftestfile3
1395+
tabfirst
1396+
copen | only
1397+
clast
1398+
call assert_equal(4, tabpagenr())
1399+
tabfirst | tabonly | enew | only
13731400

13741401
call delete('Xqftestfile1')
13751402
call delete('Xqftestfile2')
13761403
call delete('Xqftestfile3')
1404+
set switchbuf&vim
1405+
1406+
enew | only
13771407
endfunc
13781408

13791409
func Xadjust_qflnum(cchar)
@@ -1691,3 +1721,56 @@ func Test_dirstack_cleanup()
16911721
caddbuffer
16921722
let &efm = save_efm
16931723
endfunc
1724+
1725+
" Tests for jumping to entries from the location list window and quickfix
1726+
" window
1727+
func Test_cwindow_jump()
1728+
set efm=%f%%%l%%%m
1729+
lgetexpr ["F1%10%Line 10", "F2%20%Line 20", "F3%30%Line 30"]
1730+
lopen | only
1731+
lfirst
1732+
call assert_true(winnr('$') == 2)
1733+
call assert_true(winnr() == 1)
1734+
" Location list for the new window should be set
1735+
call assert_true(getloclist(0)[2].text == 'Line 30')
1736+
1737+
" Open a scratch buffer
1738+
" Open a new window and create a location list
1739+
" Open the location list window and close the other window
1740+
" Jump to an entry.
1741+
" Should create a new window and jump to the entry. The scrtach buffer
1742+
" should not be used.
1743+
enew | only
1744+
set buftype=nofile
1745+
below new
1746+
lgetexpr ["F1%10%Line 10", "F2%20%Line 20", "F3%30%Line 30"]
1747+
lopen
1748+
2wincmd c
1749+
lnext
1750+
call assert_true(winnr('$') == 3)
1751+
call assert_true(winnr() == 2)
1752+
1753+
" Open two windows with two different location lists
1754+
" Open the location list window and close the previous window
1755+
" Jump to an entry in the location list window
1756+
" Should open the file in the first window and not set the location list.
1757+
enew | only
1758+
lgetexpr ["F1%5%Line 5"]
1759+
below new
1760+
lgetexpr ["F1%10%Line 10", "F2%20%Line 20", "F3%30%Line 30"]
1761+
lopen
1762+
2wincmd c
1763+
lnext
1764+
call assert_true(winnr() == 1)
1765+
call assert_true(getloclist(0)[0].text == 'Line 5')
1766+
1767+
enew | only
1768+
cgetexpr ["F1%10%Line 10", "F2%20%Line 20", "F3%30%Line 30"]
1769+
copen
1770+
cnext
1771+
call assert_true(winnr('$') == 2)
1772+
call assert_true(winnr() == 1)
1773+
1774+
enew | only
1775+
set efm&vim
1776+
endfunc

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -764,6 +764,8 @@ static char *(features[]) =
764764

765765
static int included_patches[] =
766766
{ /* Add new patch number below this line */
767+
/**/
768+
404,
767769
/**/
768770
403,
769771
/**/

0 commit comments

Comments
 (0)