Branch Coverage

blib/lib/Math/Prime/Util/PrimalityProving.pm
Criterion Covered Total %
branch 271 436 62.1


line true false branch
18 0 4 unless (defined $Math::BigInt::VERSION)
47 0 0 unless &is_prob_prime($n)
72 0 1 if not defined $n or $n < 2
73 0 1 if $n < 4
74 0 1 if &is_strong_pseudoprime($n, 2, 15, 325) == 0
91 0 1 unless Math::BigInt::bgcd($ap, $n) == 1
93 0 1 unless $ap->copy->bmodpow($nm1, $n) == 1
96 0 1 if scalar grep({$_ == 1;} map({$ap->copy->bmodpow(int $nm1 / $_, $n);} @factors)) > 0
102 0 4 if ($isp != 2)
106 0 4 if $f > $_smallval
122 0 6 if not defined $n or $n < 2
123 0 6 if $n < 4
124 0 6 if ($n & 1) == 0
125 0 6 if &is_strong_pseudoprime($n, 2, 15, 325) == 0
128 2 4 unless ref $n eq "Math::BigInt"
135 0 6 unless $nm1->is_even
139 0 6 if ($B <= $_maxint and prime_get_config()->{'xs'}) { }
141 0 0 if $tf[-1] > 20000
144 5 1 if $tf[-1] > 5000
147 6 24 if $f == $factors[-1]
154 1 5 if ($B->is_one) { }
4 1 elsif (&is_prob_prime($B)) { }
165 0 1 if $n < $fpart
169 1 0 if ref $m eq "Math::BigInt" and $m <= $_maxint
174 1 0 if scalar @ftry >= 2
177 0 1 unless scalar @ftry > 1
180 0 2 if $f == 1 or $f == $m or not $B->copy->bmod($f)->is_zero
181 2 0 if (&is_prob_prime($f)) { }
202 0 6 if $n >= $fpart
204 0 6 unless $A * $B == $nm1
205 0 6 unless $A->is_even
206 0 6 unless Math::BigInt::bgcd($A, $B)->is_one
210 0 6 if $s != 0 and $rtestroot * $rtestroot == $rtest
219 6 30 if ($qnum == 0) { }
220 0 6 unless $f == 2
227 0 47 unless $ap->copy->bmodpow($nm1, $n)->is_one
228 11 36 unless Math::BigInt::bgcd($ap->copy->bmodpow($nm1_div_f, $n)->bdec, $n)->is_one
229 9 27 unless $a == 2
234 0 36 unless $success
236 0 36 if ($isp != 2)
240 0 36 if $f > $_smallval
257 0 52 if scalar @$pdata == 0
259 3 49 if (length $n == 1)
260 1 2 if $n =~ /^[2357]$/
263 49 0 if ref $n ne "Math::BigInt"
264 1 48 if $n->is_even
266 45 3 scalar @$pdata > 0 ? :
268 3 45 if ($method eq "BPSW")
269 1 2 if $n > $_smallval
270 2 0 if &is_prob_prime($n) != 2
274 15 30 if ($method eq "Pratt" or $method eq "Lucas")
275 0 12 if (scalar @$pdata != 2 or ref $pdata->[0] ne "ARRAY" or ref $pdata->[1] eq "ARRAY")
283 4 45 ref $factors[$i] eq 'ARRAY' ? :
289 4 45 if (ref $farray eq "ARRAY")
295 16 14 if ($method eq "n-1")
296 0 1 if (scalar @$pdata == 3 and ref $pdata->[0] eq "ARRAY" and $pdata->[0][0] =~ /^(B|T7|Theorem\s*7)$/i)
299 2 13 if (scalar @$pdata != 2 or ref $pdata->[0] ne "ARRAY" or ref $pdata->[1] ne "ARRAY")
305 1 12 if (scalar @factors != scalar @as)
311 3 35 ref $factors[$i] eq 'ARRAY' ? :
312 0 38 if ($f == 2)
317 1 11 unless $factors[0] == 2
320 3 32 ref $factors[$i] eq 'ARRAY' ? :
324 7 39 if $as[$i] != 2
328 3 43 if (ref $farray eq "ARRAY")
334 13 1 if ($method eq "ECPP" or $method eq "AGKM")
335 1 12 if (scalar @$pdata < 1)
342 2 17 if (ref $block ne "ARRAY" or scalar @$block != 6)
347 1 16 if ("Math::BigInt"->new("$ni") != "Math::BigInt"->new("$q"))
351 1 15 ref $qval eq 'ARRAY' ? :
352 2 14 if (ref $P ne "ARRAY" or scalar @$P != 2)
358 1 13 if (ref $qval eq "ARRAY")
373 43 2 if scalar @pdata == 1 and ref $pdata[0] eq "ARRAY"
375 1 44 if scalar @pdata == 0
381 19 25 if $cert eq ""
391 0 0 if prime_get_config()->{'verbose'}
396 0 19 if prime_get_config()->{'verbose'}
407 0 162 unless defined $line
409 0 162 if $line =~ /^\s*#/ or $line =~ /^\s*$/
411 0 162 if $line =~ /^Type /
412 162 0 if ($line =~ /^(\S+)\s+(-?\d+)/) { }
415 0 162 unless defined $vars{$var}
430 4 0 if (ref $n eq 'Math::BigInt') { }
432 2 0 if ($mc == 0 or $mc == 1 or $mc == 4 or $mc == 9 or $mc == 16 or $mc == 17 or $mc == 25)
435 0 4 if $sq == $n
439 0 0 if ($mc == 0 or $mc == 1 or $mc == 4 or $mc == 9 or $mc == 16 or $mc == 17 or $mc == 25)
441 0 0 if $sq * $sq == $n
451 0 1 if $m <= 0 or $m % 2 == 0
453 1 0 if ($n < 0)
455 0 1 if $m % 4 == 3
458 1 0 if ($n != 0)
461 3 0 if $m % 8 == 3 or $m % 8 == 5
464 0 1 if $n % 4 == 3 and $m % 4 == 3
466 1 0 if ref $n eq "Math::BigInt" and $n <= $_maxint
467 1 0 if ref $m eq "Math::BigInt" and $m <= $_maxint
472 0 0 if $m % 8 == 3 or $m % 8 == 5
475 0 0 if $n % 4 == 3 and $m % 4 == 3
478 1 0 $m == 1 ? :
512 0 125 unless defined $line
514 0 125 if $line =~ /^\s*#/ or $line =~ /^\s*$/
516 15 110 if $line =~ /^-/
518 15 95 if ($line =~ /^N\s+(\d+)/) { }
64 31 elsif ($line =~ /^Q\[(\d+)\]\s+(\d+)/) { }
31 0 elsif ($line =~ /^A\[(\d+)\]\s+(\d+)/) { }
519 0 15 if defined $n
523 0 64 unless $1 == $index
526 0 31 unless $1 >= 0 and $1 <= $index
542 0 67 unless defined $line
544 0 67 if $line =~ /^\s*#/ or $line =~ /^\s*$/
546 11 56 if ($line =~ /^N\s+(\d+)/) { }
45 11 elsif ($line =~ /^Q\[(\d+)\]\s+(\d+)/) { }
11 0 elsif ($line =~ /^A\s+(\d+)/) { }
547 0 11 if defined $n
551 0 45 unless $1 == $index
567 0 14 unless defined $n
568 0 14 if $a < 0
569 0 14 if $b < 0
570 0 14 unless $n > 0
571 1 13 unless Math::BigInt::bgcd($n, 6) == 1
572 1 12 unless Math::BigInt::bgcd(4 * $a * $a * $a + 27 * $b * $b, $n) == 1
574 0 12 unless $y * $y % $n == ($x * $x * $x + $a * $x + $b) % $n
576 1 11 unless $m >= $n + 1 - $n->copy->bmul(4)->bsqrt
577 0 11 unless $m <= $n + 1 + $n->copy->bmul(4)->bsqrt
578 1 10 unless $q > $n->copy->broot(4)->badd(1)->bpow(2)
579 0 10 unless $q < $n
580 0 10 unless $m != $q
582 1 9 unless $rem == 0
586 0 9 if (prime_get_config()->{'gmp'} and defined &Math::Prime::Util::GMP::_validate_ecpp_curve) { }
589 1 8 unless (defined $Math::Prime::Util::ECAffinePoint::VERSION)
591 0 1 unless (eval { do { require Math::Prime::Util::ECAffinePoint; 1 } })
596 9 0 unless ($ECP->is_infinity)
599 9 0 if $ECP->is_infinity
602 0 9 unless $correct_point
607 0 1 unless defined $n
608 0 1 unless abs $a <= $n / 2
609 0 1 unless abs $b <= $n / 2
610 0 1 unless $t >= 0
611 0 1 unless $t < $n
623 0 0 unless defined $n
624 0 0 unless abs $j <= $n / 2
625 0 0 unless $t >= 0
626 0 0 unless $t < $n
641 0 1 unless defined $n
642 0 1 unless $q->is_odd
643 0 1 unless $q > 2
645 0 1 unless $rem == 0
646 0 1 unless $m * $q - 1 == $n
647 0 1 unless $m > 0
648 0 1 unless 2 * $q - 1 > $n->copy->bsqrt
650 0 1 unless $D != 0
651 0 1 unless _jacobi($D, $n) == -1
652 0 1 unless &lucasvmod($lp, $lq, $m / 2, $n) != 0
654 0 1 unless &lucasvmod($lp, $lq, ($n + 1) / 2, $n) == 0
661 0 3 unless defined $n
662 0 3 unless $q->is_odd
663 0 3 unless $q > 2
665 0 3 unless $rem == 0
666 0 3 unless $m * $q + 1 == $n
667 0 3 unless $m > 0
668 0 3 unless 2 * $q + 1 > $n->copy->bsqrt
669 0 3 unless $a->copy->bmodpow(($n - 1) / 2, $n) == $n - 1
670 0 3 unless $a->copy->bmodpow($m / 2, $n) != $n - 1
675 0 3 unless defined $n
677 0 3 unless $rem == 0
678 0 3 unless $m->is_even
679 0 3 unless $m > 0
680 0 3 unless $m < $q
681 0 3 unless $m * $q + 1 == $n
682 0 3 unless $a > 1
683 0 3 unless $a->copy->bmodpow($n - 1, $n) == 1
685 0 3 unless Math::BigInt::bgcd($a->copy->bmodpow($m, $n) - 1, $n) == 1
691 0 3 unless defined $n
692 0 3 if $n > $_smallval
693 0 3 unless &is_prob_prime($n)
699 0 15 unless defined $n
707 0 76 unless defined $Q[$i]
708 45 31 unless defined $A[$i]
709 0 76 unless $Q[$i] > 1
710 0 76 unless $Q[$i] < $nm1
711 0 76 unless $A[$i] > 1
712 0 76 unless $A[$i] < $n
713 1 75 unless $nm1 % $Q[$i] == 0
719 0 14 unless $R == $nm1 / $F
720 0 14 unless $F->is_even
721 0 14 unless Math::BigInt::bgcd($F, $R) == 1
724 2 12 unless $n < $P
725 0 12 unless $s == 0 or not _is_perfect_square($r * $r - 8 * $s)
730 0 67 unless $a->copy->bmodpow($nm1, $n)->is_one
732 1 66 unless Math::BigInt::bgcd($a->copy->bmodpow($nm1 / $q, $n)->bdec, $n)->is_one
740 0 11 unless defined $n
743 0 11 unless $a > 1
744 1 10 unless $a < $n
748 0 10 unless $a->copy->bmodpow($nm1, $n) == 1
751 0 26 unless defined $Q[$i]
752 0 26 unless $Q[$i] > 1
753 0 26 unless $Q[$i] < $nm1
754 3 23 unless $nm1 % $Q[$i] == 0
755 1 22 unless $a->copy->bmodpow($nm1 / $Q[$i], $n) != 1
762 1 5 unless $R == 1 and $F == $nm1
768 58 2 @_ == 1 ? :
769 43 17 if ref $cert eq "ARRAY"
770 20 40 if $cert eq ""
792 91 170 if $line =~ /^\s*#/ or $line =~ /^\s*$/
794 40 130 if ($line =~ /^\[(\S+) - Primality Certificate\]/)
795 0 40 if ($1 ne "MPU")
801 40 90 if ($cert_type eq "PRIMO" and $line =~ /^\[Candidate\]/ or $cert_type eq "MPU" and $line =~ /^Proof for:/)
802 0 40 if defined $N
804 2 38 unless (&is_prob_prime($N))
810 0 90 if ($line =~ /^Base (\d+)/)
812 0 0 unless $base == 10
815 50 40 if ($line =~ /^Type (.*?)\s*$/)
816 0 50 unless defined $N
819 0 50 unless defined $proof_funcs{$type}
821 15 35 unless defined $n
826 0 23 unless defined $N
831 86 31 if (not defined $parts{$q}) { }
832 0 86 if ($q > $_smallval)
836 2 84 unless (&is_prob_prime($q))
841 0 31 if ref $parts{$q} ne "ARRAY"