]> git.madduck.net Git - etc/vim.git/blob - .vim/bundle/ale/test/test_loclist_jumping.vader

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

Merge commit '56df844d3c39ec494dacc69eae34272b27db185a' as '.vim/bundle/asyncomplete'
[etc/vim.git] / .vim / bundle / ale / test / test_loclist_jumping.vader
1 Before:
2   let g:ale_buffer_info = {
3   \ bufnr(''): {
4   \   'loclist': [
5   \     {'type': 'E', 'bufnr': bufnr('') - 1, 'lnum': 3, 'col': 2},
6   \     {'type': 'E', 'bufnr': bufnr(''), 'lnum': 1, 'col': 2},
7   \     {'type': 'E', 'bufnr': bufnr(''), 'lnum': 1, 'col': 3},
8   \     {'type': 'W', 'sub_type': 'style', 'bufnr': bufnr(''), 'lnum': 2, 'col': 1},
9   \     {'type': 'E', 'bufnr': bufnr(''), 'lnum': 2, 'col': 2},
10   \     {'type': 'W', 'sub_type': 'style', 'bufnr': bufnr(''), 'lnum': 2, 'col': 3},
11   \     {'type': 'W', 'bufnr': bufnr(''), 'lnum': 2, 'col': 6},
12   \     {'type': 'E', 'bufnr': bufnr(''), 'lnum': 2, 'col': 700},
13   \     {'type': 'E', 'bufnr': bufnr('') + 1, 'lnum': 3, 'col': 2},
14   \   ],
15   \ },
16   \}
17
18   function! TestJump(position, wrap, filter, subtype_filter, pos)
19     call cursor(a:pos)
20
21     if type(a:position) == type(0)
22       call ale#loclist_jumping#JumpToIndex(a:position)
23     else
24       call ale#loclist_jumping#Jump(a:position, a:wrap, a:filter,
25       \                             a:subtype_filter)
26     endif
27
28     return getcurpos()[1:2]
29   endfunction
30
31 After:
32   let g:ale_buffer_info = {}
33   delfunction TestJump
34
35 Given foobar (Some imaginary filetype):
36   12345678
37   12345678
38
39 Execute(loclist jumping should jump correctly when not wrapping):
40   AssertEqual [2, 1], TestJump('before', 0, 'any', 'any', [2, 2])
41   AssertEqual [1, 3], TestJump('before', 0, 'any', 'any', [2, 1])
42   AssertEqual [2, 3], TestJump('after', 0, 'any', 'any', [2, 2])
43   AssertEqual [2, 1], TestJump('after', 0, 'any', 'any', [1, 3])
44   AssertEqual [2, 6], TestJump('after', 0, 'any', 'any', [2, 4])
45   AssertEqual [2, 8], TestJump('after', 0, 'any', 'any', [2, 6])
46
47 Execute(loclist jumping should jump correctly when wrapping):
48   AssertEqual [2, 1], TestJump('before', 1, 'any', 'any', [2, 2])
49   AssertEqual [1, 3], TestJump('before', 1, 'any', 'any', [2, 1])
50   AssertEqual [2, 3], TestJump('after', 1, 'any', 'any', [2, 2])
51   AssertEqual [2, 1], TestJump('after', 1, 'any', 'any', [1, 3])
52   AssertEqual [2, 6], TestJump('after', 1, 'any', 'any', [2, 4])
53
54   AssertEqual [1, 2], TestJump('after', 1, 'any', 'any', [2, 8])
55   AssertEqual [2, 8], TestJump('before', 1, 'any', 'any', [1, 2])
56
57 Execute(loclist jumping should jump correctly with warning filters):
58   AssertEqual [2, 1], TestJump('after', 0, 'W', 'any', [1, 2])
59   AssertEqual [2, 6], TestJump('after', 0, 'W', 'any', [2, 3])
60   AssertEqual [2, 1], TestJump('after', 1, 'W', 'any', [2, 6])
61
62 Execute(loclist jumping should jump correctly with error filters):
63   AssertEqual [1, 2], TestJump('after', 1, 'E', 'any', [2, 700])
64   AssertEqual [2, 2], TestJump('before', 0, 'E', 'any', [2, 700])
65   AssertEqual [2, 2], TestJump('after', 1, 'E', 'any', [1, 3])
66
67 Execute(loclist jumping should jump correctly with sub type filters):
68   AssertEqual [2, 3], TestJump('after', 0, 'any', 'style', [2, 1])
69   AssertEqual [2, 2], TestJump('after', 0, 'any', '', [1, 3])
70   AssertEqual [2, 1], TestJump('after', 1, 'any', 'style', [2, 6])
71
72 Execute(loclist jumping not jump when the loclist is empty):
73   let g:ale_buffer_info[bufnr('%')].loclist = []
74
75   AssertEqual [1, 6], TestJump('before', 0, 'any', 'any', [1, 6])
76   AssertEqual [1, 6], TestJump('before', 1, 'any', 'any', [1, 6])
77   AssertEqual [1, 6], TestJump('after', 0, 'any', 'any', [1, 6])
78   AssertEqual [1, 6], TestJump('after', 1, 'any', 'any', [1, 6])
79
80 Execute(We should be able to jump to the last item):
81   AssertEqual [2, 8], TestJump(-1, 0, 'any', 'any', [1, 6])
82
83 Execute(We shouldn't move when jumping to the last item where there are none):
84   let g:ale_buffer_info[bufnr('%')].loclist = []
85
86   AssertEqual [1, 6], TestJump(-1, 0, 'any', 'any', [1, 6])
87
88 Execute(We should be able to jump to the first item):
89   AssertEqual [1, 2], TestJump(0, 0, 'any', 'any', [1, 6])
90
91 Execute(We shouldn't move when jumping to the first item where there are none):
92   let g:ale_buffer_info[bufnr('%')].loclist = []
93
94   AssertEqual [1, 6], TestJump(0, 0, 'any', 'any', [1, 6])
95
96 Execute(We should be able to jump when the error line is blank):
97   " Add a blank line at the end.
98   call setline(1, getline('.', '$') + [''])
99   " Add a problem on the blank line.
100   call add(g:ale_buffer_info[bufnr('%')].loclist, {'type': 'E', 'bufnr': bufnr(''), 'lnum': 3, 'col': 1})
101
102   AssertEqual 0, len(getline(3))
103   AssertEqual [2, 8], TestJump('before', 0, 'any', 'any', [3, 1])
104   AssertEqual [2, 8], TestJump('before', 1, 'any', 'any', [3, 1])
105   AssertEqual [3, 1], TestJump('after', 0, 'any', 'any', [3, 1])
106   AssertEqual [1, 2], TestJump('after', 1, 'any', 'any', [3, 1])
107
108 Execute(ALE should jump to column 1 instead of 0):
109   let g:ale_buffer_info = {
110   \ bufnr(''): {
111   \   'loclist': [
112   \     {'type': 'E', 'bufnr': bufnr(''), 'lnum': 1, 'col': 5},
113   \     {'type': 'E', 'bufnr': bufnr(''), 'lnum': 2, 'col': 0},
114   \   ],
115   \ },
116   \}
117
118   AssertEqual [2, 1], TestJump('after', 1, 'any', 'any', [1, 5])
119   AssertEqual [1, 5], TestJump('after', 1, 'any', 'any', [2, 1])
120   AssertEqual [2, 1], TestJump('before', 1, 'any', 'any', [1, 5])
121   AssertEqual [1, 5], TestJump('before', 1, 'any', 'any', [2, 1])