diff --git a/t/16-randomprime.t b/t/16-randomprime.t index 07091f93..4498464f 100644 --- a/t/16-randomprime.t +++ b/t/16-randomprime.t @@ -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)) @@ -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)"); diff --git a/t/52-primearray.t b/t/52-primearray.t index 64fe106c..504c26c6 100644 --- a/t/52-primearray.t +++ b/t/52-primearray.t @@ -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);