summaryrefslogtreecommitdiff
path: root/test/test_ale_toggle.vader
diff options
context:
space:
mode:
Diffstat (limited to 'test/test_ale_toggle.vader')
-rw-r--r--test/test_ale_toggle.vader66
1 files changed, 61 insertions, 5 deletions
diff --git a/test/test_ale_toggle.vader b/test/test_ale_toggle.vader
index 202d8a35..f5d8599f 100644
--- a/test/test_ale_toggle.vader
+++ b/test/test_ale_toggle.vader
@@ -1,4 +1,12 @@
Before:
+ Save g:ale_buffer_info
+ Save g:ale_set_signs
+ Save g:ale_set_lists_synchronously
+
+ let g:ale_set_signs = 1
+ let g:ale_set_lists_synchronously = 1
+
+ let g:ale_buffer_info = {}
let g:expected_loclist = [{
\ 'bufnr': bufnr('%'),
\ 'lnum': 2,
@@ -42,10 +50,11 @@ Before:
for l:line in split(l:output, "\n")
let l:match = matchlist(l:line, '^ALE[a-zA-Z]\+Group')
- " We don't care about checking for the completion or fixing groups here.
+ " We don't care about some groups here.
if !empty(l:match)
\&& l:match[0] !=# 'ALECompletionGroup'
\&& l:match[0] !=# 'ALEBufferFixGroup'
+ \&& l:match[0] !=# 'ALEPatternOptionsGroup'
call add(l:results, l:match[0])
endif
endfor
@@ -63,11 +72,14 @@ Before:
\ 'read_buffer': 0,
\})
+ sign unplace *
+
After:
+ Restore
+
unlet! g:expected_loclist
unlet! g:expected_groups
- let g:ale_buffer_info = {}
call ale#linter#Reset()
" Toggle ALE back on if we fail when it's disabled.
@@ -91,7 +103,7 @@ Execute(ALEToggle should reset everything and then run again):
" First check that everything is there...
AssertEqual g:expected_loclist, getloclist(0)
- AssertEqual [[2, 1000001, 'ALEErrorSign']], ale#sign#FindCurrentSigns(bufnr('%'))
+ AssertEqual [0, [[2, 1000001, 'ALEErrorSign']]], ale#sign#FindCurrentSigns(bufnr('%'))
AssertEqual
\ [{'group': 'ALEError', 'pos1': [2, 3, 1]}],
\ map(getmatches(), '{''group'': v:val.group, ''pos1'': v:val.pos1}')
@@ -104,7 +116,7 @@ Execute(ALEToggle should reset everything and then run again):
" Everything should be cleared.
Assert !has_key(g:ale_buffer_info, bufnr('')), 'The g:ale_buffer_info Dictionary was not removed'
AssertEqual [], getloclist(0), 'The loclist was not cleared'
- AssertEqual [], ale#sign#FindCurrentSigns(bufnr('%')), 'The signs were not cleared'
+ AssertEqual [0, []], ale#sign#FindCurrentSigns(bufnr('%')), 'The signs were not cleared'
AssertEqual [], getmatches(), 'The highlights were not cleared'
AssertEqual ['ALECleanupGroup', 'ALEHighlightBufferGroup'], ParseAuGroups()
@@ -113,9 +125,53 @@ Execute(ALEToggle should reset everything and then run again):
call ale#engine#WaitForJobs(2000)
AssertEqual g:expected_loclist, getloclist(0)
- AssertEqual [[2, 1000001, 'ALEErrorSign']], ale#sign#FindCurrentSigns(bufnr('%'))
+ AssertEqual [0, [[2, 1000001, 'ALEErrorSign']]], ale#sign#FindCurrentSigns(bufnr('%'))
AssertEqual
\ [{'group': 'ALEError', 'pos1': [2, 3, 1]}],
\ map(getmatches(), '{''group'': v:val.group, ''pos1'': v:val.pos1}')
AssertEqual g:expected_groups, ParseAuGroups()
AssertEqual [{'lnum': 2, 'bufnr': bufnr(''), 'col': 3, 'linter_name': 'testlinter', 'vcol': 0, 'nr': -1, 'type': 'E', 'text': 'foo bar', 'sign_id': 1000001}], g:ale_buffer_info[bufnr('')].loclist
+
+Execute(ALEToggle should skip filename keys and preserve them):
+ AssertEqual 'foobar', &filetype
+
+ let g:ale_buffer_info['/foo/bar/baz.txt'] = {
+ \ 'job_list': [],
+ \ 'active_linter_list': [],
+ \ 'loclist': [],
+ \ 'temporary_file_list': [],
+ \ 'temporary_directory_list': [],
+ \ 'history': [],
+ \}
+
+ call ale#Lint()
+ call ale#engine#WaitForJobs(2000)
+
+ " Now Toggle ALE off.
+ ALEToggle
+
+ AssertEqual
+ \ {
+ \ 'job_list': [],
+ \ 'active_linter_list': [],
+ \ 'loclist': [],
+ \ 'temporary_file_list': [],
+ \ 'temporary_directory_list': [],
+ \ 'history': [],
+ \ },
+ \ get(g:ale_buffer_info, '/foo/bar/baz.txt', {})
+
+ " Toggle ALE on again.
+ ALEToggle
+ call ale#engine#WaitForJobs(2000)
+
+ AssertEqual
+ \ {
+ \ 'job_list': [],
+ \ 'active_linter_list': [],
+ \ 'loclist': [],
+ \ 'temporary_file_list': [],
+ \ 'temporary_directory_list': [],
+ \ 'history': [],
+ \ },
+ \ get(g:ale_buffer_info, '/foo/bar/baz.txt', {})