Repository navigation
How to change a variable after each nested case? #2573
Contributing guidelines
Module(s)mini.test QuestionThis is a bit of a strange one to describe but I'll do my best. Essentially I have two functions using different implementations (one is using treesitter the other is using patterns) but they are returning the exact same thing. Currently I have the tests like this, local expected = ... -- whatever
local ret = child.lua([[ return func_re() ]])
eq(ret, expected)
ret = child.lua([[ return func_ts() ]])
eq(ret, expected)Ideally I would like to be able to do this, local expected = ... -- whatever
local ret = func()
eq(ret, expected)where |
Replies: 1 comment 1 reply
|
T['impl'] = MiniTest.new_set({ parametrize = { { 'func_re' }, { 'func_ts' } } })
T['impl']['returns the thing'] = function(fname)
local ret = child.lua('return ' .. fname .. '()')
eq(ret, expected)
endworks for nested sets too, everything under |
parametrizedoes this. put the tests in a set parametrized by the function name and every case inside runs once per entry, getting it as an argument:works for nested sets too, everything under
T['impl']gets multiplied. there's a small example under:h MiniTest.new_set().