mikeman has asked for the wisdom of the Perl Monks concerning the following question:
When unit testing, how do I test that a function returns nothing when called in void context?
For example, I can easily test if the following function returns a list or a scalar containing 'value'. But as soon as I test its return value, I am no longer calling the function in void context.
sub context { return unless defined wantarray; return wantarray ? ('value') : 'value'; }
Thanks, and sorry if this is a dumb question!
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Unit testing, context and wantarray
by BrowserUk (Patriarch) on Aug 13, 2011 at 11:05 UTC | |
by mikeman (Acolyte) on Aug 13, 2011 at 11:22 UTC | |
by GrandFather (Saint) on Aug 13, 2011 at 11:33 UTC | |
by eyepopslikeamosquito (Archbishop) on Aug 13, 2011 at 11:43 UTC | |
by FunkyMonk (Chancellor) on Aug 13, 2011 at 14:15 UTC | |
Re: Unit testing, context and wantarray
by ikegami (Patriarch) on Aug 13, 2011 at 16:48 UTC | |
Re: Unit testing, context and wantarray
by happy.barney (Friar) on Aug 13, 2011 at 15:42 UTC |