diff options
author | Drew Neil <andrew.jr.neil@gmail.com> | 2017-06-03 12:45:52 +0100 |
---|---|---|
committer | w0rp <w0rp@users.noreply.github.com> | 2017-06-03 12:45:52 +0100 |
commit | 33b0852c84452afbaf0f41c2abc954008be7ef77 (patch) | |
tree | 89b405d4ec3237d6ee89a856493b137f777fa4ad /test/test_loclist_jumping.vader | |
parent | fcb57187126b0f0b8b176073a81911fd8ca3331a (diff) | |
download | ale-33b0852c84452afbaf0f41c2abc954008be7ef77.zip |
Add :ALEFirst and :ALELast commands (#616)
* Add :ALEFirst and :ALELast commands
* Add documentation for ALEFirst and ALELast commands
* Add tests for ale#loclist_jumping#JumpToIndex()
* Fix the loclist jumping tests
Diffstat (limited to 'test/test_loclist_jumping.vader')
-rw-r--r-- | test/test_loclist_jumping.vader | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/test/test_loclist_jumping.vader b/test/test_loclist_jumping.vader new file mode 100644 index 00000000..13eac5ce --- /dev/null +++ b/test/test_loclist_jumping.vader @@ -0,0 +1,76 @@ +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(position, wrap, pos) + call cursor(a:pos) + + if type(a:position) == type(0) + call ale#loclist_jumping#JumpToIndex(a:position) + else + call ale#loclist_jumping#Jump(a:position, a:wrap) + endif + + 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]) + +Execute(We should be able to jump to the last item): + AssertEqual [2, 8], TestJump(-1, 0, [1, 6]) + +Execute(We shouldn't move when jumping to the last item where there are none): + let g:ale_buffer_info[bufnr('%')].loclist = [] + + AssertEqual [1, 6], TestJump(-1, 0, [1, 6]) + +Execute(We should be able to jump to the first item): + AssertEqual [1, 2], TestJump(0, 0, [1, 6]) + +Execute(We shouldn't move when jumping to the first item where there are none): + let g:ale_buffer_info[bufnr('%')].loclist = [] + + AssertEqual [1, 6], TestJump(0, 0, [1, 6]) |