Mercurial > vim
comparison src/testdir/test_quickfix.vim @ 18740:d23bb26ba98f v8.1.2360
patch 8.1.2360: quickfix test coverage can still be improved
Commit: https://github.com/vim/vim/commit/15a7bdcb77faabbd3a9a889957f810da2bcda13e
Author: Bram Moolenaar <Bram@vim.org>
Date: Fri Nov 29 22:06:47 2019 +0100
patch 8.1.2360: quickfix test coverage can still be improved
Problem: Quickfix test coverage can still be improved.
Solution: Add more test cases. (Yegappan Lakshmanan, closes https://github.com/vim/vim/issues/5276)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Fri, 29 Nov 2019 22:15:04 +0100 |
parents | 97d534e17874 |
children | f98368dd6615 |
comparison
equal
deleted
inserted
replaced
18739:0a576092723e | 18740:d23bb26ba98f |
---|---|
268 Xopen 7 | 268 Xopen 7 |
269 call assert_true(winnr('$') == 2 && winnr() == 2 && | 269 call assert_true(winnr('$') == 2 && winnr() == 2 && |
270 \ winheight('.') == 7 && | 270 \ winheight('.') == 7 && |
271 \ getline('.') ==# '|| non-error 1') | 271 \ getline('.') ==# '|| non-error 1') |
272 | 272 |
273 " :cnext in quickfix window should move to the next entry | |
274 Xnext | |
275 call assert_equal(2, g:Xgetlist({'idx' : 0}).idx) | |
273 | 276 |
274 " Calling cwindow should close the quickfix window with no valid errors | 277 " Calling cwindow should close the quickfix window with no valid errors |
275 Xwindow | 278 Xwindow |
276 call assert_true(winnr('$') == 1) | 279 call assert_true(winnr('$') == 1) |
277 | 280 |
454 call g:Xsetlist([], 'f') | 457 call g:Xsetlist([], 'f') |
455 " Jumping to first or next location list entry without any error should | 458 " Jumping to first or next location list entry without any error should |
456 " result in failure | 459 " result in failure |
457 if a:cchar == 'c' | 460 if a:cchar == 'c' |
458 let err = 'E42:' | 461 let err = 'E42:' |
462 let cmd = '$cc' | |
459 else | 463 else |
460 let err = 'E776:' | 464 let err = 'E776:' |
465 let cmd = '$ll' | |
461 endif | 466 endif |
462 call assert_fails('Xnext', err) | 467 call assert_fails('Xnext', err) |
463 call assert_fails('Xprev', err) | 468 call assert_fails('Xprev', err) |
464 call assert_fails('Xnfile', err) | 469 call assert_fails('Xnfile', err) |
465 call assert_fails('Xpfile', err) | 470 call assert_fails('Xpfile', err) |
471 call assert_fails(cmd, err) | |
466 | 472 |
467 Xexpr '' | 473 Xexpr '' |
468 let cmd = (a:cchar == 'c') ? '$cc' : '$ll' | |
469 call assert_fails(cmd, 'E42:') | 474 call assert_fails(cmd, 'E42:') |
470 | 475 |
471 call s:create_test_file('Xqftestfile1') | 476 call s:create_test_file('Xqftestfile1') |
472 call s:create_test_file('Xqftestfile2') | 477 call s:create_test_file('Xqftestfile2') |
473 | 478 |
1884 " GrepAdd_Test_Text: Match 1 | 1889 " GrepAdd_Test_Text: Match 1 |
1885 " GrepAdd_Test_Text: Match 2 | 1890 " GrepAdd_Test_Text: Match 2 |
1886 enew! | only | 1891 enew! | only |
1887 set makeef&vim | 1892 set makeef&vim |
1888 silent Xgrep Grep_Test_Text: test_quickfix.vim | 1893 silent Xgrep Grep_Test_Text: test_quickfix.vim |
1889 call assert_true(len(g:Xgetlist()) == 4) | 1894 call assert_true(len(g:Xgetlist()) == 5) |
1890 Xopen | 1895 Xopen |
1891 call assert_true(w:quickfix_title =~ '^:grep') | 1896 call assert_true(w:quickfix_title =~ '^:grep') |
1892 Xclose | 1897 Xclose |
1893 enew | 1898 enew |
1894 set makeef=Temp_File_## | 1899 set makeef=Temp_File_## |
1895 silent Xgrepadd GrepAdd_Test_Text: test_quickfix.vim | 1900 silent Xgrepadd GrepAdd_Test_Text: test_quickfix.vim |
1896 call assert_true(len(g:Xgetlist()) == 7) | 1901 call assert_true(len(g:Xgetlist()) == 9) |
1902 | |
1903 " Try with 'grepprg' set to 'internal' | |
1904 set grepprg=internal | |
1905 silent Xgrep Grep_Test_Text: test_quickfix.vim | |
1906 silent Xgrepadd GrepAdd_Test_Text: test_quickfix.vim | |
1907 call assert_true(len(g:Xgetlist()) == 9) | |
1908 set grepprg&vim | |
1897 | 1909 |
1898 call writefile(['Vim'], 'XtestTempFile') | 1910 call writefile(['Vim'], 'XtestTempFile') |
1899 set makeef=XtestTempFile | 1911 set makeef=XtestTempFile |
1900 silent Xgrep Grep_Test_Text: test_quickfix.vim | 1912 silent Xgrep Grep_Test_Text: test_quickfix.vim |
1901 call assert_equal(4, len(g:Xgetlist())) | 1913 call assert_equal(5, len(g:Xgetlist())) |
1902 call assert_false(filereadable('XtestTempFile')) | 1914 call assert_false(filereadable('XtestTempFile')) |
1903 set makeef&vim | 1915 set makeef&vim |
1904 endfunc | 1916 endfunc |
1905 | 1917 |
1906 func Test_grep() | 1918 func Test_grep() |
2456 let g:acmds = [] | 2468 let g:acmds = [] |
2457 silent grep Grep_Autocmd_Text test_quickfix.vim | 2469 silent grep Grep_Autocmd_Text test_quickfix.vim |
2458 silent grepadd GrepAdd_Autocmd_Text test_quickfix.vim | 2470 silent grepadd GrepAdd_Autocmd_Text test_quickfix.vim |
2459 silent grep abc123def Xtest | 2471 silent grep abc123def Xtest |
2460 silent grepadd abc123def Xtest | 2472 silent grepadd abc123def Xtest |
2473 set grepprg=internal | |
2474 silent grep Grep_Autocmd_Text test_quickfix.vim | |
2475 silent grepadd GrepAdd_Autocmd_Text test_quickfix.vim | |
2476 silent lgrep Grep_Autocmd_Text test_quickfix.vim | |
2477 silent lgrepadd GrepAdd_Autocmd_Text test_quickfix.vim | |
2478 set grepprg&vim | |
2461 let l = ['pregrep', | 2479 let l = ['pregrep', |
2462 \ 'postgrep', | 2480 \ 'postgrep', |
2463 \ 'pregrepadd', | 2481 \ 'pregrepadd', |
2464 \ 'postgrepadd', | 2482 \ 'postgrepadd', |
2465 \ 'pregrep', | 2483 \ 'pregrep', |
2466 \ 'postgrep', | 2484 \ 'postgrep', |
2467 \ 'pregrepadd', | 2485 \ 'pregrepadd', |
2468 \ 'postgrepadd'] | 2486 \ 'postgrepadd', |
2487 \ 'pregrep', | |
2488 \ 'postgrep', | |
2489 \ 'pregrepadd', | |
2490 \ 'postgrepadd', | |
2491 \ 'prelgrep', | |
2492 \ 'postlgrep', | |
2493 \ 'prelgrepadd', | |
2494 \ 'postlgrepadd'] | |
2469 call assert_equal(l, g:acmds) | 2495 call assert_equal(l, g:acmds) |
2470 endif | 2496 endif |
2471 | 2497 |
2472 call delete('Xtest') | 2498 call delete('Xtest') |
2473 call delete('Xempty') | 2499 call delete('Xempty') |
2600 wincmd t | 2626 wincmd t |
2601 clast | 2627 clast |
2602 call assert_equal(2, winnr()) | 2628 call assert_equal(2, winnr()) |
2603 call assert_equal('quickfix', getwinvar(1, '&buftype')) | 2629 call assert_equal('quickfix', getwinvar(1, '&buftype')) |
2604 call assert_equal('quickfix', getwinvar(3, '&buftype')) | 2630 call assert_equal('quickfix', getwinvar(3, '&buftype')) |
2631 | |
2632 " Jumping to a file from the location list window should find a usuable | |
2633 " window by wrapping around the window list. | |
2634 enew | only | |
2635 call setloclist(0, [], 'f') | |
2636 new | new | |
2637 lgetexpr ["F1%10%Line 10", "F2%20%Line 20", "F3%30%Line 30"] | |
2638 lopen | |
2639 1close | |
2640 call assert_equal(0, getloclist(3, {'id' : 0}).id) | |
2641 lnext | |
2642 call assert_equal(3, winnr()) | |
2643 call assert_equal(getloclist(1, {'id' : 0}).id, getloclist(3, {'id' : 0}).id) | |
2605 | 2644 |
2606 enew | only | 2645 enew | only |
2607 set efm&vim | 2646 set efm&vim |
2608 endfunc | 2647 endfunc |
2609 | 2648 |