add support for mercury language using mmc as linter

This commit is contained in:
Stewy Slocum
2018-03-25 13:33:24 -04:00
parent 92e6e4d1ba
commit 84952918cc
4 changed files with 171 additions and 0 deletions

View File

@@ -0,0 +1,42 @@
Before:
Save g:ale_mercury_mmc_executable
Save g:ale_mercury_mmc_options
unlet! g:ale_mercury_mmc_executable
unlet! b:ale_mercury_mmc_executable
unlet! g:ale_mercury_mmc_options
unlet! b:ale_mercury_mmc_options
runtime ale_linters/mercury/mmc.vim
call ale#test#SetDirectory('/testplugin/test/command_callback')
After:
unlet! b:ale_mercury_mmc_executable
unlet! b:ale_mercury_mmc_options
Restore
call ale#test#RestoreDirectory()
call ale#linter#Reset()
Execute(The default command should be correct):
AssertEqual
\ ale#path#BufferCdString(bufnr(''))
\ . 'mmc --errorcheck-only --make --output-compile-error-lines 100 dummy',
\
\ ale_linters#mercury#mmc#GetCommand(bufnr(''))
Execute(The executable should be configurable):
let b:ale_mercury_mmc_executable = 'foo'
AssertEqual
\ ale#path#BufferCdString(bufnr(''))
\ . 'foo --errorcheck-only --make --output-compile-error-lines 100 dummy',
\
\ ale_linters#mercury#mmc#GetCommand(bufnr(''))
Execute(The options should be configurable):
let b:ale_mercury_mmc_options = '--bar'
AssertEqual
\ ale#path#BufferCdString(bufnr(''))
\ . 'mmc --errorcheck-only --bar dummy',
\
\ ale_linters#mercury#mmc#GetCommand(bufnr(''))

View File

@@ -0,0 +1,58 @@
Before:
runtime ale_linters/mercury/mmc.vim
After:
call ale#linter#Reset()
Execute(The mmc handler should handle syntax errors):
AssertEqual
\ [
\ {
\ 'lnum': 3,
\ 'type': 'E',
\ 'text': "Syntax error at token ',': operator precedence error."
\ }
\ ],
\ ale_linters#mercury#mmc#Handle(1, [
\ "file_name.m:003: Syntax error at token ',': operator precedence error."
\ ])
Execute(The mmc handler should handle warnings):
AssertEqual
\ [
\ {
\ 'lnum': 10,
\ 'type': 'W',
\ 'text': 'Warning: reference to uninitialized state variable !.X.'
\ },
\ {
\ 'lnum': 12,
\ 'type': 'W',
\ 'text': 'warning: determinism declaration could be tighter.'
\ }
\ ],
\ ale_linters#mercury#mmc#Handle(1, [
\ 'file_name.m:010: Warning: reference to uninitialized state variable !.X.',
\ "file_name.m:012: In `some_predicate':",
\ 'file_name.m:012: warning: determinism declaration could be tighter.'
\ ])
Execute(The mmc handler should handle semantic errors):
AssertEqual
\ [
\ {
\ 'lnum': 7,
\ 'type': 'E',
\ 'text': "error: undefined type `bar'/0."
\ },
\ {
\ 'lnum': 15,
\ 'type': 'E',
\ 'text': "Error: circular equivalence type `file_name.foo'/0."
\ }
\ ],
\ ale_linters#mercury#mmc#Handle(1, [
\ "file_name.m:007: In clause for predicate `foldit'/4:",
\ "file_name.m:007: error: undefined type `bar'/0.",
\ "file_name.m:015: Error: circular equivalence type `file_name.foo'/0."
\ ])