2020-08-12 21:11:33 +00:00
|
|
|
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):
|
2024-02-22 02:10:32 +00:00
|
|
|
AssertEqual
|
|
|
|
\ [
|
|
|
|
\ [
|
|
|
|
\ ],
|
|
|
|
\ [
|
|
|
|
\ 'def foo():',
|
|
|
|
\ ' pass',
|
|
|
|
\ ],
|
|
|
|
\ ],
|
|
|
|
\ ale#hover#ParseLSPResult(join([
|
|
|
|
\ '```',
|
|
|
|
\ 'def foo():',
|
|
|
|
\ ' pass',
|
|
|
|
\ '```',
|
|
|
|
\ ], "\n"))
|
|
|
|
|
2020-08-12 21:11:33 +00:00
|
|
|
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',
|
2023-08-15 10:20:47 +00:00
|
|
|
\ 'syntax include @ALE_hover_javascript syntax/javascript.vim',
|
2020-08-12 21:11:33 +00:00
|
|
|
\ 'unlet! b:current_syntax',
|
2023-08-15 10:20:47 +00:00
|
|
|
\ 'syntax include @ALE_hover_python syntax/python.vim',
|
2020-08-12 21:11:33 +00:00
|
|
|
\ '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',
|
2023-08-15 10:20:47 +00:00
|
|
|
\ 'syntax region ALE_hover_3 start=/\%8l/ end=/\%10l/ contains=@ALE_hover_javascript',
|
2020-08-12 21:11:33 +00:00
|
|
|
\ ],
|
|
|
|
\ [
|
|
|
|
\ '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',
|
|
|
|
\ '```',
|
2023-08-15 10:20:47 +00:00
|
|
|
\ '```javascript',
|
2020-08-12 21:11:33 +00:00
|
|
|
\ 'const baz = () => undefined',
|
|
|
|
\ '```',
|
|
|
|
\ ], "\n"))
|
|
|
|
|
|
|
|
Execute(Multiple strings with fences should be handled):
|
|
|
|
AssertEqual
|
|
|
|
\ [
|
|
|
|
\ [
|
|
|
|
\ 'unlet! b:current_syntax',
|
2023-08-15 10:20:47 +00:00
|
|
|
\ 'syntax include @ALE_hover_javascript syntax/javascript.vim',
|
2020-08-12 21:11:33 +00:00
|
|
|
\ 'unlet! b:current_syntax',
|
2023-08-15 10:20:47 +00:00
|
|
|
\ 'syntax include @ALE_hover_python syntax/python.vim',
|
2020-08-12 21:11:33 +00:00
|
|
|
\ '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',
|
2023-08-15 10:20:47 +00:00
|
|
|
\ 'syntax region ALE_hover_3 start=/\%8l/ end=/\%10l/ contains=@ALE_hover_javascript',
|
2020-08-12 21:11:33 +00:00
|
|
|
\ ],
|
|
|
|
\ [
|
|
|
|
\ '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',
|
|
|
|
\ '```',
|
2023-08-15 10:20:47 +00:00
|
|
|
\ '```javascript',
|
2020-08-12 21:11:33 +00:00
|
|
|
\ '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',
|
|
|
|
\ '',
|
2023-08-15 10:20:47 +00:00
|
|
|
\ '```javascript',
|
2020-08-12 21:11:33 +00:00
|
|
|
\ 'const baz = () => undefined',
|
|
|
|
\ '```',
|
|
|
|
\ ],
|
|
|
|
\ ],
|
|
|
|
\ ale#hover#ParseLSPResult([
|
|
|
|
\ {
|
|
|
|
\ 'kind': 'markdown',
|
|
|
|
\ 'value': join([
|
|
|
|
\ '```python',
|
|
|
|
\ 'def foo():',
|
|
|
|
\ ' pass',
|
|
|
|
\ '```',
|
|
|
|
\ ], "\n"),
|
|
|
|
\ },
|
|
|
|
\ {
|
|
|
|
\ 'kind': 'plaintext',
|
|
|
|
\ 'value': join([
|
2023-08-15 10:20:47 +00:00
|
|
|
\ '```javascript',
|
2020-08-12 21:11:33 +00:00
|
|
|
\ '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"))
|
2023-08-15 10:20:47 +00:00
|
|
|
|
2023-09-16 22:04:46 +00:00
|
|
|
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"))
|
|
|
|
|
2023-08-15 10:20:47 +00:00
|
|
|
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"))
|