Group sign tests

This commit is contained in:
w0rp
2017-03-09 22:18:45 +00:00
parent 3cababc83b
commit 587360e760
3 changed files with 0 additions and 0 deletions

View File

@@ -0,0 +1,39 @@
Given javascript (Some JavaScript with problems):
var y = 3+3;
var y = 3
Before:
sign unplace *
let g:actual_sign_list = []
let g:expected_sign_list = [
\ ['1', 'ALEWarningSign'],
\ ['2', 'ALEErrorSign'],
\]
function! g:CollectSigns()
redir => l:output
silent exec 'sign place'
redir END
for l:line in split(l:output, "\n")
let l:match = matchlist(l:line, 'line=\(\d\+\).*name=\(ALE[a-zA-Z]\+\)')
if len(l:match) > 0
call add(g:actual_sign_list, [l:match[1], l:match[2]])
endif
endfor
endfunction
After:
sign unplace *
let g:ale_buffer_info = {}
delfunction g:CollectSigns
unlet g:actual_sign_list
unlet g:expected_sign_list
Execute(The signs should be updated after linting is done):
call ale#Lint()
call ale#engine#WaitForJobs(2000)
call g:CollectSigns()
AssertEqual g:expected_sign_list, g:actual_sign_list

View File

@@ -0,0 +1,11 @@
Execute (Parsing English signs should work):
AssertEqual [1000001], ale#sign#ParseSigns(['Signs for app.js:', ' line=9 id=1000001 name=ALEWarningSign'])
Execute (Parsing Russian signs should work):
AssertEqual [1000001], ale#sign#ParseSigns([' строка=1 id=1000001 имя=ALEErrorSign'])
Execute (Parsing Japanese signs should work):
AssertEqual [1000001], ale#sign#ParseSigns([' 行=1 識別子=1000001 名前=ALEWarningSign'])
Execute (Parsing Spanish signs should work):
AssertEqual [1000001], ale#sign#ParseSigns([' línea=12 id=1000001 nombre=ALEWarningSign'])

View File

@@ -0,0 +1,68 @@
Before:
function! GenerateResults(buffer, output)
return [
\ {
\ 'lnum': 1,
\ 'col': 1,
\ 'bufnr': bufnr('%'),
\ 'vcol': 0,
\ 'nr': -1,
\ 'type': 'E',
\ 'text': 'foo',
\ },
\ {
\ 'lnum': 2,
\ 'col': 1,
\ 'bufnr': bufnr('%'),
\ 'vcol': 0,
\ 'nr': -1,
\ 'type': 'W',
\ 'text': 'bar',
\ },
\ {
\ 'lnum': 3,
\ 'col': 1,
\ 'bufnr': bufnr('%'),
\ 'vcol': 0,
\ 'nr': -1,
\ 'type': 'E',
\ 'text': 'baz',
\ },
\]
endfunction
call ale#linter#Define('testft', {
\ 'name': 'x',
\ 'executable': 'echo',
\ 'command': 'echo',
\ 'callback': 'GenerateResults',
\})
After:
call ale#linter#Reset()
delfunction GenerateResults
unlet! g:output
Given testft(A Javscript file with warnings/errors):
foo
bar
baz
Execute:
call ale#Lint()
call ale#engine#WaitForJobs(2000)
redir => g:output
:sign place
redir END
AssertEqual
\ [
\ ['1', '1000001', 'ALEErrorSign'],
\ ['2', '1000002', 'ALEWarningSign'],
\ ['3', '1000003', 'ALEErrorSign'],
\ ],
\ map(
\ split(g:output, '\n')[2:],
\ 'matchlist(v:val, "[^=]*=\\(\\d\\+\\)[^=]*=\\(\\d\\+\\).*\\(ALE.*\\)$")[1:3]'
\ )