2020-10-28 10:48:57 +00:00
|
|
|
Before:
|
|
|
|
call ale#assert#SetUpLinterTest('erlang', 'erlc')
|
|
|
|
|
|
|
|
After:
|
|
|
|
call ale#assert#TearDownLinterTest()
|
|
|
|
|
|
|
|
Execute(The default command should be correct.):
|
|
|
|
let g:cmd = ale_linters#erlang#erlc#GetCommand(bufnr(''))
|
2020-10-28 11:58:15 +00:00
|
|
|
let g:regex = 'erlc.\+-o.\+%t'
|
2020-10-28 10:48:57 +00:00
|
|
|
let g:matched = match(g:cmd, g:regex)
|
|
|
|
|
|
|
|
" match returns -1 if not found
|
|
|
|
AssertNotEqual
|
|
|
|
\ g:matched,
|
|
|
|
\ -1,
|
|
|
|
\ 'Command error: expected [' . g:cmd . '] to match [' . g:regex . ']'
|
|
|
|
|
|
|
|
Execute(The command should accept configured executable.):
|
|
|
|
let b:ale_erlang_erlc_executable = '/usr/bin/erlc'
|
|
|
|
let g:cmd = ale_linters#erlang#erlc#GetCommand(bufnr(''))
|
2020-10-28 11:58:15 +00:00
|
|
|
let g:regex = '/usr/bin/erlc.\+-o.\+%t'
|
2020-10-28 10:48:57 +00:00
|
|
|
let g:matched = match(g:cmd, g:regex)
|
|
|
|
|
|
|
|
" match returns -1 if not found
|
|
|
|
AssertNotEqual
|
|
|
|
\ g:matched,
|
|
|
|
\ -1,
|
|
|
|
\ 'Command error: expected [' . g:cmd . '] to match [' . g:regex . ']'
|
|
|
|
|
|
|
|
Execute(The command should accept configured options.):
|
|
|
|
let b:ale_erlang_erlc_options = '-I include'
|
|
|
|
let g:cmd = ale_linters#erlang#erlc#GetCommand(bufnr(''))
|
2020-10-28 11:58:15 +00:00
|
|
|
let g:regex = 'erlc.\+-o.\+-I include.\+%t'
|
2020-10-28 10:48:57 +00:00
|
|
|
let g:matched = match(g:cmd, g:regex)
|
|
|
|
|
|
|
|
" match returns -1 if not found
|
|
|
|
AssertNotEqual
|
|
|
|
\ g:matched,
|
|
|
|
\ -1,
|
|
|
|
\ 'Command error: expected [' . g:cmd . '] to match [' . g:regex . ']'
|
2021-07-17 12:51:17 +00:00
|
|
|
|
|
|
|
Execute(Linter should recognize OTP23 format.):
|
|
|
|
let g:lines = ["t.erl:6: only association operators '=>' are allowed in map construction"]
|
|
|
|
let g:output_text = ale_linters#erlang#erlc#Handle(bufnr(''), g:lines)[0].text
|
|
|
|
|
|
|
|
let g:expected = "only association operators '=>' are allowed in map construction"
|
|
|
|
AssertEqual
|
|
|
|
\ g:output_text,
|
|
|
|
\ g:expected,
|
|
|
|
\ 'Command error: expected [' . g:output_text . '] to match [' . g:expected . ']'
|
|
|
|
|
|
|
|
Execute(Linter should recognize OTP24 format.):
|
|
|
|
let g:lines = ["t.erl:6:16: only association operators '=>' are allowed in map construction",
|
|
|
|
\ "% 6| #{ a => A, b := B }.",
|
|
|
|
\ "% | ^"]
|
|
|
|
let g:output_text = ale_linters#erlang#erlc#Handle(bufnr(''), g:lines)[0].text
|
|
|
|
|
|
|
|
let g:expected = "only association operators '=>' are allowed in map construction"
|
|
|
|
AssertEqual
|
|
|
|
\ g:output_text,
|
|
|
|
\ g:expected,
|
|
|
|
\ 'Command error: expected [' . g:output_text . '] to match [' . g:expected . ']'
|