]> git.madduck.net Git - etc/vim.git/blob - test/test_lint_on_enter_when_file_changed.vader

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

Squashed '.vim/bundle/ale/' content from commit 22185c4c
[etc/vim.git] / test / test_lint_on_enter_when_file_changed.vader
1 Before:
2   Save &filetype
3   Save g:ale_buffer_info
4   Save g:ale_lint_on_enter
5   Save g:ale_set_lists_synchronously
6
7   let g:buf = bufnr('')
8   let g:ale_lint_on_enter = 1
9   let g:ale_run_synchronously = 1
10   let g:ale_set_lists_synchronously = 1
11
12   function! TestCallback(buffer, output)
13     return [{
14     \ 'lnum': 1,
15     \ 'col': 3,
16     \ 'text': 'baz boz',
17     \}]
18   endfunction
19
20   call ale#linter#Define('foobar', {
21   \ 'name': 'testlinter',
22   \ 'callback': 'TestCallback',
23   \ 'executable': has('win32') ? 'cmd' : 'true',
24   \ 'command': has('win32') ? 'echo' : 'true',
25   \})
26
27 After:
28   Restore
29   unlet! g:buf
30   let g:ale_run_synchronously = 0
31   delfunction TestCallback
32   call ale#linter#Reset()
33   call setloclist(0, [])
34
35 Execute(The file changed event function should set b:ale_file_changed):
36   let g:ale_lint_on_enter = 0
37
38   if has('gui_running')
39     new
40   else
41     e test
42   endif
43
44   call ale#events#FileChangedEvent(g:buf)
45   close
46
47   " We should set the flag in the other buffer
48   AssertEqual 1, getbufvar(g:buf, 'ale_file_changed')
49
50 Execute(The file changed event function should lint the current buffer when it has changed):
51   set filetype=foobar
52   call ale#events#FileChangedEvent(bufnr(''))
53   call ale#test#FlushJobs()
54
55   AssertEqual [{
56   \   'bufnr': bufnr(''),
57   \   'lnum': 1,
58   \   'vcol': 0,
59   \   'col': 3,
60   \   'text': 'baz boz',
61   \   'type': 'E',
62   \   'nr': -1,
63   \   'pattern': '',
64   \   'valid': 1,
65   \ }], ale#test#GetLoclistWithoutNewerKeys()
66
67 Execute(The buffer should be checked after entering it after the file has changed):
68   let b:ale_file_changed = 1
69
70   set filetype=foobar
71   call ale#events#ReadOrEnterEvent(bufnr(''))
72   call ale#test#FlushJobs()
73
74   AssertEqual [{
75   \   'bufnr': bufnr(''),
76   \   'lnum': 1,
77   \   'vcol': 0,
78   \   'col': 3,
79   \   'text': 'baz boz',
80   \   'type': 'E',
81   \   'nr': -1,
82   \   'pattern': '',
83   \   'valid': 1,
84   \ }], ale#test#GetLoclistWithoutNewerKeys()