diff options
author | w0rp <devw0rp@gmail.com> | 2017-06-24 12:24:31 +0100 |
---|---|---|
committer | w0rp <devw0rp@gmail.com> | 2017-06-24 12:24:31 +0100 |
commit | 1ea61162a0c43da9a149b24dc35911cb981fbe7c (patch) | |
tree | a88621586401f17299cd85835f47a8a27d224296 /test/test_lint_on_enter_when_file_changed.vader | |
parent | fbf8ccb882eb7819011fa837ea2b4930ed4fa9c7 (diff) | |
download | ale-1ea61162a0c43da9a149b24dc35911cb981fbe7c.zip |
Fix #687 - Check files on enter if they have changed
Diffstat (limited to 'test/test_lint_on_enter_when_file_changed.vader')
-rw-r--r-- | test/test_lint_on_enter_when_file_changed.vader | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/test/test_lint_on_enter_when_file_changed.vader b/test/test_lint_on_enter_when_file_changed.vader new file mode 100644 index 00000000..ff4e7dd5 --- /dev/null +++ b/test/test_lint_on_enter_when_file_changed.vader @@ -0,0 +1,77 @@ +Before: + Save &filetype + Save g:ale_buffer_info + Save g:ale_lint_on_enter + let g:buf = bufnr('') + let g:ale_lint_on_enter = 1 + let g:ale_run_synchronously = 1 + + function! TestCallback(buffer, output) + return [{ + \ 'lnum': 1, + \ 'col': 3, + \ 'text': 'baz boz', + \}] + endfunction + + call ale#linter#Define('foobar', { + \ 'name': 'testlinter', + \ 'callback': 'TestCallback', + \ 'executable': 'true', + \ 'command': 'true', + \}) + +After: + Restore + unlet! g:buf + let g:ale_run_synchronously = 0 + delfunction TestCallback + call ale#linter#Reset() + call setloclist(0, []) + +Execute(The file changed event function should set b:ale_file_changed): + if has('gui') + new + else + e test + endif + + call ale#events#FileChangedEvent(g:buf) + close + + " We should set the flag in the other buffer + AssertEqual 1, getbufvar(g:buf, 'ale_file_changed') + +Execute(The file changed event function should lint the current buffer when it has changed): + set filetype=foobar + call ale#events#FileChangedEvent(bufnr('')) + + AssertEqual [{ + \ 'bufnr': bufnr(''), + \ 'lnum': 1, + \ 'vcol': 0, + \ 'col': 3, + \ 'text': 'baz boz', + \ 'type': 'E', + \ 'nr': -1, + \ 'pattern': '', + \ 'valid': 1, + \ }], getloclist(0) + +Execute(The buffer should be checked after entering it after the file has changed): + let b:ale_file_changed = 1 + + set filetype=foobar + call ale#events#EnterEvent() + + AssertEqual [{ + \ 'bufnr': bufnr(''), + \ 'lnum': 1, + \ 'vcol': 0, + \ 'col': 3, + \ 'text': 'baz boz', + \ 'type': 'E', + \ 'nr': -1, + \ 'pattern': '', + \ 'valid': 1, + \ }], getloclist(0) |