From 790c614b7a2360446aee6e003e3e834d21b2f04b Mon Sep 17 00:00:00 2001 From: w0rp Date: Tue, 14 Mar 2017 23:04:25 +0000 Subject: #333 Update line numbers for loclist items when current sign_id values are set --- test/sign/test_sign_parsing.vader | 23 ++++++++++--- test/sign/test_sign_placement.vader | 69 +++++++++++++++++++++++++++++++------ test/test_ale_toggle.vader | 4 +-- 3 files changed, 78 insertions(+), 18 deletions(-) (limited to 'test') diff --git a/test/sign/test_sign_parsing.vader b/test/sign/test_sign_parsing.vader index 916fb570..ee112a1b 100644 --- a/test/sign/test_sign_parsing.vader +++ b/test/sign/test_sign_parsing.vader @@ -1,14 +1,27 @@ Execute (Parsing English signs should work): - AssertEqual [[9, 1000001]], ale#sign#ParseSigns(['Signs for app.js:', ' line=9 id=1000001 name=ALEWarningSign']) + AssertEqual + \ [[9, 1000001, 'ALEWarningSign']], + \ ale#sign#ParseSigns([ + \ 'Signs for app.js:', + \ ' line=9 id=1000001 name=ALEWarningSign', + \ ]) Execute (Parsing Russian signs should work): - AssertEqual [[1, 1000001]], ale#sign#ParseSigns([' строка=1 id=1000001 имя=ALEErrorSign']) + AssertEqual + \ [[1, 1000001, 'ALEErrorSign']], + \ ale#sign#ParseSigns([' строка=1 id=1000001 имя=ALEErrorSign']) Execute (Parsing Japanese signs should work): - AssertEqual [[1, 1000001]], ale#sign#ParseSigns([' 行=1 識別子=1000001 名前=ALEWarningSign']) + AssertEqual + \ [[1, 1000001, 'ALEWarningSign']], + \ ale#sign#ParseSigns([' 行=1 識別子=1000001 名前=ALEWarningSign']) Execute (Parsing Spanish signs should work): - AssertEqual [[12, 1000001]], ale#sign#ParseSigns([' línea=12 id=1000001 nombre=ALEWarningSign']) + AssertEqual + \ [[12, 1000001, 'ALEWarningSign']], + \ ale#sign#ParseSigns([' línea=12 id=1000001 nombre=ALEWarningSign']) Execute (Parsing Italian signs should work): - AssertEqual [[1, 1000001]], ale#sign#ParseSigns([' riga=1 id=1000001, nome=ALEWarningSign']) + AssertEqual + \ [[1, 1000001, 'ALEWarningSign']], + \ ale#sign#ParseSigns([' riga=1 id=1000001, nome=ALEWarningSign']) diff --git a/test/sign/test_sign_placement.vader b/test/sign/test_sign_placement.vader index 6fa72c86..396ef5c4 100644 --- a/test/sign/test_sign_placement.vader +++ b/test/sign/test_sign_placement.vader @@ -46,6 +46,17 @@ Before: \] endfunction + function! ParseSigns() + redir => l:output + silent sign place + redir END + + return map( + \ split(l:output, '\n')[2:], + \ 'matchlist(v:val, ''^.*=\(\d\+\).*=\(\d\+\).*=\(.*\)$'')[1:3]', + \) + endfunction + call ale#linter#Define('testft', { \ 'name': 'x', \ 'executable': 'echo', @@ -54,9 +65,11 @@ Before: \}) After: - call ale#linter#Reset() + unlet! g:loclist delfunction GenerateResults - unlet! g:output + delfunction ParseSigns + call ale#linter#Reset() + sign unplace * Given testft(A file with warnings/errors): foo @@ -65,14 +78,10 @@ Given testft(A file with warnings/errors): fourth line fifth line -Execute: +Execute(The current signs should be set for running a job): call ale#Lint() call ale#engine#WaitForJobs(2000) - redir => g:output - silent sign place - redir END - AssertEqual \ [ \ ['1', '1000001', 'ALEErrorSign'], @@ -81,7 +90,45 @@ Execute: \ ['4', '1000004', 'ALEErrorSign'], \ ['5', '1000005', 'ALEErrorSign'], \ ], - \ map( - \ split(g:output, '\n')[2:], - \ 'matchlist(v:val, "[^=]*=\\(\\d\\+\\)[^=]*=\\(\\d\\+\\).*\\(ALE.*\\)$")[1:3]' - \ ) + \ ParseSigns() + + +Execute(Loclist items with sign_id values should be kept): + exec 'sign place 1000347 line=15 name=ALEErrorSign buffer=' . bufnr('%') + exec 'sign place 1000348 line=16 name=ALEWarningSign buffer=' . bufnr('%') + + let g:loclist = [ + \ {'lnum': 1, 'col': 1, 'type': 'E', 'text': 'a', 'sign_id': 1000347}, + \ {'lnum': 2, 'col': 1, 'type': 'W', 'text': 'b', 'sign_id': 1000348}, + \ {'lnum': 3, 'col': 1, 'type': 'E', 'text': 'c'}, + \ {'lnum': 4, 'col': 1, 'type': 'W', 'text': 'd'}, + \ {'lnum': 15, 'col': 2, 'type': 'W', 'text': 'e'}, + \ {'lnum': 16, 'col': 2, 'type': 'E', 'text': 'f'}, + \] + + call ale#sign#SetSigns(bufnr('%'), g:loclist) + + " Line numbers should be changed, sign_id values should be replaced, + " and items should be sorted again. + AssertEqual + \ [ + \ {'lnum': 3, 'col': 1, 'type': 'E', 'text': 'c', 'sign_id': 1000001}, + \ {'lnum': 4, 'col': 1, 'type': 'W', 'text': 'd', 'sign_id': 1000002}, + \ {'lnum': 15, 'col': 1, 'type': 'E', 'text': 'a', 'sign_id': 1000003}, + \ {'lnum': 15, 'col': 2, 'type': 'W', 'text': 'e', 'sign_id': 1000003}, + \ {'lnum': 16, 'col': 1, 'type': 'W', 'text': 'b', 'sign_id': 1000004}, + \ {'lnum': 16, 'col': 2, 'type': 'E', 'text': 'f', 'sign_id': 1000004}, + \ ], + \ g:loclist + + " Items should be grouped again. We should see error signs, where there + " were warnings before, and errors where there were errors and where we + " now have new warnings. + AssertEqual + \ [ + \ ['3', '1000001', 'ALEErrorSign'], + \ ['4', '1000002', 'ALEWarningSign'], + \ ['15', '1000003', 'ALEErrorSign'], + \ ['16', '1000004', 'ALEErrorSign'], + \ ], + \ ParseSigns() diff --git a/test/test_ale_toggle.vader b/test/test_ale_toggle.vader index 90dba401..2cd0110d 100644 --- a/test/test_ale_toggle.vader +++ b/test/test_ale_toggle.vader @@ -85,7 +85,7 @@ Execute(ALEToggle should reset everything and then run again): " First check that everything is there... AssertEqual g:expected_loclist, getloclist(0) - AssertEqual [[2, 1000001]], ale#sign#FindCurrentSigns(bufnr('%')) + AssertEqual [[2, 1000001, 'ALEErrorSign']], ale#sign#FindCurrentSigns(bufnr('%')) AssertEqual \ [{'group': 'ALEError', 'pos1': [2, 3, 1]}], \ map(getmatches(), '{''group'': v:val.group, ''pos1'': v:val.pos1}') @@ -105,7 +105,7 @@ Execute(ALEToggle should reset everything and then run again): call ale#engine#WaitForJobs(2000) AssertEqual g:expected_loclist, getloclist(0) - AssertEqual [[2, 1000001]], ale#sign#FindCurrentSigns(bufnr('%')) + AssertEqual [[2, 1000001, 'ALEErrorSign']], ale#sign#FindCurrentSigns(bufnr('%')) AssertEqual \ [{'group': 'ALEError', 'pos1': [2, 3, 1]}], \ map(getmatches(), '{''group'': v:val.group, ''pos1'': v:val.pos1}') -- cgit v1.2.3