How to unittest nested functions

Era Scarecrow rtcvb32 at yahoo.com
Wed May 9 14:37:12 PDT 2012


On Wednesday, 9 May 2012 at 20:38:05 UTC, Jonathan M Davis wrote:
> You can't. Either just unit test the outer function or extract  
> the nested function as a private one outside of the outer one. 
> And if you  can't do that because it's a delegate, then it 
> wouldn't make sense to unit  test it anyway,

  Maybe. But if it doesn't need to be a delegate, you could tag 
static on it and give it a second go since it's just another 
function at that point. Worse case is it doesn't work. An idea is 
coming to mind to change it all to a struct and build and test 
it, then remove the outer struct when your done, but that's a 
second level of work. Just gotta consider the inner function as 
just another part of the function itself.


More information about the Digitalmars-d-learn mailing list