summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/test_list_opening.vader25
-rw-r--r--test/test_list_titles.vader6
-rw-r--r--test/test_loclist_sorting.vader56
-rw-r--r--test/test_quickfix_deduplication.vader50
-rw-r--r--test/test_setting_loclist_from_another_buffer.vader11
5 files changed, 110 insertions, 38 deletions
diff --git a/test/test_list_opening.vader b/test/test_list_opening.vader
index 024e55ae..7d386d80 100644
--- a/test/test_list_opening.vader
+++ b/test/test_list_opening.vader
@@ -5,6 +5,7 @@ Before:
Save g:ale_open_list
Save g:ale_keep_list_window_open
Save g:ale_list_window_size
+ Save g:ale_buffer_info
let g:ale_set_loclist = 1
let g:ale_set_quickfix = 0
@@ -13,11 +14,12 @@ Before:
let g:ale_list_window_size = 10
let g:loclist = [
- \ {'lnum': 5, 'col': 5},
- \ {'lnum': 5, 'col': 4},
- \ {'lnum': 2, 'col': 10},
- \ {'lnum': 3, 'col': 2},
+ \ {'bufnr': bufnr(''), 'lnum': 5, 'col': 5, 'text': 'x'},
+ \ {'bufnr': bufnr(''), 'lnum': 5, 'col': 4, 'text': 'x'},
+ \ {'bufnr': bufnr(''), 'lnum': 2, 'col': 10, 'text': 'x'},
+ \ {'bufnr': bufnr(''), 'lnum': 3, 'col': 2, 'text': 'x'},
\]
+ let g:ale_buffer_info = {bufnr(''): {'loclist': g:loclist}}
function GetQuickfixHeight() abort
for l:win in range(1, winnr('$'))
@@ -121,6 +123,10 @@ Execute(The quickfix window should open for the quickfix list):
let g:ale_set_quickfix = 1
let g:ale_open_list = 1
+ let g:ale_buffer_info[bufnr('') + 1] = {
+ \ 'loclist': [{'bufnr': -1, 'filename': '/foo/bar', 'lnum': 5, 'col': 5, 'text': 'x'}],
+ \}
+
" It should not open for an empty list.
call ale#list#SetLists(bufnr('%'), [])
call ale#list#CloseWindowIfNeeded(bufnr(''))
@@ -131,10 +137,17 @@ Execute(The quickfix window should open for the quickfix list):
call ale#list#CloseWindowIfNeeded(bufnr(''))
Assert ale#list#IsQuickfixOpen(), 'The quickfix window was closed when the list was not empty'
- " Clear the list and it should close again.
+ " Clear this List. The window should stay open, as there are other items.
+ let g:ale_buffer_info[bufnr('')].loclist = []
+ call ale#list#SetLists(bufnr('%'), [])
+ call ale#list#CloseWindowIfNeeded(bufnr(''))
+ Assert ale#list#IsQuickfixOpen(), 'The quickfix window closed even though there are items in another buffer'
+
+ " Clear the other List now. Now the window should close.
+ call remove(g:ale_buffer_info, bufnr('') + 1)
call ale#list#SetLists(bufnr('%'), [])
call ale#list#CloseWindowIfNeeded(bufnr(''))
- Assert !ale#list#IsQuickfixOpen(), 'The quickfix window was not closed when the list was empty'
+ Assert !ale#list#IsQuickfixOpen(), 'The quickfix window was not closed'
Execute(The quickfix window should stay open for the quickfix list):
let g:ale_set_quickfix = 1
diff --git a/test/test_list_titles.vader b/test/test_list_titles.vader
index fe28629d..74cb4bcc 100644
--- a/test/test_list_titles.vader
+++ b/test/test_list_titles.vader
@@ -1,7 +1,9 @@
Before:
Save g:ale_set_loclist
Save g:ale_set_quickfix
+ Save g:ale_buffer_info
+ let g:ale_buffer_info = {}
let g:ale_set_loclist = 0
let g:ale_set_quickfix = 0
@@ -43,6 +45,10 @@ Execute(The quickfix titles should be set appropriately):
let g:ale_set_quickfix = 1
+ let g:ale_buffer_info[bufnr('')] = {
+ \ 'loclist': [{'bufnr': bufnr(''), 'lnum': 5, 'col': 5, 'text': 'x', 'type': 'E'}],
+ \}
+
call ale#list#SetLists(bufnr(''), [
\ {'bufnr': bufnr(''), 'lnum': 5, 'col': 5, 'text': 'x', 'type': 'E'},
\])
diff --git a/test/test_loclist_sorting.vader b/test/test_loclist_sorting.vader
index c095bdda..157b2a25 100644
--- a/test/test_loclist_sorting.vader
+++ b/test/test_loclist_sorting.vader
@@ -1,31 +1,27 @@
-Before:
- let g:loclist = [
- \ {'bufnr': 3, 'lnum': 1, 'col': 1},
- \ {'bufnr': 1, 'lnum': 5, 'col': 5},
- \ {'bufnr': 2, 'lnum': 5, 'col': 5},
- \ {'bufnr': 1, 'lnum': 5, 'col': 4},
- \ {'bufnr': 1, 'lnum': 2, 'col': 10},
- \ {'bufnr': 2, 'lnum': 1, 'col': 5},
- \ {'bufnr': 1, 'lnum': 3, 'col': 2},
- \ {'bufnr': 2, 'lnum': 1, 'col': 2},
- \ {'bufnr': -1, 'lnum': 3, 'col': 2},
- \]
-
-Execute (Sort loclist with comparison function):
- call sort(g:loclist, 'ale#util#LocItemCompare')
-
-Then (loclist item should be sorted):
+Execute(loclist item should be sorted):
AssertEqual [
- \ {'bufnr': -1, 'lnum': 3, 'col': 2},
- \ {'bufnr': 1, 'lnum': 2, 'col': 10},
- \ {'bufnr': 1, 'lnum': 3, 'col': 2},
- \ {'bufnr': 1, 'lnum': 5, 'col': 4},
- \ {'bufnr': 1, 'lnum': 5, 'col': 5},
- \ {'bufnr': 2, 'lnum': 1, 'col': 2},
- \ {'bufnr': 2, 'lnum': 1, 'col': 5},
- \ {'bufnr': 2, 'lnum': 5, 'col': 5},
- \ {'bufnr': 3, 'lnum': 1, 'col': 1},
- \], g:loclist
-
-After:
- unlet g:loclist
+ \ {'bufnr': -1, 'filename': 'b', 'lnum': 4, 'col': 2},
+ \ {'bufnr': -1, 'filename': 'b', 'lnum': 5, 'col': 2},
+ \ {'bufnr': -1, 'filename': 'c', 'lnum': 3, 'col': 2},
+ \ {'bufnr': 1, 'lnum': 2, 'col': 10},
+ \ {'bufnr': 1, 'lnum': 3, 'col': 2},
+ \ {'bufnr': 1, 'lnum': 5, 'col': 4},
+ \ {'bufnr': 1, 'lnum': 5, 'col': 5},
+ \ {'bufnr': 2, 'lnum': 1, 'col': 2},
+ \ {'bufnr': 2, 'lnum': 1, 'col': 5},
+ \ {'bufnr': 2, 'lnum': 5, 'col': 5},
+ \ {'bufnr': 3, 'lnum': 1, 'col': 1},
+ \ ],
+ \ sort([
+ \ {'bufnr': 3, 'lnum': 1, 'col': 1},
+ \ {'bufnr': -1, 'filename': 'b', 'lnum': 5, 'col': 2},
+ \ {'bufnr': 1, 'lnum': 5, 'col': 5},
+ \ {'bufnr': 2, 'lnum': 5, 'col': 5},
+ \ {'bufnr': -1, 'filename': 'b', 'lnum': 4, 'col': 2},
+ \ {'bufnr': 1, 'lnum': 5, 'col': 4},
+ \ {'bufnr': 1, 'lnum': 2, 'col': 10},
+ \ {'bufnr': 2, 'lnum': 1, 'col': 5},
+ \ {'bufnr': 1, 'lnum': 3, 'col': 2},
+ \ {'bufnr': 2, 'lnum': 1, 'col': 2},
+ \ {'bufnr': -1, 'filename': 'c', 'lnum': 3, 'col': 2},
+ \], 'ale#util#LocItemCompare')
diff --git a/test/test_quickfix_deduplication.vader b/test/test_quickfix_deduplication.vader
new file mode 100644
index 00000000..0dff3f2e
--- /dev/null
+++ b/test/test_quickfix_deduplication.vader
@@ -0,0 +1,50 @@
+Before:
+ Save g:ale_buffer_info
+
+After:
+ Restore
+
+Execute:
+ " Results from multiple buffers should be gathered together.
+ " Equal problems should be de-duplicated.
+ let g:ale_buffer_info = {
+ \ '1': {'loclist': [
+ \ {'bufnr': 2, 'lnum': 1, 'col': 2, 'text': 'foo'},
+ \ {'bufnr': 2, 'lnum': 1, 'col': 5, 'text': 'bar'},
+ \ {'bufnr': -1, 'filename': 'c', 'lnum': 3, 'col': 2, 'text': 'x'},
+ \ {'bufnr': 1, 'lnum': 5, 'col': 4, 'text': 'x'},
+ \ {'bufnr': 2, 'lnum': 5, 'col': 5, 'text': 'foo'},
+ \ {'bufnr': 1, 'lnum': 2, 'col': 10, 'text': 'x'},
+ \ {'bufnr': 1, 'lnum': 3, 'col': 2, 'text': 'x'},
+ \ {'bufnr': 1, 'lnum': 5, 'col': 5, 'text': 'x'},
+ \ {'bufnr': -1, 'filename': 'b', 'lnum': 4, 'col': 2, 'text': 'x'},
+ \ {'bufnr': -1, 'filename': 'b', 'lnum': 5, 'col': 2, 'text': 'x'},
+ \ {'bufnr': 3, 'lnum': 1, 'col': 1, 'text': 'foo'},
+ \ ]},
+ \ '2': {'loclist': [
+ \ {'bufnr': 1, 'lnum': 2, 'col': 10, 'text': 'x'},
+ \ {'bufnr': 1, 'lnum': 5, 'col': 5, 'text': 'x'},
+ \ {'bufnr': 2, 'lnum': 1, 'col': 2, 'text': 'foo'},
+ \ {'bufnr': 1, 'lnum': 3, 'col': 2, 'text': 'x'},
+ \ {'bufnr': 1, 'lnum': 5, 'col': 4, 'text': 'x'},
+ \ {'bufnr': 2, 'lnum': 1, 'col': 5, 'text': 'bar'},
+ \ {'bufnr': 2, 'lnum': 5, 'col': 5, 'text': 'another error'},
+ \ ]},
+ \}
+
+ AssertEqual
+ \ [
+ \ {'bufnr': -1, 'filename': 'b', 'lnum': 4, 'col': 2, 'text': 'x'},
+ \ {'bufnr': -1, 'filename': 'b', 'lnum': 5, 'col': 2, 'text': 'x'},
+ \ {'bufnr': -1, 'filename': 'c', 'lnum': 3, 'col': 2, 'text': 'x'},
+ \ {'bufnr': 1, 'lnum': 2, 'col': 10, 'text': 'x'},
+ \ {'bufnr': 1, 'lnum': 3, 'col': 2, 'text': 'x'},
+ \ {'bufnr': 1, 'lnum': 5, 'col': 4, 'text': 'x'},
+ \ {'bufnr': 1, 'lnum': 5, 'col': 5, 'text': 'x'},
+ \ {'bufnr': 2, 'lnum': 1, 'col': 2, 'text': 'foo'},
+ \ {'bufnr': 2, 'lnum': 1, 'col': 5, 'text': 'bar'},
+ \ {'bufnr': 2, 'lnum': 5, 'col': 5, 'text': 'another error'},
+ \ {'bufnr': 2, 'lnum': 5, 'col': 5, 'text': 'foo'},
+ \ {'bufnr': 3, 'lnum': 1, 'col': 1, 'text': 'foo'},
+ \ ],
+ \ ale#list#GetCombinedList()
diff --git a/test/test_setting_loclist_from_another_buffer.vader b/test/test_setting_loclist_from_another_buffer.vader
index ae53de1f..10a44cce 100644
--- a/test/test_setting_loclist_from_another_buffer.vader
+++ b/test/test_setting_loclist_from_another_buffer.vader
@@ -1,7 +1,11 @@
Before:
Save g:ale_buffer_info
- let g:ale_buffer_info = {}
+ let g:ale_buffer_info = {
+ \ bufnr(''): {
+ \ 'loclist': [{'bufnr': bufnr(''), 'lnum': 4, 'col': 1, 'text': 'foo'}]
+ \ },
+ \}
let g:original_buffer = bufnr('%')
noautocmd new
@@ -12,7 +16,10 @@ After:
unlet! g:original_buffer
Execute(Errors should be set in the loclist for the original buffer, not the new one):
- call ale#list#SetLists(g:original_buffer, [{'lnum': 4, 'text': 'foo'}])
+ call ale#list#SetLists(
+ \ g:original_buffer,
+ \ g:ale_buffer_info[(g:original_buffer)].loclist,
+ \ )
AssertEqual [], getloclist(0)
AssertEqual 1, len(getloclist(bufwinid(g:original_buffer)))