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