in reply to Unit testing, context and wantarray
how do I test that a function returns nothing when called in void context?
Two thoughts:
If a function returned a value in a void context, it is just discarded.
Not returning anything in a void context is not the point, it is not calculating the return values if they are never going to be used that makes a difference.
If the first line of the sub is return unless defined wantarray;, the sub will not return anything when called in a void context. There is no need to test that.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Unit testing, context and wantarray
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 (Bishop) on Aug 13, 2011 at 14:15 UTC |