mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
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)
3ef5bf7d45
This commit is contained in:
parent
4ac88c4faa
commit
2244253c14
@ -6,24 +6,67 @@ endif
|
|||||||
|
|
||||||
set encoding=utf-8
|
set encoding=utf-8
|
||||||
|
|
||||||
|
function! s:setup_commands(cchar)
|
||||||
|
if a:cchar == 'c'
|
||||||
|
command! -nargs=* -bang Xlist <mods>clist<bang> <args>
|
||||||
|
command! -nargs=* Xgetexpr <mods>cgetexpr <args>
|
||||||
|
command! -nargs=* Xolder <mods>colder <args>
|
||||||
|
command! -nargs=* Xnewer <mods>cnewer <args>
|
||||||
|
command! -nargs=* Xopen <mods>copen <args>
|
||||||
|
command! -nargs=* Xwindow <mods>cwindow <args>
|
||||||
|
command! -nargs=* Xclose <mods>cclose <args>
|
||||||
|
command! -nargs=* -bang Xfile <mods>cfile<bang> <args>
|
||||||
|
command! -nargs=* Xgetfile <mods>cgetfile <args>
|
||||||
|
command! -nargs=* Xaddfile <mods>caddfile <args>
|
||||||
|
command! -nargs=* -bang Xbuffer <mods>cbuffer<bang> <args>
|
||||||
|
command! -nargs=* Xgetbuffer <mods>cgetbuffer <args>
|
||||||
|
command! -nargs=* Xaddbuffer <mods>caddbuffer <args>
|
||||||
|
command! -nargs=* Xrewind <mods>crewind <args>
|
||||||
|
command! -nargs=* -bang Xnext <mods>cnext<bang> <args>
|
||||||
|
command! -nargs=* Xexpr <mods>cexpr <args>
|
||||||
|
command! -nargs=* Xvimgrep <mods>vimgrep <args>
|
||||||
|
let g:Xgetlist = function('getqflist')
|
||||||
|
let g:Xsetlist = function('setqflist')
|
||||||
|
else
|
||||||
|
command! -nargs=* -bang Xlist <mods>llist<bang> <args>
|
||||||
|
command! -nargs=* Xgetexpr <mods>lgetexpr <args>
|
||||||
|
command! -nargs=* Xolder <mods>lolder <args>
|
||||||
|
command! -nargs=* Xnewer <mods>lnewer <args>
|
||||||
|
command! -nargs=* Xopen <mods>lopen <args>
|
||||||
|
command! -nargs=* Xwindow <mods>lwindow <args>
|
||||||
|
command! -nargs=* Xclose <mods>lclose <args>
|
||||||
|
command! -nargs=* -bang Xfile <mods>lfile<bang> <args>
|
||||||
|
command! -nargs=* Xgetfile <mods>lgetfile <args>
|
||||||
|
command! -nargs=* Xaddfile <mods>laddfile <args>
|
||||||
|
command! -nargs=* -bang Xbuffer <mods>lbuffer<bang> <args>
|
||||||
|
command! -nargs=* Xgetbuffer <mods>lgetbuffer <args>
|
||||||
|
command! -nargs=* Xaddbuffer <mods>laddbuffer <args>
|
||||||
|
command! -nargs=* Xrewind <mods>lrewind <args>
|
||||||
|
command! -nargs=* -bang Xnext <mods>lnext<bang> <args>
|
||||||
|
command! -nargs=* Xexpr <mods>lexpr <args>
|
||||||
|
command! -nargs=* Xvimgrep <mods>lvimgrep <args>
|
||||||
|
let g:Xgetlist = function('getloclist', [0])
|
||||||
|
let g:Xsetlist = function('setloclist', [0])
|
||||||
|
endif
|
||||||
|
endfunction
|
||||||
|
|
||||||
" Tests for the :clist and :llist commands
|
" Tests for the :clist and :llist commands
|
||||||
function XlistTests(cchar)
|
function XlistTests(cchar)
|
||||||
let Xlist = a:cchar . 'list'
|
call s:setup_commands(a:cchar)
|
||||||
let Xgetexpr = a:cchar . 'getexpr'
|
|
||||||
|
|
||||||
" With an empty list, command should return error
|
" With an empty list, command should return error
|
||||||
exe Xgetexpr . ' []'
|
Xgetexpr []
|
||||||
exe 'silent! ' . Xlist
|
silent! Xlist
|
||||||
call assert_true(v:errmsg ==# 'E42: No Errors')
|
call assert_true(v:errmsg ==# 'E42: No Errors')
|
||||||
|
|
||||||
" Populate the list and then try
|
" 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 2', 'Xtestfile2:2:2:Line2',
|
||||||
\ 'non-error 3', 'Xtestfile3:3:1:Line3']"
|
\ 'non-error 3', 'Xtestfile3:3:1:Line3']
|
||||||
|
|
||||||
" List only valid entries
|
" List only valid entries
|
||||||
redir => result
|
redir => result
|
||||||
exe Xlist
|
Xlist
|
||||||
redir END
|
redir END
|
||||||
let l = split(result, "\n")
|
let l = split(result, "\n")
|
||||||
call assert_equal([' 2 Xtestfile1:1 col 3: Line1',
|
call assert_equal([' 2 Xtestfile1:1 col 3: Line1',
|
||||||
@ -32,7 +75,7 @@ function XlistTests(cchar)
|
|||||||
|
|
||||||
" List all the entries
|
" List all the entries
|
||||||
redir => result
|
redir => result
|
||||||
exe Xlist . "!"
|
Xlist!
|
||||||
redir END
|
redir END
|
||||||
let l = split(result, "\n")
|
let l = split(result, "\n")
|
||||||
call assert_equal([' 1: non-error 1', ' 2 Xtestfile1:1 col 3: Line1',
|
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
|
" List a range of errors
|
||||||
redir => result
|
redir => result
|
||||||
exe Xlist . " 3,6"
|
Xlist 3,6
|
||||||
redir END
|
redir END
|
||||||
let l = split(result, "\n")
|
let l = split(result, "\n")
|
||||||
call assert_equal([' 4 Xtestfile2:2 col 2: Line2',
|
call assert_equal([' 4 Xtestfile2:2 col 2: Line2',
|
||||||
\ ' 6 Xtestfile3:3 col 1: Line3'], l)
|
\ ' 6 Xtestfile3:3 col 1: Line3'], l)
|
||||||
|
|
||||||
redir => result
|
redir => result
|
||||||
exe Xlist . "! 3,4"
|
Xlist! 3,4
|
||||||
redir END
|
redir END
|
||||||
let l = split(result, "\n")
|
let l = split(result, "\n")
|
||||||
call assert_equal([' 3: non-error 2', ' 4 Xtestfile2:2 col 2: Line2'], l)
|
call assert_equal([' 3: non-error 2', ' 4 Xtestfile2:2 col 2: Line2'], l)
|
||||||
|
|
||||||
redir => result
|
redir => result
|
||||||
exe Xlist . " -6,-4"
|
Xlist -6,-4
|
||||||
redir END
|
redir END
|
||||||
let l = split(result, "\n")
|
let l = split(result, "\n")
|
||||||
call assert_equal([' 2 Xtestfile1:1 col 3: Line1'], l)
|
call assert_equal([' 2 Xtestfile1:1 col 3: Line1'], l)
|
||||||
|
|
||||||
redir => result
|
redir => result
|
||||||
exe Xlist . "! -5,-3"
|
Xlist! -5,-3
|
||||||
redir END
|
redir END
|
||||||
let l = split(result, "\n")
|
let l = split(result, "\n")
|
||||||
call assert_equal([' 2 Xtestfile1:1 col 3: Line1',
|
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
|
" Note that this test assumes that a quickfix/location list is
|
||||||
" already set by the caller.
|
" already set by the caller.
|
||||||
function XageTests(cchar)
|
function XageTests(cchar)
|
||||||
let Xolder = a:cchar . 'older'
|
call s:setup_commands(a:cchar)
|
||||||
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
|
|
||||||
|
|
||||||
" Jumping to a non existent list should return error
|
" 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')
|
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')
|
call assert_true(v:errmsg ==# 'E381: At top of quickfix stack')
|
||||||
|
|
||||||
" Add three quickfix/location lists
|
" Add three quickfix/location lists
|
||||||
exe Xgetexpr . " ['Xtestfile1:1:3:Line1']"
|
Xgetexpr ['Xtestfile1:1:3:Line1']
|
||||||
exe Xgetexpr . " ['Xtestfile2:2:2:Line2']"
|
Xgetexpr ['Xtestfile2:2:2:Line2']
|
||||||
exe Xgetexpr . " ['Xtestfile3:3:1:Line3']"
|
Xgetexpr ['Xtestfile3:3:1:Line3']
|
||||||
|
|
||||||
" Go back two lists
|
" Go back two lists
|
||||||
exe Xolder
|
Xolder
|
||||||
let l = Xgetlist()
|
let l = g:Xgetlist()
|
||||||
call assert_equal('Line2', l[0].text)
|
call assert_equal('Line2', l[0].text)
|
||||||
|
|
||||||
" Go forward two lists
|
" Go forward two lists
|
||||||
exe Xnewer
|
Xnewer
|
||||||
let l = Xgetlist()
|
let l = g:Xgetlist()
|
||||||
call assert_equal('Line3', l[0].text)
|
call assert_equal('Line3', l[0].text)
|
||||||
|
|
||||||
" Test for the optional count argument
|
" Test for the optional count argument
|
||||||
exe Xolder . ' 2'
|
Xolder 2
|
||||||
let l = Xgetlist()
|
let l = g:Xgetlist()
|
||||||
call assert_equal('Line1', l[0].text)
|
call assert_equal('Line1', l[0].text)
|
||||||
|
|
||||||
exe Xnewer . ' 2'
|
Xnewer 2
|
||||||
let l = Xgetlist()
|
let l = g:Xgetlist()
|
||||||
call assert_equal('Line3', l[0].text)
|
call assert_equal('Line3', l[0].text)
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
@ -129,49 +165,46 @@ endfunction
|
|||||||
" Tests for the :cwindow, :lwindow :cclose, :lclose, :copen and :lopen
|
" Tests for the :cwindow, :lwindow :cclose, :lclose, :copen and :lopen
|
||||||
" commands
|
" commands
|
||||||
function XwindowTests(cchar)
|
function XwindowTests(cchar)
|
||||||
let Xwindow = a:cchar . 'window'
|
call s:setup_commands(a:cchar)
|
||||||
let Xclose = a:cchar . 'close'
|
|
||||||
let Xopen = a:cchar . 'open'
|
|
||||||
let Xgetexpr = a:cchar . 'getexpr'
|
|
||||||
|
|
||||||
" Create a list with no valid entries
|
" 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
|
" Quickfix/Location window should not open with no valid errors
|
||||||
exe Xwindow
|
Xwindow
|
||||||
call assert_true(winnr('$') == 1)
|
call assert_true(winnr('$') == 1)
|
||||||
|
|
||||||
" Create a list with valid entries
|
" Create a list with valid entries
|
||||||
exe Xgetexpr . " ['Xtestfile1:1:3:Line1', 'Xtestfile2:2:2:Line2',
|
Xgetexpr ['Xtestfile1:1:3:Line1', 'Xtestfile2:2:2:Line2',
|
||||||
\ 'Xtestfile3:3:1:Line3']"
|
\ 'Xtestfile3:3:1:Line3']
|
||||||
|
|
||||||
" Open the window
|
" Open the window
|
||||||
exe Xwindow
|
Xwindow
|
||||||
call assert_true(winnr('$') == 2 && winnr() == 2 &&
|
call assert_true(winnr('$') == 2 && winnr() == 2 &&
|
||||||
\ getline('.') ==# 'Xtestfile1|1 col 3| Line1')
|
\ getline('.') ==# 'Xtestfile1|1 col 3| Line1')
|
||||||
|
|
||||||
" Close the window
|
" Close the window
|
||||||
exe Xclose
|
Xclose
|
||||||
call assert_true(winnr('$') == 1)
|
call assert_true(winnr('$') == 1)
|
||||||
|
|
||||||
" Create a list with no valid entries
|
" 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
|
" Open the window
|
||||||
exe Xopen . ' 5'
|
Xopen 5
|
||||||
call assert_true(winnr('$') == 2 && getline('.') ==# '|| non-error 1'
|
call assert_true(winnr('$') == 2 && getline('.') ==# '|| non-error 1'
|
||||||
\ && winheight('.') == 5)
|
\ && winheight('.') == 5)
|
||||||
|
|
||||||
" Opening the window again, should move the cursor to that window
|
" Opening the window again, should move the cursor to that window
|
||||||
wincmd t
|
wincmd t
|
||||||
exe Xopen . ' 7'
|
Xopen 7
|
||||||
call assert_true(winnr('$') == 2 && winnr() == 2 &&
|
call assert_true(winnr('$') == 2 && winnr() == 2 &&
|
||||||
\ winheight('.') == 7 &&
|
\ winheight('.') == 7 &&
|
||||||
\ getline('.') ==# '|| non-error 1')
|
\ getline('.') ==# '|| non-error 1')
|
||||||
|
|
||||||
|
|
||||||
" Calling cwindow should close the quickfix window with no valid errors
|
" Calling cwindow should close the quickfix window with no valid errors
|
||||||
exe Xwindow
|
Xwindow
|
||||||
call assert_true(winnr('$') == 1)
|
call assert_true(winnr('$') == 1)
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
@ -183,21 +216,14 @@ endfunction
|
|||||||
" Tests for the :cfile, :lfile, :caddfile, :laddfile, :cgetfile and :lgetfile
|
" Tests for the :cfile, :lfile, :caddfile, :laddfile, :cgetfile and :lgetfile
|
||||||
" commands.
|
" commands.
|
||||||
function XfileTests(cchar)
|
function XfileTests(cchar)
|
||||||
let Xfile = a:cchar . 'file'
|
call s:setup_commands(a:cchar)
|
||||||
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 writefile(['Xtestfile1:700:10:Line 700',
|
call writefile(['Xtestfile1:700:10:Line 700',
|
||||||
\ 'Xtestfile2:800:15:Line 800'], 'Xqftestfile1')
|
\ 'Xtestfile2:800:15:Line 800'], 'Xqftestfile1')
|
||||||
|
|
||||||
enew!
|
enew!
|
||||||
exe Xfile . ' Xqftestfile1'
|
Xfile Xqftestfile1
|
||||||
let l = Xgetlist()
|
let l = g:Xgetlist()
|
||||||
call assert_true(len(l) == 2 &&
|
call assert_true(len(l) == 2 &&
|
||||||
\ l[0].lnum == 700 && l[0].col == 10 && l[0].text ==# 'Line 700' &&
|
\ 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')
|
\ 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
|
" Run cfile/lfile from a modified buffer
|
||||||
enew!
|
enew!
|
||||||
silent! put ='Quickfix'
|
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 assert_true(v:errmsg ==# 'E37: No write since last change (add ! to override)')
|
||||||
|
|
||||||
call writefile(['Xtestfile3:900:30:Line 900'], 'Xqftestfile1')
|
call writefile(['Xtestfile3:900:30:Line 900'], 'Xqftestfile1')
|
||||||
exe Xaddfile . ' Xqftestfile1'
|
Xaddfile Xqftestfile1
|
||||||
let l = Xgetlist()
|
let l = g:Xgetlist()
|
||||||
call assert_true(len(l) == 3 &&
|
call assert_true(len(l) == 3 &&
|
||||||
\ l[2].lnum == 900 && l[2].col == 30 && l[2].text ==# 'Line 900')
|
\ 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')
|
\ 'Xtestfile2:333:88:Line 333'], 'Xqftestfile1')
|
||||||
|
|
||||||
enew!
|
enew!
|
||||||
exe Xgetfile . ' Xqftestfile1'
|
Xgetfile Xqftestfile1
|
||||||
let l = Xgetlist()
|
let l = g:Xgetlist()
|
||||||
call assert_true(len(l) == 2 &&
|
call assert_true(len(l) == 2 &&
|
||||||
\ l[0].lnum == 222 && l[0].col == 77 && l[0].text ==# 'Line 222' &&
|
\ 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')
|
\ 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
|
" Tests for the :cbuffer, :lbuffer, :caddbuffer, :laddbuffer, :cgetbuffer and
|
||||||
" :lgetbuffer commands.
|
" :lgetbuffer commands.
|
||||||
function XbufferTests(cchar)
|
function XbufferTests(cchar)
|
||||||
let Xbuffer = a:cchar . 'buffer'
|
call s:setup_commands(a:cchar)
|
||||||
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
|
|
||||||
|
|
||||||
enew!
|
enew!
|
||||||
silent! call setline(1, ['Xtestfile7:700:10:Line 700',
|
silent! call setline(1, ['Xtestfile7:700:10:Line 700',
|
||||||
\ 'Xtestfile8:800:15:Line 800'])
|
\ 'Xtestfile8:800:15:Line 800'])
|
||||||
exe Xbuffer . "!"
|
Xbuffer!
|
||||||
let l = Xgetlist()
|
let l = g:Xgetlist()
|
||||||
call assert_true(len(l) == 2 &&
|
call assert_true(len(l) == 2 &&
|
||||||
\ l[0].lnum == 700 && l[0].col == 10 && l[0].text ==# 'Line 700' &&
|
\ 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')
|
\ l[1].lnum == 800 && l[1].col == 15 && l[1].text ==# 'Line 800')
|
||||||
@ -256,8 +275,8 @@ function XbufferTests(cchar)
|
|||||||
enew!
|
enew!
|
||||||
silent! call setline(1, ['Xtestfile9:900:55:Line 900',
|
silent! call setline(1, ['Xtestfile9:900:55:Line 900',
|
||||||
\ 'Xtestfile10:950:66:Line 950'])
|
\ 'Xtestfile10:950:66:Line 950'])
|
||||||
exe Xgetbuffer
|
Xgetbuffer
|
||||||
let l = Xgetlist()
|
let l = g:Xgetlist()
|
||||||
call assert_true(len(l) == 2 &&
|
call assert_true(len(l) == 2 &&
|
||||||
\ l[0].lnum == 900 && l[0].col == 55 && l[0].text ==# 'Line 900' &&
|
\ 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')
|
\ l[1].lnum == 950 && l[1].col == 66 && l[1].text ==# 'Line 950')
|
||||||
@ -265,8 +284,8 @@ function XbufferTests(cchar)
|
|||||||
enew!
|
enew!
|
||||||
silent! call setline(1, ['Xtestfile11:700:20:Line 700',
|
silent! call setline(1, ['Xtestfile11:700:20:Line 700',
|
||||||
\ 'Xtestfile12:750:25:Line 750'])
|
\ 'Xtestfile12:750:25:Line 750'])
|
||||||
exe Xaddbuffer
|
Xaddbuffer
|
||||||
let l = Xgetlist()
|
let l = g:Xgetlist()
|
||||||
call assert_true(len(l) == 4 &&
|
call assert_true(len(l) == 4 &&
|
||||||
\ l[1].lnum == 950 && l[1].col == 66 && l[1].text ==# 'Line 950' &&
|
\ 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[2].lnum == 700 && l[2].col == 20 && l[2].text ==# 'Line 700' &&
|
||||||
@ -320,37 +339,30 @@ func Test_vimgreptitle()
|
|||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
function XqfTitleTests(cchar)
|
function XqfTitleTests(cchar)
|
||||||
let Xgetexpr = a:cchar . 'getexpr'
|
call s:setup_commands(a:cchar)
|
||||||
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'
|
|
||||||
|
|
||||||
exe Xgetexpr . " ['file:1:1:message']"
|
Xgetexpr ['file:1:1:message']
|
||||||
let l = Xgetlist()
|
let l = g:Xgetlist()
|
||||||
if a:cchar == 'c'
|
if a:cchar == 'c'
|
||||||
call setqflist(l, 'r')
|
call setqflist(l, 'r')
|
||||||
else
|
else
|
||||||
call setloclist(0, l, 'r')
|
call setloclist(0, l, 'r')
|
||||||
endif
|
endif
|
||||||
|
|
||||||
exe Xopen
|
Xopen
|
||||||
if a:cchar == 'c'
|
if a:cchar == 'c'
|
||||||
let title = ':setqflist()'
|
let title = ':setqflist()'
|
||||||
else
|
else
|
||||||
let title = ':setloclist()'
|
let title = ':setloclist()'
|
||||||
endif
|
endif
|
||||||
call assert_equal(title, w:quickfix_title)
|
call assert_equal(title, w:quickfix_title)
|
||||||
exe Xclose
|
Xclose
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" Tests for quickfix window's title
|
" Tests for quickfix window's title
|
||||||
function Test_qf_title()
|
function Test_qf_title()
|
||||||
call XqfTitleTests('c')
|
call XqfTitleTests('c')
|
||||||
call XqfTitleTests('l')
|
call XqfTitleTests('l')
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" Tests for 'errorformat'
|
" Tests for 'errorformat'
|
||||||
@ -623,13 +635,6 @@ endfunction
|
|||||||
|
|
||||||
" Test for quickfix directory stack support
|
" Test for quickfix directory stack support
|
||||||
function! s:dir_stack_tests(cchar)
|
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
|
let save_efm=&efm
|
||||||
set efm=%DEntering\ dir\ '%f',%f:%l:%m,%XLeaving\ dir\ '%f'
|
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" .
|
\ "Leaving dir 'dir1/a'\n" .
|
||||||
\ 'habits1.txt:4:2 Liters of water' . "\n" .
|
\ 'habits1.txt:4:2 Liters of water' . "\n" .
|
||||||
\ "Entering dir 'dir2'\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"
|
\ "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('dir1/a/habits2.txt', bufname(qf[1].bufnr))
|
||||||
call assert_equal(1, qf[1].lnum)
|
call assert_equal(1, qf[1].lnum)
|
||||||
@ -703,18 +708,14 @@ function! Test_efm_dirstack()
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function XquickfixChangedByAutocmd(cchar)
|
function XquickfixChangedByAutocmd(cchar)
|
||||||
let Xolder = a:cchar . 'older'
|
call s:setup_commands(a:cchar)
|
||||||
let Xgetexpr = a:cchar . 'getexpr'
|
|
||||||
let Xrewind = a:cchar . 'rewind'
|
|
||||||
if a:cchar == 'c'
|
if a:cchar == 'c'
|
||||||
let Xsetlist = function('setqflist')
|
|
||||||
let ErrorNr = 'E925'
|
let ErrorNr = 'E925'
|
||||||
function! ReadFunc()
|
function! ReadFunc()
|
||||||
colder
|
colder
|
||||||
cgetexpr []
|
cgetexpr []
|
||||||
endfunc
|
endfunc
|
||||||
else
|
else
|
||||||
let Xsetlist = function('setloclist', [0])
|
|
||||||
let ErrorNr = 'E926'
|
let ErrorNr = 'E926'
|
||||||
function! ReadFunc()
|
function! ReadFunc()
|
||||||
lolder
|
lolder
|
||||||
@ -732,9 +733,9 @@ function XquickfixChangedByAutocmd(cchar)
|
|||||||
let qflist = []
|
let qflist = []
|
||||||
for word in words
|
for word in words
|
||||||
call add(qflist, {'filename': 'test_changed.txt'})
|
call add(qflist, {'filename': 'test_changed.txt'})
|
||||||
call Xsetlist(qflist, ' ')
|
call g:Xsetlist(qflist, ' ')
|
||||||
endfor
|
endfor
|
||||||
exec "call assert_fails('" . Xrewind . "', '" . ErrorNr . ":')"
|
call assert_fails('Xrewind', ErrorNr . ':')
|
||||||
|
|
||||||
augroup! testgroup
|
augroup! testgroup
|
||||||
endfunc
|
endfunc
|
||||||
@ -760,51 +761,44 @@ endfunc
|
|||||||
func Test_cgetexpr_works()
|
func Test_cgetexpr_works()
|
||||||
" this must not crash Vim
|
" this must not crash Vim
|
||||||
cgetexpr [$x]
|
cgetexpr [$x]
|
||||||
|
lgetexpr [$x]
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
" Tests for the setqflist() and setloclist() functions
|
" Tests for the setqflist() and setloclist() functions
|
||||||
function SetXlistTests(cchar, bnum)
|
function SetXlistTests(cchar, bnum)
|
||||||
let Xwindow = a:cchar . 'window'
|
call s:setup_commands(a:cchar)
|
||||||
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 Xsetlist([{'bufnr': a:bnum, 'lnum': 1},
|
call g:Xsetlist([{'bufnr': a:bnum, 'lnum': 1},
|
||||||
\ {'bufnr': a:bnum, 'lnum': 2}])
|
\ {'bufnr': a:bnum, 'lnum': 2}])
|
||||||
let l = Xgetlist()
|
let l = g:Xgetlist()
|
||||||
call assert_equal(2, len(l))
|
call assert_equal(2, len(l))
|
||||||
call assert_equal(2, l[1].lnum)
|
call assert_equal(2, l[1].lnum)
|
||||||
|
|
||||||
exe Xnext
|
Xnext
|
||||||
call Xsetlist([{'bufnr': a:bnum, 'lnum': 3}], 'a')
|
call g:Xsetlist([{'bufnr': a:bnum, 'lnum': 3}], 'a')
|
||||||
let l = Xgetlist()
|
let l = g:Xgetlist()
|
||||||
call assert_equal(3, len(l))
|
call assert_equal(3, len(l))
|
||||||
exe Xnext
|
Xnext
|
||||||
call assert_equal(3, line('.'))
|
call assert_equal(3, line('.'))
|
||||||
|
|
||||||
" Appending entries to the list should not change the cursor position
|
" Appending entries to the list should not change the cursor position
|
||||||
" in the quickfix window
|
" in the quickfix window
|
||||||
exe Xwindow
|
Xwindow
|
||||||
1
|
1
|
||||||
call Xsetlist([{'bufnr': a:bnum, 'lnum': 4},
|
call g:Xsetlist([{'bufnr': a:bnum, 'lnum': 4},
|
||||||
\ {'bufnr': a:bnum, 'lnum': 5}], 'a')
|
\ {'bufnr': a:bnum, 'lnum': 5}], 'a')
|
||||||
call assert_equal(1, line('.'))
|
call assert_equal(1, line('.'))
|
||||||
close
|
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': 4},
|
||||||
\ {'bufnr': a:bnum, 'lnum': 5}], 'r')
|
\ {'bufnr': a:bnum, 'lnum': 5}], 'r')
|
||||||
let l = Xgetlist()
|
let l = g:Xgetlist()
|
||||||
call assert_equal(3, len(l))
|
call assert_equal(3, len(l))
|
||||||
call assert_equal(5, l[2].lnum)
|
call assert_equal(5, l[2].lnum)
|
||||||
|
|
||||||
call Xsetlist([])
|
call g:Xsetlist([])
|
||||||
let l = Xgetlist()
|
let l = g:Xgetlist()
|
||||||
call assert_equal(0, len(l))
|
call assert_equal(0, len(l))
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
@ -820,58 +814,65 @@ function Test_setqflist()
|
|||||||
call delete('Xtestfile')
|
call delete('Xtestfile')
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
func Test_setqflist_empty_middle()
|
function Xlist_empty_middle(cchar)
|
||||||
|
call s:setup_commands(a:cchar)
|
||||||
|
|
||||||
" create three quickfix lists
|
" create three quickfix lists
|
||||||
vimgrep Test_ test_quickfix.vim
|
Xvimgrep Test_ test_quickfix.vim
|
||||||
let testlen = len(getqflist())
|
let testlen = len(g:Xgetlist())
|
||||||
call assert_true(testlen > 0)
|
call assert_true(testlen > 0)
|
||||||
vimgrep empty test_quickfix.vim
|
Xvimgrep empty test_quickfix.vim
|
||||||
call assert_true(len(getqflist()) > 0)
|
call assert_true(len(g:Xgetlist()) > 0)
|
||||||
vimgrep matches test_quickfix.vim
|
Xvimgrep matches test_quickfix.vim
|
||||||
let matchlen = len(getqflist())
|
let matchlen = len(g:Xgetlist())
|
||||||
call assert_true(matchlen > 0)
|
call assert_true(matchlen > 0)
|
||||||
colder
|
Xolder
|
||||||
" make the middle list empty
|
" make the middle list empty
|
||||||
call setqflist([], 'r')
|
call g:Xsetlist([], 'r')
|
||||||
call assert_true(len(getqflist()) == 0)
|
call assert_true(len(g:Xgetlist()) == 0)
|
||||||
colder
|
Xolder
|
||||||
call assert_equal(testlen, len(getqflist()))
|
call assert_equal(testlen, len(g:Xgetlist()))
|
||||||
cnewer
|
Xnewer
|
||||||
cnewer
|
Xnewer
|
||||||
call assert_equal(matchlen, len(getqflist()))
|
call assert_equal(matchlen, len(g:Xgetlist()))
|
||||||
endfunc
|
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
|
" create three quickfix lists
|
||||||
vimgrep one test_quickfix.vim
|
Xvimgrep one test_quickfix.vim
|
||||||
let onelen = len(getqflist())
|
let onelen = len(g:Xgetlist())
|
||||||
call assert_true(onelen > 0)
|
call assert_true(onelen > 0)
|
||||||
vimgrep two test_quickfix.vim
|
Xvimgrep two test_quickfix.vim
|
||||||
let twolen = len(getqflist())
|
let twolen = len(g:Xgetlist())
|
||||||
call assert_true(twolen > 0)
|
call assert_true(twolen > 0)
|
||||||
vimgrep three test_quickfix.vim
|
Xvimgrep three test_quickfix.vim
|
||||||
let threelen = len(getqflist())
|
let threelen = len(g:Xgetlist())
|
||||||
call assert_true(threelen > 0)
|
call assert_true(threelen > 0)
|
||||||
colder 2
|
Xolder 2
|
||||||
" make the first list empty, check the others didn't change
|
" make the first list empty, check the others didn't change
|
||||||
call setqflist([], 'r')
|
call g:Xsetlist([], 'r')
|
||||||
call assert_true(len(getqflist()) == 0)
|
call assert_true(len(g:Xgetlist()) == 0)
|
||||||
cnewer
|
Xnewer
|
||||||
call assert_equal(twolen, len(getqflist()))
|
call assert_equal(twolen, len(g:Xgetlist()))
|
||||||
cnewer
|
Xnewer
|
||||||
call assert_equal(threelen, len(getqflist()))
|
call assert_equal(threelen, len(g:Xgetlist()))
|
||||||
endfunc
|
endfunction
|
||||||
|
|
||||||
|
function Test_setqflist_empty_older()
|
||||||
|
call Xlist_empty_older('c')
|
||||||
|
call Xlist_empty_older('l')
|
||||||
|
endfunction
|
||||||
|
|
||||||
function! XquickfixSetListWithAct(cchar)
|
function! XquickfixSetListWithAct(cchar)
|
||||||
let Xolder = a:cchar . 'older'
|
call s:setup_commands(a:cchar)
|
||||||
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'},
|
let list1 = [{'filename': 'fnameA', 'text': 'A'},
|
||||||
\ {'filename': 'fnameB', 'text': 'B'}]
|
\ {'filename': 'fnameB', 'text': 'B'}]
|
||||||
let list2 = [{'filename': 'fnameC', 'text': 'C'},
|
let list2 = [{'filename': 'fnameC', 'text': 'C'},
|
||||||
@ -880,42 +881,42 @@ function! XquickfixSetListWithAct(cchar)
|
|||||||
|
|
||||||
" {action} is unspecified. Same as specifing ' '.
|
" {action} is unspecified. Same as specifing ' '.
|
||||||
new | only
|
new | only
|
||||||
exec "silent! " . Xnewer . "99"
|
silent! Xnewer 99
|
||||||
call Xsetlist(list1)
|
call g:Xsetlist(list1)
|
||||||
call Xsetlist(list2)
|
call g:Xsetlist(list2)
|
||||||
let li = Xgetlist()
|
let li = g:Xgetlist()
|
||||||
call assert_equal(3, len(li))
|
call assert_equal(3, len(li))
|
||||||
call assert_equal('C', li[0]['text'])
|
call assert_equal('C', li[0]['text'])
|
||||||
call assert_equal('D', li[1]['text'])
|
call assert_equal('D', li[1]['text'])
|
||||||
call assert_equal('E', li[2]['text'])
|
call assert_equal('E', li[2]['text'])
|
||||||
exec "silent! " . Xolder
|
silent! Xolder
|
||||||
let li = Xgetlist()
|
let li = g:Xgetlist()
|
||||||
call assert_equal(2, len(li))
|
call assert_equal(2, len(li))
|
||||||
call assert_equal('A', li[0]['text'])
|
call assert_equal('A', li[0]['text'])
|
||||||
call assert_equal('B', li[1]['text'])
|
call assert_equal('B', li[1]['text'])
|
||||||
|
|
||||||
" {action} is specified ' '.
|
" {action} is specified ' '.
|
||||||
new | only
|
new | only
|
||||||
exec "silent! " . Xnewer . "99"
|
silent! Xnewer 99
|
||||||
call Xsetlist(list1)
|
call g:Xsetlist(list1)
|
||||||
call Xsetlist(list2, ' ')
|
call g:Xsetlist(list2, ' ')
|
||||||
let li = Xgetlist()
|
let li = g:Xgetlist()
|
||||||
call assert_equal(3, len(li))
|
call assert_equal(3, len(li))
|
||||||
call assert_equal('C', li[0]['text'])
|
call assert_equal('C', li[0]['text'])
|
||||||
call assert_equal('D', li[1]['text'])
|
call assert_equal('D', li[1]['text'])
|
||||||
call assert_equal('E', li[2]['text'])
|
call assert_equal('E', li[2]['text'])
|
||||||
exec "silent! " . Xolder
|
silent! Xolder
|
||||||
let li = Xgetlist()
|
let li = g:Xgetlist()
|
||||||
call assert_equal(2, len(li))
|
call assert_equal(2, len(li))
|
||||||
call assert_equal('A', li[0]['text'])
|
call assert_equal('A', li[0]['text'])
|
||||||
call assert_equal('B', li[1]['text'])
|
call assert_equal('B', li[1]['text'])
|
||||||
|
|
||||||
" {action} is specified 'a'.
|
" {action} is specified 'a'.
|
||||||
new | only
|
new | only
|
||||||
exec "silent! " . Xnewer . "99"
|
silent! Xnewer 99
|
||||||
call Xsetlist(list1)
|
call g:Xsetlist(list1)
|
||||||
call Xsetlist(list2, 'a')
|
call g:Xsetlist(list2, 'a')
|
||||||
let li = Xgetlist()
|
let li = g:Xgetlist()
|
||||||
call assert_equal(5, len(li))
|
call assert_equal(5, len(li))
|
||||||
call assert_equal('A', li[0]['text'])
|
call assert_equal('A', li[0]['text'])
|
||||||
call assert_equal('B', li[1]['text'])
|
call assert_equal('B', li[1]['text'])
|
||||||
@ -925,10 +926,10 @@ function! XquickfixSetListWithAct(cchar)
|
|||||||
|
|
||||||
" {action} is specified 'r'.
|
" {action} is specified 'r'.
|
||||||
new | only
|
new | only
|
||||||
exec "silent! " . Xnewer . "99"
|
silent! Xnewer 99
|
||||||
call Xsetlist(list1)
|
call g:Xsetlist(list1)
|
||||||
call Xsetlist(list2, 'r')
|
call g:Xsetlist(list2, 'r')
|
||||||
let li = Xgetlist()
|
let li = g:Xgetlist()
|
||||||
call assert_equal(3, len(li))
|
call assert_equal(3, len(li))
|
||||||
call assert_equal('C', li[0]['text'])
|
call assert_equal('C', li[0]['text'])
|
||||||
call assert_equal('D', li[1]['text'])
|
call assert_equal('D', li[1]['text'])
|
||||||
@ -936,11 +937,11 @@ function! XquickfixSetListWithAct(cchar)
|
|||||||
|
|
||||||
" Test for wrong value.
|
" Test for wrong value.
|
||||||
new | only
|
new | only
|
||||||
call assert_fails("call Xsetlist(0)", 'E714:')
|
call assert_fails("call g:Xsetlist(0)", 'E714:')
|
||||||
call assert_fails("call Xsetlist(list1, '')", 'E927:')
|
call assert_fails("call g:Xsetlist(list1, '')", 'E927:')
|
||||||
call assert_fails("call Xsetlist(list1, 'aa')", 'E927:')
|
call assert_fails("call g:Xsetlist(list1, 'aa')", 'E927:')
|
||||||
call assert_fails("call Xsetlist(list1, ' a')", 'E927:')
|
call assert_fails("call g:Xsetlist(list1, ' a')", 'E927:')
|
||||||
call assert_fails("call Xsetlist(list1, 0)", 'E928:')
|
call assert_fails("call g:Xsetlist(list1, 0)", 'E928:')
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
function Test_quickfix_set_list_with_act()
|
function Test_quickfix_set_list_with_act()
|
||||||
@ -948,8 +949,8 @@ function Test_quickfix_set_list_with_act()
|
|||||||
call XquickfixSetListWithAct('l')
|
call XquickfixSetListWithAct('l')
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
func XLongLinesTests()
|
function XLongLinesTests(cchar)
|
||||||
let l = getqflist()
|
let l = g:Xgetlist()
|
||||||
|
|
||||||
call assert_equal(3, len(l))
|
call assert_equal(3, len(l))
|
||||||
call assert_equal(1, l[0].lnum)
|
call assert_equal(1, l[0].lnum)
|
||||||
@ -962,25 +963,32 @@ func XLongLinesTests()
|
|||||||
call assert_equal(1, l[2].col)
|
call assert_equal(1, l[2].col)
|
||||||
call assert_equal(10, len(l[2].text))
|
call assert_equal(10, len(l[2].text))
|
||||||
|
|
||||||
call setqflist([], 'r')
|
call g:Xsetlist([], 'r')
|
||||||
endfunc
|
endfunction
|
||||||
|
|
||||||
|
function s:long_lines_tests(cchar)
|
||||||
|
call s:setup_commands(a:cchar)
|
||||||
|
|
||||||
func Test_long_lines()
|
|
||||||
let testfile = 'samples/quickfix.txt'
|
let testfile = 'samples/quickfix.txt'
|
||||||
|
|
||||||
" file
|
" file
|
||||||
exe 'cgetfile' testfile
|
exe 'Xgetfile' testfile
|
||||||
call XLongLinesTests()
|
call XLongLinesTests(a:cchar)
|
||||||
|
|
||||||
" list
|
" list
|
||||||
cexpr readfile(testfile)
|
Xexpr readfile(testfile)
|
||||||
call XLongLinesTests()
|
call XLongLinesTests(a:cchar)
|
||||||
|
|
||||||
" string
|
" string
|
||||||
cexpr join(readfile(testfile), "\n")
|
Xexpr join(readfile(testfile), "\n")
|
||||||
call XLongLinesTests()
|
call XLongLinesTests(a:cchar)
|
||||||
|
|
||||||
" buffer
|
" buffer
|
||||||
e testfile
|
exe 'edit' testfile
|
||||||
exe 'cbuffer' bufnr('%')
|
exe 'Xbuffer' bufnr('%')
|
||||||
endfunc
|
endfunction
|
||||||
|
|
||||||
|
function Test_long_lines()
|
||||||
|
call s:long_lines_tests('c')
|
||||||
|
call s:long_lines_tests('l')
|
||||||
|
endfunction
|
||||||
|
@ -499,7 +499,7 @@ static int included_patches[] = {
|
|||||||
// 1944 NA
|
// 1944 NA
|
||||||
// 1943 NA
|
// 1943 NA
|
||||||
// 1942 NA
|
// 1942 NA
|
||||||
// 1941,
|
1941,
|
||||||
// 1940,
|
// 1940,
|
||||||
// 1939 NA
|
// 1939 NA
|
||||||
// 1938 NA
|
// 1938 NA
|
||||||
|
Loading…
Reference in New Issue
Block a user