Branch Coverage

blib/lib/Math/Prime/Util.pm
Criterion Covered Total %
branch 215 388 55.4


line true false branch
90 0 154 if ($] < 5.02)
98 0 308 if @options != @_
101 0 154 if $_Config{'xs'} and $_Config{'secure'}
123 0 72 if defined $ENV{'MPU_NO_XS'} and $ENV{'MPU_NO_XS'} == 1
130 0 72 unless (eval { do { return 0 if defined $ENV{'MPU_NO_XS'} and $ENV{'MPU_NO_XS'} == 1; require XSLoader; XSLoader::load('Math::Prime::Util', $Math::Prime::Util::VERSION); &prime_precalc(0); $_Config{'maxbits'} = &_XS_prime_maxbits(); $_Config{'xs'} = 1; 1 } })
132 0 0 unless defined $ENV{'MPU_NO_XS'} and $ENV{'MPU_NO_XS'} == 1
152 72 0 if (not defined $ENV{'MPU_NO_GMP'} or $ENV{'MPU_NO_GMP'} != 1)
153 0 72 if (eval { do { require Math::Prime::Util::GMP; 'Math::Prime::Util::GMP'->import; 1 } })
162 0 0 if ($_Config{'gmp'} >= 42 and not Math::Prime::Util::GMP::is_csprng_well_seeded() and &_is_csprng_well_seeded())
195 2258 5 $_Config{'xs'} ? :
210 2 21 if ($param eq 'xs') { }
2 19 elsif ($param eq 'gmp') { }
2 17 elsif ($param eq 'nobigint') { }
0 17 elsif ($param eq 'secure') { }
0 17 elsif ($param eq 'irand') { }
0 17 elsif ($param eq 'use_primeinc') { }
8 9 elsif ($param =~ /^(assume[_ ]?)?[ge]?rh$/ or $param =~ /riemann\s*h/) { }
9 0 elsif ($param eq 'verbose') { }
211 1 1 $value ? :
212 1 1 $_Config{'xs'} ? :
214 0 2 $value ? :
218 1 1 if $_Config{'xs'}
220 1 1 $value ? :
222 0 0 if not $value and $_Config{'secure'}
223 0 0 if ($value)
225 0 0 if $_Config{'xs'}
232 4 4 $value ? :
234 9 0 if ($value =~ /^\d+$/) { }
0 0 elsif ($value =~ /^[ty]/i) { }
0 0 elsif ($value =~ /^[fn]/i) { }
239 8 1 if $_Config{'xs'}
240 0 9 if $_Config{'gmp'}
253 0 7451 unless (defined $Math::BigInt::VERSION)
255 7338 113 !defined($_[0]) || ref $_[0] eq 'Math::BigInt' ? :
258 0 0 unless (defined $Math::GMPz::VERSION)
259 0 0 ref $_[0] eq 'Math::GMPz' ? :
262 0 0 unless (defined $Math::GMP::VERSION)
263 0 0 ref $_[0] eq 'Math::GMP' ? :
266 0 625 unless defined $_[1]
268 59 566 if ($ref0)
269 2 57 $ref0 eq ref $_[1] ? :
271 566 0 if (do { $_[1] >= 0 }) { }
276 566 0 if $_[1] <= 18446744073709551615
278 0 0 if '' . int($_[1]) >= -9223372036854775807
280 0 0 unless (defined $Math::BigInt::VERSION)
289 0 103 unless defined $n
290 0 103 if (ref $n eq 'CODE')
294 90 13 if (ref $n eq 'Math::BigInt') { }
0 13 elsif (ref $n eq 'Math::GMPz') { }
295 0 90 if $n->sign ne '+' or not $n->is_int
297 0 90 if $n <= '18446744073709551615'
299 0 0 if Math::GMPz::Rmpz_sgn($n) < 0
300 0 0 if $n <= 18446744073709551615
303 0 13 if $strn eq '' or $strn =~ tr[0-9][\000-/:-\377]c and not $strn =~ /^\+?\d+$/
305 7 6 if ($n <= 18446744073709551615) { }
306 0 7 if ref $n
312 0 103 if ref $_[0] eq 'Math::BigInt' and $_[0]->upgrade
313 0 103 if defined $min and $_[0] < $min
314 0 103 if defined $max and $_[0] > $max
324 0 0 unless $_Config{'gmp'} >= 42
325 0 0 unless defined $seedval
332 0 0 unless $_Config{'gmp'} >= 42
333 0 0 unless defined $str
341 117 1036 if (scalar @_ > 1) { }
342 1 109 unless &_validate_num($low)
346 1 1137 unless &_validate_num($high)
349 10 1128 if $low > $high or $high < 2
351 1 1127 if ($high > $_XS_MAXVAL)
352 0 1 if ($_HAVE_GMP)
354 0 0 if ($high > 18446744073709551615) { }
372 18 1109 if ($low + 1 >= $high or $high > 100000000000000 and $high - $low < 50000) { }
1100 9 elsif ($high <= 1966080 or $high <= &_get_prime_cache_size()) { }
399 18 2 if (scalar @_ > 1) { }
400 1 17 unless &_validate_num($low)
404 1 19 unless &_validate_num($high)
406 0 20 if $low > $high or $high < 2
408 3 17 if ($high > $_XS_MAXVAL)
410 0 3 if ($_HAVE_GMP and defined &Math::Prime::Util::GMP::sieve_twin_primes and $low > 2147483648) { }
424 17 1 if (scalar @_ > 1) { }
425 0 17 unless &_validate_num($low)
429 0 18 unless &_validate_num($high)
431 0 18 if $low > $high or $high < 4
433 17 1 if $high <= $_XS_MAXVAL and $low <= 4 || $high - $low + 1 > $high / (600 * sqrt($high))
444 14 1 if (scalar @_ > 1) { }
445 0 14 unless &_validate_num($low)
449 0 15 unless &_validate_num($high)
451 0 15 if $low > $high or $high < 2
453 0 15 if ($high > $_XS_MAXVAL)
466 0 1 unless &_validate_num($bits, 2)
468 0 1 if ($Math::Prime::Util::_GMPfunc{'random_maurer_prime_with_cert'})
479 0 1 unless &_validate_num($bits, 2)
481 0 1 if ($Math::Prime::Util::_GMPfunc{'random_shawe_taylor_prime_with_cert'})
492 0 1 unless &_validate_num($bits, 2)
495 0 1 if ($Math::Prime::Util::_GMPfunc{'random_maurer_prime_with_cert'})
512 0 35 unless &_validate_num($n)
513 5 30 if $n < 10
515 0 30 if ($_HAVE_GMP and defined &Math::Prime::Util::GMP::primorial)
524 0 36 unless &_validate_num($n)
525 11 25 if $n < 10
527 0 25 if ($_HAVE_GMP and defined &Math::Prime::Util::GMP::pn_primorial)
537 0 104 unless &_validate_num($n)
538 1 103 if $n < 1
540 0 103 if ($_HAVE_GMP and defined &Math::Prime::Util::GMP::consecutive_integer_lcm)
556 1 57 if defined $n and $n <= 0
557 0 57 unless &_validate_num($n)
559 0 57 if ($_HAVE_GMP and defined &Math::Prime::Util::GMP::partitions)
573 0 1 unless (defined $end)
576 0 1 if $beg < 2
584 0 7 if &_get_forexit()
592 0 2 unless (defined $end)
597 1 1 if ($what eq 'oddcomposites') { }
598 0 1 if $beg < 9
599 1 0 unless $beg & 1
602 0 1 if $beg < 4
604 0 2 if ref $end ne 'Math::BigInt' and $end == 18446744073709551615
611 0 10 if $semiprimes and not &is_semiprime($beg)
614 0 10 if &_get_forexit()
617 0 10 if &_get_forexit()
638 0 0 if (defined $end) { }
640 0 0 if $beg < 1
649 0 0 if (not $sf or &is_square_free($beg))
653 0 0 if &_get_forexit()
678 0 16 if &_get_forexit()
686 0 5 unless ref $iref eq 'ARRAY'
704 2 24 unless defined $start
705 1 22 unless &_validate_num($start)
706 21 2 $start > 0 ? :
710 22 1 if (ref $p ne 'Math::BigInt' and $p <= $_XS_MAXVAL) { }
0 1 elsif ($_HAVE_GMP) { }
715 22 66 if (scalar @$pr == 0)
717 0 22 if $p >= 18446744073709551557
719 18 4 $p <= 10000 ? :
720 0 22 if $p + $segment > 18446744073709551615 and $p + 1 < 18446744073709551615
748 1 0 if (defined $high) { }
749 1 0 unless &_validate_num($low)
750 1 0 unless &_validate_num($high)
753 0 0 unless &_validate_num($high)
755 0 1 if $high < 2 or $low > $high
758 0 0 if $_HAVE_GMP and defined &Math::Prime::Util::GMP::prime_count and ref $high eq 'Math::BigInt' || $high - $low < int $low / 1000000
769 64 0 unless &_validate_num($n)
771 0 64 if ($_HAVE_GMP)
773 0 0 if ($n != 1)
778 0 0 if (ref $_[0])
779 0 0 $_ > 18446744073709551615 ? :
791 14 0 unless &_validate_num($n)
795 0 14 unless wantarray
803 0 0 $b % 4 == 3 ? :
0 0 if $a == 0
804 0 0 $a % 4 == 3 ? :
0 0 if $b == 0
820 0 105 if defined $n and $n < 2
821 11 94 unless &_validate_num($n)
824 94 11 if ($n <= $_XS_MAXVAL)
826 10 84 unless $isp == 2
830 0 11 if ($_HAVE_GMP and defined &Math::Prime::Util::GMP::is_provable_prime_with_cert)
834 0 0 if (ref $cert ne 'ARRAY')
846 0 11 if $isp == 0
847 0 11 if $isp == 2
866 0 11 unless $isp
880 0 6 if $n <= 0
882 0 6 if $n > 10000000
885 6 0 if not defined $bignum::VERSION and ref $n ne 'Math::BigFloat' and $_Config{'xs'}
893 2 9 if $n <= 0
896 9 0 if not defined $bignum::VERSION and ref $n ne 'Math::BigFloat' and $_Config{'xs'}
904 1 22 if $n == 0
905 1 21 if $n == $_Neg_Infinity
906 1 20 if $n == $_Infinity
909 18 2 if not defined $bignum::VERSION and ref $n ne 'Math::BigFloat' and $_Config{'xs'}
917 2 26 if $n == 0
918 1 25 if $n == 1
919 1 24 if $n == $_Infinity
921 1 23 if $n <= 0
923 23 0 if (not defined $bignum::VERSION and ref $n ne 'Math::BigFloat' and $_Config{'xs'})
924 1 22 if $n == 2
936 9 0 if not defined $bignum::VERSION and ref $x ne 'Math::BigFloat' and $_Config{'xs'}
946 0 116 if defined $n and $n < 0
947 0 116 unless &_validate_num($n)
948 11 105 if $n > 1 and $n & 1
950 0 105 if ($Math::Prime::Util::_GMPfunc{'bernfrac'})
959 1 25 unless (defined $Math::BigFloat::VERSION)
961 0 26 if ($Math::Prime::Util::_GMPfunc{'bernreal'})
962 0 0 unless defined $precision
967 11 15 if $num->is_zero
973 0 79 unless &_validate_num($n)
974 0 79 if $n <= 0
976 0 79 if ($Math::Prime::Util::_GMPfunc{'harmfrac'})
985 0 22 unless &_validate_num($n)
986 0 22 unless (defined $Math::BigFloat::VERSION)
987 1 21 if $n <= 0
989 0 21 if ($Math::Prime::Util::_GMPfunc{'harmreal'})
990 0 0 unless defined $precision
995 0 21 if (defined $precision and $precision <= 13)
997 0 0 $n < 80 ? :
1003 0 21 if ($Math::Prime::Util::_GMPfunc{'harmfrac'})