You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a function which checks that some string starts with another string in my utils.vim
# Checks if the left string starts with the right
export def StartsWith(longer: string, shorter: string): bool
if (shorter->len() > longer->len())
return false
endif
var right_bound = shorter->len() - 1
return longer[0 : right_bound] ==# shorter
enddef
:h vim9-import allows us use the exported functions from the imported script in the current script's scope. :h getcwd() is there to ensure I'm loading the right file.
The error I get back hints that the script wasn't loaded.
Do (Load the File):
source utils.vim
Execute
Assert v:true, 'vim'->g:ForTesting_StartsWith('vi')
…and this succeeds
What I'm trying to stay away from is introducing a global function for every function I would like to test in my plugin. It feels like Java's @VisibleForTesting, but polluting the global scope.
I have a function which checks that some string starts with another string in my
utils.vim
culled from https://vi.stackexchange.com/a/29063
I want to write a test that this works, so I create a
utils.vader
with the following content:h vim9-import
allows us use the exported functions from the imported script in the current script's scope.:h getcwd()
is there to ensure I'm loading the right file.The error I get back hints that the script wasn't loaded.
Any ideas?
The text was updated successfully, but these errors were encountered: