summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorpetpetpetpet <34608655+petpetpetpet@users.noreply.github.com>2019-01-27 12:44:49 +0000
committerw0rp <w0rp@users.noreply.github.com>2019-01-27 12:44:49 +0000
commit3c38fdb1bb3625bcb222cfce16acd7db360ef413 (patch)
treea3953cca25d568a0cf4f39091a75b187812c47e6 /test
parenta7b3b84899ba8752b4db91aff3b9a1b7a7a6fd83 (diff)
downloadale-3c38fdb1bb3625bcb222cfce16acd7db360ef413.zip
Extend statusline interface (#2240)
* Extended statusline.vim to provide an efficient way to access the first errors,warnings,stylerrors,stylewarnings,etc from the loclist. * Added documentation and help for the new API function.
Diffstat (limited to 'test')
-rw-r--r--test/test_statusline.vader95
1 files changed, 76 insertions, 19 deletions
diff --git a/test/test_statusline.vader b/test/test_statusline.vader
index d928e7ee..f76cbfa9 100644
--- a/test/test_statusline.vader
+++ b/test/test_statusline.vader
@@ -28,25 +28,9 @@ Before:
return l:res
endfunction
-After:
- Restore
-
- delfunction Counts
-
-Execute (Count should be 0 when data is empty):
- AssertEqual Counts({}), ale#statusline#Count(bufnr(''))
-
-Execute (Count should read data from the cache):
- let g:ale_buffer_info = {'44': {'count': Counts({'error': 1, 'warning': 2})}}
- AssertEqual Counts({'error': 1, 'warning': 2}), ale#statusline#Count(44)
-
-Execute (The count should be correct after an update):
- let g:ale_buffer_info = {'44': {}}
- call ale#statusline#Update(44, [])
- AssertEqual Counts({}), ale#statusline#Count(44)
-
-Execute (Count should be match the loclist):
- let g:ale_buffer_info = {
+ " A test simplified loclist that will be used for some of the
+ " tests in this module.
+ let g:test_buffer_info = {
\ bufnr(''): {
\ 'loclist': [
\ {'bufnr': bufnr('') - 1, 'type': 'E'},
@@ -77,6 +61,61 @@ Execute (Count should be match the loclist):
\ ],
\ },
\}
+After:
+ Restore
+
+ delfunction Counts
+ unlet g:test_buffer_info
+
+Execute (Count should be 0 when data is empty):
+ AssertEqual Counts({}), ale#statusline#Count(bufnr(''))
+
+Execute (FirstProblem should be 0 when data is empty):
+ AssertEqual {}, ale#statusline#FirstProblem(bufnr(''), 'error')
+ AssertEqual {}, ale#statusline#FirstProblem(bufnr(''), 'warning')
+ AssertEqual {}, ale#statusline#FirstProblem(bufnr(''), 'style_error')
+ AssertEqual {}, ale#statusline#FirstProblem(bufnr(''), 'style_warning')
+ AssertEqual {}, ale#statusline#FirstProblem(bufnr(''), 'info')
+
+Execute (Count should read data from the cache):
+ let g:ale_buffer_info = {'44': {'count': Counts({'error': 1, 'warning': 2})}}
+ AssertEqual Counts({'error': 1, 'warning': 2}), ale#statusline#Count(44)
+
+Execute (FirstProblem should read data from the cache):
+ let g:ale_buffer_info =
+ \{"44":
+ \{'count': 0,
+ \'first_problems':
+ \{'error': {'lnum': 3},
+ \'warning': {'lnum': 44},
+ \'style_error': {'lnum': 22},
+ \'style_warning': {'lnum': 223},
+ \'info': {'lnum': 2}
+ \}
+ \}
+ \}
+ AssertEqual {'lnum': 3}, ale#statusline#FirstProblem(44, 'error')
+ AssertEqual {'lnum': 44}, ale#statusline#FirstProblem(44, 'warning')
+ AssertEqual {'lnum': 223}, ale#statusline#FirstProblem(44, 'style_warning')
+ AssertEqual {'lnum': 22}, ale#statusline#FirstProblem(44, 'style_error')
+ AssertEqual {'lnum': 2}, ale#statusline#FirstProblem(44, 'info')
+
+Execute (The count should be correct after an update):
+ let g:ale_buffer_info = {'44': {}}
+ call ale#statusline#Update(44, [])
+ AssertEqual Counts({}), ale#statusline#Count(44)
+
+Execute (FirstProblem should be correct after an update):
+ let g:ale_buffer_info = {'44': {}}
+ call ale#statusline#Update(44, [])
+ AssertEqual {}, ale#statusline#FirstProblem(bufnr(''), 'error')
+ AssertEqual {}, ale#statusline#FirstProblem(bufnr(''), 'warning')
+ AssertEqual {}, ale#statusline#FirstProblem(bufnr(''), 'style_error')
+ AssertEqual {}, ale#statusline#FirstProblem(bufnr(''), 'style_warning')
+ AssertEqual {}, ale#statusline#FirstProblem(bufnr(''), 'info')
+
+Execute (Count should match the loclist):
+ let g:ale_buffer_info = g:test_buffer_info
AssertEqual {
\ 'error': 1,
\ 'style_error': 2,
@@ -88,8 +127,22 @@ Execute (Count should be match the loclist):
\ 'total': 15,
\}, ale#statusline#Count(bufnr(''))
+Execute (FirstProblem should pull the first matching value from the loclist):
+ let g:ale_buffer_info = g:test_buffer_info
+ AssertEqual {'bufnr': bufnr(''), 'type': 'E'}, ale#statusline#FirstProblem(bufnr(''), 'error')
+ AssertEqual {'bufnr': bufnr(''), 'type': 'W'}, ale#statusline#FirstProblem(bufnr(''), 'warning')
+ AssertEqual {'bufnr': bufnr(''), 'type': 'E', 'sub_type': 'style'}, ale#statusline#FirstProblem(bufnr(''), 'style_error')
+ AssertEqual {'bufnr': bufnr(''), 'type': 'W', 'sub_type': 'style'}, ale#statusline#FirstProblem(bufnr(''), 'style_warning')
+ AssertEqual {'bufnr': bufnr(''), 'type': 'I'}, ale#statusline#FirstProblem(bufnr(''), 'info')
+
Execute (Output should be empty for non-existent buffer):
+ let g:ale_buffer_info = g:test_buffer_info
AssertEqual Counts({}), ale#statusline#Count(9001)
+ AssertEqual {}, ale#statusline#FirstProblem(9001, 'error')
+ AssertEqual {}, ale#statusline#FirstProblem(9001, 'warning')
+ AssertEqual {}, ale#statusline#FirstProblem(9001, 'style_error')
+ AssertEqual {}, ale#statusline#FirstProblem(9001, 'style_warning')
+ AssertEqual {}, ale#statusline#FirstProblem(9001, 'info')
Execute(ale#statusline#Update shouldn't blow up when globals are undefined):
unlet! g:ale_statusline_format
@@ -98,3 +151,7 @@ Execute(ale#statusline#Update shouldn't blow up when globals are undefined):
Execute(ale#statusline#Count should return 0 counts when globals are undefined):
unlet! g:ale_statusline_format
AssertEqual Counts({}), ale#statusline#Count(1)
+
+Execute(FirstProblem should return an empty dict when globals are undefined):
+ unlet! g:ale_statusline_format
+ AssertEqual {}, ale#statusline#FirstProblem(bufnr(''), 'info')