127 lines
3.1 KiB
Plaintext
127 lines
3.1 KiB
Plaintext
Before:
|
|
let g:ale_buffer_info = {
|
|
\ bufnr('%'): {
|
|
\ 'loclist': [
|
|
\ {
|
|
\ 'lnum': 1,
|
|
\ 'col': 10,
|
|
\ 'bufnr': bufnr('%'),
|
|
\ 'vcol': 0,
|
|
\ 'linter_name': 'eslint',
|
|
\ 'nr': -1,
|
|
\ 'type': 'E',
|
|
\ 'text': 'Missing semicolon. (semi)',
|
|
\ 'detail': "Every statement should end with a semicolon\nsecond line"
|
|
\ },
|
|
\ {
|
|
\ 'lnum': 2,
|
|
\ 'col': 10,
|
|
\ 'bufnr': bufnr('%'),
|
|
\ 'vcol': 0,
|
|
\ 'linter_name': 'eslint',
|
|
\ 'nr': -1,
|
|
\ 'type': 'W',
|
|
\ 'text': 'Infix operators must be spaced. (space-infix-ops)'
|
|
\ },
|
|
\ {
|
|
\ 'lnum': 2,
|
|
\ 'col': 15,
|
|
\ 'bufnr': bufnr('%'),
|
|
\ 'vcol': 0,
|
|
\ 'linter_name': 'eslint',
|
|
\ 'nr': -1,
|
|
\ 'type': 'E',
|
|
\ 'text': 'Missing radix parameter (radix)'
|
|
\ }
|
|
\ ],
|
|
\ },
|
|
\}
|
|
|
|
" Turn off other features, we only care about this one feature in this test.
|
|
let g:ale_set_loclist = 0
|
|
let g:ale_set_signs = 0
|
|
let g:ale_set_highlights = 0
|
|
|
|
function GetLastMessage()
|
|
redir => l:output
|
|
silent mess
|
|
redir END
|
|
|
|
let l:lines = split(l:output, "\n")
|
|
|
|
return empty(l:lines) ? '' : l:lines[-1]
|
|
endfunction
|
|
|
|
After:
|
|
call cursor(1, 1)
|
|
|
|
let g:ale_set_loclist = 1
|
|
let g:ale_set_signs = 1
|
|
let g:ale_set_highlights = 1
|
|
|
|
let g:ale_buffer_info = {}
|
|
|
|
unlet! g:output
|
|
|
|
delfunction GetLastMessage
|
|
|
|
" Clearing the messages breaks tests on NeoVim for some reason, but all
|
|
" we need to do for these tests is just make it so the last message isn't
|
|
" carried over between test cases.
|
|
echomsg ''
|
|
|
|
Given javascript(A Javscript file with warnings/errors):
|
|
var x = 3
|
|
var x = 5*2 + parseInt("10");
|
|
|
|
Execute(Messages should be shown for the correct lines):
|
|
call cursor(1, 1)
|
|
call ale#cursor#EchoCursorWarning()
|
|
|
|
AssertEqual 'Missing semicolon. (semi)', GetLastMessage()
|
|
|
|
Execute(Messages should be shown for earlier columns):
|
|
call cursor(2, 1)
|
|
call ale#cursor#EchoCursorWarning()
|
|
|
|
AssertEqual 'Infix operators must be spaced. (space-infix-ops)', GetLastMessage()
|
|
|
|
Execute(Messages should be shown for later columns):
|
|
call cursor(2, 16)
|
|
call ale#cursor#EchoCursorWarning()
|
|
|
|
AssertEqual 'Missing radix parameter (radix)', GetLastMessage()
|
|
|
|
Execute(The message at the cursor should be shown when linting ends):
|
|
call cursor(1, 1)
|
|
call ale#engine#SetResults(
|
|
\ bufnr('%'),
|
|
\ g:ale_buffer_info[bufnr('%')].loclist,
|
|
\)
|
|
|
|
AssertEqual 'Missing semicolon. (semi)', GetLastMessage()
|
|
|
|
Execute(The message at the cursor should be shown on InsertLeave):
|
|
call cursor(2, 9)
|
|
doautocmd InsertLeave
|
|
|
|
AssertEqual 'Infix operators must be spaced. (space-infix-ops)', GetLastMessage()
|
|
|
|
Execute(ALEDetail should print 'detail' attributes):
|
|
call cursor(1, 1)
|
|
|
|
redir => g:output
|
|
ALEDetail
|
|
redir END
|
|
|
|
AssertEqual "\nEvery statement should end with a semicolon\nsecond line", g:output
|
|
|
|
Execute(ALEDetail should print regular 'text' attributes):
|
|
call cursor(2, 10)
|
|
|
|
redir => g:output
|
|
ALEDetail
|
|
redir END
|
|
|
|
AssertEqual "\nInfix operators must be spaced. (space-infix-ops)", g:output
|