2016-10-14 19:29:31 +00:00
|
|
|
Before:
|
2017-11-12 23:19:26 +00:00
|
|
|
Save g:ale_echo_msg_format
|
|
|
|
|
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
|
|
|
\ },
|
|
|
|
\ {
|
2017-11-12 23:19:26 +00:00
|
|
|
\ 'lnum': 1,
|
|
|
|
\ 'col': 14,
|
|
|
|
\ 'bufnr': bufnr('%'),
|
|
|
|
\ 'vcol': 0,
|
|
|
|
\ 'linter_name': 'eslint',
|
|
|
|
\ 'nr': -1,
|
|
|
|
\ 'type': 'I',
|
|
|
|
\ 'text': 'Some information',
|
|
|
|
\ },
|
|
|
|
\ {
|
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)'
|
2017-05-21 18:51:34 +00:00
|
|
|
\ },
|
|
|
|
\ {
|
|
|
|
\ 'lnum': 3,
|
|
|
|
\ 'col': 1,
|
|
|
|
\ 'bufnr': bufnr('%'),
|
|
|
|
\ 'vcol': 0,
|
|
|
|
\ 'linter_name': 'eslint',
|
|
|
|
\ 'nr': -1,
|
|
|
|
\ 'type': 'E',
|
|
|
|
\ 'text': 'lowercase error'
|
|
|
|
\ },
|
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-11-12 23:19:26 +00:00
|
|
|
Restore
|
|
|
|
|
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):
|
2017-11-12 23:19:26 +00:00
|
|
|
var x = 3 + 12345678
|
2016-10-14 19:29:31 +00:00
|
|
|
var x = 5*2 + parseInt("10");
|
2017-05-21 18:51:34 +00:00
|
|
|
// comment
|
2016-10-14 19:29:31 +00:00
|
|
|
|
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
|
2017-05-21 18:51:34 +00:00
|
|
|
|
|
|
|
Execute(ALEDetail should not capitlise cursor messages):
|
|
|
|
call cursor(3, 1)
|
|
|
|
call ale#cursor#EchoCursorWarning()
|
|
|
|
|
|
|
|
AssertEqual 'lowercase error', GetLastMessage()
|
2017-11-12 23:19:26 +00:00
|
|
|
|
|
|
|
Execute(The linter name should be formatted into the message correctly):
|
|
|
|
let g:ale_echo_msg_format = '%linter%: %s'
|
|
|
|
|
|
|
|
call cursor(2, 9)
|
|
|
|
call ale#cursor#EchoCursorWarning()
|
|
|
|
|
|
|
|
AssertEqual
|
|
|
|
\ 'eslint: Infix operators must be spaced. (space-infix-ops)',
|
|
|
|
\ GetLastMessage()
|
|
|
|
|
|
|
|
Execute(The severity should be formatted into the message correctly):
|
|
|
|
let g:ale_echo_msg_format = '%severity%: %s'
|
|
|
|
|
|
|
|
call cursor(2, 9)
|
|
|
|
call ale#cursor#EchoCursorWarning()
|
|
|
|
|
|
|
|
AssertEqual
|
|
|
|
\ 'Warning: Infix operators must be spaced. (space-infix-ops)',
|
|
|
|
\ GetLastMessage()
|
|
|
|
|
|
|
|
call cursor(1, 10)
|
|
|
|
call ale#cursor#EchoCursorWarning()
|
|
|
|
|
|
|
|
AssertEqual 'Error: Missing semicolon. (semi)', GetLastMessage()
|
|
|
|
|
|
|
|
call cursor(1, 14)
|
|
|
|
call ale#cursor#EchoCursorWarning()
|
|
|
|
|
|
|
|
AssertEqual 'Info: Some information', GetLastMessage()
|