Branch Coverage

blib/lib/Math/Prime/Util/PrimalityProving.pm
Criterion Covered Total %
branch 269 436 61.7


line true false branch
18 0 5 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 13 if not defined $n or $n < 2
123 0 13 if $n < 4
124 0 13 if ($n & 1) == 0
125 0 13 if &is_strong_pseudoprime($n, 2, 15, 325) == 0
128 2 11 unless ref $n eq 'Math::BigInt'
135 0 13 unless $nm1->is_even
139 2 11 if ($B <= $_maxint and prime_get_config()->{'xs'}) { }
141 1 1 if $tf[-1] > 20000
144 11 0 if $tf[-1] > 5000
147 11 34 if $f == $factors[-1]
154 1 12 if ($B->is_one) { }
3 9 elsif (&is_prob_prime($B)) { }
165 1 13 if $n < $fpart
169 5 8 if ref $m eq 'Math::BigInt' and $m <= $_maxint
174 13 0 if scalar @ftry >= 2
177 0 13 unless scalar @ftry > 1
180 0 26 if $f == 1 or $f == $m or not $B->copy->bmod($f)->is_zero
181 21 5 if (&is_prob_prime($f)) { }
202 0 13 if $n >= $fpart
204 0 13 unless $A * $B == $nm1
205 0 13 unless $A->is_even
206 0 13 unless Math::BigInt::bgcd($A, $B)->is_one
210 0 13 if $s != 0 and $rtestroot * $rtestroot == $rtest
219 13 58 if ($qnum == 0) { }
220 0 13 unless $f == 2
227 0 81 unless $ap->copy->bmodpow($nm1, $n)->is_one
228 10 71 unless Math::BigInt::bgcd($ap->copy->bmodpow($nm1_div_f, $n)->bdec, $n)->is_one
229 8 63 unless $a == 2
234 0 71 unless $success
236 0 71 if ($isp != 2)
240 2 69 if $f > $_smallval
257 0 38 if scalar @$pdata == 0
259 3 35 if (length $n == 1)
260 1 2 if $n =~ /^[2357]$/
263 35 0 if ref $n ne 'Math::BigInt'
264 1 34 if $n->is_even
266 31 3 scalar @$pdata > 0 ? :
268 3 31 if ($method eq 'BPSW')
269 1 2 if $n > $_smallval
270 2 0 if &is_prob_prime($n) != 2
274 12 19 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 12 7 if ($method eq 'n-1')
296 0 0 if (scalar @$pdata == 3 and ref $pdata->[0] eq 'ARRAY' and $pdata->[0][0] =~ /^(B|T7|Theorem\s*7)$/i)
299 0 12 if (scalar @$pdata != 2 or ref $pdata->[0] ne 'ARRAY' or ref $pdata->[1] ne 'ARRAY')
305 0 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 7 0 if ($method eq 'ECPP' or $method eq 'AGKM')
335 0 7 if (scalar @$pdata < 1)
342 0 14 if (ref $block ne 'ARRAY' or scalar @$block != 6)
347 0 14 if ('Math::BigInt'->new("$ni") != 'Math::BigInt'->new("$q"))
351 1 13 ref $qval eq 'ARRAY' ? :
352 0 14 if (ref $P ne 'ARRAY' or scalar @$P != 2)
358 1 13 if (ref $qval eq 'ARRAY')
373 29 2 if scalar @pdata == 1 and ref $pdata[0] eq 'ARRAY'
375 1 30 if scalar @pdata == 0
381 5 25 if $cert eq ''
391 0 0 if prime_get_config()->{'verbose'}
396 0 19 if prime_get_config()->{'verbose'}
407 0 178 unless defined $line
409 0 178 if $line =~ /^\s*#/ or $line =~ /^\s*$/
411 0 178 if $line =~ /^Type /
412 178 0 if ($line =~ /^(\S+)\s+(-?\d+)/) { }
415 0 178 unless defined $vars{$var}
429 4 0 if (ref $n eq 'Math::BigInt') { }
431 2 0 if ($mc == 0 or $mc == 1 or $mc == 4 or $mc == 9 or $mc == 16 or $mc == 17 or $mc == 25)
434 0 4 if $sq == $n
438 0 0 if ($mc == 0 or $mc == 1 or $mc == 4 or $mc == 9 or $mc == 16 or $mc == 17 or $mc == 25)
440 0 0 if $sq * $sq == $n
449 0 1 if $m <= 0 or $m % 2 == 0
451 1 0 if ($n < 0)
453 0 1 if $m % 4 == 3
456 1 0 if ($n != 0)
459 3 0 if $m % 8 == 3 or $m % 8 == 5
462 0 1 if $n % 4 == 3 and $m % 4 == 3
464 1 0 if ref $n eq 'Math::BigInt' and $n <= $_maxint
465 1 0 if ref $m eq 'Math::BigInt' and $m <= $_maxint
470 0 0 if $m % 8 == 3 or $m % 8 == 5
473 0 0 if $n % 4 == 3 and $m % 4 == 3
476 1 0 $m == 1 ? :
510 0 124 unless defined $line
512 0 124 if $line =~ /^\s*#/ or $line =~ /^\s*$/
514 16 108 if $line =~ /^-/
516 16 92 if ($line =~ /^N\s+(\d+)/) { }
64 28 elsif ($line =~ /^Q\[(\d+)\]\s+(\d+)/) { }
28 0 elsif ($line =~ /^A\[(\d+)\]\s+(\d+)/) { }
517 0 16 if defined $n
521 0 64 unless $1 == $index
524 0 28 unless $1 >= 0 and $1 <= $index
540 0 67 unless defined $line
542 0 67 if $line =~ /^\s*#/ or $line =~ /^\s*$/
544 11 56 if ($line =~ /^N\s+(\d+)/) { }
45 11 elsif ($line =~ /^Q\[(\d+)\]\s+(\d+)/) { }
11 0 elsif ($line =~ /^A\s+(\d+)/) { }
545 0 11 if defined $n
549 0 45 unless $1 == $index
565 0 14 unless defined $n
566 0 14 if $a < 0
567 0 14 if $b < 0
568 0 14 unless $n > 0
569 1 13 unless Math::BigInt::bgcd($n, 6) == 1
570 1 12 unless Math::BigInt::bgcd(4 * $a * $a * $a + 27 * $b * $b, $n) == 1
572 0 12 unless $y * $y % $n == ($x * $x * $x + $a * $x + $b) % $n
574 1 11 unless $m >= $n + 1 - $n->copy->bmul(4)->bsqrt
575 0 11 unless $m <= $n + 1 + $n->copy->bmul(4)->bsqrt
576 1 10 unless $q > $n->copy->broot(4)->badd(1)->bpow(2)
577 0 10 unless $q < $n
578 0 10 unless $m != $q
580 1 9 unless $rem == 0
584 0 9 if (prime_get_config()->{'gmp'} and defined &Math::Prime::Util::GMP::_validate_ecpp_curve) { }
587 1 8 unless (defined $Math::Prime::Util::ECAffinePoint::VERSION)
589 0 1 unless (eval { do { require Math::Prime::Util::ECAffinePoint; 1 } })
594 9 0 unless ($ECP->is_infinity)
597 9 0 if $ECP->is_infinity
600 0 9 unless $correct_point
605 0 1 unless defined $n
606 0 1 unless abs $a <= $n / 2
607 0 1 unless abs $b <= $n / 2
608 0 1 unless $t >= 0
609 0 1 unless $t < $n
621 0 0 unless defined $n
622 0 0 unless abs $j <= $n / 2
623 0 0 unless $t >= 0
624 0 0 unless $t < $n
639 0 1 unless defined $n
640 0 1 unless $q->is_odd
641 0 1 unless $q > 2
643 0 1 unless $rem == 0
644 0 1 unless $m * $q - 1 == $n
645 0 1 unless $m > 0
646 0 1 unless 2 * $q - 1 > $n->copy->bsqrt
648 0 1 unless $D != 0
649 0 1 unless _jacobi($D, $n) == -1
650 0 1 unless (&lucas_sequence($n, $lp, $lq, $m / 2))[1] != 0
652 0 1 unless (&lucas_sequence($n, $lp, $lq, ($n + 1) / 2))[1] == 0
659 0 5 unless defined $n
660 0 5 unless $q->is_odd
661 0 5 unless $q > 2
663 0 5 unless $rem == 0
664 0 5 unless $m * $q + 1 == $n
665 0 5 unless $m > 0
666 0 5 unless 2 * $q + 1 > $n->copy->bsqrt
667 0 5 unless $a->copy->bmodpow(($n - 1) / 2, $n) == $n - 1
668 0 5 unless $a->copy->bmodpow($m / 2, $n) != $n - 1
673 0 5 unless defined $n
675 0 5 unless $rem == 0
676 0 5 unless $m->is_even
677 0 5 unless $m > 0
678 0 5 unless $m < $q
679 0 5 unless $m * $q + 1 == $n
680 0 5 unless $a > 1
681 0 5 unless $a->copy->bmodpow($n - 1, $n) == 1
683 0 5 unless Math::BigInt::bgcd($a->copy->bmodpow($m, $n) - 1, $n) == 1
689 0 3 unless defined $n
690 0 3 if $n > $_smallval
691 0 3 unless &is_prob_prime($n)
697 0 16 unless defined $n
705 0 77 unless defined $Q[$i]
706 49 28 unless defined $A[$i]
707 0 77 unless $Q[$i] > 1
708 0 77 unless $Q[$i] < $nm1
709 0 77 unless $A[$i] > 1
710 0 77 unless $A[$i] < $n
711 1 76 unless $nm1 % $Q[$i] == 0
717 0 15 unless $R == $nm1 / $F
718 0 15 unless $F->is_even
719 0 15 unless Math::BigInt::bgcd($F, $R) == 1
722 2 13 unless $n < $P
723 0 13 unless $s == 0 or not _is_perfect_square($r * $r - 8 * $s)
728 0 68 unless $a->copy->bmodpow($nm1, $n)->is_one
730 1 67 unless Math::BigInt::bgcd($a->copy->bmodpow($nm1 / $q, $n)->bdec, $n)->is_one
738 0 11 unless defined $n
741 0 11 unless $a > 1
742 1 10 unless $a < $n
746 0 10 unless $a->copy->bmodpow($nm1, $n) == 1
749 0 26 unless defined $Q[$i]
750 0 26 unless $Q[$i] > 1
751 0 26 unless $Q[$i] < $nm1
752 3 23 unless $nm1 % $Q[$i] == 0
753 1 22 unless $a->copy->bmodpow($nm1 / $Q[$i], $n) != 1
760 1 5 unless $R == 1 and $F == $nm1
766 48 2 @_ == 1 ? :
767 29 21 if ref $cert eq 'ARRAY'
768 6 44 if $cert eq ''
790 100 187 if $line =~ /^\s*#/ or $line =~ /^\s*$/
792 44 143 if ($line =~ /^\[(\S+) - Primality Certificate\]/)
793 0 44 if ($1 ne 'MPU')
799 44 99 if ($cert_type eq 'PRIMO' and $line =~ /^\[Candidate\]/ or $cert_type eq 'MPU' and $line =~ /^Proof for:/)
800 0 44 if defined $N
802 2 42 unless (&is_prob_prime($N))
808 0 99 if ($line =~ /^Base (\d+)/)
810 0 0 unless $base == 10
813 55 44 if ($line =~ /^Type (.*?)\s*$/)
814 0 55 unless defined $N
817 0 55 unless defined $proof_funcs{$type}
819 15 40 unless defined $n
824 0 27 unless defined $N
829 90 36 if (not defined $parts{$q}) { }
830 0 90 if ($q > $_smallval)
834 2 88 unless (&is_prob_prime($q))
839 0 36 if ref $parts{$q} ne 'ARRAY'