ale/test/test_ale_statusline.vader
Bjorn Neergaard f49f615ef6
Add support for dot-seperate linters, improve linter tests
This PR first and formost implements support for dot-seperate filetypes,
a very trivial change.

This closes #132

But more importantly, this PR vastly improves the test quality for
`ale#linter#Get`. It enables us to reset the state of ale's internal
linter cache, to facilitate better testing, as well as making use of
mocked linters instead of depending on linters on disk (which may
change). In addition, a dummy linter is defined to test the autoloading
behavior.

Header guards were removed from all linters as:

* A: ale won't try and load linters if they already exist in memory
* B: we can't reset state for testing if they can't be loaded again
2016-10-21 21:02:20 -05:00

66 lines
1.9 KiB
Plaintext

Before:
let g:ale_buffer_loclist_map = {}
After:
let g:ale_buffer_loclist_map = {}
Execute (Count should be 0 when data is empty):
AssertEqual [0, 0], ale#statusline#Count(bufnr('%'))
Before:
let g:ale_buffer_count_map = {'44': [1, 2]}
After:
let g:ale_buffer_loclist_map = {}
Execute (Count should read data from the cache):
AssertEqual [1, 2], ale#statusline#Count(44)
Execute (Update the cache with new data):
call ale#statusline#Update(44, [])
Then (The cache should reflect the new data):
AssertEqual [0, 0], ale#statusline#Count(44)
Before:
let g:ale_buffer_loclist_map = {'1': [{'lnum': 1, 'bufnr': 1, 'vcol': 0, 'linter_name': 'testlinter', 'nr': -1, 'type': 'E', 'col': 1, 'text': 'Test Error'}]}
After:
let g:ale_buffer_loclist_map = {}
Execute (Count should be match the loclist):
AssertEqual [1, 0], ale#statusline#Count(1)
Execute (Output should be empty for non-existant buffer):
AssertEqual [0, 0], ale#statusline#Count(9001)
Before:
let g:ale_statusline_format = ['%sE', '%sW', 'OKIE']
After:
let g:ale_buffer_loclist_map = {}
Execute (Given some errors):
call ale#statusline#Update(bufnr('%'), [{'type': 'E'}, {'type': 'E'}])
Then (Statusline is formatted to the users preference):
AssertEqual '2E', ale#statusline#Status()
Execute (Given some warnings):
call ale#statusline#Update(bufnr('%'), [{'type': 'W'}, {'type': 'W'}, {'type': 'W'}])
Then (Statusline is formatted to the users preference):
AssertEqual '3W', ale#statusline#Status()
Execute (Given some warnings, and errors):
call ale#statusline#Update(bufnr('%'), [{'type': 'E'}, {'type': 'W'}, {'type': 'W'}])
Then (Statusline is formatted to the users preference):
AssertEqual '1E 2W', ale#statusline#Status()
Execute (Given a lack of data):
call ale#statusline#Update(bufnr('%'), [])
Then (Statusline is formatted to the users preference):
AssertEqual 'OKIE', ale#statusline#Status()