vim-unittest icon indicating copy to clipboard operation
vim-unittest copied to clipboard

BUGFIX: 's:Asserts' not found

Open laurentalacoque opened this issue 1 year ago • 0 comments

UnitTest makes use of funcrefs defined as local script functions. To allow the creation of a funcref, one should get the unique ID of the script that contains the function. For example, the object s:Assertions that is defined in some script in the plugin's autoload path can be referenced as e.g. <SNR>96_Assertions The functions get_SID() in the plugin's scripts are responsible for finding the sequence <SNR>XXX_ from <sfile> to reference local functions in this script.

Sadly, the expansion of the <sfile> have multiple occurences of the original match pattern and returned the SID of the base script, thus leading to invalid funcrefs.

Here's an example for the get_SID() function in autoload/unittest/oop/module.vim The <sfile> expands to function unittest#run[8]..<SNR>90_TestRunner_load_testcases[5]..script test_yank_vhd.vim[74]..vim-unittest/autoload/unittest/testcase. vim[70]..vim-unittest/autoload/unittest/assertions.vim[61]..vim-unittest/autoload/unittest/oop/module.vim[41]..function <SNR>96_get_SID

The actual <SID> for the script autoload/unittest/oop/module.vim should be <SNR>96_ but the original match pattern was capturing the first occurence of it (<SNR>90_), thus matching script autoload/unittest.vim instead of autoload/unittest/oop/module.vim

Fixes #8

laurentalacoque avatar Oct 23 '23 06:10 laurentalacoque