Closed glts closed 10 years ago
Thank you for the report. It might be a bug in Vim. I confirmed a similar problem without vim-vspec. Try the following steps with vim -u NONE -i NONE -N
:
set runtimepath+=path/to/bundles/autovar
echo autovar#Number()
" => Echos 12
echo autovar#NUMBER
" => Echos 12
function Foo()
return autovar#NUMBER
endfunction
echo Foo()
" => Fails with the following message:
" Error detected while processing function Foo:
" line 1:
" E121: Undefined variable: autovar#NUMBER
" E15: Invalid expression: autovar#NUMBER
" 0
After reading your reply I found this message and a work-around:
describe 'autovar#NUMBER'
it 'works now'
Expect g:autovar#NUMBER == 12
end
end
So technically this might not be a bug, but a very strange scoping rule in Vim eval.
I am not sure if I should report it on vim_dev, but I agree that this is not a vspec problem. I'm closing it, thank you.
Thank you. I've added a note on the problem and the workaround to the document. Because it's hard to guess the scoping rule of autoload variables form :help
.
I am trying to write a test that uses an autoloaded variable. The variable is part of my API and I can use it everywhere without problems, but I can't seem to use it in vspec
it
...end
blocks.path/to/bundles/autovar/autoload/autovar.vim
:path/to/bundles/autovar/t/test.vim
:Run it: