Open igbanam opened 1 year ago
If I introduce a global function like so
def g:ForTesting_StartsWith(longer: string, shorter: string): bool
returns longer->StartsWith(shorter)
enddef
Then I can write the utils.vader
like so
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?