Though I'm not quite sure how tests 3-5 are supposed to go
Neither was I! So I made it die (a.k.a throws an exception) when the array consists only of NULLs. Garbage in, garbage out, as we used to say. Exceptions prevent the garbage leaking out.
If you decide it should do something other than die, just change this line:
die "No values found" if @arr && 0 == grep $_ ne '_', @arr;
| [reply] [Watch: Dir/Any] [d/l] |
Yea, but when it dies, the tests are never executed (in my case). That's probably not what's supposed to happen :).
| [reply] [Watch: Dir/Any] |
If you don't want the code to die, you need to use something to catch the exception. I like Try::Tiny:
use Try::Tiny;
my @bad = try { fill_in_the_blanks(qw<_ _ _>) } # fails
catch { print "bad data!\n" };
my @good = try { fill_in_the_blanks(qw<_ 1 _>) } # succeeds
catch { print "bad data!\n" };
| [reply] [Watch: Dir/Any] [d/l] |
Ah, found out where things went wrong:
My code dies with a 'No values found' for is_deeply [fill_in_the_blanks(qw< >)], [qw< >], "( )";.
I thought that throws_ok didn't catch the die but that wasn't the case.
Seems our approach of the 'empty array'-situation differs :)
| [reply] [Watch: Dir/Any] [d/l] [select] |