diff options
author | w0rp <devw0rp@gmail.com> | 2017-02-21 12:46:07 +0000 |
---|---|---|
committer | w0rp <devw0rp@gmail.com> | 2017-02-21 12:46:07 +0000 |
commit | c310080359189b6b880a7e37170263a427026bc4 (patch) | |
tree | 45f45745ac62a67ea545be7ddd5d97ed6436eb68 /test | |
parent | 1a9c8b8d06d4b2b188b667148b26426ccf29e559 (diff) | |
download | ale-c310080359189b6b880a7e37170263a427026bc4.zip |
#314 filter both lists, and add tests to cover the list retrieval
Diffstat (limited to 'test')
-rw-r--r-- | test/test_loclist_jumping_loading.vader | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/test/test_loclist_jumping_loading.vader b/test/test_loclist_jumping_loading.vader new file mode 100644 index 00000000..06ae3742 --- /dev/null +++ b/test/test_loclist_jumping_loading.vader @@ -0,0 +1,74 @@ +Before: + let g:buffer = bufnr('%') + + function! GetList() abort + return map( + \ ale#loclist_jumping#GetSortedList(), + \ '{''lnum'': v:val.lnum, ''col'': v:val.col, ''text'': v:val.text}' + \) + endfunction + +After: + unlet! g:buffer + unlet! g:new_buffer + let g:ale_set_loclist = 1 + let g:ale_set_quickfix = 0 + call setloclist(winnr(), []) + call setqflist([]) + delfunction GetList + +Execute(The loclist should be filtered and sorted appropriately for jumping): + :new + + let g:new_buffer = bufnr('%') + + AssertNotEqual g:new_buffer, g:buffer + + call setloclist(winnr(), [ + \ {'lnum': 1, 'col': 1, 'text': 'ignore this', 'bufnr': g:buffer}, + \ {'lnum': 20, 'col': 5, 'text': 'baz', 'bufnr': g:new_buffer}, + \ {'lnum': 10, 'col': 6, 'text': 'bar', 'bufnr': g:new_buffer}, + \ {'lnum': 10, 'col': 5, 'text': 'foo', 'bufnr': g:new_buffer}, + \]) + + AssertEqual + \ [ + \ {'lnum': 10, 'col': 5, 'text': 'foo'}, + \ {'lnum': 10, 'col': 6, 'text': 'bar'}, + \ {'lnum': 20, 'col': 5, 'text': 'baz'}, + \ ], + \ GetList() + +Execute(quickfix should be filtered and sorted appropriately for jumping): + let g:ale_set_loclist = 0 + let g:ale_set_quickfix = 1 + + :new + + let g:new_buffer = bufnr('%') + + AssertNotEqual g:new_buffer, g:buffer + + call setqflist([ + \ {'lnum': 1, 'col': 1, 'text': 'ignore this', 'bufnr': g:buffer}, + \ {'lnum': 20, 'col': 5, 'text': 'baz', 'bufnr': g:new_buffer}, + \ {'lnum': 10, 'col': 6, 'text': 'bar', 'bufnr': g:new_buffer}, + \ {'lnum': 10, 'col': 5, 'text': 'foo', 'bufnr': g:new_buffer}, + \]) + + AssertEqual + \ [ + \ {'lnum': 10, 'col': 5, 'text': 'foo'}, + \ {'lnum': 10, 'col': 6, 'text': 'bar'}, + \ {'lnum': 20, 'col': 5, 'text': 'baz'}, + \ ], + \ GetList() + +Execute(An empty List should be returned when both lists are turned off): + let g:ale_set_loclist = 0 + let g:ale_set_quickfix = 0 + + call setqflist([{'lnum': 1, 'col': 1, 'text': 'foo', 'bufnr': bufnr('%')}]) + call setloclist(winnr(), [{'lnum': 1, 'col': 1, 'text': 'foo', 'bufnr': bufnr('%')}]) + + AssertEqual [], GetList() |