ale/test/test_list_opening.vader

151 lines
4.2 KiB
Plaintext
Raw Normal View History

2017-01-22 13:33:16 +00:00
" Author: Yann Fery <yann@fery.me>
Before:
Save g:ale_set_loclist
Save g:ale_set_quickfix
Save g:ale_open_list
Save g:ale_keep_list_window_open
Save g:ale_list_window_size
let g:ale_set_loclist = 1
let g:ale_set_quickfix = 0
let g:ale_open_list = 0
let g:ale_keep_list_window_open = 0
let g:ale_list_window_size = 10
2017-01-22 13:33:16 +00:00
let g:loclist = [
\ {'lnum': 5, 'col': 5},
\ {'lnum': 5, 'col': 4},
\ {'lnum': 2, 'col': 10},
\ {'lnum': 3, 'col': 2},
\]
function GetQuickfixHeight() abort
for l:win in range(1, winnr('$'))
if getwinvar(l:win, '&buftype') ==# 'quickfix'
return winheight(l:win)
endif
endfor
return 0
endfunction
2017-01-22 13:33:16 +00:00
After:
Restore
unlet! g:loclist
unlet! b:ale_list_window_size
delfunction GetQuickfixHeight
2017-01-22 13:33:16 +00:00
" Close quickfix window after every execute block
lcl
ccl
call setloclist(0, [])
call setqflist([])
Execute(IsQuickfixOpen should return the right output):
AssertEqual 0, ale#list#IsQuickfixOpen()
call setloclist(0, g:loclist)
lopen
AssertEqual 1, ale#list#IsQuickfixOpen()
lcl
AssertEqual 0, ale#list#IsQuickfixOpen()
call setqflist(g:loclist)
copen
AssertEqual 1, ale#list#IsQuickfixOpen()
ccl
AssertEqual 0, ale#list#IsQuickfixOpen()
Execute(The quickfix window should not open by default for the loclist):
call ale#list#SetLists(bufnr('%'), g:loclist)
2017-01-22 13:33:16 +00:00
Assert !ale#list#IsQuickfixOpen()
Execute(The quickfix window should open for just the loclist):
let g:ale_open_list = 1
" It should not open for an empty list.
call ale#list#SetLists(bufnr('%'), [])
2017-01-22 13:33:16 +00:00
Assert !ale#list#IsQuickfixOpen()
" With a non-empty loclist, the window must open.
call ale#list#SetLists(bufnr('%'), g:loclist)
2017-01-22 13:33:16 +00:00
Assert ale#list#IsQuickfixOpen()
" Clear the list and it should close again.
call ale#list#SetLists(bufnr('%'), [])
Assert !ale#list#IsQuickfixOpen()
Execute(The quickfix window height should be correct for the loclist):
let g:ale_open_list = 1
let g:ale_list_window_size = 7
call ale#list#SetLists(bufnr('%'), g:loclist)
AssertEqual 7, GetQuickfixHeight()
Execute(The quickfix window height should be correct for the loclist with buffer variables):
let g:ale_open_list = 1
let b:ale_list_window_size = 8
call ale#list#SetLists(bufnr('%'), g:loclist)
AssertEqual 8, GetQuickfixHeight()
2017-01-22 13:33:16 +00:00
Execute(The quickfix window should stay open for just the loclist):
let g:ale_open_list = 1
let g:ale_keep_list_window_open = 1
" The window should stay open after even after it is made blank again.
call ale#list#SetLists(bufnr('%'), g:loclist)
call ale#list#SetLists(bufnr('%'), [])
2017-01-22 13:33:16 +00:00
Assert ale#list#IsQuickfixOpen()
Execute(The quickfix window should not open by default when quickfix is on):
let g:ale_set_quickfix = 1
call ale#list#SetLists(bufnr('%'), g:loclist)
2017-01-22 13:33:16 +00:00
Assert !ale#list#IsQuickfixOpen()
Execute(The quickfix window should open for the quickfix list):
let g:ale_set_quickfix = 1
let g:ale_open_list = 1
" It should not open for an empty list.
call ale#list#SetLists(bufnr('%'), [])
2017-01-22 13:33:16 +00:00
Assert !ale#list#IsQuickfixOpen()
" With a non-empty quickfix list, the window must open.
call ale#list#SetLists(bufnr('%'), g:loclist)
2017-01-22 13:33:16 +00:00
Assert ale#list#IsQuickfixOpen()
" Clear the list and it should close again.
call ale#list#SetLists(bufnr('%'), [])
Assert !ale#list#IsQuickfixOpen()
2017-01-22 13:33:16 +00:00
Execute(The quickfix window should stay open for the quickfix list):
let g:ale_set_quickfix = 1
let g:ale_open_list = 1
let g:ale_keep_list_window_open = 1
" The window should stay open after even after it is made blank again.
call ale#list#SetLists(bufnr('%'), g:loclist)
call ale#list#SetLists(bufnr('%'), [])
2017-01-22 13:33:16 +00:00
Assert ale#list#IsQuickfixOpen()
Execute(The quickfix window height should be correct for the quickfix list):
let g:ale_set_quickfix = 1
let g:ale_open_list = 1
let g:ale_list_window_size = 7
call ale#list#SetLists(bufnr('%'), g:loclist)
AssertEqual 7, GetQuickfixHeight()
Execute(The quickfix window height should be correct for the quickfix list with buffer variables):
let g:ale_set_quickfix = 1
let g:ale_open_list = 1
let b:ale_list_window_size = 8
call ale#list#SetLists(bufnr('%'), g:loclist)
AssertEqual 8, GetQuickfixHeight()