]> git.madduck.net Git - etc/vim.git/blobdiff - .vim/bundle/ale/test/completion/test_omnifunc_completion.vader

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

Merge commit '76265755a1add77121c8f9dabb3e9bb70fe9a972' as '.vim/bundle/ale'
[etc/vim.git] / .vim / bundle / ale / test / completion / test_omnifunc_completion.vader
diff --git a/.vim/bundle/ale/test/completion/test_omnifunc_completion.vader b/.vim/bundle/ale/test/completion/test_omnifunc_completion.vader
new file mode 100644 (file)
index 0000000..c9ecd20
--- /dev/null
@@ -0,0 +1,60 @@
+Before:
+  unlet! b:ale_completion_info
+  unlet! b:ale_completion_result
+
+  let b:lsp_started = 0
+
+  runtime autoload/ale/lsp_linter.vim
+
+  function! ale#lsp_linter#StartLSP(buffer, linter, Callback) abort
+    return b:lsp_started
+  endfunction
+
+  function! SetCompletionResult(...) abort
+    let b:ale_completion_result = ['foo']
+  endfunction
+
+  function! SetCompletionResponse(...) abort
+    let b:ale_completion_result = ['foo']
+  endfunction
+
+After:
+  unlet! b:ale_completion_info
+  unlet! b:ale_completion_result
+  unlet! b:lsp_started
+
+  delfunction SetCompletionResult
+  delfunction SetCompletionResponse
+
+  runtime autoload/ale/lsp_linter.vim
+
+  call ale#linter#Reset()
+
+Given typescript():
+  let abc = y.
+  let foo = ab
+  let foo = (ab)
+
+Execute(-3 should be returned when completion results cannot be requested):
+  AssertEqual -3, ale#completion#OmniFunc(1, '')
+
+Execute(The start position should be returned when results can be requested):
+  let b:lsp_started = 1
+  call setpos('.', [bufnr(''), 3, 14, 0])
+
+  AssertEqual 11, ale#completion#OmniFunc(1, '')
+
+Execute(The omnifunc function should return async results):
+  " Neovim struggles at running these tests.
+  if !has('nvim')
+    call timer_start(0, function('SetCompletionResult'))
+
+    AssertEqual ['foo'], ale#completion#OmniFunc(0, '')
+  endif
+
+Execute(The omnifunc function should parse and return async responses):
+  if !has('nvim')
+    call timer_start(0, function('SetCompletionResponse'))
+
+    AssertEqual ['foo'], ale#completion#OmniFunc(0, '')
+  endif