diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/test_ale_init_au_groups.vader | 15 | ||||
-rw-r--r-- | test/test_list_modification_error_cancelling.vader | 96 | ||||
-rw-r--r-- | test/test_set_list_timers.vader | 38 | ||||
-rw-r--r-- | test/test_statusline.vader | 10 | ||||
-rw-r--r-- | test/vimrc | 3 |
5 files changed, 46 insertions, 116 deletions
diff --git a/test/test_ale_init_au_groups.vader b/test/test_ale_init_au_groups.vader index 3606402f..2685f50b 100644 --- a/test/test_ale_init_au_groups.vader +++ b/test/test_ale_init_au_groups.vader @@ -60,11 +60,6 @@ After: call ALEInitAuGroups() - " Clean up the quickfix group. - augroup ALEQuickfixCursorMovedEvent - autocmd! * <buffer> - augroup END - Execute (g:ale_lint_on_text_changed = 0 should bind no events): let g:ale_lint_on_text_changed = 0 @@ -139,7 +134,6 @@ Execute (g:ale_lint_on_enter = 1 should bind the required events): \ '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>'')))', - \ 'BufWinLeave * call ale#events#BufWinLeave()', \ 'FileChangedShellPost * call ale#events#FileChangedEvent(str2nr(expand(''<abuf>'')))', \], CheckAutocmd('ALERunOnEnterGroup') @@ -222,12 +216,3 @@ Execute(Disabling completion should remove autocmd events correctly): AssertEqual [], CheckAutocmd('ALECompletionGroup') AssertEqual 0, g:ale_completion_enabled - -Execute(The cursor events should be set up for the quickfix list): - runtime! ftplugin/qf.vim - - AssertEqual - \ [ - \ 'CursorMoved <buffer> call ale#events#ParseLoclistWindowItemPosition()', - \ ], - \ CheckAutocmd('ALEQuickfixCursorMovedEvent') diff --git a/test/test_list_modification_error_cancelling.vader b/test/test_list_modification_error_cancelling.vader deleted file mode 100644 index e4aa3afa..00000000 --- a/test/test_list_modification_error_cancelling.vader +++ /dev/null @@ -1,96 +0,0 @@ -Before: - let b:fake_mode = 'r' - let b:feedkeys_calls = [] - - " Mock mode() and feedkeys() for the check - function! ale#util#Mode(...) abort - return b:fake_mode - endfunction - - function! ale#util#FeedKeys(...) abort - call add(b:feedkeys_calls, a:000) - endfunction - - function! CheckError(mode, message, expected_list) abort - let b:fake_mode = a:mode - - echom a:message - - call ale#events#BufWinLeave() - AssertEqual [], b:feedkeys_calls - - sleep 1ms - AssertEqual a:expected_list, b:feedkeys_calls - endfunction - -After: - unlet! b:fake_mode - unlet! b:feedkeys_calls - unlet! g:ale_list_window_selection - - delfunction CheckError - - runtime autoload/ale/util.vim - -Execute(The BufWinLeave event function should hide E924 errors): - " For some reason, this test fails the first time when running in NeoVim - " in Docker, so just execute this twice. - echom 'E924' - call ale#events#BufWinLeave() - sleep 1ms - let b:feedkeys_calls = [] - - call CheckError('r', 'E924', [["\<CR>", 'n']]) - -Execute(The BufWinLeave event function should hide E925 errors): - call CheckError('r', 'E925', [["\<CR>", 'n']]) - -Execute(The BufWinLeave event function should hide E926 errors): - call CheckError('r', 'E926', [["\<CR>", 'n']]) - -Execute(The BufWinLeave event function should ignore other errors): - call CheckError('r', 'E999', []) - -Execute(The BufWinLeave event function not send keys for other modes): - call CheckError('n', 'E924', []) - -Execute(The last window selection should always be cleared by the timer): - let g:ale_list_window_selection = [347, 2] - - " The message and mode shouldn't matter, we should still clear the variable. - echom 'xyz' - let b:fake_mode = 'n' - call ale#events#BufWinLeave() - sleep 1ms - - Assert !has_key(g:, 'ale_list_window_selection') - -Given qf(A quickfix list with some errors): - test.txt|23 col 9 warning| Some warning - test.txt|72 col 25 error| Some column error - test.txt|93 error| Some line error - -Execute(Line and column numbers should be parsed by the quickfix event function): - call setpos('.', [bufnr(''), 2, 1, 0]) - call ale#events#ParseLoclistWindowItemPosition() - AssertEqual [72, 25], g:ale_list_window_selection - -Execute(Just Line numbers should be parsed by the quickfix event function): - call setpos('.', [bufnr(''), 3, 1, 0]) - call ale#events#ParseLoclistWindowItemPosition() - AssertEqual [93, 1], g:ale_list_window_selection - -Given python(Some example Python file): - class FooBar: - def whatever(self): - self.do_something() - -Execute(We should jump to the window selection after cancelling the errors): - call setpos('.', [bufnr(''), 1, 1, 0]) - let g:ale_list_window_selection = [3, 9] - - echom 'E925' - call ale#events#BufWinLeave() - sleep 1ms - - AssertEqual [3, 9], getcurpos()[1:2] diff --git a/test/test_set_list_timers.vader b/test/test_set_list_timers.vader new file mode 100644 index 00000000..90aacb55 --- /dev/null +++ b/test/test_set_list_timers.vader @@ -0,0 +1,38 @@ +Before: + Save g:ale_set_lists_synchronously + Save g:ale_open_list + + let g:ale_set_lists_synchronously = 0 + +After: + Restore + + sleep 1ms + call setloclist(0, []) + lclose + +Execute(The SetLists function should work when run in a timer): + call ale#list#SetLists(bufnr(''), [ + \ {'bufnr': bufnr(''), 'lnum': 5, 'col': 5, 'text': 'x', 'type': 'E'}, + \]) + sleep 1ms + AssertEqual [{ + \ 'lnum': 5, + \ 'bufnr': bufnr(''), + \ 'col': 5, + \ 'text': 'x', + \ 'valid': 1, + \ 'vcol': 0, + \ 'nr': 0, + \ 'type': 'E', + \ 'pattern': '', + \}], getloclist(0) + +Execute(The CloseWindowIfNeeded function should work when run in a timer): + let g:ale_open_list = 1 + lopen + + call ale#list#CloseWindowIfNeeded(bufnr('')) + sleep 1ms + + Assert !ale#list#IsQuickfixOpen(), 'The window was not closed!' diff --git a/test/test_statusline.vader b/test/test_statusline.vader index c47df75a..7978a509 100644 --- a/test/test_statusline.vader +++ b/test/test_statusline.vader @@ -1,9 +1,11 @@ Before: - Save g:ale_statusline_format, g:ale_buffer_info + Save g:ale_statusline_format + Save g:ale_buffer_info + let g:ale_buffer_info = {} " A function for conveniently creating expected count objects. - function Counts(data) abort + function! Counts(data) abort let l:res = { \ '0': 0, \ '1': 0, @@ -28,6 +30,7 @@ Before: After: Restore + delfunction Counts Execute (Count should be 0 when data is empty): @@ -126,16 +129,13 @@ Execute (Status() should return the custom 'OK' string with the old format): AssertEqual 'OKIE', ale#statusline#Status() 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() @@ -1,5 +1,8 @@ " vint: -ProhibitSetNoCompatible +" Make most tests just set lists synchronously when run in Docker. +let g:ale_set_lists_synchronously = 1 + " Load builtin plugins " We need this because run_vim.sh sets -i NONE set runtimepath=/home/vim,$VIM/vimfiles,$VIMRUNTIME,$VIM/vimfiles/after,/testplugin,/vader |