summaryrefslogtreecommitdiff
path: root/test/test_list_formatting.vader
diff options
context:
space:
mode:
authorw0rp <devw0rp@gmail.com>2017-11-14 10:28:36 +0000
committerw0rp <devw0rp@gmail.com>2017-11-14 10:28:36 +0000
commit16e7dc2371f908204e5191c0e9d55626352097af (patch)
tree04e40db20efea0cf135728c40f658306c9d87cf6 /test/test_list_formatting.vader
parentd8f9aef84a1271633cb4fc7ba7a063e4b922d56b (diff)
downloadale-16e7dc2371f908204e5191c0e9d55626352097af.zip
Fix #1069 Support formatting the loclist messages with g:ale_loclist_msg_format
Diffstat (limited to 'test/test_list_formatting.vader')
-rw-r--r--test/test_list_formatting.vader164
1 files changed, 164 insertions, 0 deletions
diff --git a/test/test_list_formatting.vader b/test/test_list_formatting.vader
new file mode 100644
index 00000000..6b494fc2
--- /dev/null
+++ b/test/test_list_formatting.vader
@@ -0,0 +1,164 @@
+Before:
+ Save g:ale_set_loclist
+ Save g:ale_set_quickfix
+ Save g:ale_loclist_msg_format
+ Save g:ale_open_list
+ Save g:ale_buffer_info
+ Save g:ale_set_lists_synchronously
+
+ let g:ale_set_lists_synchronously = 1
+ let g:ale_loclist_msg_format = '%code: %%s'
+ let g:ale_open_list = 0
+ let g:loclist = []
+ let g:ale_buffer_info = {bufnr(''): {'loclist': g:loclist}}
+
+ function! AddItem(data) abort
+ let l:item = {
+ \ 'bufnr': bufnr(''),
+ \ 'lnum': 1,
+ \ 'col': 1,
+ \ 'type': 'E',
+ \ 'linter_name': 'some_linter',
+ \}
+
+ call add(g:loclist, extend(l:item, a:data))
+ endfunction
+
+After:
+ Restore
+
+ unlet! g:loclist
+
+ delfunction AddItem
+
+ call setloclist(0, [])
+ call setqflist([])
+
+Execute(Formatting with codes should work for the loclist):
+ call AddItem({'text': 'nocode'})
+ call ale#list#SetLists(bufnr(''), g:loclist)
+
+ AssertEqual
+ \ [
+ \ {
+ \ 'lnum': 1,
+ \ 'bufnr': bufnr(''),
+ \ 'col': 1,
+ \ 'valid': 1,
+ \ 'vcol': 0,
+ \ 'nr': 0,
+ \ 'type': 'E',
+ \ 'pattern': '',
+ \ 'text': 'nocode',
+ \ },
+ \ ],
+ \ getloclist(0)
+
+ call remove(g:loclist, 0)
+ call AddItem({'text': 'withcode', 'code': 'E123'})
+ call ale#list#SetLists(bufnr(''), g:loclist)
+
+ AssertEqual
+ \ [
+ \ {
+ \ 'lnum': 1,
+ \ 'bufnr': bufnr(''),
+ \ 'col': 1,
+ \ 'valid': 1,
+ \ 'vcol': 0,
+ \ 'nr': 0,
+ \ 'type': 'E',
+ \ 'pattern': '',
+ \ 'text': 'E123: withcode',
+ \ },
+ \ ],
+ \ getloclist(0)
+
+Execute(Formatting with codes should work for the quickfix list):
+ let g:ale_set_loclist = 0
+ let g:ale_set_quickfix = 1
+
+ call AddItem({'text': 'nocode'})
+ call ale#list#SetLists(bufnr(''), g:loclist)
+
+ AssertEqual
+ \ [
+ \ {
+ \ 'lnum': 1,
+ \ 'bufnr': bufnr(''),
+ \ 'col': 1,
+ \ 'valid': 1,
+ \ 'vcol': 0,
+ \ 'nr': 0,
+ \ 'type': 'E',
+ \ 'pattern': '',
+ \ 'text': 'nocode',
+ \ },
+ \ ],
+ \ getqflist()
+
+ call remove(g:loclist, 0)
+ call AddItem({'text': 'withcode', 'code': 'E123'})
+ call ale#list#SetLists(bufnr(''), g:loclist)
+
+ AssertEqual
+ \ [
+ \ {
+ \ 'lnum': 1,
+ \ 'bufnr': bufnr(''),
+ \ 'col': 1,
+ \ 'valid': 1,
+ \ 'vcol': 0,
+ \ 'nr': 0,
+ \ 'type': 'E',
+ \ 'pattern': '',
+ \ 'text': 'E123: withcode',
+ \ },
+ \ ],
+ \ getqflist()
+
+Execute(Formatting with the linter name should work for the loclist):
+ let g:ale_loclist_msg_format = '(%linter%) %s'
+
+ call AddItem({'text': 'whatever'})
+ call ale#list#SetLists(bufnr(''), g:loclist)
+
+ AssertEqual
+ \ [
+ \ {
+ \ 'lnum': 1,
+ \ 'bufnr': bufnr(''),
+ \ 'col': 1,
+ \ 'valid': 1,
+ \ 'vcol': 0,
+ \ 'nr': 0,
+ \ 'type': 'E',
+ \ 'pattern': '',
+ \ 'text': '(some_linter) whatever',
+ \ },
+ \ ],
+ \ getloclist(0)
+
+Execute(Formatting with the linter name should work for the quickfix list):
+ let g:ale_loclist_msg_format = '(%linter%) %s'
+ let g:ale_set_loclist = 0
+ let g:ale_set_quickfix = 1
+
+ call AddItem({'text': 'whatever'})
+ call ale#list#SetLists(bufnr(''), g:loclist)
+
+ AssertEqual
+ \ [
+ \ {
+ \ 'lnum': 1,
+ \ 'bufnr': bufnr(''),
+ \ 'col': 1,
+ \ 'valid': 1,
+ \ 'vcol': 0,
+ \ 'nr': 0,
+ \ 'type': 'E',
+ \ 'pattern': '',
+ \ 'text': '(some_linter) whatever',
+ \ },
+ \ ],
+ \ getqflist()