2016-10-14 19:29:31 +00:00
|
|
|
Before:
|
2016-10-24 19:21:32 +00:00
|
|
|
let g:ale_buffer_info = {
|
|
|
|
\ bufnr('%'): {
|
|
|
|
\ 'loclist': [
|
|
|
|
\ {
|
|
|
|
\ 'lnum': 1,
|
2017-03-03 20:14:03 +00:00
|
|
|
\ 'col': 10,
|
2016-10-24 19:21:32 +00:00
|
|
|
\ 'bufnr': bufnr('%'),
|
|
|
|
\ 'vcol': 0,
|
|
|
|
\ 'linter_name': 'eslint',
|
|
|
|
\ 'nr': -1,
|
|
|
|
\ 'type': 'E',
|
2017-03-02 07:14:30 +00:00
|
|
|
\ 'text': 'Missing semicolon. (semi)',
|
2017-03-04 23:55:12 +00:00
|
|
|
\ 'detail': "Every statement should end with a semicolon\nsecond line"
|
2016-10-24 19:21:32 +00:00
|
|
|
\ },
|
|
|
|
\ {
|
2016-10-14 19:29:31 +00:00
|
|
|
\ 'lnum': 2,
|
2017-03-03 20:14:03 +00:00
|
|
|
\ 'col': 10,
|
2016-10-14 19:29:31 +00:00
|
|
|
\ 'bufnr': bufnr('%'),
|
|
|
|
\ 'vcol': 0,
|
|
|
|
\ 'linter_name': 'eslint',
|
|
|
|
\ 'nr': -1,
|
|
|
|
\ 'type': 'W',
|
|
|
|
\ 'text': 'Infix operators must be spaced. (space-infix-ops)'
|
2016-10-24 19:21:32 +00:00
|
|
|
\ },
|
|
|
|
\ {
|
2016-10-14 19:29:31 +00:00
|
|
|
\ 'lnum': 2,
|
2017-03-03 20:14:03 +00:00
|
|
|
\ 'col': 15,
|
2016-10-14 19:29:31 +00:00
|
|
|
\ 'bufnr': bufnr('%'),
|
|
|
|
\ 'vcol': 0,
|
|
|
|
\ 'linter_name': 'eslint',
|
|
|
|
\ 'nr': -1,
|
|
|
|
\ 'type': 'E',
|
|
|
|
\ 'text': 'Missing radix parameter (radix)'
|
2016-10-24 19:21:32 +00:00
|
|
|
\ }
|
|
|
|
\ ],
|
|
|
|
\ },
|
2016-10-14 19:29:31 +00:00
|
|
|
\}
|
|
|
|
|
2017-03-02 23:36:31 +00:00
|
|
|
" 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
|
|
|
|
|
2017-03-03 20:14:03 +00:00
|
|
|
function GetLastMessage()
|
|
|
|
redir => l:output
|
|
|
|
silent mess
|
|
|
|
redir END
|
|
|
|
|
|
|
|
let l:lines = split(l:output, "\n")
|
|
|
|
|
|
|
|
return empty(l:lines) ? '' : l:lines[-1]
|
|
|
|
endfunction
|
|
|
|
|
2016-10-14 19:29:31 +00:00
|
|
|
After:
|
2017-03-03 20:14:03 +00:00
|
|
|
call cursor(1, 1)
|
|
|
|
|
2017-03-02 23:36:31 +00:00
|
|
|
let g:ale_set_loclist = 1
|
|
|
|
let g:ale_set_signs = 1
|
|
|
|
let g:ale_set_highlights = 1
|
|
|
|
|
2016-10-24 19:21:32 +00:00
|
|
|
let g:ale_buffer_info = {}
|
2016-10-14 19:29:31 +00:00
|
|
|
|
2017-03-04 23:55:12 +00:00
|
|
|
unlet! g:output
|
|
|
|
|
2017-03-03 20:14:03 +00:00
|
|
|
delfunction GetLastMessage
|
|
|
|
|
2017-05-12 19:38:52 +00:00
|
|
|
" 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 ''
|
2017-03-03 20:14:03 +00:00
|
|
|
|
2016-10-14 19:29:31 +00:00
|
|
|
Given javascript(A Javscript file with warnings/errors):
|
|
|
|
var x = 3
|
|
|
|
var x = 5*2 + parseInt("10");
|
|
|
|
|
2017-03-03 20:14:03 +00:00
|
|
|
Execute(Messages should be shown for the correct lines):
|
|
|
|
call cursor(1, 1)
|
2016-10-14 19:29:31 +00:00
|
|
|
call ale#cursor#EchoCursorWarning()
|
|
|
|
|
2017-03-03 20:14:03 +00:00
|
|
|
AssertEqual 'Missing semicolon. (semi)', GetLastMessage()
|
2016-10-14 19:29:31 +00:00
|
|
|
|
2017-03-03 20:14:03 +00:00
|
|
|
Execute(Messages should be shown for earlier columns):
|
|
|
|
call cursor(2, 1)
|
2016-10-14 19:29:31 +00:00
|
|
|
call ale#cursor#EchoCursorWarning()
|
|
|
|
|
2017-03-03 20:14:03 +00:00
|
|
|
AssertEqual 'Infix operators must be spaced. (space-infix-ops)', GetLastMessage()
|
2016-10-14 19:29:31 +00:00
|
|
|
|
2017-03-03 20:14:03 +00:00
|
|
|
Execute(Messages should be shown for later columns):
|
|
|
|
call cursor(2, 16)
|
2016-10-14 19:29:31 +00:00
|
|
|
call ale#cursor#EchoCursorWarning()
|
|
|
|
|
2017-03-03 20:14:03 +00:00
|
|
|
AssertEqual 'Missing radix parameter (radix)', GetLastMessage()
|
2017-03-02 07:14:30 +00:00
|
|
|
|
2017-03-03 20:14:03 +00:00
|
|
|
Execute(The message at the cursor should be shown when linting ends):
|
|
|
|
call cursor(1, 1)
|
2017-03-02 23:36:31 +00:00
|
|
|
call ale#engine#SetResults(
|
|
|
|
\ bufnr('%'),
|
|
|
|
\ g:ale_buffer_info[bufnr('%')].loclist,
|
|
|
|
\)
|
|
|
|
|
2017-03-03 20:14:03 +00:00
|
|
|
AssertEqual 'Missing semicolon. (semi)', GetLastMessage()
|
2017-03-02 23:36:31 +00:00
|
|
|
|
2017-03-03 20:14:03 +00:00
|
|
|
Execute(The message at the cursor should be shown on InsertLeave):
|
|
|
|
call cursor(2, 9)
|
2017-03-02 23:36:31 +00:00
|
|
|
doautocmd InsertLeave
|
|
|
|
|
2017-03-03 20:14:03 +00:00
|
|
|
AssertEqual 'Infix operators must be spaced. (space-infix-ops)', GetLastMessage()
|
2017-03-02 07:14:30 +00:00
|
|
|
|
2017-03-03 20:14:03 +00:00
|
|
|
Execute(ALEDetail should print 'detail' attributes):
|
|
|
|
call cursor(1, 1)
|
2017-03-03 02:40:07 +00:00
|
|
|
|
2017-03-04 23:55:12 +00:00
|
|
|
redir => g:output
|
|
|
|
ALEDetail
|
|
|
|
redir END
|
|
|
|
|
|
|
|
AssertEqual "\nEvery statement should end with a semicolon\nsecond line", g:output
|
2017-03-03 02:40:07 +00:00
|
|
|
|
2017-03-03 20:14:03 +00:00
|
|
|
Execute(ALEDetail should print regular 'text' attributes):
|
|
|
|
call cursor(2, 10)
|
2017-03-03 02:40:07 +00:00
|
|
|
|
2017-03-04 23:55:12 +00:00
|
|
|
redir => g:output
|
|
|
|
ALEDetail
|
|
|
|
redir END
|
|
|
|
|
|
|
|
AssertEqual "\nInfix operators must be spaced. (space-infix-ops)", g:output
|