NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.
All the Perl that's Practical to Extract and Report
Stories, comments, journals, and other submissions on use Perl; are Copyright 1998-2006, their respective owners.
easy, be more strict. (Score:1)
You can simply enforce typing:
use Carp::Assert::More;
sub recip {
my ($num) = @_;
assert_nonzero($num);
return 1/$num;
}
Then write one test to make sure that it works:
is( recip(2), .5 );
one to show that it dies correctly:
dies_ok sub{recip(0)};
and your done, any bugs that come up later can be tested then.
benh~
Reply to This