summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorw0rp <devw0rp@gmail.com>2017-03-07 23:31:25 +0000
committerw0rp <devw0rp@gmail.com>2017-03-07 23:31:25 +0000
commit21caf54543e375a58ec9e5beb23a19f4e6137d35 (patch)
tree8e621d1e7b2d22712e7377067b375c60081dc79c /test
parentb487c621306b109e5a95cff20f2d72b454ca50d4 (diff)
downloadale-21caf54543e375a58ec9e5beb23a19f4e6137d35.zip
Make the navigation commands only work with ALE's pre-sorted list
Diffstat (limited to 'test')
-rw-r--r--test/test_loclist_jumping_loading.vader133
1 files changed, 51 insertions, 82 deletions
diff --git a/test/test_loclist_jumping_loading.vader b/test/test_loclist_jumping_loading.vader
index fe43ef2f..9da5bd5f 100644
--- a/test/test_loclist_jumping_loading.vader
+++ b/test/test_loclist_jumping_loading.vader
@@ -1,86 +1,55 @@
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}'
- \)
+ let g:ale_buffer_info = {
+ \ bufnr('%'): {
+ \ 'loclist': [
+ \ {'lnum': 1, 'col': 2},
+ \ {'lnum': 1, 'col': 3},
+ \ {'lnum': 2, 'col': 1},
+ \ {'lnum': 2, 'col': 2},
+ \ {'lnum': 2, 'col': 3},
+ \ {'lnum': 2, 'col': 6},
+ \ {'lnum': 2, 'col': 700},
+ \ ],
+ \ },
+ \}
+
+ function! TestJump(direction, wrap, pos)
+ call cursor(a:pos)
+ call ale#loclist_jumping#Jump(a:direction, a:wrap)
+
+ return getcurpos()[1:2]
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()
-
-Execute(quickfix should take precedence over loclist when on):
- let g:ale_set_quickfix = 1
-
- call setloclist(winnr(), [
- \ {'lnum': 1, 'col': 1, 'text': 'ignore this', 'bufnr': g:buffer}
- \])
- call setqflist([
- \ {'lnum': 1, 'col': 1, 'text': 'foo', 'bufnr': g:buffer},
- \])
-
- AssertEqual [{'lnum': 1, 'col': 1, 'text': 'foo'}], GetList()
+ let g:ale_buffer_info = {}
+ delfunction TestJump
+
+Given foobar (Some imaginary filetype):
+ 12345678
+ 12345678
+
+Execute(loclist jumping should jump correctly when not wrapping):
+ AssertEqual [2, 1], TestJump('before', 0, [2, 2])
+ AssertEqual [1, 3], TestJump('before', 0, [2, 1])
+ AssertEqual [2, 3], TestJump('after', 0, [2, 2])
+ AssertEqual [2, 1], TestJump('after', 0, [1, 3])
+ AssertEqual [2, 6], TestJump('after', 0, [2, 4])
+ AssertEqual [2, 8], TestJump('after', 0, [2, 6])
+
+Execute(loclist jumping should jump correctly when wrapping):
+ AssertEqual [2, 1], TestJump('before', 1, [2, 2])
+ AssertEqual [1, 3], TestJump('before', 1, [2, 1])
+ AssertEqual [2, 3], TestJump('after', 1, [2, 2])
+ AssertEqual [2, 1], TestJump('after', 1, [1, 3])
+ AssertEqual [2, 6], TestJump('after', 1, [2, 4])
+
+ AssertEqual [1, 2], TestJump('after', 1, [2, 8])
+ AssertEqual [2, 8], TestJump('before', 1, [1, 2])
+
+Execute(loclist jumping not jump when the loclist is empty):
+ let g:ale_buffer_info[bufnr('%')].loclist = []
+
+ AssertEqual [1, 6], TestJump('before', 0, [1, 6])
+ AssertEqual [1, 6], TestJump('before', 1, [1, 6])
+ AssertEqual [1, 6], TestJump('after', 0, [1, 6])
+ AssertEqual [1, 6], TestJump('after', 1, [1, 6])