diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/completion/test_lsp_completion_messages.vader | 30 | ||||
-rw-r--r-- | test/lsp/test_did_save_event.vader | 10 | ||||
-rw-r--r-- | test/lsp/test_lsp_command_formatting.vader | 1 | ||||
-rw-r--r-- | test/lsp/test_other_initialize_message_handling.vader | 2 | ||||
-rw-r--r-- | test/test_find_references.vader | 32 | ||||
-rw-r--r-- | test/test_go_to_definition.vader | 52 | ||||
-rw-r--r-- | test/test_symbol_search.vader | 24 |
7 files changed, 84 insertions, 67 deletions
diff --git a/test/completion/test_lsp_completion_messages.vader b/test/completion/test_lsp_completion_messages.vader index 130f31b9..35b167b6 100644 --- a/test/completion/test_lsp_completion_messages.vader +++ b/test/completion/test_lsp_completion_messages.vader @@ -16,18 +16,20 @@ Before: let g:capability_checked = '' let g:conn_id = v:null let g:Callback = '' - let g:wait_callback_list = [] + let g:init_callback_list = [] - function! ale#lsp_linter#StartLSP(buffer, linter) abort + function! ale#lsp_linter#StartLSP(buffer, linter, Callback) abort let g:conn_id = ale#lsp#Register('executable', '/foo/bar', {}) call ale#lsp#MarkDocumentAsOpen(g:conn_id, a:buffer) - return { + let l:details = { \ 'buffer': a:buffer, \ 'connection_id': g:conn_id, \ 'project_root': '/foo/bar', \ 'language_id': 'python', \} + + call add(g:init_callback_list, {-> a:Callback(a:linter, l:details)}) endfunction " Pretend we're in insert mode for most tests. @@ -35,9 +37,10 @@ Before: return 'i' endfunction - function! ale#lsp#WaitForCapability(conn_id, capability, callback) abort + function! ale#lsp#HasCapability(conn_id, capability) abort let g:capability_checked = a:capability - call add(g:wait_callback_list, a:callback) + + return 1 endfunction function! ale#lsp#RegisterCallback(conn_id, callback) abort @@ -60,7 +63,7 @@ After: unlet! g:message_list unlet! g:capability_checked - unlet! g:wait_callback_list + unlet! g:init_callback_list unlet! g:conn_id unlet! g:Callback unlet! b:ale_old_omnifunc @@ -104,9 +107,10 @@ Execute(The right message should be sent for the initial tsserver request): " We shouldn't register the callback yet. AssertEqual '''''', string(g:Callback) - AssertEqual 1, len(g:wait_callback_list) + AssertEqual 1, len(g:init_callback_list) + call map(g:init_callback_list, 'v:val()') + AssertEqual 'completion', g:capability_checked - call map(g:wait_callback_list, 'v:val([g:conn_id, ''/foo/bar''])') " We should send the right callback. AssertEqual @@ -191,9 +195,10 @@ Execute(The right message should be sent for the initial LSP request): " We shouldn't register the callback yet. AssertEqual '''''', string(g:Callback) - AssertEqual 1, len(g:wait_callback_list) + AssertEqual 1, len(g:init_callback_list) + call map(g:init_callback_list, 'v:val()') + AssertEqual 'completion', g:capability_checked - call map(g:wait_callback_list, 'v:val([g:conn_id, ''/foo/bar''])') " We should send the right callback. AssertEqual @@ -258,9 +263,10 @@ Execute(Two completion requests shouldn't be sent in a row): " We shouldn't register the callback yet. AssertEqual '''''', string(g:Callback) - AssertEqual 2, len(g:wait_callback_list) + AssertEqual 2, len(g:init_callback_list) + call map(g:init_callback_list, 'v:val()') + AssertEqual 'completion', g:capability_checked - call map(g:wait_callback_list, 'v:val([347, ''/foo/bar''])') " We should only send one completion message for two LSP servers. AssertEqual diff --git a/test/lsp/test_did_save_event.vader b/test/lsp/test_did_save_event.vader index f8ff8f70..1d6065ec 100644 --- a/test/lsp/test_did_save_event.vader +++ b/test/lsp/test_did_save_event.vader @@ -34,16 +34,19 @@ Before: \ }) let g:ale_linters = {'foobar': ['dummy_linter']} - function! ale#lsp_linter#StartLSP(buffer, linter) abort + function! ale#lsp_linter#StartLSP(buffer, linter, Callback) abort let g:conn_id = ale#lsp#Register('executable', '/foo/bar', {}) call ale#lsp#MarkDocumentAsOpen(g:conn_id, a:buffer) - - return { + let l:details = { \ 'buffer': a:buffer, \ 'connection_id': g:conn_id, \ 'project_root': '/foo/bar', \ 'language_id': 'foobar', \} + + call a:Callback(a:linter, l:details) + + return 1 endfunction " Replace the Send function for LSP, so we can monitor calls to it. @@ -61,6 +64,7 @@ After: unlet! b:ale_enabled unlet! b:ale_linters unlet! g:message_list + unlet! b:ale_save_event_fired delfunction LanguageCallback delfunction ProjectRootCallback diff --git a/test/lsp/test_lsp_command_formatting.vader b/test/lsp/test_lsp_command_formatting.vader index fcd4f78c..ec3b4120 100644 --- a/test/lsp/test_lsp_command_formatting.vader +++ b/test/lsp/test_lsp_command_formatting.vader @@ -24,6 +24,7 @@ Execute(Command formatting should be applied correctly for LSP linters): \ 'executable': has('win32') ? 'cmd': 'true', \ 'command': '%e --foo', \ }, + \ {-> 0} \) if has('win32') diff --git a/test/lsp/test_other_initialize_message_handling.vader b/test/lsp/test_other_initialize_message_handling.vader index 2f59535d..8ae63e91 100644 --- a/test/lsp/test_other_initialize_message_handling.vader +++ b/test/lsp/test_other_initialize_message_handling.vader @@ -10,7 +10,7 @@ Before: \ 'config': {}, \ 'callback_list': [], \ 'message_queue': [], - \ 'capabilities_queue': [], + \ 'init_queue': [], \ 'capabilities': { \ 'hover': 0, \ 'references': 0, diff --git a/test/test_find_references.vader b/test/test_find_references.vader index d31424ef..078333bb 100644 --- a/test/test_find_references.vader +++ b/test/test_find_references.vader @@ -11,28 +11,30 @@ Before: let g:options = {} let g:capability_checked = '' let g:conn_id = v:null - let g:WaitCallback = v:null + let g:InitCallback = v:null runtime autoload/ale/linter.vim runtime autoload/ale/lsp.vim runtime autoload/ale/util.vim runtime autoload/ale/preview.vim - function! ale#lsp_linter#StartLSP(buffer, linter) abort + function! ale#lsp_linter#StartLSP(buffer, linter, Callback) abort let g:conn_id = ale#lsp#Register('executable', '/foo/bar', {}) call ale#lsp#MarkDocumentAsOpen(g:conn_id, a:buffer) - - return { + let l:details = { \ 'buffer': a:buffer, \ 'connection_id': g:conn_id, \ 'project_root': '/foo/bar', \ 'language_id': 'python', \} + + let g:InitCallback = {-> a:Callback(a:linter, l:details)} endfunction - function! ale#lsp#WaitForCapability(conn_id, capability, callback) abort + function! ale#lsp#HasCapability(conn_id, capability) abort let g:capability_checked = a:capability - let g:WaitCallback = a:callback + + return 1 endfunction function! ale#lsp#RegisterCallback(conn_id, callback) abort @@ -65,7 +67,7 @@ After: call ale#linter#Reset() unlet! g:capability_checked - unlet! g:WaitCallback + unlet! g:InitCallback unlet! g:old_filename unlet! g:conn_id unlet! g:Callback @@ -173,10 +175,10 @@ Execute(tsserver reference requests should be sent): " We shouldn't register the callback yet. AssertEqual '''''', string(g:Callback) - AssertEqual type(function('type')), type(g:WaitCallback) - AssertEqual 'references', g:capability_checked - call call(g:WaitCallback, [g:conn_id, '/foo/bar']) + AssertEqual type(function('type')), type(g:InitCallback) + call g:InitCallback() + AssertEqual 'references', g:capability_checked AssertEqual \ 'function(''ale#references#HandleTSServerResponse'')', \ string(g:Callback) @@ -191,7 +193,7 @@ Execute('-relative' argument should enable 'use_relative_paths' in HandleTSServe ALEFindReferences -relative - call call(g:WaitCallback, [g:conn_id, '/foo/bar']) + call g:InitCallback() AssertEqual {'42': {'use_relative_paths': 1}}, ale#references#GetMap() @@ -264,10 +266,10 @@ Execute(LSP reference requests should be sent): " We shouldn't register the callback yet. AssertEqual '''''', string(g:Callback) - AssertEqual type(function('type')), type(g:WaitCallback) - AssertEqual 'references', g:capability_checked - call call(g:WaitCallback, [g:conn_id, '/foo/bar']) + AssertEqual type(function('type')), type(g:InitCallback) + call g:InitCallback() + AssertEqual 'references', g:capability_checked AssertEqual \ 'function(''ale#references#HandleLSPResponse'')', \ string(g:Callback) @@ -298,6 +300,6 @@ Execute('-relative' argument should enable 'use_relative_paths' in HandleLSPResp ALEFindReferences -relative - call call(g:WaitCallback, [g:conn_id, '/foo/bar']) + call g:InitCallback() AssertEqual {'42': {'use_relative_paths': 1}}, ale#references#GetMap() diff --git a/test/test_go_to_definition.vader b/test/test_go_to_definition.vader index 3cc2a58c..880d7123 100644 --- a/test/test_go_to_definition.vader +++ b/test/test_go_to_definition.vader @@ -8,27 +8,29 @@ Before: let g:expr_list = [] let g:capability_checked = '' let g:conn_id = v:null - let g:WaitCallback = v:null + let g:InitCallback = v:null runtime autoload/ale/linter.vim runtime autoload/ale/lsp.vim runtime autoload/ale/util.vim - function! ale#lsp_linter#StartLSP(buffer, linter) abort + function! ale#lsp_linter#StartLSP(buffer, linter, Callback) abort let g:conn_id = ale#lsp#Register('executable', '/foo/bar', {}) call ale#lsp#MarkDocumentAsOpen(g:conn_id, a:buffer) - - return { + let l:details = { \ 'buffer': a:buffer, \ 'connection_id': g:conn_id, \ 'project_root': '/foo/bar', \ 'language_id': 'python', \} + + let g:InitCallback = {-> a:Callback(a:linter, l:details)} endfunction - function! ale#lsp#WaitForCapability(conn_id, capability, callback) abort + function! ale#lsp#HasCapability(conn_id, capability) abort let g:capability_checked = a:capability - let g:WaitCallback = a:callback + + return 1 endfunction function! ale#lsp#RegisterCallback(conn_id, callback) abort @@ -55,7 +57,7 @@ After: call ale#linter#Reset() unlet! g:capability_checked - unlet! g:WaitCallback + unlet! g:InitCallback unlet! g:old_filename unlet! g:conn_id unlet! g:Callback @@ -205,10 +207,10 @@ Execute(tsserver definition requests should be sent): " We shouldn't register the callback yet. AssertEqual '''''', string(g:Callback) - AssertEqual type(function('type')), type(g:WaitCallback) - AssertEqual 'definition', g:capability_checked - call call(g:WaitCallback, [g:conn_id, '/foo/bar']) + AssertEqual type(function('type')), type(g:InitCallback) + call g:InitCallback() + AssertEqual 'definition', g:capability_checked AssertEqual \ 'function(''ale#definition#HandleTSServerResponse'')', \ string(g:Callback) @@ -226,10 +228,10 @@ Execute(tsserver tab definition requests should be sent): " We shouldn't register the callback yet. AssertEqual '''''', string(g:Callback) - AssertEqual type(function('type')), type(g:WaitCallback) - AssertEqual 'definition', g:capability_checked - call call(g:WaitCallback, [g:conn_id, '/foo/bar']) + AssertEqual type(function('type')), type(g:InitCallback) + call g:InitCallback() + AssertEqual 'definition', g:capability_checked AssertEqual \ 'function(''ale#definition#HandleTSServerResponse'')', \ string(g:Callback) @@ -358,10 +360,10 @@ Execute(LSP definition requests should be sent): " We shouldn't register the callback yet. AssertEqual '''''', string(g:Callback) - AssertEqual type(function('type')), type(g:WaitCallback) - AssertEqual 'definition', g:capability_checked - call call(g:WaitCallback, [g:conn_id, '/foo/bar']) + AssertEqual type(function('type')), type(g:InitCallback) + call g:InitCallback() + AssertEqual 'definition', g:capability_checked AssertEqual \ 'function(''ale#definition#HandleLSPResponse'')', \ string(g:Callback) @@ -394,10 +396,10 @@ Execute(LSP type definition requests should be sent): " We shouldn't register the callback yet. AssertEqual '''''', string(g:Callback) - AssertEqual type(function('type')), type(g:WaitCallback) - AssertEqual 'typeDefinition', g:capability_checked - call call(g:WaitCallback, [g:conn_id, '/foo/bar']) + AssertEqual type(function('type')), type(g:InitCallback) + call g:InitCallback() + AssertEqual 'typeDefinition', g:capability_checked AssertEqual \ 'function(''ale#definition#HandleLSPResponse'')', \ string(g:Callback) @@ -430,10 +432,10 @@ Execute(LSP tab definition requests should be sent): " We shouldn't register the callback yet. AssertEqual '''''', string(g:Callback) - AssertEqual type(function('type')), type(g:WaitCallback) - AssertEqual 'definition', g:capability_checked - call call(g:WaitCallback, [g:conn_id, '/foo/bar']) + AssertEqual type(function('type')), type(g:InitCallback) + call g:InitCallback() + AssertEqual 'definition', g:capability_checked AssertEqual \ 'function(''ale#definition#HandleLSPResponse'')', \ string(g:Callback) @@ -466,10 +468,10 @@ Execute(LSP tab type definition requests should be sent): " We shouldn't register the callback yet. AssertEqual '''''', string(g:Callback) - AssertEqual type(function('type')), type(g:WaitCallback) - AssertEqual 'typeDefinition', g:capability_checked - call call(g:WaitCallback, [g:conn_id, '/foo/bar']) + AssertEqual type(function('type')), type(g:InitCallback) + call g:InitCallback() + AssertEqual 'typeDefinition', g:capability_checked AssertEqual \ 'function(''ale#definition#HandleLSPResponse'')', \ string(g:Callback) diff --git a/test/test_symbol_search.vader b/test/test_symbol_search.vader index 9d50e267..053a8b04 100644 --- a/test/test_symbol_search.vader +++ b/test/test_symbol_search.vader @@ -10,28 +10,30 @@ Before: let g:options = {} let g:capability_checked = '' let g:conn_id = v:null - let g:WaitCallback = v:null + let g:InitCallback = v:null runtime autoload/ale/lsp_linter.vim runtime autoload/ale/lsp.vim runtime autoload/ale/util.vim runtime autoload/ale/preview.vim - function! ale#lsp_linter#StartLSP(buffer, linter) abort + function! ale#lsp_linter#StartLSP(buffer, linter, Callback) abort let g:conn_id = ale#lsp#Register('executable', '/foo/bar', {}) call ale#lsp#MarkDocumentAsOpen(g:conn_id, a:buffer) - - return { + let l:details = { \ 'buffer': a:buffer, \ 'connection_id': g:conn_id, \ 'project_root': '/foo/bar', \ 'language_id': 'python', \} + + let g:InitCallback = {-> a:Callback(a:linter, l:details)} endfunction - function! ale#lsp#WaitForCapability(conn_id, capability, callback) abort + function! ale#lsp#HasCapability(conn_id, capability) abort let g:capability_checked = a:capability - let g:WaitCallback = a:callback + + return 1 endfunction function! ale#lsp#RegisterCallback(conn_id, callback) abort @@ -59,7 +61,7 @@ After: call ale#linter#Reset() unlet! g:capability_checked - unlet! g:WaitCallback + unlet! g:InitCallback unlet! g:conn_id unlet! g:Callback unlet! g:message_list @@ -159,10 +161,10 @@ Execute(LSP symbol requests should be sent): " We shouldn't register the callback yet. AssertEqual '''''', string(g:Callback) - AssertEqual 'symbol_search', g:capability_checked - AssertEqual type(function('type')), type(g:WaitCallback) - call call(g:WaitCallback, [g:conn_id, '/foo/bar']) + AssertEqual type(function('type')), type(g:InitCallback) + call g:InitCallback() + AssertEqual 'symbol_search', g:capability_checked AssertEqual \ 'function(''ale#symbol#HandleLSPResponse'')', \ string(g:Callback) @@ -182,6 +184,6 @@ Execute('-relative' argument should enable 'use_relative_paths' in HandleLSPResp ALESymbolSearch -relative foo bar - call call(g:WaitCallback, [g:conn_id, '/foo/bar']) + call g:InitCallback() AssertEqual {'42': {'buffer': bufnr(''), 'use_relative_paths': 1}}, ale#symbol#GetMap() |