ale/test/test_list_modification_error_cancelling.vader

97 lines
2.7 KiB
Plaintext
Raw Normal View History

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]