]> git.madduck.net Git - etc/vim.git/blob - .vim/bundle/ale/test/test_list_formatting.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:

Merge commit '76265755a1add77121c8f9dabb3e9bb70fe9a972' as '.vim/bundle/ale'
[etc/vim.git] / .vim / bundle / ale / test / test_list_formatting.vader
1 Before:
2   Save g:ale_set_loclist
3   Save g:ale_set_quickfix
4   Save g:ale_loclist_msg_format
5   Save g:ale_open_list
6   Save g:ale_buffer_info
7   Save g:ale_set_lists_synchronously
8
9   let g:ale_set_lists_synchronously = 1
10   let g:ale_loclist_msg_format = '%code: %%s'
11   let g:ale_open_list = 0
12   let g:loclist = []
13   let g:ale_buffer_info = {bufnr(''): {'loclist': g:loclist}}
14
15   function! AddItem(data) abort
16     let l:item = {
17     \ 'bufnr': bufnr(''),
18     \ 'lnum': 1,
19     \ 'col': 1,
20     \ 'type': 'E',
21     \ 'linter_name': 'some_linter',
22     \}
23
24     call add(g:loclist, extend(l:item, a:data))
25   endfunction
26
27 After:
28   Restore
29
30   unlet! g:loclist
31   unlet! b:ale_loclist_msg_format
32
33   delfunction AddItem
34
35   call setloclist(0, [])
36   call setqflist([])
37
38 Execute(Formatting with codes should work for the loclist):
39   call AddItem({'text': "nocode\r"})
40   call ale#list#SetLists(bufnr(''), g:loclist)
41
42   AssertEqual
43   \ [
44   \   {
45   \     'lnum': 1,
46   \     'bufnr': bufnr(''),
47   \     'col': 1,
48   \     'valid': 1,
49   \     'vcol': 0,
50   \     'nr': 0,
51   \     'type': 'E',
52   \     'pattern': '',
53   \     'text': 'nocode',
54   \   },
55   \ ],
56   \ ale#test#GetLoclistWithoutNewerKeys()
57
58   call remove(g:loclist, 0)
59   call AddItem({'text': 'withcode', 'code': 'E123'})
60   call ale#list#SetLists(bufnr(''), g:loclist)
61
62   AssertEqual
63   \ [
64   \   {
65   \     'lnum': 1,
66   \     'bufnr': bufnr(''),
67   \     'col': 1,
68   \     'valid': 1,
69   \     'vcol': 0,
70   \     'nr': 0,
71   \     'type': 'E',
72   \     'pattern': '',
73   \     'text': 'E123: withcode',
74   \   },
75   \ ],
76   \ ale#test#GetLoclistWithoutNewerKeys()
77
78 Execute(Formatting with codes should work for the quickfix list):
79   let g:ale_set_loclist = 0
80   let g:ale_set_quickfix = 1
81
82   call AddItem({'text': "nocode\r"})
83   call ale#list#SetLists(bufnr(''), g:loclist)
84
85   AssertEqual
86   \ [
87   \   {
88   \     'lnum': 1,
89   \     'bufnr': bufnr(''),
90   \     'col': 1,
91   \     'valid': 1,
92   \     'vcol': 0,
93   \     'nr': 0,
94   \     'type': 'E',
95   \     'pattern': '',
96   \     'text': 'nocode',
97   \   },
98   \ ],
99   \ ale#test#GetQflistWithoutNewerKeys()
100
101   call remove(g:loclist, 0)
102   call AddItem({'text': 'withcode', 'code': 'E123'})
103   call ale#list#SetLists(bufnr(''), g:loclist)
104
105   AssertEqual
106   \ [
107   \   {
108   \     'lnum': 1,
109   \     'bufnr': bufnr(''),
110   \     'col': 1,
111   \     'valid': 1,
112   \     'vcol': 0,
113   \     'nr': 0,
114   \     'type': 'E',
115   \     'pattern': '',
116   \     'text': 'E123: withcode',
117   \   },
118   \ ],
119   \ ale#test#GetQflistWithoutNewerKeys()
120
121 Execute(Formatting with the linter name should work for the loclist):
122   let g:ale_loclist_msg_format = '(%linter%) %s'
123
124   call AddItem({'text': 'whatever'})
125   call ale#list#SetLists(bufnr(''), g:loclist)
126
127   AssertEqual
128   \ [
129   \   {
130   \     'lnum': 1,
131   \     'bufnr': bufnr(''),
132   \     'col': 1,
133   \     'valid': 1,
134   \     'vcol': 0,
135   \     'nr': 0,
136   \     'type': 'E',
137   \     'pattern': '',
138   \     'text': '(some_linter) whatever',
139   \   },
140   \ ],
141   \ ale#test#GetLoclistWithoutNewerKeys()
142
143 Execute(Formatting with the linter name should work for the quickfix list):
144   let g:ale_loclist_msg_format = '(%linter%) %s'
145   let g:ale_set_loclist = 0
146   let g:ale_set_quickfix = 1
147
148   call AddItem({'text': 'whatever'})
149   call ale#list#SetLists(bufnr(''), g:loclist)
150
151   AssertEqual
152   \ [
153   \   {
154   \     'lnum': 1,
155   \     'bufnr': bufnr(''),
156   \     'col': 1,
157   \     'valid': 1,
158   \     'vcol': 0,
159   \     'nr': 0,
160   \     'type': 'E',
161   \     'pattern': '',
162   \     'text': '(some_linter) whatever',
163   \   },
164   \ ],
165   \ ale#test#GetQflistWithoutNewerKeys()
166
167 Execute(The buffer loclist format option should take precedence):
168   let g:ale_loclist_msg_format = '(%linter%) %s'
169   let b:ale_loclist_msg_format = 'FOO %s'
170
171   call AddItem({'text': 'whatever'})
172   call ale#list#SetLists(bufnr(''), g:loclist)
173
174   AssertEqual
175   \ [
176   \   {
177   \     'lnum': 1,
178   \     'bufnr': bufnr(''),
179   \     'col': 1,
180   \     'valid': 1,
181   \     'vcol': 0,
182   \     'nr': 0,
183   \     'type': 'E',
184   \     'pattern': '',
185   \     'text': 'FOO whatever',
186   \   },
187   \ ],
188   \ ale#test#GetLoclistWithoutNewerKeys()