diff options
author | w0rp <devw0rp@gmail.com> | 2020-08-18 23:03:43 +0100 |
---|---|---|
committer | w0rp <devw0rp@gmail.com> | 2020-08-18 23:03:43 +0100 |
commit | 5eda1df0a96e691ebf24e5d8a3585c2feb2a48a3 (patch) | |
tree | f6495a88666d59f44719b36276d1631d96d662aa /test | |
parent | 4df352eee585cf50edb208aea713fe1a67ac4094 (diff) | |
download | ale-5eda1df0a96e691ebf24e5d8a3585c2feb2a48a3.zip |
Remove features deprecated in previous versions
Diffstat (limited to 'test')
-rw-r--r-- | test/fix/test_ale_fix.vader | 108 | ||||
-rw-r--r-- | test/lsp/test_did_save_event.vader | 4 | ||||
-rw-r--r-- | test/lsp/test_lsp_command_formatting.vader | 4 | ||||
-rw-r--r-- | test/lsp/test_lsp_custom_request.vader | 1 | ||||
-rw-r--r-- | test/test_command_chain.vader | 73 | ||||
-rw-r--r-- | test/test_engine_invocation.vader | 108 | ||||
-rw-r--r-- | test/test_go_to_definition.vader | 2 | ||||
-rw-r--r-- | test/test_linter_defintion_processing.vader | 387 | ||||
-rw-r--r-- | test/test_temporary_file_management.vader | 2 |
9 files changed, 61 insertions, 628 deletions
diff --git a/test/fix/test_ale_fix.vader b/test/fix/test_ale_fix.vader index 6081f4e2..53079d16 100644 --- a/test/fix/test_ale_fix.vader +++ b/test/fix/test_ale_fix.vader @@ -84,56 +84,6 @@ Before: return [{'lnum': 1, 'col': 1, 'text': 'xxx'}] endfunction - function! FirstChainCallback(buffer) - return {'command': 'echo echoline', 'chain_with': 'SecondChainCallback'} - endfunction - - function! FirstChainCallbackSkipped(buffer) - let l:ChainWith = 'SecondChainCallback' - - " Test with lambdas where support is available. - if has('lambda') - let l:ChainWith = {buffer, output -> SecondChainCallback(buffer, output)} - endif - - return {'command': '', 'chain_with': l:ChainWith} - endfunction - - function! FirstChainCallbackSecondSkipped(buffer) - return {'command': 'echo skipit', 'chain_with': 'SecondChainCallback'} - endfunction - - function! SecondChainCallback(buffer, output) - let l:previous_line = empty(a:output) - \ ? 'emptydefault' - \ : join(split(a:output[0])) - - if l:previous_line is# 'skipit' - return {'command': '', 'chain_with': 'ThirdChainCallback'} - endif - - return { - \ 'command': 'echo ' . l:previous_line, - \ 'chain_with': 'ThirdChainCallback', - \} - endfunction - - function! ThirdChainCallback(buffer, output, input) - let l:previous_line = empty(a:output) - \ ? 'thirddefault' - \ : join(split(a:output[0])) - - return a:input + [l:previous_line] - endfunction - - function! ChainWhereLastIsSkipped(buffer) - return {'command': 'echo echoline', 'chain_with': 'ChainEndSkipped'} - endfunction - - function! ChainEndSkipped(buffer, output) - return {'command': ''} - endfunction - " echo will output a single blank line, and we should ingore it. function! IgnoredEmptyOutput(buffer, output) return {'command': has('win32') ? 'echo(' : 'echo'} @@ -208,13 +158,6 @@ After: delfunction RemoveLastLine delfunction RemoveLastLineOneArg delfunction TestCallback - delfunction FirstChainCallback - delfunction FirstChainCallbackSkipped - delfunction FirstChainCallbackSecondSkipped - delfunction SecondChainCallback - delfunction ThirdChainCallback - delfunction ChainWhereLastIsSkipped - delfunction ChainEndSkipped delfunction SetUpLinters delfunction GetLastMessage delfunction IgnoredEmptyOutput @@ -816,57 +759,6 @@ Execute(ALE should tolerate valid fixers with minuses in the name): ALEFix call ale#test#FlushJobs() -Execute(Test fixing with chained callbacks): - let g:ale_fixers.testft = ['FirstChainCallback'] - ALEFix - call ale#test#FlushJobs() - - " The buffer shouldn't be piped in for earlier commands in the chain. - AssertEqual - \ [ - \ string(ale#job#PrepareCommand(bufnr(''), 'echo echoline')), - \ string(ale#job#PrepareCommand(bufnr(''), 'echo echoline')), - \ ], - \ map(ale#history#Get(bufnr(''))[-2:-1], 'string(v:val.command)') - -Expect(The echoed line should be added): - a - b - c - echoline - -Execute(Test fixing with chained callback where the first command is skipped): - let g:ale_fixers.testft = ['FirstChainCallbackSkipped'] - ALEFix - call ale#test#FlushJobs() - -Expect(The default line should be added): - a - b - c - emptydefault - -Execute(Test fixing with chained callback where the second command is skipped): - let g:ale_fixers.testft = ['FirstChainCallbackSecondSkipped'] - ALEFix - call ale#test#FlushJobs() - -Expect(The default line should be added): - a - b - c - thirddefault - -Execute(Test fixing with chained callback where the final callback is skipped): - let g:ale_fixers.testft = ['ChainWhereLastIsSkipped'] - ALEFix - call ale#test#FlushJobs() - -Expect(The lines should be the same): - a - b - c - Execute(Empty output should be ignored): let g:ale_fixers.testft = ['IgnoredEmptyOutput'] ALEFix diff --git a/test/lsp/test_did_save_event.vader b/test/lsp/test_did_save_event.vader index bdea6d98..1d811363 100644 --- a/test/lsp/test_did_save_event.vader +++ b/test/lsp/test_did_save_event.vader @@ -33,8 +33,8 @@ Before: \ 'lsp': 'stdio', \ 'command': 'cat - > /dev/null', \ 'executable': has('win32') ? 'cmd' : 'echo', - \ 'language_callback': 'LanguageCallback', - \ 'project_root_callback': 'ProjectRootCallback', + \ 'language': function('LanguageCallback'), + \ 'project_root': function('ProjectRootCallback'), \ }) let g:ale_linters = {'foobar': ['dummy_linter']} diff --git a/test/lsp/test_lsp_command_formatting.vader b/test/lsp/test_lsp_command_formatting.vader index 2c1e8788..e99e1dad 100644 --- a/test/lsp/test_lsp_command_formatting.vader +++ b/test/lsp/test_lsp_command_formatting.vader @@ -24,8 +24,8 @@ Execute(Command formatting should be applied correctly for LSP linters): \ bufnr(''), \ { \ 'name': 'linter', - \ 'language_callback': {-> 'x'}, - \ 'project_root_callback': {-> '/foo/bar'}, + \ 'language': {-> 'x'}, + \ 'project_root': {-> '/foo/bar'}, \ 'lsp': 'stdio', \ 'executable': has('win32') ? 'cmd': 'true', \ 'command': '%e --foo', diff --git a/test/lsp/test_lsp_custom_request.vader b/test/lsp/test_lsp_custom_request.vader index 04f044af..c8767e59 100644 --- a/test/lsp/test_lsp_custom_request.vader +++ b/test/lsp/test_lsp_custom_request.vader @@ -25,7 +25,6 @@ Before: \ 'name': g:linter_name, \ 'project_root': {b -> g:project_root}, \ 'aliases': [], - \ 'language_callback': {b -> 'cpp'}, \ 'read_buffer': 1, \ 'command': '%e' \ }] diff --git a/test/test_command_chain.vader b/test/test_command_chain.vader deleted file mode 100644 index 329ebc97..00000000 --- a/test/test_command_chain.vader +++ /dev/null @@ -1,73 +0,0 @@ -Before: - Save &shell, g:ale_run_synchronously - let g:ale_run_synchronously = 1 - unlet! g:ale_run_synchronously_callbacks - - if !has('win32') - set shell=/bin/sh - endif - - let g:linter_output = [] - let g:first_echo_called = 0 - let g:second_echo_called = 0 - let g:final_callback_called = 0 - - function! CollectResults(buffer, output) - let g:final_callback_called = 1 - let g:linter_output = map(copy(a:output), 'join(split(v:val))') - return [] - endfunction - function! RunFirstEcho(buffer) - let g:first_echo_called = 1 - - return 'echo foo' - endfunction - function! RunSecondEcho(buffer, output) - let g:second_echo_called = 1 - - return 'echo bar' - endfunction - - call ale#linter#Define('foobar', { - \ 'name': 'testlinter', - \ 'callback': 'CollectResults', - \ 'executable': has('win32') ? 'cmd' : 'echo', - \ 'command_chain': [ - \ { - \ 'callback': 'RunFirstEcho', - \ 'output_stream': 'stdout', - \ 'read_buffer': 0, - \ }, - \ { - \ 'callback': 'RunSecondEcho', - \ 'output_stream': 'stdout', - \ 'read_buffer': 0, - \ }, - \ ], - \}) - -After: - Restore - unlet! g:ale_run_synchronously_callbacks - unlet! g:first_echo_called - unlet! g:second_echo_called - unlet! g:final_callback_called - unlet! g:linter_output - let g:ale_buffer_info = {} - call ale#linter#Reset() - delfunction CollectResults - delfunction RunFirstEcho - delfunction RunSecondEcho - -Given foobar (Some imaginary filetype): - anything - -Execute(Check the results of running the chain): - AssertEqual 'foobar', &filetype - call ale#Queue(0) - call ale#test#FlushJobs() - - Assert g:first_echo_called, 'The first chain item was not called' - Assert g:second_echo_called, 'The second chain item was not called' - Assert g:final_callback_called, 'The final callback was not called' - AssertEqual ['bar'], g:linter_output diff --git a/test/test_engine_invocation.vader b/test/test_engine_invocation.vader deleted file mode 100644 index af713953..00000000 --- a/test/test_engine_invocation.vader +++ /dev/null @@ -1,108 +0,0 @@ -Before: - function! CollectResults(buffer, output) - return [] - endfunction - - function! FirstChainFunction(buffer) - return 'first' - endfunction - - function! SecondChainFunction(buffer, output) - " We'll skip this command - return '' - endfunction - - function! ThirdChainFunction(buffer, output) - return 'third' - endfunction - - function! FourthChainFunction(buffer, output) - return 'fourth' - endfunction - - let g:linter = { - \ 'name': 'testlinter', - \ 'callback': 'CollectResults', - \ 'executable': 'echo', - \ 'command_chain': [ - \ {'callback': 'FirstChainFunction'}, - \ {'callback': 'SecondChainFunction'}, - \ {'callback': 'ThirdChainFunction'}, - \ {'callback': 'FourthChainFunction'}, - \ ], - \ 'read_buffer': 1, - \} - - function! ProcessIndex(chain_index) - let [l:command, l:options] = ale#engine#ProcessChain(347, '', g:linter, a:chain_index, []) - let l:options.command = l:command - - return l:options - endfunction - -After: - delfunction CollectResults - delfunction FirstChainFunction - delfunction SecondChainFunction - delfunction ThirdChainFunction - delfunction ProcessIndex - unlet! g:linter - unlet! g:result - -Execute(Engine invocation should return the command for the first item correctly): - let g:result = ProcessIndex(0) - - AssertEqual 'first', g:result.command - AssertEqual 1, g:result.next_chain_index - -Execute(Engine invocation should return the command for the second item correctly): - let g:result = ProcessIndex(1) - - AssertEqual 'third', g:result.command - AssertEqual 3, g:result.next_chain_index - -Execute(Engine invocation should return the command for the fourth item correctly): - let g:result = ProcessIndex(3) - - AssertEqual 'fourth', g:result.command - AssertEqual 4, g:result.next_chain_index - -Execute(Engine invocation should allow read_buffer to be enabled for a command in the middle of a chain): - let g:linter.command_chain[2].read_buffer = 1 - - let g:result = ProcessIndex(2) - - AssertEqual g:result.command, 'third' - AssertEqual g:result.read_buffer, 1 - -Execute(Engine invocation should allow read_buffer to be disabled for the end of a chain): - let g:linter.command_chain[3].read_buffer = 0 - - let g:result = ProcessIndex(3) - - AssertEqual g:result.command, 'fourth' - AssertEqual g:result.read_buffer, 0 - -Execute(Engine invocation should not use read_buffer from earlier items in a chain): - let g:linter.command_chain[1].read_buffer = 1 - - let g:result = ProcessIndex(1) - - AssertEqual g:result.command, 'third' - AssertEqual g:result.read_buffer, 0 - -Execute(Engine invocation should allow the output_stream setting to be changed in the middle of a chain): - let g:linter.command_chain[2].output_stream = 'both' - - let g:result = ProcessIndex(2) - - AssertEqual g:result.command, 'third' - AssertEqual g:result.output_stream, 'both' - -Execute(Engine invocation should not use output_stream from earlier items in a chain): - let g:linter.command_chain[1].output_stream = 'both' - - let g:result = ProcessIndex(1) - - AssertEqual g:result.command, 'third' - AssertEqual g:result.output_stream, 'stdout' diff --git a/test/test_go_to_definition.vader b/test/test_go_to_definition.vader index a517bd54..f2f34280 100644 --- a/test/test_go_to_definition.vader +++ b/test/test_go_to_definition.vader @@ -514,7 +514,7 @@ Execute(LSP tab type definition requests should be sent): let b:ale_linters = ['pyls'] call setpos('.', [bufnr(''), 1, 5, 0]) - ALEGoToTypeDefinitionInTab + ALEGoToTypeDefinition -tab " We shouldn't register the callback yet. AssertEqual '''''', string(g:Callback) diff --git a/test/test_linter_defintion_processing.vader b/test/test_linter_defintion_processing.vader index cd32ebc8..2c85299b 100644 --- a/test/test_linter_defintion_processing.vader +++ b/test/test_linter_defintion_processing.vader @@ -39,13 +39,13 @@ Execute (PreProcess should throw when then callback is not a function): \}) AssertEqual '`callback` must be defined with a callback to accept output', g:vader_exception -Execute (PreProcess should throw when there is no executable or executable_callback): +Execute (PreProcess should throw when there is no executable): AssertThrows call ale#linter#PreProcess('testft', { \ 'name': 'foo', \ 'callback': 'SomeFunction', \ 'command': 'echo', \}) - AssertEqual 'Either `executable` or `executable_callback` must be defined', g:vader_exception + AssertEqual '`executable` must be defined', g:vader_exception Execute (PreProcess should throw when executable is not a string): AssertThrows call ale#linter#PreProcess('testft', { @@ -56,15 +56,6 @@ Execute (PreProcess should throw when executable is not a string): \}) AssertEqual '`executable` must be a String or Function if defined', g:vader_exception -Execute (PreProcess should throw when executable_callback is not a callback): - AssertThrows call ale#linter#PreProcess('testft', { - \ 'name': 'foo', - \ 'callback': 'SomeFunction', - \ 'executable_callback': 123, - \ 'command': 'echo', - \}) - AssertEqual '`executable_callback` must be a callback if defined', g:vader_exception - Execute (PreProcess should allow executable to be a callback): call ale#linter#PreProcess('testft', { \ 'name': 'foo', @@ -79,7 +70,7 @@ Execute (PreProcess should throw when there is no command): \ 'callback': 'SomeFunction', \ 'executable': 'echo', \}) - AssertEqual 'Either `command`, `executable_callback`, `command_chain` must be defined', g:vader_exception + AssertEqual '`command` must be defined', g:vader_exception Execute (PreProcess should throw when command is not a string): AssertThrows call ale#linter#PreProcess('testft', { @@ -98,15 +89,6 @@ Execute (PreProcess should allow command to be a callback): \ 'command': function('type'), \}) -Execute (PreProcess should throw when command_callback is not a callback): - AssertThrows call ale#linter#PreProcess('testft', { - \ 'name': 'foo', - \ 'callback': 'SomeFunction', - \ 'executable': 'echo', - \ 'command_callback': 123, - \}) - AssertEqual '`command_callback` must be a callback if defined', g:vader_exception - Execute (PreProcess should when the output stream isn't a valid string): AssertThrows call ale#linter#PreProcess('testft', { \ 'name': 'foo', @@ -152,117 +134,12 @@ Execute (PreProcess should accept a 'both' output_stream): \ 'output_stream': 'both', \}) -Execute(PreProcess should complain if the command_chain is not a List): - let g:linter = { - \ 'name': 'x', - \ 'callback': 'x', - \ 'executable': 'x', - \ 'command_chain': 'x', - \} - AssertThrows call ale#linter#PreProcess('testft', g:linter) - AssertEqual '`command_chain` must be a List', g:vader_exception - -Execute(PreProcess should complain if the command_chain is empty): - let g:linter = { - \ 'name': 'x', - \ 'callback': 'x', - \ 'executable': 'x', - \ 'command_chain': [], - \} - AssertThrows call ale#linter#PreProcess('testft', g:linter) - AssertEqual '`command_chain` must contain at least one item', g:vader_exception - -Execute(PreProcess should complain if the command_chain has no callback): - let g:linter = { - \ 'name': 'x', - \ 'callback': 'x', - \ 'executable': 'x', - \ 'command_chain': [{}], - \} - AssertThrows call ale#linter#PreProcess('testft', g:linter) - AssertEqual 'The `command_chain` item 0 must define a `callback` function', g:vader_exception - -Execute(PreProcess should complain if the command_chain callback is not a function): - let g:linter = { - \ 'name': 'x', - \ 'callback': 'x', - \ 'executable': 'x', - \ 'command_chain': [{'callback': 2}], - \} - AssertThrows call ale#linter#PreProcess('testft', g:linter) - AssertEqual 'The `command_chain` item 0 must define a `callback` function', g:vader_exception - -Execute(PreProcess should accept a chain with one callback): - let g:linter = { - \ 'name': 'x', - \ 'callback': 'x', - \ 'executable': 'x', - \ 'command_chain': [{'callback': 'foo'}], - \} - call ale#linter#PreProcess('testft', g:linter) - -Execute(PreProcess should complain about invalid output_stream values in the chain): - let g:linter = { - \ 'name': 'x', - \ 'callback': 'x', - \ 'executable': 'x', - \ 'command_chain': [{'callback': 'foo', 'output_stream': ''}], - \} - AssertThrows call ale#linter#PreProcess('testft', g:linter) - AssertEqual "The `command_chain` item 0 `output_stream` flag must be 'stdout', 'stderr', or 'both'", g:vader_exception - -Execute(PreProcess should complain about valid output_stream values in the chain): - let g:linter = { - \ 'name': 'x', - \ 'callback': 'x', - \ 'executable': 'x', - \ 'command_chain': [{'callback': 'foo', 'output_stream': 'stdout'}], - \} - call ale#linter#PreProcess('testft', g:linter) - let g:linter.command_chain[0].output_stream = 'stderr' - call ale#linter#PreProcess('testft', g:linter) - let g:linter.command_chain[0].output_stream = 'both' - call ale#linter#PreProcess('testft', g:linter) - -Execute(PreProcess should complain about invalid chain items at higher indices): - let g:linter = { - \ 'name': 'x', - \ 'callback': 'x', - \ 'executable': 'x', - \ 'command_chain': [{'callback': 'foo'}, {'callback': 123}], - \} - AssertThrows call ale#linter#PreProcess('testft', g:linter) - AssertEqual 'The `command_chain` item 1 must define a `callback` function', g:vader_exception - -Execute(PreProcess should complain when conflicting command options are used): - let g:linter = { - \ 'name': 'x', - \ 'callback': 'x', - \ 'executable': 'x', - \ 'command': 'foo', - \ 'command_chain': [{'callback': 'foo'}], - \} - AssertThrows call ale#linter#PreProcess('testft', g:linter) - AssertEqual 'Only one of `command`, `command_callback`, or `command_chain` should be set', g:vader_exception - - unlet g:linter.command - let g:linter.command_callback = 'foo' - - AssertThrows call ale#linter#PreProcess('testft', g:linter) - AssertEqual 'Only one of `command`, `command_callback`, or `command_chain` should be set', g:vader_exception - - let g:linter.command = 'foo' - unlet g:linter.command_chain - - AssertThrows call ale#linter#PreProcess('testft', g:linter) - AssertEqual 'Only one of `command`, `command_callback`, or `command_chain` should be set', g:vader_exception - Execute(PreProcess should process the read_buffer option correctly): let g:linter = { \ 'name': 'x', \ 'callback': 'x', \ 'executable': 'x', - \ 'command_chain': [{'callback': 'foo'}, {'callback': 'bar'}], + \ 'command': 'x', \ 'read_buffer': '0', \} @@ -277,25 +154,6 @@ Execute(PreProcess should process the read_buffer option correctly): call ale#linter#PreProcess('testft', g:linter) - unlet g:linter.read_buffer - let g:linter.command_chain[0].read_buffer = '0' - - AssertThrows call ale#linter#PreProcess('testft', g:linter) - AssertEqual 'The `command_chain` item 0 value for `read_buffer` must be `0` or `1`', g:vader_exception - - let g:linter.command_chain[0].read_buffer = 0 - - call ale#linter#PreProcess('testft', g:linter) - - let g:linter.command_chain[1].read_buffer = '0' - - AssertThrows call ale#linter#PreProcess('testft', g:linter) - AssertEqual 'The `command_chain` item 1 value for `read_buffer` must be `0` or `1`', g:vader_exception - - let g:linter.command_chain[1].read_buffer = 1 - - call ale#linter#PreProcess('testft', g:linter) - Execute(PreProcess should set a default value for read_buffer): let g:linter = { \ 'name': 'x', @@ -394,151 +252,96 @@ Execute(PreProcess should accept tsserver LSP configuration): \ 'executable': 'x', \ 'command': 'x', \ 'lsp': 'tsserver', - \ 'language_callback': 'x', - \ 'project_root_callback': 'x', + \ 'language': 'x', + \ 'project_root': 'x', \} AssertEqual 'tsserver', ale#linter#PreProcess('testft', g:linter).lsp - call remove(g:linter, 'executable') - let g:linter.executable_callback = 'X' - - call ale#linter#PreProcess('testft', g:linter) - - call remove(g:linter, 'command') - let g:linter.command_callback = 'X' - - call ale#linter#PreProcess('testft', g:linter) - Execute(PreProcess should accept stdio LSP configuration): let g:linter = { \ 'name': 'x', \ 'executable': 'x', \ 'command': 'x', \ 'lsp': 'stdio', - \ 'language_callback': 'x', - \ 'project_root_callback': 'x', + \ 'language': 'x', + \ 'project_root': 'x', \} AssertEqual 'stdio', ale#linter#PreProcess('testft', g:linter).lsp - call remove(g:linter, 'executable') - let g:linter.executable_callback = 'X' - - call ale#linter#PreProcess('testft', g:linter) - - call remove(g:linter, 'command') - let g:linter.command_callback = 'X' - - call ale#linter#PreProcess('testft', g:linter) - Execute(PreProcess should accept LSP server configurations): let g:linter = { \ 'name': 'x', \ 'lsp': 'socket', - \ 'address_callback': 'X', - \ 'language_callback': 'x', - \ 'project_root_callback': 'x', - \} - - AssertEqual 'socket', ale#linter#PreProcess('testft', g:linter).lsp - -Execute(PreProcess should accept let you specify the language as just a string): - let g:linter = { - \ 'name': 'x', - \ 'lsp': 'socket', - \ 'address_callback': 'X', + \ 'address': 'X', \ 'language': 'foobar', - \ 'project_root_callback': 'x', + \ 'project_root': 'x', \} - AssertEqual 'foobar', ale#linter#PreProcess('testft', g:linter).language_callback(0) + AssertEqual 'socket', ale#linter#PreProcess('testft', g:linter).lsp -Execute(PreProcess should complain about using language and language_callback together): +Execute(PreProcess should accept let you specify the `language` as a Function): let g:linter = { \ 'name': 'x', \ 'lsp': 'socket', - \ 'address_callback': 'X', - \ 'language': 'x', - \ 'language_callback': 'x', - \ 'project_root_callback': 'x', + \ 'address': 'X', + \ 'language': {-> 'foobar'}, + \ 'project_root': 'x', \} - AssertThrows call ale#linter#PreProcess('testft', g:linter) - AssertEqual 'Only one of `language` or `language_callback` should be set', g:vader_exception + AssertEqual 'foobar', ale#linter#PreProcess('testft', g:linter).language(bufnr('')) Execute(PreProcess should complain about invalid language values): let g:linter = { \ 'name': 'x', \ 'lsp': 'socket', - \ 'address_callback': 'X', + \ 'address': 'X', \ 'language': 0, - \ 'project_root_callback': 'x', + \ 'project_root': 'x', \} AssertThrows call ale#linter#PreProcess('testft', g:linter) - AssertEqual '`language` must be a String or Funcref', g:vader_exception + AssertEqual '`language` must be a String or Funcref if defined', g:vader_exception Execute(PreProcess should use the filetype as the language string by default): let g:linter = { \ 'name': 'x', \ 'lsp': 'socket', - \ 'address_callback': 'X', - \ 'project_root_callback': 'x', - \} - - AssertEqual 'testft', ale#linter#PreProcess('testft', g:linter).language_callback(0) - -Execute(PreProcess should allow language to be set to a callback): - let g:linter = { - \ 'name': 'x', - \ 'lsp': 'socket', - \ 'address_callback': 'X', - \ 'language': {-> 'foo'}, - \ 'project_root_callback': 'x', + \ 'address': 'X', + \ 'project_root': 'x', \} - AssertEqual 'foo', ale#linter#PreProcess('testft', g:linter).language_callback(0) + AssertEqual 'testft', ale#linter#PreProcess('testft', g:linter).language -Execute(PreProcess should require an address_callback for LSP socket configurations): +Execute(PreProcess should require an `address` for LSP socket configurations): let g:linter = { \ 'name': 'x', \ 'lsp': 'socket', \} AssertThrows call ale#linter#PreProcess('testft', g:linter) - AssertEqual '`address` or `address_callback` must be defined for getting the LSP address', g:vader_exception + AssertEqual '`address` must be defined for getting the LSP address', g:vader_exception -Execute(PreProcess should complain about address_callback for non-LSP linters): +Execute(PreProcess should complain about `address` for non-LSP linters): let g:linter = { \ 'name': 'x', \ 'callback': 'SomeFunction', \ 'executable': 'echo', \ 'command': 'echo', - \ 'address_callback': 'X', + \ 'address': 'X', \} AssertThrows call ale#linter#PreProcess('testft', g:linter) - AssertEqual '`address` or `address_callback` cannot be used when lsp != ''socket''', g:vader_exception + AssertEqual '`address` cannot be used when lsp != ''socket''', g:vader_exception -Execute(PreProcess accept valid address_callback values): - let g:linter = ale#linter#PreProcess('testft', { - \ 'name': 'x', - \ 'lsp': 'socket', - \ 'address_callback': {-> 'foo:123'}, - \ 'language': 'x', - \ 'project_root_callback': 'x', - \}) - - AssertEqual 'foo:123', ale#linter#GetAddress(0, g:linter) - -Execute(PreProcess accept address as a String): +Execute(PreProcess accept `address` as a String): let g:linter = ale#linter#PreProcess('testft', { \ 'name': 'x', \ 'lsp': 'socket', \ 'address': 'foo:123', \ 'language': 'x', - \ 'project_root_callback': 'x', + \ 'project_root': 'x', \}) AssertEqual 'foo:123', ale#linter#GetAddress(0, g:linter) @@ -549,7 +352,7 @@ Execute(PreProcess accept address as a Function): \ 'lsp': 'socket', \ 'address': {-> 'foo:123'}, \ 'language': 'x', - \ 'project_root_callback': 'x', + \ 'project_root': 'x', \}) AssertEqual 'foo:123', ale#linter#GetAddress(0, g:linter) @@ -560,11 +363,11 @@ Execute(PreProcess should complain about invalid address values): \ 'lsp': 'socket', \ 'address': 0, \ 'language': 'x', - \ 'project_root_callback': 'x', + \ 'project_root': 'x', \}) AssertEqual '`address` must be a String or Function if defined', g:vader_exception -Execute(PreProcess should accept allow the project root be set as a String): +Execute(PreProcess should allow the `project_root` to be set as a String): let g:linter = ale#linter#PreProcess('testft', { \ 'name': 'x', \ 'lsp': 'socket', @@ -575,7 +378,7 @@ Execute(PreProcess should accept allow the project root be set as a String): AssertEqual '/foo/bar', ale#lsp_linter#FindProjectRoot(0, g:linter) -Execute(PreProcess should accept allow the project root be set as a Function): +Execute(PreProcess should `project_root` be set as a Function): let g:linter = ale#linter#PreProcess('testft', { \ 'name': 'x', \ 'lsp': 'socket', @@ -586,7 +389,7 @@ Execute(PreProcess should accept allow the project root be set as a Function): AssertEqual '/foo/bar', ale#lsp_linter#FindProjectRoot(0, g:linter) -Execute(PreProcess should complain when the project_root valid is invalid): +Execute(PreProcess should complain when `project_root` is invalid): AssertThrows call ale#linter#PreProcess('testft', { \ 'name': 'x', \ 'lsp': 'socket', @@ -594,154 +397,74 @@ Execute(PreProcess should complain when the project_root valid is invalid): \ 'language': 'x', \ 'project_root': 0, \}) - AssertEqual '`project_root` must be a String or Function if defined', g:vader_exception + AssertEqual '`project_root` must be a String or Function', g:vader_exception -Execute(PreProcess should accept project_root_callback as a String): - call ale#linter#PreProcess('testft', { - \ 'name': 'x', - \ 'lsp': 'socket', - \ 'address': 'foo:123', - \ 'language': 'x', - \ 'project_root_callback': 'Foobar', - \}) - -Execute(PreProcess should accept project_root_callback as a Function): - let g:linter = ale#linter#PreProcess('testft', { - \ 'name': 'x', - \ 'lsp': 'socket', - \ 'address': 'foo:123', - \ 'language': 'x', - \ 'project_root_callback': {-> '/foo/bar'}, - \}) - - AssertEqual '/foo/bar', ale#lsp_linter#FindProjectRoot(0, g:linter) - -Execute(PreProcess should complain when the project_root_callback valid is invalid): - AssertThrows call ale#linter#PreProcess('testft', { - \ 'name': 'x', - \ 'lsp': 'socket', - \ 'address': 'foo:123', - \ 'language': 'x', - \ 'project_root_callback': 0, - \}) - AssertEqual '`project_root_callback` must be a callback if defined', g:vader_exception - -Execute(PreProcess should complain about using initialization_options and initialization_options_callback together): - let g:linter = { - \ 'name': 'x', - \ 'lsp': 'socket', - \ 'address_callback': 'X', - \ 'language': 'x', - \ 'project_root_callback': 'x', - \ 'initialization_options': 'x', - \ 'initialization_options_callback': 'x', - \} - - AssertThrows call ale#linter#PreProcess('testft', g:linter) - AssertEqual 'Only one of `initialization_options` or `initialization_options_callback` should be set', g:vader_exception - -Execute(PreProcess should throw when initialization_options_callback is not a callback): - AssertThrows call ale#linter#PreProcess('testft', { - \ 'name': 'foo', - \ 'lsp': 'socket', - \ 'address_callback': 'X', - \ 'language': 'x', - \ 'project_root_callback': 'x', - \ 'initialization_options_callback': {}, - \}) - AssertEqual '`initialization_options_callback` must be a callback if defined', g:vader_exception - -Execute(PreProcess should throw when initialization_options is not a Dictionary or callback): +Execute(PreProcess should throw when `initialization_options` is not a Dictionary or callback): AssertThrows call ale#linter#PreProcess('testft', { \ 'name': 'foo', \ 'lsp': 'socket', - \ 'address_callback': 'X', + \ 'address': 'X', \ 'language': 'x', - \ 'project_root_callback': 'x', + \ 'project_root': 'x', \ 'initialization_options': 0, \}) - AssertEqual '`initialization_options` must be a String or Function if defined', g:vader_exception + AssertEqual '`initialization_options` must be a Dictionary or Function if defined', g:vader_exception -Execute(PreProcess should accept initialization_options as a Dictionary): +Execute(PreProcess should accept `initialization_options` as a Dictionary): let g:linter = ale#linter#PreProcess('testft', { \ 'name': 'foo', \ 'lsp': 'socket', - \ 'address_callback': 'X', + \ 'address': 'X', \ 'language': 'x', - \ 'project_root_callback': 'x', + \ 'project_root': 'x', \ 'initialization_options': {'foo': v:true}, \}) AssertEqual {'foo': v:true}, ale#lsp_linter#GetOptions(0, g:linter) -Execute(PreProcess should accept initialization_options as a Funcref): +Execute(PreProcess should accept `initialization_options` as a Function): let g:linter = ale#linter#PreProcess('testft', { \ 'name': 'foo', \ 'lsp': 'socket', - \ 'address_callback': 'X', + \ 'address': 'X', \ 'language': 'x', - \ 'project_root_callback': 'x', + \ 'project_root': 'x', \ 'initialization_options': {-> {'foo': v:true}}, \}) AssertEqual {'foo': v:true}, ale#lsp_linter#GetOptions(0, g:linter) -Execute(PreProcess should complain about using lsp_config and lsp_config_callback together): +Execute(PreProcess should accept `lsp_config` as a Dictionary): let g:linter = { \ 'name': 'x', \ 'lsp': 'socket', - \ 'address_callback': 'X', + \ 'address': 'X', \ 'language': 'x', - \ 'project_root_callback': 'x', - \ 'lsp_config': 'x', - \ 'lsp_config_callback': 'x', - \} - - AssertThrows call ale#linter#PreProcess('testft', g:linter) - AssertEqual 'Only one of `lsp_config` or `lsp_config_callback` should be set', g:vader_exception - -Execute(PreProcess should throw when lsp_config_callback is not a callback): - AssertThrows call ale#linter#PreProcess('testft', { - \ 'name': 'foo', - \ 'lsp': 'socket', - \ 'address_callback': 'X', - \ 'language': 'x', - \ 'project_root_callback': 'x', - \ 'lsp_config_callback': {}, - \}) - AssertEqual '`lsp_config_callback` must be a callback if defined', g:vader_exception - -Execute(PreProcess should accept LSP configuration options via lsp_config): - let g:linter = { - \ 'name': 'x', - \ 'lsp': 'socket', - \ 'address_callback': 'X', - \ 'language_callback': 'x', - \ 'project_root_callback': 'x', + \ 'project_root': 'x', \ 'lsp_config': {'foo': 'bar'}, \} AssertEqual {'foo': 'bar'}, ale#lsp_linter#GetConfig(0, g:linter) -Execute(PreProcess should accept LSP configuration options via lsp_config as a function): +Execute(PreProcess should accept `lsp_config` as a Function): let g:linter = { \ 'name': 'x', \ 'lsp': 'socket', - \ 'address_callback': 'X', - \ 'language_callback': 'x', - \ 'project_root_callback': 'x', + \ 'address': 'X', + \ 'language': 'x', + \ 'project_root': 'x', \ 'lsp_config': {-> {'foo': 'bar'}}, \} AssertEqual {'foo': 'bar'}, ale#lsp_linter#GetConfig(0, g:linter) -Execute(PreProcess should throw when lsp_config is not a Dictionary or Function): +Execute(PreProcess should throw when `lsp_config` is not a Dictionary or Function): AssertThrows call ale#linter#PreProcess('testft', { \ 'name': 'foo', \ 'lsp': 'socket', - \ 'address_callback': 'X', + \ 'address': 'X', \ 'language': 'x', - \ 'project_root_callback': 'x', + \ 'project_root': 'x', \ 'lsp_config': 'x', \}) AssertEqual '`lsp_config` must be a Dictionary or Function if defined', g:vader_exception diff --git a/test/test_temporary_file_management.vader b/test/test_temporary_file_management.vader index 9fff1ace..bb735886 100644 --- a/test/test_temporary_file_management.vader +++ b/test/test_temporary_file_management.vader @@ -40,7 +40,7 @@ Before: \ 'name': 'testlinter', \ 'executable': has('win32') ? 'cmd' : 'echo', \ 'callback': 'TestCallback', - \ 'command_callback': 'TestCommandCallback', + \ 'command': function('TestCommandCallback'), \}) call ale#command#ClearData() |