ale/test/test_loclist_jumping_loadin...

56 lines
1.7 KiB
Plaintext
Raw Normal View History

Before:
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:
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])