comparison src/testdir/test_quickfix.vim @ 11030:9d40a98f0834 v8.0.0404

patch 8.0.0404: not enough testing for quickfix commit https://github.com/vim/vim/commit/391b1dd040af204b150d43c5a1c97477ee450a28 Author: Bram Moolenaar <Bram@vim.org> Date: Sat Mar 4 13:47:11 2017 +0100 patch 8.0.0404: not enough testing for quickfix Problem: Not enough testing for quickfix. Solution: Add some more tests. (Yegappan Lakshmanan)
author Christian Brabandt <cb@256bit.org>
date Sat, 04 Mar 2017 14:00:04 +0100
parents 73e2a7abe2a3
children 13c660bd07b2
comparison
equal deleted inserted replaced
11029:80594d56020f 11030:9d40a98f0834
126 Xlist! -5,-3 126 Xlist! -5,-3
127 redir END 127 redir END
128 let l = split(result, "\n") 128 let l = split(result, "\n")
129 call assert_equal([' 2 Xtestfile1:1 col 3: Line1', 129 call assert_equal([' 2 Xtestfile1:1 col 3: Line1',
130 \ ' 3: non-error 2', ' 4 Xtestfile2:2 col 2: Line2'], l) 130 \ ' 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)
131 endfunc 139 endfunc
132 140
133 func Test_clist() 141 func Test_clist()
134 call XlistTests('c') 142 call XlistTests('c')
135 call XlistTests('l') 143 call XlistTests('l')
923 \ "NEW compiler v1.1", 931 \ "NEW compiler v1.1",
924 \ "(2,2) warning: variable 'x' not defined", 932 \ "(2,2) warning: variable 'x' not defined",
925 \ "(67,3) warning: 's' already defined" 933 \ "(67,3) warning: 's' already defined"
926 \] 934 \]
927 set efm=%+P[%f],(%l\\,%c)%*[\ ]%t%*[^:]:\ %m,%-Q 935 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')
928 cexpr "" 941 cexpr ""
929 for l in lines 942 for l in lines
930 caddexpr l 943 caddexpr l
931 endfor 944 endfor
932 let l = getqflist() 945 let l = getqflist()
933 call assert_equal(9, len(l)) 946 call assert_equal(9, len(l))
934 call assert_equal(21, l[2].lnum) 947 call assert_equal(21, l[2].lnum)
935 call assert_equal(2, l[2].col) 948 call assert_equal(2, l[2].col)
936 call assert_equal('w', l[2].type) 949 call assert_equal('w', l[2].type)
937 call assert_equal('e', l[3].type) 950 call assert_equal('e', l[3].type)
951 call delete('Xtestfile1')
952 call delete('Xtestfile2')
953 call delete('Xtestfile3')
938 954
939 " Tests for %E, %C and %Z format specifiers 955 " Tests for %E, %C and %Z format specifiers
940 let lines = ["Error 275", 956 let lines = ["Error 275",
941 \ "line 42", 957 \ "line 42",
942 \ "column 3", 958 \ "column 3",
1367 copen | only 1383 copen | only
1368 exe "normal 5G\<CR>" 1384 exe "normal 5G\<CR>"
1369 call assert_equal(2, winnr('$')) 1385 call assert_equal(2, winnr('$'))
1370 call assert_equal(1, bufwinnr('Xqftestfile3')) 1386 call assert_equal(1, bufwinnr('Xqftestfile3'))
1371 1387
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.
1372 enew | only 1390 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
1373 1400
1374 call delete('Xqftestfile1') 1401 call delete('Xqftestfile1')
1375 call delete('Xqftestfile2') 1402 call delete('Xqftestfile2')
1376 call delete('Xqftestfile3') 1403 call delete('Xqftestfile3')
1404 set switchbuf&vim
1405
1406 enew | only
1377 endfunc 1407 endfunc
1378 1408
1379 func Xadjust_qflnum(cchar) 1409 func Xadjust_qflnum(cchar)
1380 call s:setup_commands(a:cchar) 1410 call s:setup_commands(a:cchar)
1381 1411
1689 call X('l') 1719 call X('l')
1690 call setqflist([], 'r') 1720 call setqflist([], 'r')
1691 caddbuffer 1721 caddbuffer
1692 let &efm = save_efm 1722 let &efm = save_efm
1693 endfunc 1723 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