Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PRC] Adds some tests #27

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion t/16-randomprime.t
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ my %range_edge_empty = (
"3842610774 to 3842611108" => [],
);

plan tests => 13+1+1+1+1
plan tests => 15+1+1+1+1
+ (1 * scalar (keys %range_edge_empty))
+ (3 * scalar (keys %range_edge))
+ (2 * scalar (keys %ranges))
Expand All @@ -85,8 +85,11 @@ plan tests => 13+1+1+1+1
+ 0;

my $infinity = 20**20**20;
my $superbig = 1000000003;
my $nrandom_range_samples = $extra ? 1000 : 50;

ok(!eval { random_prime(1); }, "random_prime(1)"); # Just for coverage
ok(!eval { random_prime(2,1); }, "random_prime(2,1)"); # Just for coverage
ok(!eval { random_prime(undef); }, "random_prime(undef)");
ok(!eval { random_prime(-3); }, "random_prime(-3)");
ok(!eval { random_prime("a"); }, "random_prime(a)");
Expand Down
14 changes: 13 additions & 1 deletion t/52-primearray.t
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,20 @@ my %test_indices = (
);


plan tests => 3 + 2 + scalar(keys %test_indices) + 8;
plan tests => 3 + 3 + 2 + scalar(keys %test_indices) + 8;

my $stderr = '';

{
local $SIG{__WARN__} = sub { $stderr = $_[0] };
my @primes; tie @primes, 'Math::Prime::Util::PrimeArray';
eval { $primes[0] = 0; };
like( $stderr, qr/cannot write/, "Can't store in PrimeArray");
eval { delete $primes[0]; };
like( $stderr, qr/cannot write/, "Can't delete in PrimeArray");
ok( defined $primes[7777], "All are defined" );
}

{
my @primes; tie @primes, 'Math::Prime::Util::PrimeArray';
my (@order, @got, @exp);
Expand Down