]> git.madduck.net Git - etc/vim.git/blob - test/test_hover_parsing.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:

Squashed '.vim/bundle/ale/' content from commit 22185c4c
[etc/vim.git] / test / test_hover_parsing.vader
1 Execute(Invalid results should be handled):
2   AssertEqual [[], []], ale#hover#ParseLSPResult(0)
3   AssertEqual [[], []], ale#hover#ParseLSPResult([0])
4   AssertEqual [[], []], ale#hover#ParseLSPResult('')
5   AssertEqual [[], []], ale#hover#ParseLSPResult({})
6   AssertEqual [[], []], ale#hover#ParseLSPResult([{}])
7   AssertEqual [[], []], ale#hover#ParseLSPResult([''])
8   AssertEqual [[], []], ale#hover#ParseLSPResult({'value': ''})
9   AssertEqual [[], []], ale#hover#ParseLSPResult([{'value': ''}])
10   AssertEqual [[], []], ale#hover#ParseLSPResult({'kind': 'markdown'})
11   AssertEqual [[], []], ale#hover#ParseLSPResult({'kind': 'plaintext'})
12   AssertEqual [[], []], ale#hover#ParseLSPResult({'kind': 'x', 'value': 'xxx'})
13
14 Execute(A string with a code fence should be handled):
15   AssertEqual
16   \ [
17   \   [
18   \   ],
19   \   [
20   \     'def foo():',
21   \     '    pass',
22   \   ],
23   \ ],
24   \ ale#hover#ParseLSPResult(join([
25   \   '```',
26   \   'def foo():',
27   \   '    pass',
28   \   '```',
29   \ ], "\n"))
30
31   AssertEqual
32   \ [
33   \   [
34   \     'unlet! b:current_syntax',
35   \     'syntax include @ALE_hover_python syntax/python.vim',
36   \     'syntax region ALE_hover_1 start=/\%1l/ end=/\%3l/ contains=@ALE_hover_python',
37   \   ],
38   \   [
39   \     'def foo():',
40   \     '    pass',
41   \   ],
42   \ ],
43   \ ale#hover#ParseLSPResult(join([
44   \   '```python',
45   \   'def foo():',
46   \   '    pass',
47   \   '```',
48   \ ], "\n"))
49
50   AssertEqual
51   \ [
52   \   [
53   \     'unlet! b:current_syntax',
54   \     'syntax include @ALE_hover_javascript syntax/javascript.vim',
55   \     'unlet! b:current_syntax',
56   \     'syntax include @ALE_hover_python syntax/python.vim',
57   \     'syntax region ALE_hover_1 start=/\%1l/ end=/\%3l/ contains=@ALE_hover_python',
58   \     'syntax region ALE_hover_2 start=/\%5l/ end=/\%8l/ contains=@ALE_hover_python',
59   \     'syntax region ALE_hover_3 start=/\%8l/ end=/\%10l/ contains=@ALE_hover_javascript',
60   \   ],
61   \   [
62   \     'def foo():',
63   \     '    pass',
64   \     '',
65   \     'middle line',
66   \     '',
67   \     'def bar():',
68   \     '    pass',
69   \     '',
70   \     'const baz = () => undefined',
71   \   ],
72   \ ],
73   \ ale#hover#ParseLSPResult(join([
74   \   '```python',
75   \   'def foo():',
76   \   '    pass',
77   \   '```',
78   \   'middle line',
79   \   '```python',
80   \   'def bar():',
81   \   '    pass',
82   \   '```',
83   \   '```javascript',
84   \   'const baz = () => undefined',
85   \   '```',
86   \ ], "\n"))
87
88 Execute(Multiple strings with fences should be handled):
89   AssertEqual
90   \ [
91   \   [
92   \     'unlet! b:current_syntax',
93   \     'syntax include @ALE_hover_javascript syntax/javascript.vim',
94   \     'unlet! b:current_syntax',
95   \     'syntax include @ALE_hover_python syntax/python.vim',
96   \     'syntax region ALE_hover_1 start=/\%1l/ end=/\%3l/ contains=@ALE_hover_python',
97   \     'syntax region ALE_hover_2 start=/\%5l/ end=/\%8l/ contains=@ALE_hover_python',
98   \     'syntax region ALE_hover_3 start=/\%8l/ end=/\%10l/ contains=@ALE_hover_javascript',
99   \   ],
100   \   [
101   \     'def foo():',
102   \     '    pass',
103   \     '',
104   \     'middle line',
105   \     '',
106   \     'def bar():',
107   \     '    pass',
108   \     '',
109   \     'const baz = () => undefined',
110   \   ],
111   \ ],
112   \ ale#hover#ParseLSPResult([
113   \   join([
114   \     '```python',
115   \     'def foo():',
116   \     '    pass',
117   \     '```',
118   \   ], "\n"),
119   \   join([
120   \     'middle line',
121   \     '```python',
122   \     'def bar():',
123   \     '    pass',
124   \     '```',
125   \     '```javascript',
126   \     'const baz = () => undefined',
127   \     '```',
128   \   ], "\n"),
129   \ ])
130
131 Execute(Objects with kinds should be handled):
132   AssertEqual
133   \ [
134   \   [
135   \     'unlet! b:current_syntax',
136   \     'syntax include @ALE_hover_python syntax/python.vim',
137   \     'syntax region ALE_hover_1 start=/\%1l/ end=/\%3l/ contains=@ALE_hover_python',
138   \   ],
139   \   [
140   \     'def foo():',
141   \     '    pass',
142   \     '',
143   \     '```javascript',
144   \     'const baz = () => undefined',
145   \     '```',
146   \   ],
147   \ ],
148   \ ale#hover#ParseLSPResult([
149   \   {
150   \     'kind': 'markdown',
151   \     'value': join([
152   \       '```python',
153   \       'def foo():',
154   \       '    pass',
155   \       '```',
156   \     ], "\n"),
157   \   },
158   \   {
159   \     'kind': 'plaintext',
160   \     'value': join([
161   \       '```javascript',
162   \       'const baz = () => undefined',
163   \       '```',
164   \     ], "\n"),
165   \   },
166   \ ])
167
168 Execute(Simple markdown formatting should be handled):
169   AssertEqual
170   \ [
171   \   [
172   \     'unlet! b:current_syntax',
173   \     'syntax include @ALE_hover_python syntax/python.vim',
174   \     'syntax region ALE_hover_1 start=/\%1l/ end=/\%3l/ contains=@ALE_hover_python',
175   \   ],
176   \   [
177   \     'def foo():',
178   \     '    pass',
179   \     '',
180   \     'formatted _ line _',
181   \   ],
182   \ ],
183   \ ale#hover#ParseLSPResult(join([
184   \   '```python',
185   \   'def foo():',
186   \   '    pass',
187   \   '```',
188   \   'formatted \_ line \_',
189   \ ], "\n"))
190
191 Execute(Fences padded with spaces should be handled):
192   AssertEqual
193   \ [
194   \   [
195   \     'unlet! b:current_syntax',
196   \     'syntax include @ALE_hover_python syntax/python.vim',
197   \     'syntax region ALE_hover_1 start=/\%1l/ end=/\%3l/ contains=@ALE_hover_python',
198   \   ],
199   \   [
200   \     'def foo():',
201   \     '    pass',
202   \     '',
203   \     'formatted _ line _',
204   \   ],
205   \ ],
206   \ ale#hover#ParseLSPResult(join([
207   \   '``` python ',
208   \   'def foo():',
209   \   '    pass',
210   \   '```',
211   \   'formatted \_ line \_',
212   \ ], "\n"))
213
214 Execute(Non-existent syntax files shouldn't be loaded):
215   AssertEqual
216   \ [
217   \   [
218   \     'syntax region ALE_hover_1 start=/\%1l/ end=/\%2l/ contains=@ALE_hover_text',
219   \   ],
220   \   [
221   \     'hello',
222   \   ],
223   \ ],
224   \ ale#hover#ParseLSPResult(join([
225   \   '```text',
226   \   'hello',
227   \   '```',
228   \ ], "\n"))