| 1 |
source plugin/jedi.vim |
| 2 |
|
| 3 |
describe 'signatures' |
| 4 |
before |
| 5 |
enew |
| 6 |
set filetype=python |
| 7 |
end |
| 8 |
|
| 9 |
after |
| 10 |
try | %bwipeout! | catch | endtry |
| 11 |
end |
| 12 |
|
| 13 |
it 'simple' |
| 14 |
normal odef xyz(number): return |
| 15 |
normal o |
| 16 |
normal oxyz() |
| 17 |
doautocmd CursorHoldI |
| 18 |
Expect getline(3) == '?!?jedi=0, ?!? (*_*number*_*) ?!?jedi?!?' |
| 19 |
|
| 20 |
doautocmd InsertLeave |
| 21 |
Expect getline(3) == '' |
| 22 |
end |
| 23 |
|
| 24 |
it 'multiple buffers' |
| 25 |
set hidden |
| 26 |
new |
| 27 |
setfiletype python |
| 28 |
redir => autocmds |
| 29 |
autocmd jedi_call_signatures * <buffer> |
| 30 |
redir END |
| 31 |
Expect autocmds =~# 'jedi_call_signatures' |
| 32 |
buffer # |
| 33 |
redir => autocmds |
| 34 |
autocmd jedi_call_signatures * <buffer> |
| 35 |
redir END |
| 36 |
Expect autocmds =~# 'jedi_call_signatures' |
| 37 |
end |
| 38 |
|
| 39 |
it 'simple after CursorHoldI with only parenthesis' |
| 40 |
noautocmd normal o |
| 41 |
doautocmd CursorHoldI |
| 42 |
noautocmd normal istaticmethod() |
| 43 |
doautocmd CursorHoldI |
| 44 |
Expect getline(1) == '?!?jedi=0, ?!? (*_*f: Callable[..., Any]*_*) ?!?jedi?!?' |
| 45 |
end |
| 46 |
|
| 47 |
it 'highlights correct argument' |
| 48 |
noautocmd normal o |
| 49 |
doautocmd CursorHoldI |
| 50 |
noautocmd normal iformat(42, "x") |
| 51 |
" Move to x - highlights "x". |
| 52 |
noautocmd normal 2h |
| 53 |
doautocmd CursorHoldI |
| 54 |
Expect getline(1) == '?!?jedi=0, ?!? (value: object, *_*format_spec: str=...*_*) ?!?jedi?!?' |
| 55 |
" Move left to 42 - hightlights first argument ("value"). |
| 56 |
noautocmd normal 4h |
| 57 |
doautocmd CursorHoldI |
| 58 |
Expect getline(1) == '?!?jedi=0, ?!? (*_*value: object*_*, format_spec: str=...) ?!?jedi?!?' |
| 59 |
end |
| 60 |
|
| 61 |
it 'no signature' |
| 62 |
exe 'normal ostr ' |
| 63 |
python3 jedi_vim.show_call_signatures() |
| 64 |
Expect getline(1, '$') == ['', 'str '] |
| 65 |
end |
| 66 |
|
| 67 |
it 'signatures disabled' |
| 68 |
let g:jedi#show_call_signatures = 0 |
| 69 |
|
| 70 |
exe 'normal ostr( ' |
| 71 |
python3 jedi_vim.show_call_signatures() |
| 72 |
Expect getline(1, '$') == ['', 'str( '] |
| 73 |
|
| 74 |
let g:jedi#show_call_signatures = 1 |
| 75 |
end |
| 76 |
|
| 77 |
it 'command line simple' |
| 78 |
let g:jedi#show_call_signatures = 2 |
| 79 |
call jedi#configure_call_signatures() |
| 80 |
|
| 81 |
exe 'normal ostaticmethod( ' |
| 82 |
redir => msg |
| 83 |
python3 jedi_vim.show_call_signatures() |
| 84 |
redir END |
| 85 |
Expect msg == "\nstaticmethod(f: Callable[..., Any])" |
| 86 |
|
| 87 |
redir => msg |
| 88 |
doautocmd InsertLeave |
| 89 |
redir END |
| 90 |
Expect msg == "\n" |
| 91 |
|
| 92 |
normal Sdef foo(a, b): pass |
| 93 |
exe 'normal ofoo(a, b, c, ' |
| 94 |
redir => msg |
| 95 |
python3 jedi_vim.show_call_signatures() |
| 96 |
redir END |
| 97 |
Expect msg == "\nfoo(a, b)" |
| 98 |
end |
| 99 |
|
| 100 |
it 'command line truncation' |
| 101 |
let g:jedi#show_call_signatures = 2 |
| 102 |
call jedi#configure_call_signatures() |
| 103 |
|
| 104 |
function! Signature() |
| 105 |
redir => msg |
| 106 |
python3 jedi_vim.show_call_signatures() |
| 107 |
redir END |
| 108 |
return msg |
| 109 |
endfunction |
| 110 |
|
| 111 |
let funcname = repeat('a', &columns - (30 + (&ruler ? 18 : 0))) |
| 112 |
put = 'def '.funcname.'(arg1, arg2, arg3, a, b, c):' |
| 113 |
put = ' pass' |
| 114 |
execute "normal o\<BS>".funcname."( " |
| 115 |
Expect Signature() == "\n".funcname."(arg1, …)" |
| 116 |
|
| 117 |
exe 'normal sarg1, ' |
| 118 |
Expect Signature() == "\n".funcname."(…, arg2, …)" |
| 119 |
|
| 120 |
exe 'normal sarg2, arg3, ' |
| 121 |
Expect Signature() == "\n".funcname."(…, a, b, c)" |
| 122 |
|
| 123 |
exe 'normal sa, b, ' |
| 124 |
Expect Signature() == "\n".funcname."(…, c)" |
| 125 |
|
| 126 |
g/^/d |
| 127 |
put = 'def '.funcname.'('.repeat('b', 20).', arg2):' |
| 128 |
put = ' pass' |
| 129 |
execute "normal o\<BS>".funcname."( " |
| 130 |
Expect Signature() == "\n".funcname."(…)" |
| 131 |
end |
| 132 |
|
| 133 |
it 'command line no signature' |
| 134 |
let g:jedi#show_call_signatures = 2 |
| 135 |
call jedi#configure_call_signatures() |
| 136 |
|
| 137 |
exe 'normal ostr ' |
| 138 |
redir => msg |
| 139 |
python3 jedi_vim.show_call_signatures() |
| 140 |
redir END |
| 141 |
Expect msg == "\n" |
| 142 |
end |
| 143 |
end |