summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/test_ale_toggle.vader16
-rw-r--r--test/test_autocmd_commands.vader187
2 files changed, 90 insertions, 113 deletions
diff --git a/test/test_ale_toggle.vader b/test/test_ale_toggle.vader
index 427000b6..cac762b4 100644
--- a/test/test_ale_toggle.vader
+++ b/test/test_ale_toggle.vader
@@ -32,12 +32,8 @@ Before:
\}]
let g:expected_groups = [
\ 'ALECleanupGroup',
- \ 'ALECursorGroup',
+ \ 'ALEEvents',
\ 'ALEHighlightBufferGroup',
- \ 'ALERunOnEnterGroup',
- \ 'ALERunOnFiletypeChangeGroup',
- \ 'ALERunOnSaveGroup',
- \ 'ALERunOnTextChangedGroup',
\]
function! ToggleTestCallback(buffer, output)
@@ -60,7 +56,7 @@ Before:
let l:results = []
for l:line in split(l:output, "\n")
- let l:match = matchlist(l:line, '^ALE[a-zA-Z]\+Group')
+ let l:match = matchlist(l:line, '^ALE[a-zA-Z]\+')
" We don't care about some groups here.
if !empty(l:match)
@@ -139,13 +135,7 @@ Execute(ALEToggle should reset everything and then run again):
AssertEqual [], getloclist(0), 'The loclist was not cleared'
AssertEqual [0, []], ale#sign#FindCurrentSigns(bufnr('%')), 'The signs were not cleared'
AssertEqual [], getmatches(), 'The highlights were not cleared'
- AssertEqual
- \ [
- \ 'ALECleanupGroup',
- \ 'ALEHighlightBufferGroup',
- \ 'ALERunOnSaveGroup',
- \ ],
- \ ParseAuGroups()
+ AssertEqual g:expected_groups, ParseAuGroups()
" Toggle ALE on, everything should be set up and run again.
ALEToggle
diff --git a/test/test_autocmd_commands.vader b/test/test_autocmd_commands.vader
index f82577f4..01646606 100644
--- a/test/test_autocmd_commands.vader
+++ b/test/test_autocmd_commands.vader
@@ -26,8 +26,9 @@ Before:
" for the one matching the current buffer.
if l:line =~# '<buffer=' . bufnr('') . '>'
let l:header .= ' <buffer>'
- else
+ elseif l:line[:0] is# ' '
call add(l:matches, join(split(l:header . l:line)))
+ else
let l:header = ''
endif
endif
@@ -38,16 +39,28 @@ Before:
return l:matches
endfunction
+ Save g:ale_completion_enabled
+ Save g:ale_echo_cursor
Save g:ale_enabled
- Save g:ale_lint_on_text_changed
- Save g:ale_lint_on_insert_leave
- Save g:ale_pattern_options_enabled
+ Save g:ale_fix_on_save
Save g:ale_lint_on_enter
Save g:ale_lint_on_filetype_changed
+ Save g:ale_lint_on_insert_leave
Save g:ale_lint_on_save
- Save g:ale_echo_cursor
- Save g:ale_fix_on_save
- Save g:ale_completion_enabled
+ Save g:ale_lint_on_text_changed
+ Save g:ale_pattern_options_enabled
+
+ " Turn everything on by defaul for these tests.
+ let g:ale_completion_enabled = 1
+ let g:ale_echo_cursor = 1
+ let g:ale_enabled = 1
+ let g:ale_fix_on_save = 1
+ let g:ale_lint_on_enter = 1
+ let g:ale_lint_on_filetype_changed = 1
+ let g:ale_lint_on_insert_leave = 1
+ let g:ale_lint_on_save = 1
+ let g:ale_lint_on_text_changed = 1
+ let g:ale_pattern_options_enabled = 1
After:
delfunction CheckAutocmd
@@ -61,98 +74,95 @@ After:
call ale#events#Init()
-Execute (g:ale_lint_on_text_changed = 0 should bind no events):
+Execute (All events should be set up when everything is on):
+ let g:ale_echo_cursor = 1
+
+ AssertEqual
+ \ [
+ \ 'BufEnter * call ale#pattern_options#SetOptions(str2nr(expand(''<abuf>'')))',
+ \ 'BufEnter call ale#events#EnterEvent(str2nr(expand(''<abuf>'')))',
+ \ 'BufReadPost * call ale#pattern_options#SetOptions(str2nr(expand(''<abuf>'')))',
+ \ 'BufReadPost call ale#Queue(0, ''lint_file'', str2nr(expand(''<abuf>'')))',
+ \ 'BufWinEnter * call ale#Queue(0, ''lint_file'', str2nr(expand(''<abuf>'')))',
+ \ 'BufWritePost * call ale#events#SaveEvent(str2nr(expand(''<abuf>'')))',
+ \ 'CursorHold * call ale#cursor#EchoCursorWarningWithDelay()',
+ \ 'CursorMoved * call ale#cursor#EchoCursorWarningWithDelay()',
+ \ 'FileChangedShellPost * call ale#events#FileChangedEvent(str2nr(expand(''<abuf>'')))',
+ \ 'FileType * call ale#events#FileTypeEvent( str2nr(expand(''<abuf>'')), expand(''<amatch>''))',
+ \ 'InsertLeave * call ale#Queue(0)',
+ \ 'InsertLeave call ale#cursor#EchoCursorWarning()',
+ \ 'TextChanged * call ale#Queue(g:ale_lint_delay)',
+ \ 'TextChangedI * call ale#Queue(g:ale_lint_delay)',
+ \ ],
+ \ CheckAutocmd('ALEEvents')
+
+Execute (Only the required events should be bound even if various settings are off):
+ let g:ale_completion_enabled = 0
+ let g:ale_echo_cursor = 0
+ let g:ale_enabled = 0
+ let g:ale_fix_on_save = 0
+ let g:ale_lint_on_enter = 0
+ let g:ale_lint_on_filetype_changed = 0
+ let g:ale_lint_on_insert_leave = 0
+ let g:ale_lint_on_save = 0
let g:ale_lint_on_text_changed = 0
+ let g:ale_pattern_options_enabled = 0
- AssertEqual [], CheckAutocmd('ALERunOnTextChangedGroup')
+ AssertEqual
+ \ [
+ \ 'BufEnter * call ale#pattern_options#SetOptions(str2nr(expand(''<abuf>'')))',
+ \ 'BufReadPost * call ale#pattern_options#SetOptions(str2nr(expand(''<abuf>'')))',
+ \ 'BufWritePost * call ale#events#SaveEvent(str2nr(expand(''<abuf>'')))',
+ \ ],
+ \ CheckAutocmd('ALEEvents')
Execute (g:ale_lint_on_text_changed = 1 bind both events):
let g:ale_lint_on_text_changed = 1
- AssertEqual [
- \ 'TextChanged * call ale#Queue(g:ale_lint_delay)',
- \ 'TextChangedI * call ale#Queue(g:ale_lint_delay)'
- \], CheckAutocmd('ALERunOnTextChangedGroup')
+ AssertEqual
+ \ [
+ \ 'TextChanged * call ale#Queue(g:ale_lint_delay)',
+ \ 'TextChangedI * call ale#Queue(g:ale_lint_delay)',
+ \ ],
+ \ filter(CheckAutocmd('ALEEvents'), 'v:val =~ ''^TextChanged''')
Execute (g:ale_lint_on_text_changed = 'always' should bind both events):
let g:ale_lint_on_text_changed = 'always'
- AssertEqual [
- \ 'TextChanged * call ale#Queue(g:ale_lint_delay)',
- \ 'TextChangedI * call ale#Queue(g:ale_lint_delay)'
- \], CheckAutocmd('ALERunOnTextChangedGroup')
+ AssertEqual
+ \ [
+ \ 'TextChanged * call ale#Queue(g:ale_lint_delay)',
+ \ 'TextChangedI * call ale#Queue(g:ale_lint_delay)',
+ \ ],
+ \ filter(CheckAutocmd('ALEEvents'), 'v:val =~ ''^TextChanged''')
Execute (g:ale_lint_on_text_changed = 'normal' should bind only TextChanged):
let g:ale_lint_on_text_changed = 'normal'
- AssertEqual [
- \ 'TextChanged * call ale#Queue(g:ale_lint_delay)',
- \], CheckAutocmd('ALERunOnTextChangedGroup')
+ AssertEqual
+ \ [
+ \ 'TextChanged * call ale#Queue(g:ale_lint_delay)',
+ \ ],
+ \ filter(CheckAutocmd('ALEEvents'), 'v:val =~ ''^TextChanged''')
Execute (g:ale_lint_on_text_changed = 'insert' should bind only TextChangedI):
let g:ale_lint_on_text_changed = 'insert'
- AssertEqual [
- \ 'TextChangedI * call ale#Queue(g:ale_lint_delay)',
- \], CheckAutocmd('ALERunOnTextChangedGroup')
+ AssertEqual
+ \ [
+ \ 'TextChangedI * call ale#Queue(g:ale_lint_delay)',
+ \ ],
+ \ filter(CheckAutocmd('ALEEvents'), 'v:val =~ ''^TextChanged''')
Execute (g:ale_lint_on_insert_leave = 1 should bind InsertLeave):
let g:ale_lint_on_insert_leave = 1
-
- AssertEqual [
- \ 'InsertLeave * call ale#Queue(0)',
- \], CheckAutocmd('ALERunOnInsertLeave')
-
-Execute (g:ale_lint_on_insert_leave = 0 should bind no events):
- let g:ale_lint_on_insert_leave = 0
-
- AssertEqual [], CheckAutocmd('ALERunOnInsertLeave')
-
-Execute (g:ale_pattern_options_enabled = 1 should bind BufReadPost and BufEnter):
- let g:ale_pattern_options_enabled = 1
-
- AssertEqual [
- \ 'BufEnter * call ale#pattern_options#SetOptions(str2nr(expand(''<abuf>'')))',
- \ 'BufReadPost * call ale#pattern_options#SetOptions(str2nr(expand(''<abuf>'')))',
- \], CheckAutocmd('ALEPatternOptionsGroup')
-
-Execute (g:ale_pattern_options_enabled = 0 should still bind events):
- let g:ale_pattern_options_enabled = 0
-
- AssertEqual [
- \ 'BufEnter * call ale#pattern_options#SetOptions(str2nr(expand(''<abuf>'')))',
- \ 'BufReadPost * call ale#pattern_options#SetOptions(str2nr(expand(''<abuf>'')))',
- \], CheckAutocmd('ALEPatternOptionsGroup')
-
-Execute (g:ale_enabled = 0 should still bind pattern events):
- let g:ale_enabled = 0
-
- AssertEqual [
- \ 'BufEnter * call ale#pattern_options#SetOptions(str2nr(expand(''<abuf>'')))',
- \ 'BufReadPost * call ale#pattern_options#SetOptions(str2nr(expand(''<abuf>'')))',
- \], CheckAutocmd('ALEPatternOptionsGroup')
-
-Execute (g:ale_lint_on_enter = 0 should bind only the BufEnter event):
- let g:ale_lint_on_enter = 0
+ let g:ale_echo_cursor = 0
AssertEqual
- \ ['BufEnter * call ale#events#EnterEvent(str2nr(expand(''<abuf>'')))'],
- \ CheckAutocmd('ALERunOnEnterGroup')
-
-Execute (g:ale_lint_on_enter = 1 should bind the required events):
- let g:ale_lint_on_enter = 1
-
- AssertEqual [
- \ 'BufEnter * call ale#events#EnterEvent(str2nr(expand(''<abuf>'')))',
- \ 'BufReadPost * call ale#Queue(0, ''lint_file'', str2nr(expand(''<abuf>'')))',
- \ 'BufWinEnter * call ale#Queue(0, ''lint_file'', str2nr(expand(''<abuf>'')))',
- \ 'FileChangedShellPost * call ale#events#FileChangedEvent(str2nr(expand(''<abuf>'')))',
- \], CheckAutocmd('ALERunOnEnterGroup')
-
-Execute (g:ale_lint_on_filetype_changed = 0 should bind no events):
- let g:ale_lint_on_filetype_changed = 0
-
- AssertEqual [], CheckAutocmd('ALERunOnFiletypeChangeGroup')
+ \ [
+ \ 'InsertLeave * call ale#Queue(0)',
+ \ ],
+ \ filter(CheckAutocmd('ALEEvents'), 'v:val =~ ''^InsertLeave''')
Execute (g:ale_lint_on_filetype_changed = 1 should bind the FileType event):
let g:ale_lint_on_filetype_changed = 1
@@ -164,30 +174,7 @@ Execute (g:ale_lint_on_filetype_changed = 1 should bind the FileType event):
\ . 'expand(''<amatch>'')'
\ . ')',
\ ],
- \ CheckAutocmd('ALERunOnFiletypeChangeGroup')
-
-Execute (The SaveEvent should always be bound):
- let g:ale_enabled = 0
- let g:ale_lint_on_save = 0
- let g:ale_fix_on_save = 0
-
- AssertEqual [
- \ 'BufWritePost * call ale#events#SaveEvent(str2nr(expand(''<abuf>'')))',
- \], CheckAutocmd('ALERunOnSaveGroup')
-
-Execute (g:ale_echo_cursor = 0 should bind no events):
- let g:ale_echo_cursor = 0
-
- AssertEqual [], CheckAutocmd('ALECursorGroup')
-
-Execute (g:ale_echo_cursor = 1 should bind cursor events):
- let g:ale_echo_cursor = 1
-
- AssertEqual [
- \ 'CursorHold * call ale#cursor#EchoCursorWarningWithDelay()',
- \ 'CursorMoved * call ale#cursor#EchoCursorWarningWithDelay()',
- \ 'InsertLeave * call ale#cursor#EchoCursorWarning()',
- \], CheckAutocmd('ALECursorGroup')
+ \ filter(CheckAutocmd('ALEEvents'), 'v:val =~ ''\v^FileType''')
Execute (ALECleanupGroup should include the right commands):
AssertEqual [