install.fairie/dotfiles/.vim/plugged/YouCompleteMe/test/commands.test.vim
Git E2E Dev Test Username 1dcbe335e1 git subrepo clone (merge) https://github.com/ycm-core/YouCompleteMe.git ./dotfiles/.vim/plugged/YouCompleteMe
subrepo:
  subdir:   "dotfiles/.vim/plugged/YouCompleteMe"
  merged:   "99ccab251"
upstream:
  origin:   "https://github.com/ycm-core/YouCompleteMe.git"
  branch:   "master"
  commit:   "99ccab251"
git-subrepo:
  version:  "0.4.3"
  origin:   "???"
  commit:   "???"
2022-10-18 10:37:46 -04:00

113 lines
3.7 KiB
VimL

function! SetUp()
let g:ycm_use_clangd = 1
let g:ycm_keep_logfiles = 1
let g:ycm_log_level = 'DEBUG'
call youcompleteme#test#setup#SetUp()
endfunction
function! Test_ToggleLogs()
let log_files = pyxeval( 'ycm_state.GetLogfiles()' )
let bcount = len( getbufinfo() )
" default - show
silent exe 'YcmToggleLogs' keys( log_files )[ 0 ]
call assert_equal( bcount + 1, len( getbufinfo() ) )
let win = getbufinfo( keys( log_files )[ 0 ] )[ 0 ].windows[ 0 ]
call assert_equal( &previewheight, winheight( win_id2win( win ) ) )
" default - hide
silent exe 'YcmToggleLogs' keys( log_files )[ 0 ]
" buffer is wiped out
call assert_equal( bcount, len( getbufinfo() ) )
call assert_equal( [], getbufinfo( keys( log_files )[ 0 ] ) )
" show - 10 lines
silent exe '10YcmToggleLogs' keys( log_files )[ 0 ]
call assert_equal( bcount + 1, len( getbufinfo() ) )
let win = getbufinfo( keys( log_files )[ 0 ] )[ 0 ].windows[ 0 ]
call assert_equal( 10, winheight( win_id2win( win ) ) )
" hide
silent exe '10YcmToggleLogs' keys( log_files )[ 0 ]
call assert_equal( bcount, len( getbufinfo() ) )
call assert_equal( [], getbufinfo( keys( log_files )[ 0 ] ) )
" show - 15 cols
silent exe 'vertical 15YcmToggleLogs' keys( log_files )[ 0 ]
call assert_equal( bcount + 1, len( getbufinfo() ) )
let win = getbufinfo( keys( log_files )[ 0 ] )[ 0 ].windows[ 0 ]
call assert_equal( 15, winwidth( win_id2win( win ) ) )
" hide
silent exe 'YcmToggleLogs' keys( log_files )[ 0 ]
call assert_equal( bcount, len( getbufinfo() ) )
call assert_equal( [], getbufinfo( keys( log_files )[ 0 ] ) )
endfunction
function! Test_GetCommandResponse()
call youcompleteme#test#setup#OpenFile( '/test/testdata/python/doc.py', {} )
" detailed_info
call setpos( '.', [ 0, 12, 3 ] )
call assert_equal( "Test_OneLine()\n\nThis is the one line output.",
\ youcompleteme#GetCommandResponse( 'GetDoc' ) )
call setpos( '.', [ 0, 13, 7 ] )
call assert_equal( "Test_MultiLine()\n\nThis is the one line output.\n"
\ . "This is second line.",
\ youcompleteme#GetCommandResponse( 'GetDoc' ) )
" display message
call setpos( '.', [ 0, 12, 10 ] )
call assert_equal( 'def Test_OneLine()',
\ youcompleteme#GetCommandResponse( 'GetType' ) )
" Location
call setpos( '.', [ 0, 12, 10 ] )
call assert_equal( '',
\ youcompleteme#GetCommandResponse( 'GoTo' ) )
" Error
call setpos( '.', [ 0, 12, 10 ] )
call assert_equal( '',
\ youcompleteme#GetCommandResponse( 'NotACommand', 'arg' ) )
" Specify completer
call setpos( '.', [ 0, 13, 7 ] )
call assert_equal( "Test_MultiLine()\n\nThis is the one line output.\n"
\ . "This is second line.",
\ youcompleteme#GetCommandResponse( 'ft=python', 'GetDoc' ) )
" on a command, no error
call setpos( '.', [ 0, 1, 3 ] )
call assert_equal( '', youcompleteme#GetCommandResponse( 'GetDoc' ) )
endfunction
function! Test_GetCommandResponse_FixIt()
call youcompleteme#test#setup#OpenFile( '/test/testdata/cpp/fixit.c', {} )
" fixit returns empty
call setpos( '.', [ 0, 3, 4 ] )
call assert_equal( '',
\ youcompleteme#GetCommandResponse( 'FixIt' ) )
endfunction
function! Test_GetDefinedSubcommands_Native()
call youcompleteme#test#setup#OpenFile( '/test/testdata/cpp/fixit.c', {} )
call assert_equal( 1, count( youcompleteme#GetDefinedSubcommands(),
\ 'GetDoc' ) )
endfunction
function! Test_GetDefinedSubcommands_NoNative()
enew
setf not_a_filetype
call assert_equal( [], youcompleteme#GetDefinedSubcommands() )
" The above call prints ValueError: No semantic completer ...."
messages clear
endfunction