]> git.madduck.net Git - etc/vim.git/blobdiff - .vim/bundle/ale/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:

Merge commit '76265755a1add77121c8f9dabb3e9bb70fe9a972' as '.vim/bundle/ale'
[etc/vim.git] / .vim / bundle / ale / test / test_hover_parsing.vader
diff --git a/.vim/bundle/ale/test/test_hover_parsing.vader b/.vim/bundle/ale/test/test_hover_parsing.vader
new file mode 100644 (file)
index 0000000..b9e56de
--- /dev/null
@@ -0,0 +1,228 @@
+Execute(Invalid results should be handled):
+  AssertEqual [[], []], ale#hover#ParseLSPResult(0)
+  AssertEqual [[], []], ale#hover#ParseLSPResult([0])
+  AssertEqual [[], []], ale#hover#ParseLSPResult('')
+  AssertEqual [[], []], ale#hover#ParseLSPResult({})
+  AssertEqual [[], []], ale#hover#ParseLSPResult([{}])
+  AssertEqual [[], []], ale#hover#ParseLSPResult([''])
+  AssertEqual [[], []], ale#hover#ParseLSPResult({'value': ''})
+  AssertEqual [[], []], ale#hover#ParseLSPResult([{'value': ''}])
+  AssertEqual [[], []], ale#hover#ParseLSPResult({'kind': 'markdown'})
+  AssertEqual [[], []], ale#hover#ParseLSPResult({'kind': 'plaintext'})
+  AssertEqual [[], []], ale#hover#ParseLSPResult({'kind': 'x', 'value': 'xxx'})
+
+Execute(A string with a code fence should be handled):
+  AssertEqual
+  \ [
+  \   [
+  \   ],
+  \   [
+  \     'def foo():',
+  \     '    pass',
+  \   ],
+  \ ],
+  \ ale#hover#ParseLSPResult(join([
+  \   '```',
+  \   'def foo():',
+  \   '    pass',
+  \   '```',
+  \ ], "\n"))
+
+  AssertEqual
+  \ [
+  \   [
+  \     'unlet! b:current_syntax',
+  \     'syntax include @ALE_hover_python syntax/python.vim',
+  \     'syntax region ALE_hover_1 start=/\%1l/ end=/\%3l/ contains=@ALE_hover_python',
+  \   ],
+  \   [
+  \     'def foo():',
+  \     '    pass',
+  \   ],
+  \ ],
+  \ ale#hover#ParseLSPResult(join([
+  \   '```python',
+  \   'def foo():',
+  \   '    pass',
+  \   '```',
+  \ ], "\n"))
+
+  AssertEqual
+  \ [
+  \   [
+  \     'unlet! b:current_syntax',
+  \     'syntax include @ALE_hover_javascript syntax/javascript.vim',
+  \     'unlet! b:current_syntax',
+  \     'syntax include @ALE_hover_python syntax/python.vim',
+  \     'syntax region ALE_hover_1 start=/\%1l/ end=/\%3l/ contains=@ALE_hover_python',
+  \     'syntax region ALE_hover_2 start=/\%5l/ end=/\%8l/ contains=@ALE_hover_python',
+  \     'syntax region ALE_hover_3 start=/\%8l/ end=/\%10l/ contains=@ALE_hover_javascript',
+  \   ],
+  \   [
+  \     'def foo():',
+  \     '    pass',
+  \     '',
+  \     'middle line',
+  \     '',
+  \     'def bar():',
+  \     '    pass',
+  \     '',
+  \     'const baz = () => undefined',
+  \   ],
+  \ ],
+  \ ale#hover#ParseLSPResult(join([
+  \   '```python',
+  \   'def foo():',
+  \   '    pass',
+  \   '```',
+  \   'middle line',
+  \   '```python',
+  \   'def bar():',
+  \   '    pass',
+  \   '```',
+  \   '```javascript',
+  \   'const baz = () => undefined',
+  \   '```',
+  \ ], "\n"))
+
+Execute(Multiple strings with fences should be handled):
+  AssertEqual
+  \ [
+  \   [
+  \     'unlet! b:current_syntax',
+  \     'syntax include @ALE_hover_javascript syntax/javascript.vim',
+  \     'unlet! b:current_syntax',
+  \     'syntax include @ALE_hover_python syntax/python.vim',
+  \     'syntax region ALE_hover_1 start=/\%1l/ end=/\%3l/ contains=@ALE_hover_python',
+  \     'syntax region ALE_hover_2 start=/\%5l/ end=/\%8l/ contains=@ALE_hover_python',
+  \     'syntax region ALE_hover_3 start=/\%8l/ end=/\%10l/ contains=@ALE_hover_javascript',
+  \   ],
+  \   [
+  \     'def foo():',
+  \     '    pass',
+  \     '',
+  \     'middle line',
+  \     '',
+  \     'def bar():',
+  \     '    pass',
+  \     '',
+  \     'const baz = () => undefined',
+  \   ],
+  \ ],
+  \ ale#hover#ParseLSPResult([
+  \   join([
+  \     '```python',
+  \     'def foo():',
+  \     '    pass',
+  \     '```',
+  \   ], "\n"),
+  \   join([
+  \     'middle line',
+  \     '```python',
+  \     'def bar():',
+  \     '    pass',
+  \     '```',
+  \     '```javascript',
+  \     'const baz = () => undefined',
+  \     '```',
+  \   ], "\n"),
+  \ ])
+
+Execute(Objects with kinds should be handled):
+  AssertEqual
+  \ [
+  \   [
+  \     'unlet! b:current_syntax',
+  \     'syntax include @ALE_hover_python syntax/python.vim',
+  \     'syntax region ALE_hover_1 start=/\%1l/ end=/\%3l/ contains=@ALE_hover_python',
+  \   ],
+  \   [
+  \     'def foo():',
+  \     '    pass',
+  \     '',
+  \     '```javascript',
+  \     'const baz = () => undefined',
+  \     '```',
+  \   ],
+  \ ],
+  \ ale#hover#ParseLSPResult([
+  \   {
+  \     'kind': 'markdown',
+  \     'value': join([
+  \       '```python',
+  \       'def foo():',
+  \       '    pass',
+  \       '```',
+  \     ], "\n"),
+  \   },
+  \   {
+  \     'kind': 'plaintext',
+  \     'value': join([
+  \       '```javascript',
+  \       'const baz = () => undefined',
+  \       '```',
+  \     ], "\n"),
+  \   },
+  \ ])
+
+Execute(Simple markdown formatting should be handled):
+  AssertEqual
+  \ [
+  \   [
+  \     'unlet! b:current_syntax',
+  \     'syntax include @ALE_hover_python syntax/python.vim',
+  \     'syntax region ALE_hover_1 start=/\%1l/ end=/\%3l/ contains=@ALE_hover_python',
+  \   ],
+  \   [
+  \     'def foo():',
+  \     '    pass',
+  \     '',
+  \     'formatted _ line _',
+  \   ],
+  \ ],
+  \ ale#hover#ParseLSPResult(join([
+  \   '```python',
+  \   'def foo():',
+  \   '    pass',
+  \   '```',
+  \   'formatted \_ line \_',
+  \ ], "\n"))
+
+Execute(Fences padded with spaces should be handled):
+  AssertEqual
+  \ [
+  \   [
+  \     'unlet! b:current_syntax',
+  \     'syntax include @ALE_hover_python syntax/python.vim',
+  \     'syntax region ALE_hover_1 start=/\%1l/ end=/\%3l/ contains=@ALE_hover_python',
+  \   ],
+  \   [
+  \     'def foo():',
+  \     '    pass',
+  \     '',
+  \     'formatted _ line _',
+  \   ],
+  \ ],
+  \ ale#hover#ParseLSPResult(join([
+  \   '``` python ',
+  \   'def foo():',
+  \   '    pass',
+  \   '```',
+  \   'formatted \_ line \_',
+  \ ], "\n"))
+
+Execute(Non-existent syntax files shouldn't be loaded):
+  AssertEqual
+  \ [
+  \   [
+  \     'syntax region ALE_hover_1 start=/\%1l/ end=/\%2l/ contains=@ALE_hover_text',
+  \   ],
+  \   [
+  \     'hello',
+  \   ],
+  \ ],
+  \ ale#hover#ParseLSPResult(join([
+  \   '```text',
+  \   'hello',
+  \   '```',
+  \ ], "\n"))