2016-10-13 09:50:57 -04:00
|
|
|
Before:
|
2017-05-21 10:37:45 -04:00
|
|
|
Save g:ale_statusline_format, g:ale_buffer_info
|
|
|
|
let g:ale_buffer_info = {}
|
|
|
|
|
|
|
|
" A function for conveniently creating expected count objects.
|
|
|
|
function Counts(data) abort
|
|
|
|
let l:res = {
|
|
|
|
\ '0': 0,
|
|
|
|
\ '1': 0,
|
|
|
|
\ 'error': 0,
|
|
|
|
\ 'warning': 0,
|
|
|
|
\ 'info': 0,
|
|
|
|
\ 'style_error': 0,
|
|
|
|
\ 'style_warning': 0,
|
|
|
|
\ 'total': 0,
|
|
|
|
\}
|
|
|
|
|
|
|
|
for l:key in keys(a:data)
|
|
|
|
let l:res[l:key] = a:data[l:key]
|
|
|
|
endfor
|
|
|
|
|
|
|
|
let l:res[0] = l:res.error + l:res.style_error
|
|
|
|
let l:res[1] = l:res.warning + l:res.style_warning + l:res.info
|
|
|
|
let l:res.total = l:res[0] + l:res[1]
|
|
|
|
|
|
|
|
return l:res
|
|
|
|
endfunction
|
2016-10-23 17:41:00 -04:00
|
|
|
|
|
|
|
After:
|
2017-05-21 10:37:45 -04:00
|
|
|
Restore
|
|
|
|
delfunction Counts
|
2016-10-13 09:50:57 -04:00
|
|
|
|
|
|
|
Execute (Count should be 0 when data is empty):
|
2017-08-13 08:24:10 -04:00
|
|
|
AssertEqual Counts({}), ale#statusline#Count(bufnr(''))
|
2016-10-13 09:50:57 -04:00
|
|
|
|
|
|
|
Execute (Count should read data from the cache):
|
2017-05-21 10:37:45 -04:00
|
|
|
let g:ale_buffer_info = {'44': {'count': Counts({'error': 1, 'warning': 2})}}
|
|
|
|
AssertEqual Counts({'error': 1, 'warning': 2}), ale#statusline#Count(44)
|
2016-10-13 09:50:57 -04:00
|
|
|
|
2016-10-23 17:41:00 -04:00
|
|
|
Execute (The count should be correct after an update):
|
|
|
|
let g:ale_buffer_info = {'44': {}}
|
2016-10-13 09:50:57 -04:00
|
|
|
call ale#statusline#Update(44, [])
|
2017-05-21 10:37:45 -04:00
|
|
|
AssertEqual Counts({}), ale#statusline#Count(44)
|
2016-10-13 09:50:57 -04:00
|
|
|
|
|
|
|
Execute (Count should be match the loclist):
|
2016-10-24 15:21:32 -04:00
|
|
|
let g:ale_buffer_info = {
|
2017-08-13 08:24:10 -04:00
|
|
|
\ bufnr(''): {
|
2016-10-24 15:21:32 -04:00
|
|
|
\ 'loclist': [
|
2017-08-13 08:24:10 -04:00
|
|
|
\ {'bufnr': bufnr('') - 1, 'type': 'E'},
|
|
|
|
\ {'bufnr': bufnr('') - 1, 'type': 'E', 'sub_type': 'style'},
|
|
|
|
\ {'bufnr': bufnr('') - 1, 'type': 'W'},
|
|
|
|
\ {'bufnr': bufnr('') - 1, 'type': 'W', 'sub_type': 'style'},
|
|
|
|
\ {'bufnr': bufnr('') - 1, 'type': 'I'},
|
|
|
|
\ {'bufnr': bufnr(''), 'type': 'E'},
|
|
|
|
\ {'bufnr': bufnr(''), 'type': 'E', 'sub_type': 'style'},
|
|
|
|
\ {'bufnr': bufnr(''), 'type': 'E', 'sub_type': 'style'},
|
|
|
|
\ {'bufnr': bufnr(''), 'type': 'W'},
|
|
|
|
\ {'bufnr': bufnr(''), 'type': 'W'},
|
|
|
|
\ {'bufnr': bufnr(''), 'type': 'W'},
|
|
|
|
\ {'bufnr': bufnr(''), 'type': 'W', 'sub_type': 'style'},
|
|
|
|
\ {'bufnr': bufnr(''), 'type': 'W', 'sub_type': 'style'},
|
|
|
|
\ {'bufnr': bufnr(''), 'type': 'W', 'sub_type': 'style'},
|
|
|
|
\ {'bufnr': bufnr(''), 'type': 'W', 'sub_type': 'style'},
|
|
|
|
\ {'bufnr': bufnr(''), 'type': 'I'},
|
|
|
|
\ {'bufnr': bufnr(''), 'type': 'I'},
|
|
|
|
\ {'bufnr': bufnr(''), 'type': 'I'},
|
|
|
|
\ {'bufnr': bufnr(''), 'type': 'I'},
|
|
|
|
\ {'bufnr': bufnr(''), 'type': 'I'},
|
|
|
|
\ {'bufnr': bufnr('') + 1, 'type': 'E'},
|
|
|
|
\ {'bufnr': bufnr('') + 1, 'type': 'E', 'sub_type': 'style'},
|
|
|
|
\ {'bufnr': bufnr('') + 1, 'type': 'W'},
|
|
|
|
\ {'bufnr': bufnr('') + 1, 'type': 'W', 'sub_type': 'style'},
|
|
|
|
\ {'bufnr': bufnr('') + 1, 'type': 'I'},
|
2016-10-24 15:21:32 -04:00
|
|
|
\ ],
|
|
|
|
\ },
|
|
|
|
\}
|
2017-05-21 13:58:26 -04:00
|
|
|
AssertEqual {
|
|
|
|
\ 'error': 1,
|
|
|
|
\ 'style_error': 2,
|
|
|
|
\ 'warning': 3,
|
|
|
|
\ 'style_warning': 4,
|
|
|
|
\ 'info': 5,
|
|
|
|
\ '0': 3,
|
|
|
|
\ '1': 12,
|
|
|
|
\ 'total': 15,
|
2017-08-13 08:24:10 -04:00
|
|
|
\}, ale#statusline#Count(bufnr(''))
|
2016-10-13 09:50:57 -04:00
|
|
|
|
|
|
|
Execute (Output should be empty for non-existant buffer):
|
2017-05-21 10:37:45 -04:00
|
|
|
AssertEqual Counts({}), ale#statusline#Count(9001)
|
2016-10-13 09:50:57 -04:00
|
|
|
|
2017-05-21 10:37:45 -04:00
|
|
|
Execute (Status() should return just errors for the old format):
|
|
|
|
let g:ale_statusline_format = ['%sE', '%sW', 'OKIE']
|
2017-08-13 08:24:10 -04:00
|
|
|
let g:ale_buffer_info = {bufnr(''): {}}
|
|
|
|
call ale#statusline#Update(bufnr(''), [
|
|
|
|
\ {'bufnr': bufnr(''), 'type': 'E'},
|
|
|
|
\ {'bufnr': bufnr(''), 'type': 'E', 'sub_type': 'style'},
|
2017-05-21 10:37:45 -04:00
|
|
|
\])
|
2016-10-14 15:34:21 -04:00
|
|
|
AssertEqual '2E', ale#statusline#Status()
|
2016-10-13 09:50:57 -04:00
|
|
|
|
2017-05-21 10:37:45 -04:00
|
|
|
Execute (Status() should return just warnings for the old format):
|
|
|
|
let g:ale_statusline_format = ['%sE', '%sW', 'OKIE']
|
2017-08-13 08:24:10 -04:00
|
|
|
let g:ale_buffer_info = {bufnr(''): {}}
|
|
|
|
call ale#statusline#Update(bufnr(''), [
|
|
|
|
\ {'bufnr': bufnr(''), 'type': 'W'},
|
|
|
|
\ {'bufnr': bufnr(''), 'type': 'W', 'sub_type': 'style'},
|
|
|
|
\ {'bufnr': bufnr(''), 'type': 'I'},
|
2017-05-21 10:37:45 -04:00
|
|
|
\])
|
2016-10-14 15:34:21 -04:00
|
|
|
AssertEqual '3W', ale#statusline#Status()
|
2016-10-13 09:50:57 -04:00
|
|
|
|
2017-05-21 10:37:45 -04:00
|
|
|
Execute (Status() should return errors and warnings for the old format):
|
|
|
|
let g:ale_statusline_format = ['%sE', '%sW', 'OKIE']
|
2017-08-13 08:24:10 -04:00
|
|
|
let g:ale_buffer_info = {bufnr(''): {}}
|
|
|
|
call ale#statusline#Update(bufnr(''), [
|
|
|
|
\ {'bufnr': bufnr(''), 'type': 'E'},
|
|
|
|
\ {'bufnr': bufnr(''), 'type': 'E', 'sub_type': 'style'},
|
|
|
|
\ {'bufnr': bufnr(''), 'type': 'W'},
|
|
|
|
\ {'bufnr': bufnr(''), 'type': 'W', 'sub_type': 'style'},
|
|
|
|
\ {'bufnr': bufnr(''), 'type': 'I'},
|
2017-05-21 10:37:45 -04:00
|
|
|
\])
|
|
|
|
AssertEqual '2E 3W', ale#statusline#Status()
|
2016-10-13 09:50:57 -04:00
|
|
|
|
2017-05-21 10:37:45 -04:00
|
|
|
Execute (Status() should return the custom 'OK' string with the old format):
|
|
|
|
let g:ale_statusline_format = ['%sE', '%sW', 'OKIE']
|
2017-08-13 08:24:10 -04:00
|
|
|
let g:ale_buffer_info = {bufnr(''): {}}
|
|
|
|
call ale#statusline#Update(bufnr(''), [])
|
2016-10-14 15:34:21 -04:00
|
|
|
AssertEqual 'OKIE', ale#statusline#Status()
|
2017-05-21 10:37:45 -04:00
|
|
|
|
|
|
|
Execute(ale#statusline#Update shouldn't blow up when globals are undefined):
|
|
|
|
unlet! g:ale_buffer_info
|
|
|
|
unlet! g:ale_statusline_format
|
|
|
|
call ale#statusline#Update(1, [])
|
|
|
|
|
|
|
|
Execute(ale#statusline#Count should return 0 counts when globals are undefined):
|
|
|
|
unlet! g:ale_buffer_info
|
|
|
|
unlet! g:ale_statusline_format
|
|
|
|
AssertEqual Counts({}), ale#statusline#Count(1)
|
|
|
|
|
|
|
|
Execute(ale#statusline#Status should return 'OK' when globals are undefined):
|
|
|
|
unlet! g:ale_buffer_info
|
|
|
|
unlet! g:ale_statusline_format
|
|
|
|
AssertEqual 'OK', ale#statusline#Status()
|