Closed NicolasWebDev closed 8 years ago
You can use getcurpos()
to get the cursor position information.
Well, let's say I have a python buffer content like that:
for number in numbers:
print number
and I have a function in my vim plugin that should backward search the "for" keyword and insert something there.
How can I test that the function works, giving it the initial buffer content and the cursor position, and checking the final buffer content and cursor position?
I have read all the themis helper file, and I understand how to test values, but how can I test vim side-effects?
% delete _ " clear the buffer
" set buffer content
0put ='for number in numbers:'
1put =' print number'
call setpos('.', [0, 1, 1, 0]) " set cursor position
" call your function
Assert Equals(getline(1, '$'), ['expected', 'buffer', 'lines']) " check buffer content
Assert Equals(getpos('.')[1 : 2], [expected_lnum, expected_col]) " check cursor position
Please read Vim's help more.
Thanks for your help, I was reading the vim's help, only that I needed some direction to know what to look for.
Is there a way to test a script which relies on the cursor position with movements?
Thanks for the great work!