use strict;
use warnings;
use Test::More qw( no_plan );
use DateTime;
for my $min (1 .. 20) {
for my $max (30 .. 80) {
for my $inc ( 0 .. 1 ) {
is_deeply
[ jeffa( $min, $max, $inc ) ],
[ over2sd( $min, $max, $inc ) ],
;
}
}
}
done_testing();
sub jeffa {
my $min = shift || 0;
my $max = shift || 0;
my $inclusive = $_[0] ? 1 : 0;
my ($xs,$ns) = (DateTime->now,DateTime->now);
$xs->subtract(years => $min, days => -$inclusive);
$ns->subtract(years => $max, days => 364 + $inclusive);
return $xs->ymd('-'),$ns->ymd('-');
}
sub over2sd {
my ($agemin,$agemax,$inclusive) = @_;
die "Minimum age omitted in DoBrangefromAges" unless (defined $agemin and $agemin ne '');
$agemin = int($agemin);
$agemax = int($agemin) unless defined $agemax;
$agemax = int($agemax);
$inclusive = ($inclusive ? $inclusive : 0);
my ($maxdob,$mindob) = (DateTime->now,DateTime->now);
$maxdob->subtract(years => $agemin, days => -$inclusive);
$mindob->subtract(years => $agemax, days => 364 + $inclusive);
return $maxdob->ymd('-'),$mindob->ymd('-');
}
####
my $max = shift || 0;
####
my $max = shift || $min;
####
use Test::More qw( no_plan );
is_deeply
[ jeffa( ) ],
[ over2sd( ) ],
;
is_deeply
[ jeffa( 10 ) ],
[ over2sd( 10 ) ],
;
__END__
Use of uninitialized value $agemin in int at foo.pl line 37.
ok 1
ok 2
1..2