2016-10-14 15:29:31 -04:00
|
|
|
Before:
|
2017-11-12 18:19:26 -05:00
|
|
|
Save g:ale_echo_msg_format
|
|
|
|
|
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-11-12 19:47:34 -05:00
|
|
|
\ 'code': 'semi',
|
|
|
|
\ 'text': 'Missing semicolon.',
|
|
|
|
\ 'detail': "Every statement should end with a semicolon\nsecond line",
|
2016-10-24 15:21:32 -04:00
|
|
|
\ },
|
|
|
|
\ {
|
2017-11-12 18:19:26 -05:00
|
|
|
\ 'lnum': 1,
|
|
|
|
\ 'col': 14,
|
|
|
|
\ 'bufnr': bufnr('%'),
|
|
|
|
\ 'vcol': 0,
|
|
|
|
\ 'linter_name': 'eslint',
|
|
|
|
\ 'nr': -1,
|
|
|
|
\ 'type': 'I',
|
|
|
|
\ 'text': 'Some information',
|
|
|
|
\ },
|
|
|
|
\ {
|
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',
|
2017-11-12 19:47:34 -05:00
|
|
|
\ 'code': 'space-infix-ops',
|
|
|
|
\ 'text': 'Infix operators must be spaced.',
|
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',
|
2017-11-12 19:47:34 -05:00
|
|
|
\ 'code': 'radix',
|
|
|
|
\ 'text': 'Missing radix parameter',
|
2017-05-21 14:51:34 -04:00
|
|
|
\ },
|
|
|
|
\ {
|
|
|
|
\ 'lnum': 3,
|
|
|
|
\ 'col': 1,
|
|
|
|
\ 'bufnr': bufnr('%'),
|
|
|
|
\ 'vcol': 0,
|
|
|
|
\ 'linter_name': 'eslint',
|
|
|
|
\ 'nr': -1,
|
|
|
|
\ 'type': 'E',
|
2017-11-12 19:47:34 -05:00
|
|
|
\ 'text': 'lowercase error',
|
2017-05-21 14:51:34 -04:00
|
|
|
\ },
|
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-11-12 18:19:26 -05:00
|
|
|
Restore
|
|
|
|
|
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):
|
2017-11-12 18:19:26 -05:00
|
|
|
var x = 3 + 12345678
|
2016-10-14 15:29:31 -04:00
|
|
|
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-11-12 19:47:34 -05:00
|
|
|
AssertEqual 'semi: Missing semicolon.', 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-11-12 19:47:34 -05:00
|
|
|
AssertEqual 'space-infix-ops: Infix operators must be spaced.', 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-11-12 19:47:34 -05:00
|
|
|
AssertEqual 'radix: Missing radix parameter', 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-11-12 19:47:34 -05:00
|
|
|
AssertEqual 'semi: Missing semicolon.', 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-11-12 19:47:34 -05:00
|
|
|
AssertEqual 'space-infix-ops: Infix operators must be spaced.', 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
|
|
|
|
|
2017-11-12 19:47:34 -05:00
|
|
|
AssertEqual "\nInfix operators must be spaced.", 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()
|
2017-11-12 18:19:26 -05: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
|
2017-11-12 19:47:34 -05:00
|
|
|
\ 'eslint: Infix operators must be spaced.',
|
2017-11-12 18:19:26 -05:00
|
|
|
\ 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
|
2017-11-12 19:47:34 -05:00
|
|
|
\ 'Warning: Infix operators must be spaced.',
|
2017-11-12 18:19:26 -05:00
|
|
|
\ GetLastMessage()
|
|
|
|
|
|
|
|
call cursor(1, 10)
|
|
|
|
call ale#cursor#EchoCursorWarning()
|
|
|
|
|
2017-11-12 19:47:34 -05:00
|
|
|
AssertEqual 'Error: Missing semicolon.', GetLastMessage()
|
2017-11-12 18:19:26 -05:00
|
|
|
|
|
|
|
call cursor(1, 14)
|
|
|
|
call ale#cursor#EchoCursorWarning()
|
|
|
|
|
|
|
|
AssertEqual 'Info: Some information', GetLastMessage()
|
2017-11-12 19:47:34 -05:00
|
|
|
|
|
|
|
Execute(The %code% and %ifcode% should show the code and some text):
|
|
|
|
let g:ale_echo_msg_format = '%(code) %%s'
|
|
|
|
|
|
|
|
call cursor(2, 9)
|
|
|
|
call ale#cursor#EchoCursorWarning()
|
|
|
|
|
|
|
|
AssertEqual
|
|
|
|
\ '(space-infix-ops) Infix operators must be spaced.',
|
|
|
|
\ GetLastMessage()
|
|
|
|
|
|
|
|
Execute(The %code% and %ifcode% should be removed when there's no code):
|
|
|
|
let g:ale_echo_msg_format = '%(code) %%s'
|
|
|
|
|
|
|
|
call cursor(1, 14)
|
|
|
|
call ale#cursor#EchoCursorWarning()
|
|
|
|
|
|
|
|
AssertEqual 'Some information', GetLastMessage()
|