mirror of
https://github.com/dense-analysis/ale.git
synced 2026-02-17 15:34:14 +08:00
Suggest functions for fixing issues for ALEFix
This commit is contained in:
@@ -53,7 +53,7 @@ Given testft (A file with three lines):
|
||||
|
||||
Execute(ALEFix should complain when there are no functions to call):
|
||||
AssertThrows ALEFix
|
||||
AssertEqual 'Vim(echoerr):No fixers have been defined for filetype: testft', g:vader_exception
|
||||
AssertEqual 'Vim(echoerr):No fixers have been defined. Try :ALEFixSuggest', g:vader_exception
|
||||
|
||||
Execute(ALEFix should apply simple functions):
|
||||
let g:ale_fixers.testft = ['AddCarets']
|
||||
|
||||
75
test/test_ale_fix_suggest.vader
Normal file
75
test/test_ale_fix_suggest.vader
Normal file
@@ -0,0 +1,75 @@
|
||||
Before:
|
||||
call ale#fix#registry#Clear()
|
||||
|
||||
function GetSuggestions()
|
||||
redir => l:output
|
||||
silent ALEFixSuggest
|
||||
redir END
|
||||
|
||||
return split(l:output, "\n")
|
||||
endfunction
|
||||
|
||||
After:
|
||||
call ale#fix#registry#ResetToDefaults()
|
||||
delfunction GetSuggestions
|
||||
|
||||
Execute(ALEFixSuggest should return something sensible with no suggestions):
|
||||
AssertEqual
|
||||
\ [
|
||||
\ 'There is nothing in the registry to suggest.',
|
||||
\ ],
|
||||
\ GetSuggestions()
|
||||
|
||||
Execute(ALEFixSuggest output should be correct for only generic handlers):
|
||||
call ale#fix#registry#Add('zed', 'XYZ', [], 'Zedify things.')
|
||||
call ale#fix#registry#Add('alpha', 'XYZ', [], 'Alpha things.')
|
||||
|
||||
AssertEqual
|
||||
\ [
|
||||
\ 'Try the following generic fixers:',
|
||||
\ '',
|
||||
\ '''alpha'' - Alpha things.',
|
||||
\ '''zed'' - Zedify things.',
|
||||
\ '',
|
||||
\ 'See :help ale-fix-configuration',
|
||||
\ ],
|
||||
\ GetSuggestions()
|
||||
|
||||
Execute(ALEFixSuggest output should be correct for only filetype handlers):
|
||||
let &filetype = 'testft2.testft'
|
||||
|
||||
call ale#fix#registry#Add('zed', 'XYZ', ['testft2'], 'Zedify things.')
|
||||
call ale#fix#registry#Add('alpha', 'XYZ', ['testft'], 'Alpha things.')
|
||||
|
||||
AssertEqual
|
||||
\ [
|
||||
\ 'Try the following fixers appropriate for the filetype:',
|
||||
\ '',
|
||||
\ '''alpha'' - Alpha things.',
|
||||
\ '''zed'' - Zedify things.',
|
||||
\ '',
|
||||
\ 'See :help ale-fix-configuration',
|
||||
\ ],
|
||||
\ GetSuggestions()
|
||||
|
||||
Execute(ALEFixSuggest should suggest filetype and generic handlers):
|
||||
let &filetype = 'testft2.testft'
|
||||
|
||||
call ale#fix#registry#Add('zed', 'XYZ', ['testft2'], 'Zedify things.')
|
||||
call ale#fix#registry#Add('alpha', 'XYZ', ['testft'], 'Alpha things.')
|
||||
call ale#fix#registry#Add('generic', 'XYZ', [], 'Generic things.')
|
||||
|
||||
AssertEqual
|
||||
\ [
|
||||
\ 'Try the following fixers appropriate for the filetype:',
|
||||
\ '',
|
||||
\ '''alpha'' - Alpha things.',
|
||||
\ '''zed'' - Zedify things.',
|
||||
\ '',
|
||||
\ 'Try the following generic fixers:',
|
||||
\ '',
|
||||
\ '''generic'' - Generic things.',
|
||||
\ '',
|
||||
\ 'See :help ale-fix-configuration',
|
||||
\ ],
|
||||
\ GetSuggestions()
|
||||
Reference in New Issue
Block a user