Subject: | [PATCH] minor patch fixing T::P::P->generate($len) |
Date: | Sat, 10 Mar 2007 19:21:34 -0300 |
To: | clkao [...] clkao.org, bugs-Text-Password-Pronounceable [...] rt.cpan.org |
From: | "Adriano Ferreira" <a.r.ferreira [...] gmail.com> |
The patch I provided at http://rt.cpan.org/Public/Bug/Display.html?id=23981
made "new($len)" and "$pp->generate($len)" work, but
not "Text::Password::Pronounceable->generate($len)".
This patch fixes that, besides tweaking the docs for a more
precise description of the method signatures.
It add a few more tests to check for the behavior of generate
as a class method.
########
As a side note, the following tests actually pass,
but should they be documented? Are they desirable behavior?
{
my $pp = Text::Password::Pronounceable->new(1, 10);
my $str = $pp->generate(undef, 5); # $min = undef, so use $min = 1
ok(length($str) <= 5 && length($str) >= 1);
$str = $pp->generate(0, 5); # $min = 0, so use $min = 1
ok(length($str) <= 5 && length($str) >= 1);
$str = $pp->generate("", 5); # $min = "", so use $min = 1
ok(length($str) <= 5 && length($str) >= 1);
}
Maybe replacing this test and warning in the sub generate
Carp::carp "min and max length must be defined" if !$min || !$max;
by
Carp::carp "min and max length must be defined" if $min>0 || $max>0;
so that arguments are forced to be numbers is more sensible,
discontinuing with the behavior exhibited above.
But obviously it depends on the compatibility issues of the
code.
Kind regards,
Adriano Ferreira.
Message body is not shown because sender requested not to inline it.