1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217
|
let mapleader = '\'
source plugin/jedi.vim
source test/utils.vim
describe 'goto_simple'
before
new " open a new split
set filetype=python
put =[
\ 'def a(): pass',
\ 'b = a',
\ 'c = b',
\ ]
normal! ggdd
normal! G$
Expect line('.') == 3
end
after
bd!
end
it 'goto_definitions'
silent normal \d
Expect line('.') == 1
"Expect col('.') == 5 " not working yet.
end
it 'goto_assignments'
silent normal \g
Expect line('.') == 2
Expect col('.') == 1
" cursor before `=` means that it stays there.
silent normal \g
Expect line('.') == 2
Expect col('.') == 1
" going to the last line changes it.
normal! $
silent normal \g
Expect line('.') == 1
Expect col('.') == 5
end
end
describe 'goto_with_tabs'
before
set filetype=python
let g:jedi#use_tabs_not_buffers = 1
end
after
bd!
bd!
end
it 'follow_import'
put = ['import subprocess', 'subprocess']
silent normal G\g
Expect getline('.') == 'import subprocess'
Expect line('.') == 2
Expect col('.') == 8
silent normal G\d
Expect CurrentBufferIsModule('subprocess') == 1
Expect line('.') == 1
Expect col('.') == 1
Expect tabpagenr('$') == 2
Expect winnr('$') == 1
tabprevious
Expect bufname('%') == ''
end
it 'multi_definitions'
" This used to behave differently. Now we don't have any real multi
" definitions.
" put = ['import tokenize']
" silent normal G$\d
" Expect CurrentBufferIsModule('tokenize') == 1
" Expect CurrentBufferIsModule('token') == 0
" execute "normal \<CR>"
" Expect tabpagenr('$') == 2
" Expect winnr('$') == 1
" Expect CurrentBufferIsModule('token') == 1
" bd
" silent normal G$\d
" execute "normal j\<CR>"
" Expect tabpagenr('$') == 2
" Expect winnr('$') == 1
" Expect CurrentBufferIsModule('tokenize') == 1
end
end
describe 'goto_with_buffers'
before
set filetype=python
let g:jedi#use_tabs_not_buffers = 0
end
after
bd!
bd!
set nohidden
end
it 'no_new_tabs'
put = ['import os']
normal G$
call jedi#goto_assignments()
python jedi_vim.goto()
Expect CurrentBufferIsModule('os') == 0
" Without hidden, it's not possible to open a new buffer, when the old
" one is not saved.
set hidden
call jedi#goto_assignments()
Expect CurrentBufferIsModule('os') == 1
Expect winnr('$') == 1
Expect tabpagenr('$') == 1
Expect line('.') == 1
Expect col('.') == 1
end
it 'multi_definitions'
" set hidden
" put = ['import tokenize']
" silent normal G$\d
" Expect CurrentBufferIsModule('tokenize') == 0
" Expect CurrentBufferIsModule('token') == 0
" execute "normal \<CR>"
" Expect tabpagenr('$') == 1
" Expect winnr('$') == 1
" Expect CurrentBufferIsModule('token') == 1
" bd
" silent normal G$\d
" execute "normal j\<CR>"
" Expect tabpagenr('$') == 1
" Expect winnr('$') == 1
" Expect CurrentBufferIsModule('tokenize') == 1
end
end
describe 'goto_with_splits'
before
set filetype=python
let g:jedi#use_splits_not_buffers = 'left'
end
after
bd!
bd!
end
it 'follow_import'
put = ['import subprocess', 'subprocess']
silent normal G\g
Expect getline('.') == 'import subprocess'
Expect line('.') == 2
Expect col('.') == 8
silent normal G\d
Expect CurrentBufferIsModule('subprocess') == 1
Expect line('.') == 1
Expect col('.') == 1
Expect winnr('$') == 2
wincmd l
Expect bufname('%') == ''
end
end
describe 'goto_wildignore'
before
set filetype=python
set wildignore=*,with\ spaces,*.pyc
set hidden
let g:jedi#use_tag_stack = 1
let g:jedi#use_tabs_not_buffers = 0
" Need to use splits for code coverage in new_buffer()
let g:jedi#use_splits_not_buffers = 1
put = ['from subprocess import Popen', 'Popen']
Expect CurrentBufferIsModule('subprocess') == 0
silent normal G
end
after
bd!
bd!
set wildignore&vim
end
it 'restores_wildignore'
let before = &wildignore
call jedi#goto()
Expect getline('.') =~ 'Popen'
Expect &wildignore == before
end
it 'not_using_tagstack'
let g:jedi#use_tag_stack = 0
call jedi#goto()
Expect CurrentBufferIsModule('subprocess') == 1
Expect getline('.') =~ 'Popen'
end
end
" vim: et:ts=4:sw=4
|