From 9ef371fd545034519e4259da001a52e9f7838ffe Mon Sep 17 00:00:00 2001 From: James McCoy Date: Tue, 13 Dec 2016 14:15:10 -0500 Subject: test: quickfix: Move upstream vim quickfix test to src/nvim/testdir Massaging the upstream patches for this test into the lua tests are too cumbersome and slow down patching. --- src/nvim/testdir/test_quickfix.vim | 681 +++++++++++++++++++++++++++++++++++++ 1 file changed, 681 insertions(+) create mode 100644 src/nvim/testdir/test_quickfix.vim (limited to 'src/nvim/testdir/test_quickfix.vim') diff --git a/src/nvim/testdir/test_quickfix.vim b/src/nvim/testdir/test_quickfix.vim new file mode 100644 index 0000000000..9dbd00b001 --- /dev/null +++ b/src/nvim/testdir/test_quickfix.vim @@ -0,0 +1,681 @@ +" Test for the quickfix commands. + +if !has('quickfix') + finish +endif + +set encoding=utf-8 + +" Tests for the :clist and :llist commands +function XlistTests(cchar) + let Xlist = a:cchar . 'list' + let Xgetexpr = a:cchar . 'getexpr' + + " With an empty list, command should return error + exe Xgetexpr . ' []' + exe 'silent! ' . Xlist + call assert_true(v:errmsg ==# 'E42: No Errors') + + " Populate the list and then try + exe Xgetexpr . " ['non-error 1', 'Xtestfile1:1:3:Line1', + \ 'non-error 2', 'Xtestfile2:2:2:Line2', + \ 'non-error 3', 'Xtestfile3:3:1:Line3']" + + " List only valid entries + redir => result + exe Xlist + redir END + let l = split(result, "\n") + call assert_equal([' 2 Xtestfile1:1 col 3: Line1', + \ ' 4 Xtestfile2:2 col 2: Line2', + \ ' 6 Xtestfile3:3 col 1: Line3'], l) + + " List all the entries + redir => result + exe Xlist . "!" + redir END + let l = split(result, "\n") + call assert_equal([' 1: non-error 1', ' 2 Xtestfile1:1 col 3: Line1', + \ ' 3: non-error 2', ' 4 Xtestfile2:2 col 2: Line2', + \ ' 5: non-error 3', ' 6 Xtestfile3:3 col 1: Line3'], l) + + " List a range of errors + redir => result + exe Xlist . " 3,6" + redir END + let l = split(result, "\n") + call assert_equal([' 4 Xtestfile2:2 col 2: Line2', + \ ' 6 Xtestfile3:3 col 1: Line3'], l) + + redir => result + exe Xlist . "! 3,4" + redir END + let l = split(result, "\n") + call assert_equal([' 3: non-error 2', ' 4 Xtestfile2:2 col 2: Line2'], l) + + redir => result + exe Xlist . " -6,-4" + redir END + let l = split(result, "\n") + call assert_equal([' 2 Xtestfile1:1 col 3: Line1'], l) + + redir => result + exe Xlist . "! -5,-3" + redir END + let l = split(result, "\n") + call assert_equal([' 2 Xtestfile1:1 col 3: Line1', + \ ' 3: non-error 2', ' 4 Xtestfile2:2 col 2: Line2'], l) +endfunction + +function Test_clist() + call XlistTests('c') + call XlistTests('l') +endfunction + +" Tests for the :colder, :cnewer, :lolder and :lnewer commands +" Note that this test assumes that a quickfix/location list is +" already set by the caller. +function XageTests(cchar) + let Xolder = a:cchar . 'older' + let Xnewer = a:cchar . 'newer' + let Xgetexpr = a:cchar . 'getexpr' + if a:cchar == 'c' + let Xgetlist = 'getqflist()' + else + let Xgetlist = 'getloclist(0)' + endif + + " Jumping to a non existent list should return error + exe 'silent! ' . Xolder . ' 99' + call assert_true(v:errmsg ==# 'E380: At bottom of quickfix stack') + + exe 'silent! ' . Xnewer . ' 99' + call assert_true(v:errmsg ==# 'E381: At top of quickfix stack') + + " Add three quickfix/location lists + exe Xgetexpr . " ['Xtestfile1:1:3:Line1']" + exe Xgetexpr . " ['Xtestfile2:2:2:Line2']" + exe Xgetexpr . " ['Xtestfile3:3:1:Line3']" + + " Go back two lists + exe Xolder + exe 'let l = ' . Xgetlist + call assert_equal('Line2', l[0].text) + + " Go forward two lists + exe Xnewer + exe 'let l = ' . Xgetlist + call assert_equal('Line3', l[0].text) + + " Test for the optional count argument + exe Xolder . ' 2' + exe 'let l = ' . Xgetlist + call assert_equal('Line1', l[0].text) + + exe Xnewer . ' 2' + exe 'let l = ' . Xgetlist + call assert_equal('Line3', l[0].text) +endfunction + +function Test_cage() + let list = [{'bufnr': 1, 'lnum': 1}] + call setqflist(list) + call XageTests('c') + + call setloclist(0, list) + call XageTests('l') +endfunction + +" Tests for the :cwindow, :lwindow :cclose, :lclose, :copen and :lopen +" commands +function XwindowTests(cchar) + let Xwindow = a:cchar . 'window' + let Xclose = a:cchar . 'close' + let Xopen = a:cchar . 'open' + let Xgetexpr = a:cchar . 'getexpr' + + " Create a list with no valid entries + exe Xgetexpr . " ['non-error 1', 'non-error 2', 'non-error 3']" + + " Quickfix/Location window should not open with no valid errors + exe Xwindow + call assert_true(winnr('$') == 1) + + " Create a list with valid entries + exe Xgetexpr . " ['Xtestfile1:1:3:Line1', 'Xtestfile2:2:2:Line2', + \ 'Xtestfile3:3:1:Line3']" + + " Open the window + exe Xwindow + call assert_true(winnr('$') == 2 && winnr() == 2 && + \ getline('.') ==# 'Xtestfile1|1 col 3| Line1') + + " Close the window + exe Xclose + call assert_true(winnr('$') == 1) + + " Create a list with no valid entries + exe Xgetexpr . " ['non-error 1', 'non-error 2', 'non-error 3']" + + " Open the window + exe Xopen . ' 5' + call assert_true(winnr('$') == 2 && getline('.') ==# '|| non-error 1' + \ && winheight('.') == 5) + + " Opening the window again, should move the cursor to that window + wincmd t + exe Xopen . ' 7' + call assert_true(winnr('$') == 2 && winnr() == 2 && + \ winheight('.') == 7 && + \ getline('.') ==# '|| non-error 1') + + + " Calling cwindow should close the quickfix window with no valid errors + exe Xwindow + call assert_true(winnr('$') == 1) +endfunction + +function Test_cwindow() + call XwindowTests('c') + call XwindowTests('l') +endfunction + +" Tests for the :cfile, :lfile, :caddfile, :laddfile, :cgetfile and :lgetfile +" commands. +function XfileTests(cchar) + let Xfile = a:cchar . 'file' + let Xgetfile = a:cchar . 'getfile' + let Xaddfile = a:cchar . 'addfile' + if a:cchar == 'c' + let Xgetlist = 'getqflist()' + else + let Xgetlist = 'getloclist(0)' + endif + + call writefile(['Xtestfile1:700:10:Line 700', + \ 'Xtestfile2:800:15:Line 800'], 'Xqftestfile1') + + enew! + exe Xfile . ' Xqftestfile1' + exe 'let l = ' . Xgetlist + call assert_true(len(l) == 2 && + \ l[0].lnum == 700 && l[0].col == 10 && l[0].text ==# 'Line 700' && + \ l[1].lnum == 800 && l[1].col == 15 && l[1].text ==# 'Line 800') + + " Run cfile/lfile from a modified buffer + enew! + silent! put ='Quickfix' + exe 'silent! ' . Xfile . ' Xqftestfile1' + call assert_true(v:errmsg ==# 'E37: No write since last change (add ! to override)') + + call writefile(['Xtestfile3:900:30:Line 900'], 'Xqftestfile1') + exe Xaddfile . ' Xqftestfile1' + exe 'let l = ' . Xgetlist + call assert_true(len(l) == 3 && + \ l[2].lnum == 900 && l[2].col == 30 && l[2].text ==# 'Line 900') + + call writefile(['Xtestfile1:222:77:Line 222', + \ 'Xtestfile2:333:88:Line 333'], 'Xqftestfile1') + + enew! + exe Xgetfile . ' Xqftestfile1' + exe 'let l = ' . Xgetlist + call assert_true(len(l) == 2 && + \ l[0].lnum == 222 && l[0].col == 77 && l[0].text ==# 'Line 222' && + \ l[1].lnum == 333 && l[1].col == 88 && l[1].text ==# 'Line 333') + + call delete('Xqftestfile1') +endfunction + +function Test_cfile() + call XfileTests('c') + call XfileTests('l') +endfunction + +" Tests for the :cbuffer, :lbuffer, :caddbuffer, :laddbuffer, :cgetbuffer and +" :lgetbuffer commands. +function XbufferTests(cchar) + let Xbuffer = a:cchar . 'buffer' + let Xgetbuffer = a:cchar . 'getbuffer' + let Xaddbuffer = a:cchar . 'addbuffer' + if a:cchar == 'c' + let Xgetlist = 'getqflist()' + else + let Xgetlist = 'getloclist(0)' + endif + + enew! + silent! call setline(1, ['Xtestfile7:700:10:Line 700', + \ 'Xtestfile8:800:15:Line 800']) + exe Xbuffer . "!" + exe 'let l = ' . Xgetlist + call assert_true(len(l) == 2 && + \ l[0].lnum == 700 && l[0].col == 10 && l[0].text ==# 'Line 700' && + \ l[1].lnum == 800 && l[1].col == 15 && l[1].text ==# 'Line 800') + + enew! + silent! call setline(1, ['Xtestfile9:900:55:Line 900', + \ 'Xtestfile10:950:66:Line 950']) + exe Xgetbuffer + exe 'let l = ' . Xgetlist + call assert_true(len(l) == 2 && + \ l[0].lnum == 900 && l[0].col == 55 && l[0].text ==# 'Line 900' && + \ l[1].lnum == 950 && l[1].col == 66 && l[1].text ==# 'Line 950') + + enew! + silent! call setline(1, ['Xtestfile11:700:20:Line 700', + \ 'Xtestfile12:750:25:Line 750']) + exe Xaddbuffer + exe 'let l = ' . Xgetlist + call assert_true(len(l) == 4 && + \ l[1].lnum == 950 && l[1].col == 66 && l[1].text ==# 'Line 950' && + \ l[2].lnum == 700 && l[2].col == 20 && l[2].text ==# 'Line 700' && + \ l[3].lnum == 750 && l[3].col == 25 && l[3].text ==# 'Line 750') + +endfunction + +function Test_cbuffer() + call XbufferTests('c') + call XbufferTests('l') +endfunction + +function Test_helpgrep() + helpgrep quickfix + copen + " This wipes out the buffer, make sure that doesn't cause trouble. + cclose +endfunc + +func Test_errortitle() + augroup QfBufWinEnter + au! + au BufWinEnter * :let g:a=get(w:, 'quickfix_title', 'NONE') + augroup END + copen + let a=[{'lnum': 308, 'bufnr': bufnr(''), 'col': 58, 'valid': 1, 'vcol': 0, 'nr': 0, 'type': '', 'pattern': '', 'text': ' au BufWinEnter * :let g:a=get(w:, ''quickfix_title'', ''NONE'')'}] + call setqflist(a) + call assert_equal(':setqflist()', g:a) + augroup QfBufWinEnter + au! + augroup END + augroup! QfBufWinEnter +endfunc + +func Test_vimgreptitle() + augroup QfBufWinEnter + au! + au BufWinEnter * :let g:a=get(w:, 'quickfix_title', 'NONE') + augroup END + try + vimgrep /pattern/j file + catch /E480/ + endtry + copen + call assert_equal(': vimgrep /pattern/j file', g:a) + augroup QfBufWinEnter + au! + augroup END + augroup! QfBufWinEnter +endfunc + +function XqfTitleTests(cchar) + let Xgetexpr = a:cchar . 'getexpr' + if a:cchar == 'c' + let Xgetlist = 'getqflist()' + else + let Xgetlist = 'getloclist(0)' + endif + let Xopen = a:cchar . 'open' + let Xclose = a:cchar . 'close' + + exe Xgetexpr . " ['file:1:1:message']" + exe 'let l = ' . Xgetlist + if a:cchar == 'c' + call setqflist(l, 'r') + else + call setloclist(0, l, 'r') + endif + + exe Xopen + if a:cchar == 'c' + let title = ':setqflist()' + else + let title = ':setloclist()' + endif + call assert_equal(title, w:quickfix_title) + exe Xclose +endfunction + +" Tests for quickfix window's title +function Test_qf_title() + call XqfTitleTests('c') + call XqfTitleTests('l') +endfunction + +" Tests for 'errorformat' +function Test_efm() + let save_efm = &efm + set efm=%EEEE%m,%WWWW%m,%+CCCC%.%#,%-GGGG%.%# + cgetexpr ['WWWW', 'EEEE', 'CCCC'] + let l = strtrans(string(map(getqflist(), '[v:val.text, v:val.valid]'))) + call assert_equal("[['W', 1], ['E^@CCCC', 1]]", l) + cgetexpr ['WWWW', 'GGGG', 'EEEE', 'CCCC'] + let l = strtrans(string(map(getqflist(), '[v:val.text, v:val.valid]'))) + call assert_equal("[['W', 1], ['E^@CCCC', 1]]", l) + cgetexpr ['WWWW', 'GGGG', 'ZZZZ', 'EEEE', 'CCCC', 'YYYY'] + let l = strtrans(string(map(getqflist(), '[v:val.text, v:val.valid]'))) + call assert_equal("[['W', 1], ['ZZZZ', 0], ['E^@CCCC', 1], ['YYYY', 0]]", l) + let &efm = save_efm +endfunction + +" This will test for problems in quickfix: +" A. incorrectly copying location lists which caused the location list to show +" a different name than the file that was actually being displayed. +" B. not reusing the window for which the location list window is opened but +" instead creating new windows. +" C. make sure that the location list window is not reused instead of the +" window it belongs to. +" +" Set up the test environment: +function! ReadTestProtocol(name) + let base = substitute(a:name, '\v^test://(.*)%(\.[^.]+)?', '\1', '') + let word = substitute(base, '\v(.*)\..*', '\1', '') + + setl modifiable + setl noreadonly + setl noswapfile + setl bufhidden=delete + %del _ + " For problem 2: + " 'buftype' has to be set to reproduce the constant opening of new windows + setl buftype=nofile + + call setline(1, word) + + setl nomodified + setl nomodifiable + setl readonly + exe 'doautocmd BufRead ' . substitute(a:name, '\v^test://(.*)', '\1', '') +endfunction + +function Test_locationlist() + enew + + augroup testgroup + au! + autocmd BufReadCmd test://* call ReadTestProtocol(expand("")) + augroup END + + let words = [ "foo", "bar", "baz", "quux", "shmoo", "spam", "eggs" ] + + let qflist = [] + for word in words + call add(qflist, {'filename': 'test://' . word . '.txt', 'text': 'file ' . word . '.txt', }) + " NOTE: problem 1: + " intentionally not setting 'lnum' so that the quickfix entries are not + " valid + call setloclist(0, qflist, ' ') + endfor + + " Test A + lrewind + enew + lopen + lnext + lnext + lnext + lnext + vert split + wincmd L + lopen + wincmd p + lnext + let fileName = expand("%") + wincmd p + let locationListFileName = substitute(getline(line('.')), '\([^|]*\)|.*', '\1', '') + let fileName = substitute(fileName, '\\', '/', 'g') + let locationListFileName = substitute(locationListFileName, '\\', '/', 'g') + call assert_equal("test://bar.txt", fileName) + call assert_equal("test://bar.txt", locationListFileName) + + wincmd n | only + + " Test B: + lrewind + lopen + 2 + exe "normal \" + wincmd p + 3 + exe "normal \" + wincmd p + 4 + exe "normal \" + call assert_equal(2, winnr('$')) + wincmd n | only + + " Test C: + lrewind + lopen + " Let's move the location list window to the top to check whether it (the + " first window found) will be reused when we try to open new windows: + wincmd K + 2 + exe "normal \" + wincmd p + 3 + exe "normal \" + wincmd p + 4 + exe "normal \" + 1wincmd w + call assert_equal('quickfix', &buftype) + 2wincmd w + let bufferName = expand("%") + let bufferName = substitute(bufferName, '\\', '/', 'g') + call assert_equal('test://quux.txt', bufferName) + + wincmd n | only + + augroup! testgroup +endfunction + +function Test_locationlist_curwin_was_closed() + augroup testgroup + au! + autocmd BufReadCmd t call R(expand("")) + augroup END + + function! R(n) + quit + endfunc + + new + let q = [] + call add(q, {'filename': 't' }) + call setloclist(0, q) + call assert_fails('lrewind', 'E924:') + + augroup! testgroup +endfunction + +" More tests for 'errorformat' +function! Test_efm1() + if !has('unix') + " The 'errorformat' setting is different on non-Unix systems. + " This test works only on Unix-like systems. + return + endif + + let l = [ + \ '"Xtestfile", line 4.12: 1506-045 (S) Undeclared identifier fd_set.', + \ '"Xtestfile", line 6 col 19; this is an error', + \ 'gcc -c -DHAVE_CONFIsing-prototypes -I/usr/X11R6/include version.c', + \ 'Xtestfile:9: parse error before `asd''', + \ 'make: *** [vim] Error 1', + \ 'in file "Xtestfile" linenr 10: there is an error', + \ '', + \ '2 returned', + \ '"Xtestfile", line 11 col 1; this is an error', + \ '"Xtestfile", line 12 col 2; this is another error', + \ '"Xtestfile", line 14:10; this is an error in column 10', + \ '=Xtestfile=, line 15:10; this is another error, but in vcol 10 this time', + \ '"Xtestfile", linenr 16: yet another problem', + \ 'Error in "Xtestfile" at line 17:', + \ 'x should be a dot', + \ ' xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 17', + \ ' ^', + \ 'Error in "Xtestfile" at line 18:', + \ 'x should be a dot', + \ ' xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 18', + \ '.............^', + \ 'Error in "Xtestfile" at line 19:', + \ 'x should be a dot', + \ ' xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 19', + \ '--------------^', + \ 'Error in "Xtestfile" at line 20:', + \ 'x should be a dot', + \ ' xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 20', + \ ' ^', + \ '', + \ 'Does anyone know what is the problem and how to correction it?', + \ '"Xtestfile", line 21 col 9: What is the title of the quickfix window?', + \ '"Xtestfile", line 22 col 9: What is the title of the quickfix window?' + \ ] + + call writefile(l, 'Xerrorfile1') + call writefile(l[:-2], 'Xerrorfile2') + + let m = [ + \ ' xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 2', + \ ' xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 3', + \ ' xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 4', + \ ' xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 5', + \ ' xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 6', + \ ' xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 7', + \ ' xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 8', + \ ' xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 9', + \ ' xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 10', + \ ' xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 11', + \ ' xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 12', + \ ' xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 13', + \ ' xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 14', + \ ' xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 15', + \ ' xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 16', + \ ' xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 17', + \ ' xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 18', + \ ' xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 19', + \ ' xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 20', + \ ' xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 21', + \ ' xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx line 22' + \ ] + call writefile(m, 'Xtestfile') + + let save_efm = &efm + set efm+==%f=\\,\ line\ %l%*\\D%v%*[^\ ]\ %m + set efm^=%AError\ in\ \"%f\"\ at\ line\ %l:,%Z%p^,%C%m + + exe 'cf Xerrorfile2' + clast + copen + call assert_equal(':cf Xerrorfile2', w:quickfix_title) + wincmd p + + exe 'cf Xerrorfile1' + call assert_equal([4, 12], [line('.'), col('.')]) + cn + call assert_equal([6, 19], [line('.'), col('.')]) + cn + call assert_equal([9, 2], [line('.'), col('.')]) + cn + call assert_equal([10, 2], [line('.'), col('.')]) + cn + call assert_equal([11, 1], [line('.'), col('.')]) + cn + call assert_equal([12, 2], [line('.'), col('.')]) + cn + call assert_equal([14, 10], [line('.'), col('.')]) + cn + call assert_equal([15, 3, 10], [line('.'), col('.'), virtcol('.')]) + cn + call assert_equal([16, 2], [line('.'), col('.')]) + cn + call assert_equal([17, 6], [line('.'), col('.')]) + cn + call assert_equal([18, 7], [line('.'), col('.')]) + cn + call assert_equal([19, 8], [line('.'), col('.')]) + cn + call assert_equal([20, 9], [line('.'), col('.')]) + clast + cprev + cprev + wincmd w + call assert_equal(':cf Xerrorfile1', w:quickfix_title) + wincmd p + + let &efm = save_efm + call delete('Xerrorfile1') + call delete('Xerrorfile2') + call delete('Xtestfile') +endfunction + +function XquickfixChangedByAutocmd(cchar) + let Xolder = a:cchar . 'older' + let Xgetexpr = a:cchar . 'getexpr' + let Xrewind = a:cchar . 'rewind' + if a:cchar == 'c' + let Xsetlist = 'setqflist(' + let ErrorNr = 'E925' + function! ReadFunc() + colder + cgetexpr [] + endfunc + else + let Xsetlist = 'setloclist(0,' + let ErrorNr = 'E926' + function! ReadFunc() + lolder + lgetexpr [] + endfunc + endif + + augroup testgroup + au! + autocmd BufReadCmd t call ReadFunc() + augroup END + + bwipe! + let words = [ "a", "b" ] + let qflist = [] + for word in words + call add(qflist, {'filename': 't'}) + exec "call " . Xsetlist . "qflist, '')" + endfor + exec "call assert_fails('" . Xrewind . "', '" . ErrorNr . ":')" + + augroup! testgroup +endfunc + +function Test_quickfix_was_changed_by_autocmd() + call XquickfixChangedByAutocmd('c') + call XquickfixChangedByAutocmd('l') +endfunction + +func Test_caddbuffer_to_empty() + helpgr quickfix + call setqflist([], 'r') + cad + try + cn + catch + " number of matches is unknown + call assert_true(v:exception =~ 'E553:') + endtry + quit! +endfunc + +func Test_cgetexpr_works() + " this must not crash Vim + cgetexpr [$x] +endfunc -- cgit From e89efe75f9fd872e2c7323ea525b35af90e8afa0 Mon Sep 17 00:00:00 2001 From: James McCoy Date: Mon, 12 Dec 2016 10:56:00 -0500 Subject: vim-patch:7.4.1752 Problem: When adding to the quickfix list the current position is reset. Solution: Do not reset the position when not needed. (Yegappan Lakshmanan) https://github.com/vim/vim/commit/c1808d5822ed9534ef7f0fe509b15bee92a5cc28 --- src/nvim/testdir/test_quickfix.vim | 48 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) (limited to 'src/nvim/testdir/test_quickfix.vim') diff --git a/src/nvim/testdir/test_quickfix.vim b/src/nvim/testdir/test_quickfix.vim index 9dbd00b001..9955b4f775 100644 --- a/src/nvim/testdir/test_quickfix.vim +++ b/src/nvim/testdir/test_quickfix.vim @@ -679,3 +679,51 @@ func Test_cgetexpr_works() " this must not crash Vim cgetexpr [$x] endfunc + +" Tests for the setqflist() and setloclist() functions +function SetXlistTests(cchar, bnum) + if a:cchar == 'c' + let Xsetlist = function('setqflist') + let Xgetlist = function('getqflist') + let Xnext = 'cnext' + else + let Xsetlist = function('setloclist', [0]) + let Xgetlist = function('getloclist', [0]) + let Xnext = 'lnext' + endif + + call Xsetlist([{'bufnr': a:bnum, 'lnum': 1}, + \ {'bufnr': a:bnum, 'lnum': 2}]) + let l = Xgetlist() + call assert_equal(2, len(l)) + call assert_equal(2, l[1].lnum) + + exe Xnext + call Xsetlist([{'bufnr': a:bnum, 'lnum': 3}], 'a') + let l = Xgetlist() + call assert_equal(3, len(l)) + exe Xnext + call assert_equal(3, line('.')) + + call Xsetlist([{'bufnr': a:bnum, 'lnum': 3}, + \ {'bufnr': a:bnum, 'lnum': 4}, + \ {'bufnr': a:bnum, 'lnum': 5}], 'r') + let l = Xgetlist() + call assert_equal(3, len(l)) + call assert_equal(5, l[2].lnum) + + call Xsetlist([]) + let l = Xgetlist() + call assert_equal(0, len(l)) +endfunction + +function Test_setqflist() + new Xtestfile | only + let bnum = bufnr('%') + call setline(1, range(1,5)) + + call SetXlistTests('c', bnum) + call SetXlistTests('l', bnum) + + call delete('Xtestfile') +endfunction -- cgit From 29d7a597115b692a7e2e39d213b87ac566444a5c Mon Sep 17 00:00:00 2001 From: James McCoy Date: Mon, 12 Dec 2016 11:33:51 -0500 Subject: vim-patch:7.4.1768 Problem: Arguments of setqflist() are not checked properly. Solution: Add better checks, add a test. (Nikolai Pavlov, Hirohito Higashi, closes vim/vim#661) https://github.com/vim/vim/commit/d106e5ba7f10f0d2a14eaefe5d78405044416cb9 --- src/nvim/testdir/test_quickfix.vim | 102 ++++++++++++++++++++++++++++++++++--- 1 file changed, 94 insertions(+), 8 deletions(-) (limited to 'src/nvim/testdir/test_quickfix.vim') diff --git a/src/nvim/testdir/test_quickfix.vim b/src/nvim/testdir/test_quickfix.vim index 9955b4f775..2c6f3c922a 100644 --- a/src/nvim/testdir/test_quickfix.vim +++ b/src/nvim/testdir/test_quickfix.vim @@ -483,7 +483,7 @@ endfunction function Test_locationlist_curwin_was_closed() augroup testgroup au! - autocmd BufReadCmd t call R(expand("")) + autocmd BufReadCmd test_curwin.txt call R(expand("")) augroup END function! R(n) @@ -492,7 +492,7 @@ function Test_locationlist_curwin_was_closed() new let q = [] - call add(q, {'filename': 't' }) + call add(q, {'filename': 'test_curwin.txt' }) call setloclist(0, q) call assert_fails('lrewind', 'E924:') @@ -625,14 +625,14 @@ function XquickfixChangedByAutocmd(cchar) let Xgetexpr = a:cchar . 'getexpr' let Xrewind = a:cchar . 'rewind' if a:cchar == 'c' - let Xsetlist = 'setqflist(' + let Xsetlist = function('setqflist') let ErrorNr = 'E925' function! ReadFunc() colder cgetexpr [] endfunc else - let Xsetlist = 'setloclist(0,' + let Xsetlist = function('setloclist', [0]) let ErrorNr = 'E926' function! ReadFunc() lolder @@ -642,15 +642,15 @@ function XquickfixChangedByAutocmd(cchar) augroup testgroup au! - autocmd BufReadCmd t call ReadFunc() + autocmd BufReadCmd test_changed.txt call ReadFunc() augroup END - bwipe! + new | only let words = [ "a", "b" ] let qflist = [] for word in words - call add(qflist, {'filename': 't'}) - exec "call " . Xsetlist . "qflist, '')" + call add(qflist, {'filename': 'test_changed.txt'}) + call Xsetlist(qflist, ' ') endfor exec "call assert_fails('" . Xrewind . "', '" . ErrorNr . ":')" @@ -727,3 +727,89 @@ function Test_setqflist() call delete('Xtestfile') endfunction + +function! XquickfixSetListWithAct(cchar) + let Xolder = a:cchar . 'older' + let Xnewer = a:cchar . 'newer' + if a:cchar == 'c' + let Xsetlist = function('setqflist') + let Xgetlist = function('getqflist') + else + let Xsetlist = function('setloclist', [0]) + let Xgetlist = function('getloclist', [0]) + endif + let list1 = [{'filename': 'fnameA', 'text': 'A'}, + \ {'filename': 'fnameB', 'text': 'B'}] + let list2 = [{'filename': 'fnameC', 'text': 'C'}, + \ {'filename': 'fnameD', 'text': 'D'}, + \ {'filename': 'fnameE', 'text': 'E'}] + + " {action} is unspecified. Same as specifing ' '. + new | only + exec "silent! " . Xnewer . "99" + call Xsetlist(list1) + call Xsetlist(list2) + let li = Xgetlist() + call assert_equal(3, len(li)) + call assert_equal('C', li[0]['text']) + call assert_equal('D', li[1]['text']) + call assert_equal('E', li[2]['text']) + exec "silent! " . Xolder + let li = Xgetlist() + call assert_equal(2, len(li)) + call assert_equal('A', li[0]['text']) + call assert_equal('B', li[1]['text']) + + " {action} is specified ' '. + new | only + exec "silent! " . Xnewer . "99" + call Xsetlist(list1) + call Xsetlist(list2, ' ') + let li = Xgetlist() + call assert_equal(3, len(li)) + call assert_equal('C', li[0]['text']) + call assert_equal('D', li[1]['text']) + call assert_equal('E', li[2]['text']) + exec "silent! " . Xolder + let li = Xgetlist() + call assert_equal(2, len(li)) + call assert_equal('A', li[0]['text']) + call assert_equal('B', li[1]['text']) + + " {action} is specified 'a'. + new | only + exec "silent! " . Xnewer . "99" + call Xsetlist(list1) + call Xsetlist(list2, 'a') + let li = Xgetlist() + call assert_equal(5, len(li)) + call assert_equal('A', li[0]['text']) + call assert_equal('B', li[1]['text']) + call assert_equal('C', li[2]['text']) + call assert_equal('D', li[3]['text']) + call assert_equal('E', li[4]['text']) + + " {action} is specified 'r'. + new | only + exec "silent! " . Xnewer . "99" + call Xsetlist(list1) + call Xsetlist(list2, 'r') + let li = Xgetlist() + call assert_equal(3, len(li)) + call assert_equal('C', li[0]['text']) + call assert_equal('D', li[1]['text']) + call assert_equal('E', li[2]['text']) + + " Test for wrong value. + new | only + call assert_fails("call Xsetlist(0)", 'E714:') + call assert_fails("call Xsetlist(list1, '')", 'E927:') + call assert_fails("call Xsetlist(list1, 'aa')", 'E927:') + call assert_fails("call Xsetlist(list1, ' a')", 'E927:') + call assert_fails("call Xsetlist(list1, 0)", 'E928:') +endfunc + +function Test_quickfix_set_list_with_act() + call XquickfixSetListWithAct('c') + call XquickfixSetListWithAct('l') +endfunction -- cgit From 39faa56bce66796f731ec339301acc3d303c08e9 Mon Sep 17 00:00:00 2001 From: James McCoy Date: Mon, 12 Dec 2016 15:04:44 -0500 Subject: vim-patch:7.4.1802 Problem: Quickfix doesn't handle long lines well, they are split. Solution: Drop characters after a limit. (Anton Lindqvist) https://github.com/vim/vim/commit/6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e --- src/nvim/testdir/test_quickfix.vim | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'src/nvim/testdir/test_quickfix.vim') diff --git a/src/nvim/testdir/test_quickfix.vim b/src/nvim/testdir/test_quickfix.vim index 2c6f3c922a..d43ab1e6db 100644 --- a/src/nvim/testdir/test_quickfix.vim +++ b/src/nvim/testdir/test_quickfix.vim @@ -813,3 +813,40 @@ function Test_quickfix_set_list_with_act() call XquickfixSetListWithAct('c') call XquickfixSetListWithAct('l') endfunction + +func XLongLinesTests() + let l = getqflist() + + call assert_equal(3, len(l)) + call assert_equal(1, l[0].lnum) + call assert_equal(1, l[0].col) + call assert_equal(4070, len(l[0].text)) + call assert_equal(2, l[1].lnum) + call assert_equal(1, l[1].col) + call assert_equal(4070, len(l[1].text)) + call assert_equal(3, l[2].lnum) + call assert_equal(1, l[2].col) + call assert_equal(10, len(l[2].text)) + + call setqflist([], 'r') +endfunc + +func Test_long_lines() + let testfile = 'samples/quickfix.txt' + + " file + exe 'cgetfile' testfile + call XLongLinesTests() + + " list + cexpr readfile(testfile) + call XLongLinesTests() + + " string + cexpr join(readfile(testfile), "\n") + call XLongLinesTests() + + " buffer + e testfile + exe 'cbuffer' bufnr('%') +endfunc -- cgit From 9df9cf4ecc4143ce23b5ab85b2ad1ef413a249bd Mon Sep 17 00:00:00 2001 From: James McCoy Date: Mon, 12 Dec 2016 15:05:01 -0500 Subject: vim-patch:7.4.1841 Problem: The code to reallocate the buffer used for quickfix is repeated. Solution: Move the code to a function. (Yegappan Lakshmanan, closes vim/vim#831) https://github.com/vim/vim/commit/2b2b8ae5ab37b04584633c469265d85825166905 --- src/nvim/testdir/test_quickfix.vim | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'src/nvim/testdir/test_quickfix.vim') diff --git a/src/nvim/testdir/test_quickfix.vim b/src/nvim/testdir/test_quickfix.vim index d43ab1e6db..73ee240c77 100644 --- a/src/nvim/testdir/test_quickfix.vim +++ b/src/nvim/testdir/test_quickfix.vim @@ -682,14 +682,14 @@ endfunc " Tests for the setqflist() and setloclist() functions function SetXlistTests(cchar, bnum) + let Xwindow = a:cchar . 'window' + let Xnext = a:cchar . 'next' if a:cchar == 'c' let Xsetlist = function('setqflist') let Xgetlist = function('getqflist') - let Xnext = 'cnext' else let Xsetlist = function('setloclist', [0]) let Xgetlist = function('getloclist', [0]) - let Xnext = 'lnext' endif call Xsetlist([{'bufnr': a:bnum, 'lnum': 1}, @@ -705,6 +705,15 @@ function SetXlistTests(cchar, bnum) exe Xnext call assert_equal(3, line('.')) + " Appending entries to the list should not change the cursor position + " in the quickfix window + exe Xwindow + 1 + call Xsetlist([{'bufnr': a:bnum, 'lnum': 4}, + \ {'bufnr': a:bnum, 'lnum': 5}], 'a') + call assert_equal(1, line('.')) + close + call Xsetlist([{'bufnr': a:bnum, 'lnum': 3}, \ {'bufnr': a:bnum, 'lnum': 4}, \ {'bufnr': a:bnum, 'lnum': 5}], 'r') -- cgit From fbcc854d49330aff7e4511eb6321487f7b4fdae4 Mon Sep 17 00:00:00 2001 From: James McCoy Date: Mon, 12 Dec 2016 15:05:24 -0500 Subject: vim-patch:7.4.1912 Problem: No test for using setqflist() on an older quickfix list. Solution: Add a couple of tests. https://github.com/vim/vim/commit/1cee693b310e1494115a1677fac064941092e1bb --- src/nvim/testdir/test_quickfix.vim | 43 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) (limited to 'src/nvim/testdir/test_quickfix.vim') diff --git a/src/nvim/testdir/test_quickfix.vim b/src/nvim/testdir/test_quickfix.vim index 73ee240c77..a7ca42e021 100644 --- a/src/nvim/testdir/test_quickfix.vim +++ b/src/nvim/testdir/test_quickfix.vim @@ -734,9 +734,52 @@ function Test_setqflist() call SetXlistTests('c', bnum) call SetXlistTests('l', bnum) + enew! call delete('Xtestfile') endfunction +func Test_setqflist_empty_middle() + " create three quickfix lists + vimgrep Test_ test_quickfix.vim + let testlen = len(getqflist()) + call assert_true(testlen > 0) + vimgrep empty test_quickfix.vim + call assert_true(len(getqflist()) > 0) + vimgrep matches test_quickfix.vim + let matchlen = len(getqflist()) + call assert_true(matchlen > 0) + colder + " make the middle list empty + call setqflist([], 'r') + call assert_true(len(getqflist()) == 0) + colder + call assert_equal(testlen, len(getqflist())) + cnewer + cnewer + call assert_equal(matchlen, len(getqflist())) +endfunc + +func Test_setqflist_empty_older() + " create three quickfix lists + vimgrep one test_quickfix.vim + let onelen = len(getqflist()) + call assert_true(onelen > 0) + vimgrep two test_quickfix.vim + let twolen = len(getqflist()) + call assert_true(twolen > 0) + vimgrep three test_quickfix.vim + let threelen = len(getqflist()) + call assert_true(threelen > 0) + colder 2 + " make the first list empty, check the others didn't change + call setqflist([], 'r') + call assert_true(len(getqflist()) == 0) + cnewer + call assert_equal(twolen, len(getqflist())) + cnewer + call assert_equal(threelen, len(getqflist())) +endfunc + function! XquickfixSetListWithAct(cchar) let Xolder = a:cchar . 'older' let Xnewer = a:cchar . 'newer' -- cgit From 4ac88c4faa1abe449e69263a3e6f8655b7a71d7c Mon Sep 17 00:00:00 2001 From: James McCoy Date: Mon, 12 Dec 2016 15:05:29 -0500 Subject: vim-patch:7.4.1937 Problem: No test for directory stack in quickfix. Solution: Add a test. (Yegappan Lakshmanan) https://github.com/vim/vim/commit/ab47c61f46f0797308217cd3c045472cb0ec3195 --- src/nvim/testdir/test_quickfix.vim | 120 +++++++++++++++++++++++++++++++------ 1 file changed, 101 insertions(+), 19 deletions(-) (limited to 'src/nvim/testdir/test_quickfix.vim') diff --git a/src/nvim/testdir/test_quickfix.vim b/src/nvim/testdir/test_quickfix.vim index a7ca42e021..4e9f404528 100644 --- a/src/nvim/testdir/test_quickfix.vim +++ b/src/nvim/testdir/test_quickfix.vim @@ -80,9 +80,9 @@ function XageTests(cchar) let Xnewer = a:cchar . 'newer' let Xgetexpr = a:cchar . 'getexpr' if a:cchar == 'c' - let Xgetlist = 'getqflist()' + let Xgetlist = function('getqflist') else - let Xgetlist = 'getloclist(0)' + let Xgetlist = function('getloclist', [0]) endif " Jumping to a non existent list should return error @@ -99,21 +99,21 @@ function XageTests(cchar) " Go back two lists exe Xolder - exe 'let l = ' . Xgetlist + let l = Xgetlist() call assert_equal('Line2', l[0].text) " Go forward two lists exe Xnewer - exe 'let l = ' . Xgetlist + let l = Xgetlist() call assert_equal('Line3', l[0].text) " Test for the optional count argument exe Xolder . ' 2' - exe 'let l = ' . Xgetlist + let l = Xgetlist() call assert_equal('Line1', l[0].text) exe Xnewer . ' 2' - exe 'let l = ' . Xgetlist + let l = Xgetlist() call assert_equal('Line3', l[0].text) endfunction @@ -187,9 +187,9 @@ function XfileTests(cchar) let Xgetfile = a:cchar . 'getfile' let Xaddfile = a:cchar . 'addfile' if a:cchar == 'c' - let Xgetlist = 'getqflist()' + let Xgetlist = function('getqflist') else - let Xgetlist = 'getloclist(0)' + let Xgetlist = function('getloclist', [0]) endif call writefile(['Xtestfile1:700:10:Line 700', @@ -197,7 +197,7 @@ function XfileTests(cchar) enew! exe Xfile . ' Xqftestfile1' - exe 'let l = ' . Xgetlist + let l = Xgetlist() call assert_true(len(l) == 2 && \ l[0].lnum == 700 && l[0].col == 10 && l[0].text ==# 'Line 700' && \ l[1].lnum == 800 && l[1].col == 15 && l[1].text ==# 'Line 800') @@ -210,7 +210,7 @@ function XfileTests(cchar) call writefile(['Xtestfile3:900:30:Line 900'], 'Xqftestfile1') exe Xaddfile . ' Xqftestfile1' - exe 'let l = ' . Xgetlist + let l = Xgetlist() call assert_true(len(l) == 3 && \ l[2].lnum == 900 && l[2].col == 30 && l[2].text ==# 'Line 900') @@ -219,7 +219,7 @@ function XfileTests(cchar) enew! exe Xgetfile . ' Xqftestfile1' - exe 'let l = ' . Xgetlist + let l = Xgetlist() call assert_true(len(l) == 2 && \ l[0].lnum == 222 && l[0].col == 77 && l[0].text ==# 'Line 222' && \ l[1].lnum == 333 && l[1].col == 88 && l[1].text ==# 'Line 333') @@ -239,16 +239,16 @@ function XbufferTests(cchar) let Xgetbuffer = a:cchar . 'getbuffer' let Xaddbuffer = a:cchar . 'addbuffer' if a:cchar == 'c' - let Xgetlist = 'getqflist()' + let Xgetlist = function('getqflist') else - let Xgetlist = 'getloclist(0)' + let Xgetlist = function('getloclist', [0]) endif enew! silent! call setline(1, ['Xtestfile7:700:10:Line 700', \ 'Xtestfile8:800:15:Line 800']) exe Xbuffer . "!" - exe 'let l = ' . Xgetlist + let l = Xgetlist() call assert_true(len(l) == 2 && \ l[0].lnum == 700 && l[0].col == 10 && l[0].text ==# 'Line 700' && \ l[1].lnum == 800 && l[1].col == 15 && l[1].text ==# 'Line 800') @@ -257,7 +257,7 @@ function XbufferTests(cchar) silent! call setline(1, ['Xtestfile9:900:55:Line 900', \ 'Xtestfile10:950:66:Line 950']) exe Xgetbuffer - exe 'let l = ' . Xgetlist + let l = Xgetlist() call assert_true(len(l) == 2 && \ l[0].lnum == 900 && l[0].col == 55 && l[0].text ==# 'Line 900' && \ l[1].lnum == 950 && l[1].col == 66 && l[1].text ==# 'Line 950') @@ -266,11 +266,12 @@ function XbufferTests(cchar) silent! call setline(1, ['Xtestfile11:700:20:Line 700', \ 'Xtestfile12:750:25:Line 750']) exe Xaddbuffer - exe 'let l = ' . Xgetlist + let l = Xgetlist() call assert_true(len(l) == 4 && \ l[1].lnum == 950 && l[1].col == 66 && l[1].text ==# 'Line 950' && \ l[2].lnum == 700 && l[2].col == 20 && l[2].text ==# 'Line 700' && \ l[3].lnum == 750 && l[3].col == 25 && l[3].text ==# 'Line 750') + enew! endfunction @@ -321,15 +322,15 @@ endfunc function XqfTitleTests(cchar) let Xgetexpr = a:cchar . 'getexpr' if a:cchar == 'c' - let Xgetlist = 'getqflist()' + let Xgetlist = function('getqflist') else - let Xgetlist = 'getloclist(0)' + let Xgetlist = function('getloclist', [0]) endif let Xopen = a:cchar . 'open' let Xclose = a:cchar . 'close' exe Xgetexpr . " ['file:1:1:message']" - exe 'let l = ' . Xgetlist + let l = Xgetlist() if a:cchar == 'c' call setqflist(l, 'r') else @@ -620,6 +621,87 @@ function! Test_efm1() call delete('Xtestfile') endfunction +" Test for quickfix directory stack support +function! s:dir_stack_tests(cchar) + let Xgetexpr = a:cchar . 'getexpr' + if a:cchar == 'c' + let Xgetlist = function('getqflist') + else + let Xgetlist = function('getloclist', [0]) + endif + + let save_efm=&efm + set efm=%DEntering\ dir\ '%f',%f:%l:%m,%XLeaving\ dir\ '%f' + + let l = "Entering dir 'dir1/a'\n" . + \ 'habits2.txt:1:Nine Healthy Habits' . "\n" . + \ "Entering dir 'b'\n" . + \ 'habits3.txt:2:0 Hours of television' . "\n" . + \ 'habits2.txt:7:5 Small meals' . "\n" . + \ "Entering dir 'dir1/c'\n" . + \ 'habits4.txt:3:1 Hour of exercise' . "\n" . + \ "Leaving dir 'dir1/c'\n" . + \ "Leaving dir 'dir1/a'\n" . + \ 'habits1.txt:4:2 Liters of water' . "\n" . + \ "Entering dir 'dir2'\n" . + \ 'habits5.txt:5:3 Cups of hot green tea' . "\n" . + \ "Leaving dir 'dir2'\n" + + exe Xgetexpr . " l" + + let qf = Xgetlist() + + call assert_equal('dir1/a/habits2.txt', bufname(qf[1].bufnr)) + call assert_equal(1, qf[1].lnum) + call assert_equal('dir1/a/b/habits3.txt', bufname(qf[3].bufnr)) + call assert_equal(2, qf[3].lnum) + call assert_equal('dir1/a/habits2.txt', bufname(qf[4].bufnr)) + call assert_equal(7, qf[4].lnum) + call assert_equal('dir1/c/habits4.txt', bufname(qf[6].bufnr)) + call assert_equal(3, qf[6].lnum) + call assert_equal('habits1.txt', bufname(qf[9].bufnr)) + call assert_equal(4, qf[9].lnum) + call assert_equal('dir2/habits5.txt', bufname(qf[11].bufnr)) + call assert_equal(5, qf[11].lnum) + + let &efm=save_efm +endfunction + +" Tests for %D and %X errorformat options +function! Test_efm_dirstack() + " Create the directory stack and files + call mkdir('dir1') + call mkdir('dir1/a') + call mkdir('dir1/a/b') + call mkdir('dir1/c') + call mkdir('dir2') + + let lines = ["Nine Healthy Habits", + \ "0 Hours of television", + \ "1 Hour of exercise", + \ "2 Liters of water", + \ "3 Cups of hot green tea", + \ "4 Short mental breaks", + \ "5 Small meals", + \ "6 AM wake up time", + \ "7 Minutes of laughter", + \ "8 Hours of sleep (at least)", + \ "9 PM end of the day and off to bed" + \ ] + call writefile(lines, 'habits1.txt') + call writefile(lines, 'dir1/a/habits2.txt') + call writefile(lines, 'dir1/a/b/habits3.txt') + call writefile(lines, 'dir1/c/habits4.txt') + call writefile(lines, 'dir2/habits5.txt') + + call s:dir_stack_tests('c') + call s:dir_stack_tests('l') + + call delete('dir1', 'rf') + call delete('dir2', 'rf') + call delete('habits1.txt') +endfunction + function XquickfixChangedByAutocmd(cchar) let Xolder = a:cchar . 'older' let Xgetexpr = a:cchar . 'getexpr' -- cgit From 2244253c14193be94dac4b40a24dcea56e1f1b15 Mon Sep 17 00:00:00 2001 From: James McCoy Date: Mon, 12 Dec 2016 15:05:34 -0500 Subject: vim-patch:7.4.1941 Problem: Not all quickfix tests are also done with the location lists. Solution: Test more quickfix code. Use user commands instead of "exe". (Yegappan Lakshmanan) https://github.com/vim/vim/commit/3ef5bf7d459d6b8a21aaefc80f65448f5a7aa59f --- src/nvim/testdir/test_quickfix.vim | 420 +++++++++++++++++++------------------ 1 file changed, 214 insertions(+), 206 deletions(-) (limited to 'src/nvim/testdir/test_quickfix.vim') diff --git a/src/nvim/testdir/test_quickfix.vim b/src/nvim/testdir/test_quickfix.vim index 4e9f404528..025f26059f 100644 --- a/src/nvim/testdir/test_quickfix.vim +++ b/src/nvim/testdir/test_quickfix.vim @@ -6,24 +6,67 @@ endif set encoding=utf-8 +function! s:setup_commands(cchar) + if a:cchar == 'c' + command! -nargs=* -bang Xlist clist + command! -nargs=* Xgetexpr cgetexpr + command! -nargs=* Xolder colder + command! -nargs=* Xnewer cnewer + command! -nargs=* Xopen copen + command! -nargs=* Xwindow cwindow + command! -nargs=* Xclose cclose + command! -nargs=* -bang Xfile cfile + command! -nargs=* Xgetfile cgetfile + command! -nargs=* Xaddfile caddfile + command! -nargs=* -bang Xbuffer cbuffer + command! -nargs=* Xgetbuffer cgetbuffer + command! -nargs=* Xaddbuffer caddbuffer + command! -nargs=* Xrewind crewind + command! -nargs=* -bang Xnext cnext + command! -nargs=* Xexpr cexpr + command! -nargs=* Xvimgrep vimgrep + let g:Xgetlist = function('getqflist') + let g:Xsetlist = function('setqflist') + else + command! -nargs=* -bang Xlist llist + command! -nargs=* Xgetexpr lgetexpr + command! -nargs=* Xolder lolder + command! -nargs=* Xnewer lnewer + command! -nargs=* Xopen lopen + command! -nargs=* Xwindow lwindow + command! -nargs=* Xclose lclose + command! -nargs=* -bang Xfile lfile + command! -nargs=* Xgetfile lgetfile + command! -nargs=* Xaddfile laddfile + command! -nargs=* -bang Xbuffer lbuffer + command! -nargs=* Xgetbuffer lgetbuffer + command! -nargs=* Xaddbuffer laddbuffer + command! -nargs=* Xrewind lrewind + command! -nargs=* -bang Xnext lnext + command! -nargs=* Xexpr lexpr + command! -nargs=* Xvimgrep lvimgrep + let g:Xgetlist = function('getloclist', [0]) + let g:Xsetlist = function('setloclist', [0]) + endif +endfunction + " Tests for the :clist and :llist commands function XlistTests(cchar) - let Xlist = a:cchar . 'list' - let Xgetexpr = a:cchar . 'getexpr' + call s:setup_commands(a:cchar) " With an empty list, command should return error - exe Xgetexpr . ' []' - exe 'silent! ' . Xlist + Xgetexpr [] + silent! Xlist call assert_true(v:errmsg ==# 'E42: No Errors') " Populate the list and then try - exe Xgetexpr . " ['non-error 1', 'Xtestfile1:1:3:Line1', + Xgetexpr ['non-error 1', 'Xtestfile1:1:3:Line1', \ 'non-error 2', 'Xtestfile2:2:2:Line2', - \ 'non-error 3', 'Xtestfile3:3:1:Line3']" + \ 'non-error 3', 'Xtestfile3:3:1:Line3'] " List only valid entries redir => result - exe Xlist + Xlist redir END let l = split(result, "\n") call assert_equal([' 2 Xtestfile1:1 col 3: Line1', @@ -32,7 +75,7 @@ function XlistTests(cchar) " List all the entries redir => result - exe Xlist . "!" + Xlist! redir END let l = split(result, "\n") call assert_equal([' 1: non-error 1', ' 2 Xtestfile1:1 col 3: Line1', @@ -41,26 +84,26 @@ function XlistTests(cchar) " List a range of errors redir => result - exe Xlist . " 3,6" + Xlist 3,6 redir END let l = split(result, "\n") call assert_equal([' 4 Xtestfile2:2 col 2: Line2', \ ' 6 Xtestfile3:3 col 1: Line3'], l) redir => result - exe Xlist . "! 3,4" + Xlist! 3,4 redir END let l = split(result, "\n") call assert_equal([' 3: non-error 2', ' 4 Xtestfile2:2 col 2: Line2'], l) redir => result - exe Xlist . " -6,-4" + Xlist -6,-4 redir END let l = split(result, "\n") call assert_equal([' 2 Xtestfile1:1 col 3: Line1'], l) redir => result - exe Xlist . "! -5,-3" + Xlist! -5,-3 redir END let l = split(result, "\n") call assert_equal([' 2 Xtestfile1:1 col 3: Line1', @@ -76,44 +119,37 @@ endfunction " Note that this test assumes that a quickfix/location list is " already set by the caller. function XageTests(cchar) - let Xolder = a:cchar . 'older' - let Xnewer = a:cchar . 'newer' - let Xgetexpr = a:cchar . 'getexpr' - if a:cchar == 'c' - let Xgetlist = function('getqflist') - else - let Xgetlist = function('getloclist', [0]) - endif + call s:setup_commands(a:cchar) " Jumping to a non existent list should return error - exe 'silent! ' . Xolder . ' 99' + silent! Xolder 99 call assert_true(v:errmsg ==# 'E380: At bottom of quickfix stack') - exe 'silent! ' . Xnewer . ' 99' + silent! Xnewer 99 call assert_true(v:errmsg ==# 'E381: At top of quickfix stack') " Add three quickfix/location lists - exe Xgetexpr . " ['Xtestfile1:1:3:Line1']" - exe Xgetexpr . " ['Xtestfile2:2:2:Line2']" - exe Xgetexpr . " ['Xtestfile3:3:1:Line3']" + Xgetexpr ['Xtestfile1:1:3:Line1'] + Xgetexpr ['Xtestfile2:2:2:Line2'] + Xgetexpr ['Xtestfile3:3:1:Line3'] " Go back two lists - exe Xolder - let l = Xgetlist() + Xolder + let l = g:Xgetlist() call assert_equal('Line2', l[0].text) " Go forward two lists - exe Xnewer - let l = Xgetlist() + Xnewer + let l = g:Xgetlist() call assert_equal('Line3', l[0].text) " Test for the optional count argument - exe Xolder . ' 2' - let l = Xgetlist() + Xolder 2 + let l = g:Xgetlist() call assert_equal('Line1', l[0].text) - exe Xnewer . ' 2' - let l = Xgetlist() + Xnewer 2 + let l = g:Xgetlist() call assert_equal('Line3', l[0].text) endfunction @@ -129,49 +165,46 @@ endfunction " Tests for the :cwindow, :lwindow :cclose, :lclose, :copen and :lopen " commands function XwindowTests(cchar) - let Xwindow = a:cchar . 'window' - let Xclose = a:cchar . 'close' - let Xopen = a:cchar . 'open' - let Xgetexpr = a:cchar . 'getexpr' + call s:setup_commands(a:cchar) " Create a list with no valid entries - exe Xgetexpr . " ['non-error 1', 'non-error 2', 'non-error 3']" + Xgetexpr ['non-error 1', 'non-error 2', 'non-error 3'] " Quickfix/Location window should not open with no valid errors - exe Xwindow + Xwindow call assert_true(winnr('$') == 1) " Create a list with valid entries - exe Xgetexpr . " ['Xtestfile1:1:3:Line1', 'Xtestfile2:2:2:Line2', - \ 'Xtestfile3:3:1:Line3']" + Xgetexpr ['Xtestfile1:1:3:Line1', 'Xtestfile2:2:2:Line2', + \ 'Xtestfile3:3:1:Line3'] " Open the window - exe Xwindow + Xwindow call assert_true(winnr('$') == 2 && winnr() == 2 && \ getline('.') ==# 'Xtestfile1|1 col 3| Line1') " Close the window - exe Xclose + Xclose call assert_true(winnr('$') == 1) " Create a list with no valid entries - exe Xgetexpr . " ['non-error 1', 'non-error 2', 'non-error 3']" + Xgetexpr ['non-error 1', 'non-error 2', 'non-error 3'] " Open the window - exe Xopen . ' 5' + Xopen 5 call assert_true(winnr('$') == 2 && getline('.') ==# '|| non-error 1' \ && winheight('.') == 5) " Opening the window again, should move the cursor to that window wincmd t - exe Xopen . ' 7' + Xopen 7 call assert_true(winnr('$') == 2 && winnr() == 2 && \ winheight('.') == 7 && \ getline('.') ==# '|| non-error 1') " Calling cwindow should close the quickfix window with no valid errors - exe Xwindow + Xwindow call assert_true(winnr('$') == 1) endfunction @@ -183,21 +216,14 @@ endfunction " Tests for the :cfile, :lfile, :caddfile, :laddfile, :cgetfile and :lgetfile " commands. function XfileTests(cchar) - let Xfile = a:cchar . 'file' - let Xgetfile = a:cchar . 'getfile' - let Xaddfile = a:cchar . 'addfile' - if a:cchar == 'c' - let Xgetlist = function('getqflist') - else - let Xgetlist = function('getloclist', [0]) - endif + call s:setup_commands(a:cchar) call writefile(['Xtestfile1:700:10:Line 700', \ 'Xtestfile2:800:15:Line 800'], 'Xqftestfile1') enew! - exe Xfile . ' Xqftestfile1' - let l = Xgetlist() + Xfile Xqftestfile1 + let l = g:Xgetlist() call assert_true(len(l) == 2 && \ l[0].lnum == 700 && l[0].col == 10 && l[0].text ==# 'Line 700' && \ l[1].lnum == 800 && l[1].col == 15 && l[1].text ==# 'Line 800') @@ -205,12 +231,12 @@ function XfileTests(cchar) " Run cfile/lfile from a modified buffer enew! silent! put ='Quickfix' - exe 'silent! ' . Xfile . ' Xqftestfile1' + silent! Xfile Xqftestfile1 call assert_true(v:errmsg ==# 'E37: No write since last change (add ! to override)') call writefile(['Xtestfile3:900:30:Line 900'], 'Xqftestfile1') - exe Xaddfile . ' Xqftestfile1' - let l = Xgetlist() + Xaddfile Xqftestfile1 + let l = g:Xgetlist() call assert_true(len(l) == 3 && \ l[2].lnum == 900 && l[2].col == 30 && l[2].text ==# 'Line 900') @@ -218,8 +244,8 @@ function XfileTests(cchar) \ 'Xtestfile2:333:88:Line 333'], 'Xqftestfile1') enew! - exe Xgetfile . ' Xqftestfile1' - let l = Xgetlist() + Xgetfile Xqftestfile1 + let l = g:Xgetlist() call assert_true(len(l) == 2 && \ l[0].lnum == 222 && l[0].col == 77 && l[0].text ==# 'Line 222' && \ l[1].lnum == 333 && l[1].col == 88 && l[1].text ==# 'Line 333') @@ -235,20 +261,13 @@ endfunction " Tests for the :cbuffer, :lbuffer, :caddbuffer, :laddbuffer, :cgetbuffer and " :lgetbuffer commands. function XbufferTests(cchar) - let Xbuffer = a:cchar . 'buffer' - let Xgetbuffer = a:cchar . 'getbuffer' - let Xaddbuffer = a:cchar . 'addbuffer' - if a:cchar == 'c' - let Xgetlist = function('getqflist') - else - let Xgetlist = function('getloclist', [0]) - endif + call s:setup_commands(a:cchar) enew! silent! call setline(1, ['Xtestfile7:700:10:Line 700', \ 'Xtestfile8:800:15:Line 800']) - exe Xbuffer . "!" - let l = Xgetlist() + Xbuffer! + let l = g:Xgetlist() call assert_true(len(l) == 2 && \ l[0].lnum == 700 && l[0].col == 10 && l[0].text ==# 'Line 700' && \ l[1].lnum == 800 && l[1].col == 15 && l[1].text ==# 'Line 800') @@ -256,8 +275,8 @@ function XbufferTests(cchar) enew! silent! call setline(1, ['Xtestfile9:900:55:Line 900', \ 'Xtestfile10:950:66:Line 950']) - exe Xgetbuffer - let l = Xgetlist() + Xgetbuffer + let l = g:Xgetlist() call assert_true(len(l) == 2 && \ l[0].lnum == 900 && l[0].col == 55 && l[0].text ==# 'Line 900' && \ l[1].lnum == 950 && l[1].col == 66 && l[1].text ==# 'Line 950') @@ -265,8 +284,8 @@ function XbufferTests(cchar) enew! silent! call setline(1, ['Xtestfile11:700:20:Line 700', \ 'Xtestfile12:750:25:Line 750']) - exe Xaddbuffer - let l = Xgetlist() + Xaddbuffer + let l = g:Xgetlist() call assert_true(len(l) == 4 && \ l[1].lnum == 950 && l[1].col == 66 && l[1].text ==# 'Line 950' && \ l[2].lnum == 700 && l[2].col == 20 && l[2].text ==# 'Line 700' && @@ -320,37 +339,30 @@ func Test_vimgreptitle() endfunc function XqfTitleTests(cchar) - let Xgetexpr = a:cchar . 'getexpr' - if a:cchar == 'c' - let Xgetlist = function('getqflist') - else - let Xgetlist = function('getloclist', [0]) - endif - let Xopen = a:cchar . 'open' - let Xclose = a:cchar . 'close' + call s:setup_commands(a:cchar) - exe Xgetexpr . " ['file:1:1:message']" - let l = Xgetlist() + Xgetexpr ['file:1:1:message'] + let l = g:Xgetlist() if a:cchar == 'c' call setqflist(l, 'r') else call setloclist(0, l, 'r') endif - exe Xopen + Xopen if a:cchar == 'c' let title = ':setqflist()' else let title = ':setloclist()' endif call assert_equal(title, w:quickfix_title) - exe Xclose + Xclose endfunction " Tests for quickfix window's title function Test_qf_title() - call XqfTitleTests('c') - call XqfTitleTests('l') + call XqfTitleTests('c') + call XqfTitleTests('l') endfunction " Tests for 'errorformat' @@ -623,13 +635,6 @@ endfunction " Test for quickfix directory stack support function! s:dir_stack_tests(cchar) - let Xgetexpr = a:cchar . 'getexpr' - if a:cchar == 'c' - let Xgetlist = function('getqflist') - else - let Xgetlist = function('getloclist', [0]) - endif - let save_efm=&efm set efm=%DEntering\ dir\ '%f',%f:%l:%m,%XLeaving\ dir\ '%f' @@ -644,12 +649,12 @@ function! s:dir_stack_tests(cchar) \ "Leaving dir 'dir1/a'\n" . \ 'habits1.txt:4:2 Liters of water' . "\n" . \ "Entering dir 'dir2'\n" . - \ 'habits5.txt:5:3 Cups of hot green tea' . "\n" . + \ 'habits5.txt:5:3 Cups of hot green tea' . "\n" \ "Leaving dir 'dir2'\n" - exe Xgetexpr . " l" + Xgetexpr l - let qf = Xgetlist() + let qf = g:Xgetlist() call assert_equal('dir1/a/habits2.txt', bufname(qf[1].bufnr)) call assert_equal(1, qf[1].lnum) @@ -703,18 +708,14 @@ function! Test_efm_dirstack() endfunction function XquickfixChangedByAutocmd(cchar) - let Xolder = a:cchar . 'older' - let Xgetexpr = a:cchar . 'getexpr' - let Xrewind = a:cchar . 'rewind' + call s:setup_commands(a:cchar) if a:cchar == 'c' - let Xsetlist = function('setqflist') let ErrorNr = 'E925' function! ReadFunc() colder cgetexpr [] endfunc else - let Xsetlist = function('setloclist', [0]) let ErrorNr = 'E926' function! ReadFunc() lolder @@ -732,9 +733,9 @@ function XquickfixChangedByAutocmd(cchar) let qflist = [] for word in words call add(qflist, {'filename': 'test_changed.txt'}) - call Xsetlist(qflist, ' ') + call g:Xsetlist(qflist, ' ') endfor - exec "call assert_fails('" . Xrewind . "', '" . ErrorNr . ":')" + call assert_fails('Xrewind', ErrorNr . ':') augroup! testgroup endfunc @@ -760,51 +761,44 @@ endfunc func Test_cgetexpr_works() " this must not crash Vim cgetexpr [$x] + lgetexpr [$x] endfunc " Tests for the setqflist() and setloclist() functions function SetXlistTests(cchar, bnum) - let Xwindow = a:cchar . 'window' - let Xnext = a:cchar . 'next' - if a:cchar == 'c' - let Xsetlist = function('setqflist') - let Xgetlist = function('getqflist') - else - let Xsetlist = function('setloclist', [0]) - let Xgetlist = function('getloclist', [0]) - endif + call s:setup_commands(a:cchar) - call Xsetlist([{'bufnr': a:bnum, 'lnum': 1}, + call g:Xsetlist([{'bufnr': a:bnum, 'lnum': 1}, \ {'bufnr': a:bnum, 'lnum': 2}]) - let l = Xgetlist() + let l = g:Xgetlist() call assert_equal(2, len(l)) call assert_equal(2, l[1].lnum) - exe Xnext - call Xsetlist([{'bufnr': a:bnum, 'lnum': 3}], 'a') - let l = Xgetlist() + Xnext + call g:Xsetlist([{'bufnr': a:bnum, 'lnum': 3}], 'a') + let l = g:Xgetlist() call assert_equal(3, len(l)) - exe Xnext + Xnext call assert_equal(3, line('.')) " Appending entries to the list should not change the cursor position " in the quickfix window - exe Xwindow + Xwindow 1 - call Xsetlist([{'bufnr': a:bnum, 'lnum': 4}, + call g:Xsetlist([{'bufnr': a:bnum, 'lnum': 4}, \ {'bufnr': a:bnum, 'lnum': 5}], 'a') call assert_equal(1, line('.')) close - call Xsetlist([{'bufnr': a:bnum, 'lnum': 3}, + call g:Xsetlist([{'bufnr': a:bnum, 'lnum': 3}, \ {'bufnr': a:bnum, 'lnum': 4}, \ {'bufnr': a:bnum, 'lnum': 5}], 'r') - let l = Xgetlist() + let l = g:Xgetlist() call assert_equal(3, len(l)) call assert_equal(5, l[2].lnum) - call Xsetlist([]) - let l = Xgetlist() + call g:Xsetlist([]) + let l = g:Xgetlist() call assert_equal(0, len(l)) endfunction @@ -820,58 +814,65 @@ function Test_setqflist() call delete('Xtestfile') endfunction -func Test_setqflist_empty_middle() +function Xlist_empty_middle(cchar) + call s:setup_commands(a:cchar) + " create three quickfix lists - vimgrep Test_ test_quickfix.vim - let testlen = len(getqflist()) + Xvimgrep Test_ test_quickfix.vim + let testlen = len(g:Xgetlist()) call assert_true(testlen > 0) - vimgrep empty test_quickfix.vim - call assert_true(len(getqflist()) > 0) - vimgrep matches test_quickfix.vim - let matchlen = len(getqflist()) + Xvimgrep empty test_quickfix.vim + call assert_true(len(g:Xgetlist()) > 0) + Xvimgrep matches test_quickfix.vim + let matchlen = len(g:Xgetlist()) call assert_true(matchlen > 0) - colder + Xolder " make the middle list empty - call setqflist([], 'r') - call assert_true(len(getqflist()) == 0) - colder - call assert_equal(testlen, len(getqflist())) - cnewer - cnewer - call assert_equal(matchlen, len(getqflist())) + call g:Xsetlist([], 'r') + call assert_true(len(g:Xgetlist()) == 0) + Xolder + call assert_equal(testlen, len(g:Xgetlist())) + Xnewer + Xnewer + call assert_equal(matchlen, len(g:Xgetlist())) endfunc -func Test_setqflist_empty_older() +function Test_setqflist_empty_middle() + call Xlist_empty_middle('c') + call Xlist_empty_middle('l') +endfunction + +function Xlist_empty_older(cchar) + call s:setup_commands(a:cchar) + " create three quickfix lists - vimgrep one test_quickfix.vim - let onelen = len(getqflist()) + Xvimgrep one test_quickfix.vim + let onelen = len(g:Xgetlist()) call assert_true(onelen > 0) - vimgrep two test_quickfix.vim - let twolen = len(getqflist()) + Xvimgrep two test_quickfix.vim + let twolen = len(g:Xgetlist()) call assert_true(twolen > 0) - vimgrep three test_quickfix.vim - let threelen = len(getqflist()) + Xvimgrep three test_quickfix.vim + let threelen = len(g:Xgetlist()) call assert_true(threelen > 0) - colder 2 + Xolder 2 " make the first list empty, check the others didn't change - call setqflist([], 'r') - call assert_true(len(getqflist()) == 0) - cnewer - call assert_equal(twolen, len(getqflist())) - cnewer - call assert_equal(threelen, len(getqflist())) -endfunc + call g:Xsetlist([], 'r') + call assert_true(len(g:Xgetlist()) == 0) + Xnewer + call assert_equal(twolen, len(g:Xgetlist())) + Xnewer + call assert_equal(threelen, len(g:Xgetlist())) +endfunction + +function Test_setqflist_empty_older() + call Xlist_empty_older('c') + call Xlist_empty_older('l') +endfunction function! XquickfixSetListWithAct(cchar) - let Xolder = a:cchar . 'older' - let Xnewer = a:cchar . 'newer' - if a:cchar == 'c' - let Xsetlist = function('setqflist') - let Xgetlist = function('getqflist') - else - let Xsetlist = function('setloclist', [0]) - let Xgetlist = function('getloclist', [0]) - endif + call s:setup_commands(a:cchar) + let list1 = [{'filename': 'fnameA', 'text': 'A'}, \ {'filename': 'fnameB', 'text': 'B'}] let list2 = [{'filename': 'fnameC', 'text': 'C'}, @@ -880,42 +881,42 @@ function! XquickfixSetListWithAct(cchar) " {action} is unspecified. Same as specifing ' '. new | only - exec "silent! " . Xnewer . "99" - call Xsetlist(list1) - call Xsetlist(list2) - let li = Xgetlist() + silent! Xnewer 99 + call g:Xsetlist(list1) + call g:Xsetlist(list2) + let li = g:Xgetlist() call assert_equal(3, len(li)) call assert_equal('C', li[0]['text']) call assert_equal('D', li[1]['text']) call assert_equal('E', li[2]['text']) - exec "silent! " . Xolder - let li = Xgetlist() + silent! Xolder + let li = g:Xgetlist() call assert_equal(2, len(li)) call assert_equal('A', li[0]['text']) call assert_equal('B', li[1]['text']) " {action} is specified ' '. new | only - exec "silent! " . Xnewer . "99" - call Xsetlist(list1) - call Xsetlist(list2, ' ') - let li = Xgetlist() + silent! Xnewer 99 + call g:Xsetlist(list1) + call g:Xsetlist(list2, ' ') + let li = g:Xgetlist() call assert_equal(3, len(li)) call assert_equal('C', li[0]['text']) call assert_equal('D', li[1]['text']) call assert_equal('E', li[2]['text']) - exec "silent! " . Xolder - let li = Xgetlist() + silent! Xolder + let li = g:Xgetlist() call assert_equal(2, len(li)) call assert_equal('A', li[0]['text']) call assert_equal('B', li[1]['text']) " {action} is specified 'a'. new | only - exec "silent! " . Xnewer . "99" - call Xsetlist(list1) - call Xsetlist(list2, 'a') - let li = Xgetlist() + silent! Xnewer 99 + call g:Xsetlist(list1) + call g:Xsetlist(list2, 'a') + let li = g:Xgetlist() call assert_equal(5, len(li)) call assert_equal('A', li[0]['text']) call assert_equal('B', li[1]['text']) @@ -925,10 +926,10 @@ function! XquickfixSetListWithAct(cchar) " {action} is specified 'r'. new | only - exec "silent! " . Xnewer . "99" - call Xsetlist(list1) - call Xsetlist(list2, 'r') - let li = Xgetlist() + silent! Xnewer 99 + call g:Xsetlist(list1) + call g:Xsetlist(list2, 'r') + let li = g:Xgetlist() call assert_equal(3, len(li)) call assert_equal('C', li[0]['text']) call assert_equal('D', li[1]['text']) @@ -936,11 +937,11 @@ function! XquickfixSetListWithAct(cchar) " Test for wrong value. new | only - call assert_fails("call Xsetlist(0)", 'E714:') - call assert_fails("call Xsetlist(list1, '')", 'E927:') - call assert_fails("call Xsetlist(list1, 'aa')", 'E927:') - call assert_fails("call Xsetlist(list1, ' a')", 'E927:') - call assert_fails("call Xsetlist(list1, 0)", 'E928:') + call assert_fails("call g:Xsetlist(0)", 'E714:') + call assert_fails("call g:Xsetlist(list1, '')", 'E927:') + call assert_fails("call g:Xsetlist(list1, 'aa')", 'E927:') + call assert_fails("call g:Xsetlist(list1, ' a')", 'E927:') + call assert_fails("call g:Xsetlist(list1, 0)", 'E928:') endfunc function Test_quickfix_set_list_with_act() @@ -948,8 +949,8 @@ function Test_quickfix_set_list_with_act() call XquickfixSetListWithAct('l') endfunction -func XLongLinesTests() - let l = getqflist() +function XLongLinesTests(cchar) + let l = g:Xgetlist() call assert_equal(3, len(l)) call assert_equal(1, l[0].lnum) @@ -962,25 +963,32 @@ func XLongLinesTests() call assert_equal(1, l[2].col) call assert_equal(10, len(l[2].text)) - call setqflist([], 'r') -endfunc + call g:Xsetlist([], 'r') +endfunction + +function s:long_lines_tests(cchar) + call s:setup_commands(a:cchar) -func Test_long_lines() let testfile = 'samples/quickfix.txt' " file - exe 'cgetfile' testfile - call XLongLinesTests() + exe 'Xgetfile' testfile + call XLongLinesTests(a:cchar) " list - cexpr readfile(testfile) - call XLongLinesTests() + Xexpr readfile(testfile) + call XLongLinesTests(a:cchar) " string - cexpr join(readfile(testfile), "\n") - call XLongLinesTests() + Xexpr join(readfile(testfile), "\n") + call XLongLinesTests(a:cchar) " buffer - e testfile - exe 'cbuffer' bufnr('%') -endfunc + exe 'edit' testfile + exe 'Xbuffer' bufnr('%') +endfunction + +function Test_long_lines() + call s:long_lines_tests('c') + call s:long_lines_tests('l') +endfunction -- cgit From 63d4ac7b2515072bffabe1d69fd6eb62aeb860f4 Mon Sep 17 00:00:00 2001 From: James McCoy Date: Mon, 12 Dec 2016 15:05:38 -0500 Subject: vim-patch:7.4.1949 Problem: Minor problems with the quickfix code. Solutio