summaryrefslogtreecommitdiff
path: root/test/test_ale_init_au_groups.vader
diff options
context:
space:
mode:
authorw0rp <devw0rp@gmail.com>2017-04-03 19:04:02 +0100
committerw0rp <devw0rp@gmail.com>2017-04-03 19:04:02 +0100
commitb7c79974bbbb3bf4261fe5ea10f629e44c8534eb (patch)
tree3b7ac36e0acf46deb90bbd5cc010ac938e83c51e /test/test_ale_init_au_groups.vader
parent927ee79026cffd50d888aa1edbe277d98d262a43 (diff)
downloadale-b7c79974bbbb3bf4261fe5ea10f629e44c8534eb.zip
#446 Fix g:ale_lint_on_text_changed compatibility issues
Diffstat (limited to 'test/test_ale_init_au_groups.vader')
-rw-r--r--test/test_ale_init_au_groups.vader84
1 files changed, 37 insertions, 47 deletions
diff --git a/test/test_ale_init_au_groups.vader b/test/test_ale_init_au_groups.vader
index bcefabe1..05d7888d 100644
--- a/test/test_ale_init_au_groups.vader
+++ b/test/test_ale_init_au_groups.vader
@@ -1,66 +1,56 @@
Before:
+ function! CheckAutocmd(group)
+ call ALEInitAuGroups()
+ redir => l:output
+ execute 'silent autocmd ' . a:group
+ redir END
+
+ return map(
+ \ filter(split(l:output, "\n"), 'v:val =~# ''^ALE'''),
+ \ 'split(v:val)[1]'
+ \)
+ endfunction
+
Save g:ale_lint_on_text_changed
Save g:ale_lint_on_insert_leave
- autocmd!
After:
- Restore g:ale_lint_on_text_changed
- Restore g:ale_lint_on_insert_leave
- unlet! g:output
- unlet! g:expected_autocmd
- autocmd!
-
-Execute (ALE should bind to TextChanged events when g:ale_lint_on_text_changed = 1):
- let g:expected_autocmd = join([
- \ '',
- \ '--- Auto-Commands ---',
- \ 'ALERunOnTextChangedGroup TextChanged',
- \ ' * call ale#Queue(g:ale_lint_delay)',
- \ 'ALERunOnTextChangedGroup TextChangedI',
- \ ' * call ale#Queue(g:ale_lint_delay)',
- \], "\n")
+ delfunction CheckAutocmd
+ Restore
- let g:ale_lint_on_text_changed = 1
call ALEInitAuGroups()
- redir => g:output
- autocmd ALERunOnTextChangedGroup TextChanged,TextChangedI *
- redir END
+Execute (g:ale_lint_on_text_changed = 0 should bind no events):
+ let g:ale_lint_on_text_changed = 0
- AssertEqual g:expected_autocmd, g:output
+ AssertEqual [], CheckAutocmd('ALERunOnTextChangedGroup')
-Execute (ALE should bind to TextChanged events when g:ale_lint_on_text_changed = 'always'):
- let g:expected_autocmd = join([
- \ '',
- \ '--- Auto-Commands ---',
- \ 'ALERunOnTextChangedGroup TextChanged',
- \ ' * call ale#Queue(g:ale_lint_delay)',
- \ 'ALERunOnTextChangedGroup TextChangedI',
- \ ' * call ale#Queue(g:ale_lint_delay)',
- \], "\n")
+Execute (g:ale_lint_on_text_changed = 1 bind both events):
+ let g:ale_lint_on_text_changed = 1
+ AssertEqual ['TextChanged', 'TextChangedI'], CheckAutocmd('ALERunOnTextChangedGroup')
+
+Execute (g:ale_lint_on_text_changed = 'always' should bind both events):
let g:ale_lint_on_text_changed = 'always'
- call ALEInitAuGroups()
- redir => g:output
- autocmd ALERunOnTextChangedGroup TextChanged,TextChangedI *
- redir END
+ AssertEqual ['TextChanged', 'TextChangedI'], CheckAutocmd('ALERunOnTextChangedGroup')
- AssertEqual g:expected_autocmd, g:output
+Execute (g:ale_lint_on_text_changed = 'normal' should bind only TextChanged):
+ let g:ale_lint_on_text_changed = 'normal'
-Execute (ALE should bind to InsertLeave event when g:ale_lint_on_insert_leave = 1):
- let g:expected_autocmd = join([
- \ "",
- \ "--- Auto-Commands ---",
- \ "ALERunOnInsertLeave InsertLeave",
- \ " * call ale#Queue(0, 'lint_file')",
- \], "\n")
+ AssertEqual ['TextChanged'], CheckAutocmd('ALERunOnTextChangedGroup')
+Execute (g:ale_lint_on_text_changed = 'insert' should bind only TextChangedI):
+ let g:ale_lint_on_text_changed = 'insert'
+
+ AssertEqual ['TextChangedI'], CheckAutocmd('ALERunOnTextChangedGroup')
+
+Execute (g:ale_lint_on_insert_leave = 1 should bind InsertLeave):
let g:ale_lint_on_insert_leave = 1
- call ALEInitAuGroups()
- redir => g:output
- autocmd ALERunOnInsertLeave InsertLeave *
- redir END
+ AssertEqual ['InsertLeave'], CheckAutocmd('ALERunOnInsertLeave')
+
+Execute (g:ale_lint_on_insert_leave = 0 should bind no events):
+ let g:ale_lint_on_insert_leave = 0
- AssertEqual g:expected_autocmd, g:output
+ AssertEqual [], CheckAutocmd('ALERunOnInsertLeave')