Branch Coverage

blib/lib/Math/BigRat.pm
Criterion Covered Total %
branch 555 834 66.5


line true false branch
38 0 53 $_[2] ? :
43 0 49 $_[2] ? :
46 0 21 $_[2] ? :
49 0 2 $_[2] ? :
52 0 0 $_[2] ? :
55 0 0 $_[2] ? :
82 0 19 $_[2] ? :
85 0 0 $_[2] ? :
88 0 24 $_[2] ? :
91 0 0 $_[2] ? :
101 0 0 defined $cmp && $_[2] ? :
103 0 1791 $_[2] ? :
126 0 289 $_[2] ? :
131 0 289 $_[2] ? :
136 0 289 $_[2] ? :
171 0 0 $_[2] ? :
190 0 0 $_[0]->is_zero ? :
230 2779 3530 if $_[1] =~ /^Math::Big(Int|Float)/
243 0 19671 if ($protoref)
247 1 19670 if (@_ < 1)
253 0 19670 if (@_ > 2)
262 1 19669 if (@_ == 1 and not defined $n or @_ == 2 and not defined $n && defined $d)
275 5828 13841 if (ref $n) { }
276 0 5828 unless $n->isa("Math::BigRat") or $n->isa("Math::BigInt") or $n->isa("Math::BigFloat")
281 5 13836 if (defined $d) { }
288 397 13439 if ($n =~ m[ ^ \s* (\S+) \s* / \s* (\S+) \s* $ ]x) { }
301 19262 407 unless (defined $d)
303 0 19262 if ($n->isa("Math::BigRat"))
304 0 0 if defined $downgrade and $n->is_int
309 333 18929 if ($n->is_nan)
313 563 18366 if ($n->is_inf)
317 5717 12649 if ($n->isa("Math::BigInt"))
322 1 5716 if defined $downgrade
326 12649 0 if ($n->isa("Math::BigFloat"))
332 747 11902 if ($e > 0) { }
880 11022 elsif ($e < 0) { }
341 852 28 unless ($LIB->_is_one($gcd))
348 5 12644 if defined $downgrade and $n->is_int
359 5 402 unless ref $d and $d->isa('Math::BigRat') || $d->isa('Math::BigInt') || $d->isa('Math::BigFloat')
366 3 404 if ($n->is_nan or $d->is_nan)
372 6 398 if ($n->is_zero)
373 0 6 if ($d->is_zero)
379 0 398 if ($d->is_zero)
390 10 388 if ($d < 0)
395 8 390 if ($n->is_inf)
396 1 7 if $d->is_inf
402 4 386 if $d->is_inf
403 0 386 if $d->is_zero
407 129 257 if ($n < 0) { }
414 0 386 if ($n->isa('Math::BigRat')) { }
416 0 0 if ($d->isa("Math::BigRat"))
435 0 0 if defined $downgrade and $self->is_int
461 0 0 if ($e > 0) { }
0 0 elsif ($e < 0) { }
471 0 386 if ($d->isa('Math::BigRat')) { }
495 0 0 if ($e > 0) { }
0 0 elsif ($e < 0) { }
528 24 362 if ($ediff > 0) { }
22 340 elsif ($ediff < 0) { }
542 0 0 if defined $downgrade and $self->is_int
554 0 1319 unless $selfref
561 0 1319 if defined $self->{'_a'}
562 0 1319 if defined $self->{'_p'}
575 344 193 unless $selfref
577 5 532 if ($_trap_nan)
581 7 525 if defined $downgrade
598 576 175 unless $selfref
601 351 400 defined $sign && substr($sign, 0, 1) eq '-' ? :
603 12 739 if ($_trap_inf)
607 7 732 if defined $downgrade
625 11 2 unless defined $sign and $sign eq "-"
627 1 12 if defined $downgrade
629 0 12 unless $selfref
645 1 61 if defined $downgrade
647 29 32 unless $selfref
664 6 6 if (@_ == 1 and ref $_[0] ne "HASH")
683 29743 0 ref $_[0] ? :
685 0 29743 if @r
689 1200 28543 if ($x->{'sign'} ne "+" and $x->{'sign'} ne "-")
690 849 351 unless $x->{'sign'} eq "+inf"
696 0 28543 if defined $upgrade and not $x->isa($class)
702 7986 20557 if $x->{'sign'} ne "+"
704 7986 20557 $x->{'sign'} eq '-' ? :
706 1823 26720 unless $LIB->_is_one($x->{'_d'})
711 8 0 ref $_[0] ? :
713 0 8 if @r
717 3 5 if ($x->{'sign'} ne "+" and $x->{'sign'} ne "-")
718 2 1 unless $x->{'sign'} eq "+inf"
724 0 5 if defined $upgrade and not $x->isa($class)
729 1 4 $x->{'sign'} eq '-' ? :
731 3 2 unless $LIB->_is_one($x->{'_d'})
736 0 0 ref $_[0] ? :
738 0 0 if @r
742 0 0 if ($x->{'sign'} ne "+" and $x->{'sign'} ne "-")
743 0 0 unless $x->{'sign'} eq "+inf"
749 0 0 if defined $upgrade and not $x->isa($class)
754 0 0 $x->{'sign'} eq '-' ? :
756 0 0 unless $LIB->_is_one($x->{'_d'})
762 745 24 ref $_[0] ? :
765 0 769 if (my $c = $LIB->_check($x->{'_n'}))
768 0 769 if (my $c = $LIB->_check($x->{'_d'}))
773 18 751 unless ($x->{'sign'} =~ /^[+-]$/)
774 2 16 if defined $downgrade
779 36 715 if ($LIB->_is_zero($x->{'_n'}))
780 3 33 if defined $downgrade
782 9 24 unless $LIB->_is_one($x->{'_d'})
787 216 499 if ($LIB->_is_one($x->{'_d'}))
788 11 205 if defined $downgrade
794 97 402 unless ($LIB->_is_one($gcd))
808 26 0 ref $_[0] ? :
810 0 26 if $x->modify("bneg")
814 24 2 unless $x->{'sign'} eq "+" and $LIB->_is_zero($x->{'_n'})
817 4 22 if defined $downgrade and $LIB->_is_one($x->{'_d'})
830 91 234 if (not ref $_[0] or ref $_[0] ne ref $_[1])
834 202 123 unless ($x->is_finite and $y->is_finite)
835 62 140 if ($x->is_nan or $y->is_nan) { }
41 99 elsif ($x->is_inf('+')) { }
41 58 elsif ($x->is_inf('-')) { }
30 28 elsif ($y->is_inf('+')) { }
28 0 elsif ($y->is_inf('-')) { }
838 6 35 if $y->is_inf("-")
841 6 35 if $y->is_inf("+")
883 5 86 if (not ref $_[0] or ref $_[0] ne ref $_[1])
889 84 7 unless $x->{'sign'} eq "+" and $x->is_zero
892 75 16 unless $x->{'sign'} eq "+" and $x->is_zero
903 6 87 if (not ref $_[0] or ref $_[0] ne ref $_[1])
907 8 85 if $x->{'sign'} eq "NaN" or $y->{'sign'} eq "NaN"
910 13 72 if ($x->{'sign'} =~ /^[+-]inf$/ or $y->{'sign'} =~ /^[+-]inf$/)
911 0 13 if $x->is_zero or $y->is_zero
915 5 8 if $x->{'sign'} =~ /^\+/ and $y->{'sign'} =~ /^\+/
916 2 6 if $x->{'sign'} =~ /^-/ and $y->{'sign'} =~ /^-/
921 5 67 if ($x->is_zero)
922 1 4 if defined $downgrade
923 0 5 wantarray ? :
926 3 64 if ($y->is_zero)
927 0 3 defined $downgrade ? :
928 0 3 wantarray ? :
949 52 12 $x->{'sign'} eq $y->{'sign'} ? :
961 7 80 if (not ref $_[0] or ref $_[0] ne ref $_[1])
965 0 87 if $x->modify("bdiv")
973 5 82 if ($x->is_nan or $y->is_nan)
974 0 5 if ($wantarray) { }
975 0 0 if defined $downgrade
979 0 5 if defined $downgrade
989 11 71 if ($y->is_zero)
991 3 8 if ($wantarray)
994 3 8 if ($x->is_zero) { }
1000 0 8 if defined $downgrade and $quo->is_int
1002 0 3 if $wantarray and defined $downgrade and $rem->is_int
1004 3 5 $wantarray ? :
1011 0 71 if ($x->is_inf)
1013 0 0 if $wantarray
1014 0 0 if ($y->is_inf) { }
1017 0 0 $x->bcmp(0) == $y->bcmp(0) ? :
1021 0 0 if defined $downgrade and $quo->is_int
1023 0 0 if $wantarray and defined $downgrade and $rem->is_int
1025 0 0 $wantarray ? :
1032 2 69 if ($y->is_inf)
1034 0 2 if ($wantarray) { }
1035 0 0 if ($x->is_zero or $x->bcmp(0) == $y->bcmp(0)) { }
1042 0 0 if defined $downgrade and $quo->is_int
1044 0 0 if defined $downgrade and $rem->is_int
1048 2 0 if ($y->is_inf)
1049 0 2 if ($x->is_nan or $x->is_inf) { }
1050 0 0 if defined $downgrade
1053 0 2 if defined $downgrade
1064 3 66 if ($x->is_zero)
1065 0 0 $wantarray ? :
0 3 if defined $downgrade
1067 1 2 $wantarray ? :
1082 54 12 $x->{'sign'} eq $y->{'sign'} ? :
1085 6 60 if (wantarray) { }
1090 0 6 if defined $downgrade and $x->is_int
1091 0 6 if defined $downgrade and $rem->is_int
1104 0 21 if (not ref $_[0] or ref $_[0] ne ref $_[1])
1108 0 21 if $x->modify("bmod")
1113 2 19 if ($x->is_nan or $y->is_nan)
1119 0 19 if ($y->is_zero)
1120 0 0 if defined $downgrade
1127 0 19 if ($x->is_inf)
1134 0 19 if ($y->is_inf)
1135 0 0 if ($x->is_zero or $x->bcmp(0) == $y->bcmp(0)) { }
1136 0 0 if defined $downgrade and $x->is_int
1139 0 0 if defined $downgrade
1147 0 19 if ($x->is_zero)
1148 0 0 if defined $downgrade
1164 12 0 ref $_[0] ? :
1166 3 9 unless ($x->{'sign'} =~ /^[+-]$/)
1167 2 1 if defined $downgrade
1171 1 8 if ($x->{'sign'} eq '-') { }
1174 3 5 if ($LIB->_acmp($x->{'_n'}, $x->{'_d'}) < 0) { }
1188 13 0 ref $_[0] ? :
1190 3 10 unless ($x->{'sign'} =~ /^[+-]$/)
1191 2 1 if defined $downgrade
1195 3 7 if ($x->{'sign'} eq '-') { }
1196 2 1 if ($LIB->_acmp($x->{'_n'}, $x->{'_d'}) < 0) { }
1213 0 20 if $x->modify("binv")
1215 2 18 if $x->is_nan
1216 4 14 if $x->is_inf
1217 2 12 if $x->is_zero
1228 9820 0 ref $_[0] ? :
1231 9789 31 if $x->{'sign'} =~ /^[+-]$/ and $LIB->_is_one($x->{'_d'})
1237 649 0 ref $_[0] ? :
1239 73 576 if $x->{'sign'} eq "+" and $LIB->_is_zero($x->{'_n'})
1245 311 0 ref $_[0] ? :
1247 0 311 if @_ > 2
1249 218 93 if $sign ne "-"
1251 37 140 if $x->{'sign'} eq $sign and $LIB->_is_one($x->{'_n'}) and $LIB->_is_one($x->{'_d'})
1257 25 0 ref $_[0] ? :
1260 10 11 if $x->{'sign'} =~ /^[+-]$/ and ($LIB->_is_one($x->{'_d'}) and $LIB->_is_odd($x->{'_n'}))
1266 18 0 ref $_[0] ? :
1268 3 15 unless $x->{'sign'} =~ /^[+-]$/
1270 6 9 if $LIB->_is_one($x->{'_d'}) and $LIB->_is_even($x->{'_n'})
1278 39 0 ref $_[0] ? :
1281 15 24 unless $x->{'sign'} =~ /^[+-]$/
1289 35 0 ref $_[0] ? :
1292 9 26 if $x->{'sign'} eq "NaN"
1294 6 20 unless $x->{'sign'} =~ /^[+-]$/
1300 11 0 ref $_[0] ? :
1304 1 10 if $x->{'sign'} eq "NaN"
1305 1 9 if $x->{'sign'} eq "+inf"
1306 1 8 if $x->{'sign'} eq "-inf"
1318 0 16 unless $class
1320 2 14 if ($x->is_nan)
1321 1 1 if wantarray
1325 4 10 if ($x->is_inf)
1326 2 2 if wantarray
1335 5 5 unless wantarray
1347 0 14 unless $class
1349 1 13 if $x->is_nan
1362 5 0 ref $_[0] ? :
1364 0 5 unless $x->is_int
1369 11 0 ref $_[0] ? :
1371 0 11 unless $x->is_int
1379 24 0 ref $_[0] ? :
1381 10 14 if (not $x->{'sign'} =~ /^[+-]$/ or $LIB->_is_one($x->{'_d'}))
1384 2 8 if defined $downgrade
1390 8 6 if $x->{'sign'} eq "+"
1391 2 12 if $x->{'sign'} eq "-" and $LIB->_is_zero($x->{'_n'})
1392 1 13 if defined $downgrade
1397 52 0 ref $_[0] ? :
1399 24 28 if (not $x->{'sign'} =~ /^[+-]$/ or $LIB->_is_one($x->{'_d'}))
1402 2 22 if defined $downgrade
1408 11 17 if $x->{'sign'} eq "-"
1409 1 27 if defined $downgrade
1414 963 0 ref $_[0] ? :
1416 552 411 if (not $x->{'sign'} =~ /^[+-]$/ or $LIB->_is_one($x->{'_d'}))
1419 2 550 if defined $downgrade
1425 1 410 if $x->{'sign'} eq "-" and $LIB->_is_zero($x->{'_n'})
1426 1 410 if defined $downgrade
1431 13 0 ref $_[0] ? :
1434 3 10 if ($x->{'sign'} ne "+" or not $LIB->_is_one($x->{'_d'}))
1450 6 184 if (not ref $_[0] or ref $_[0] ne ref $_[1])
1454 0 190 if $x->modify("bpow")
1457 29 161 if $x->is_nan or $y->is_nan
1460 13 148 if ($x->is_inf('-')) { }
13 135 elsif ($x->is_inf('+')) { }
11 124 elsif ($y->is_inf('-')) { }
11 113 elsif ($y->is_inf('+')) { }
1461 6 7 if $y->is_negative
1462 1 6 if $y->is_zero
1463 2 4 if $y->is_odd
1466 6 7 if $y->is_negative
1467 1 6 if $y->is_zero
1470 1 10 if $x->is_one("-")
1471 3 7 if $x > -1 and $x < 1
1472 1 6 if $x->is_one("+")
1475 1 10 if $x->is_one("-")
1476 3 7 if $x > -1 and $x < 1
1477 1 6 if $x->is_one("+")
1481 11 102 if ($x->is_zero)
1482 1 10 if $y->is_zero
1483 5 5 if $y->is_negative
1489 20 82 if ($x->is_negative and not $y->is_int)
1490 0 20 if defined $upgrade
1495 20 62 if ($x->is_one("+") or $y->is_one)
1499 6 56 if ($x->is_one("-"))
1500 3 3 if $y->is_odd
1505 24 32 if $y->is_negative
1507 47 9 unless ($LIB->_is_one($y->{'_n'}))
1510 12 35 if $x->{'sign'} eq "-" and $LIB->_is_even($y->{'_n'})
1513 2 54 unless ($LIB->_is_one($y->{'_d'}))
1514 1 1 if $LIB->_is_two($y->{'_d'})
1531 0 20 if (not ref $_[0] and $_[0] =~ /^[A-Za-z]|::/) { }
1533 0 0 defined $_[2] ? :
1537 10 10 defined $_[1] ? :
1541 0 20 if $x->modify("blog")
1546 5 15 if $x->is_nan
1548 7 8 if (defined $base)
1549 0 7 unless ref $base
1550 2 5 if ($base->is_nan or $base->is_one) { }
0 5 elsif ($base->is_inf or $base->is_zero) { }
2 3 elsif ($base->is_negative) { }
1553 0 0 if $x->is_inf or $x->is_zero
1556 0 2 if $x->is_one
1557 0 2 if $x == $base
1560 0 3 if $x == $base
1565 2 9 if ($x->is_inf) { }
2 7 elsif ($x->is_neg) { }
1 6 elsif ($x->is_one) { }
3 3 elsif ($x->is_zero) { }
1566 0 2 defined $base && $base < 1 ? :
1573 0 3 defined $base && $base < 1 ? :
1584 0 3 if ($x->numerator->is_one)
1588 2 1 if (defined &blessed($base) and $base->isa($class))
1589 0 2 if ($base->numerator->is_one)
1605 2 1 if defined $base
1620 0 3 $neg ? :
1628 1 0 if (not ref $_[0] or ref $_[0] ne ref $_[1])
1632 0 1 if $x->{'sign'} eq "+inf"
1633 0 1 if $x->{'sign'} eq "-inf"
1641 0 1 if $x->{'sign'} eq "NaN"
1644 1 0 if (scalar @params == 0) { }
1656 0 1 if $x->is_zero
1662 1 0 if ($scale <= 75) { }
1697 1 0 if (not $x_org->is_one) { }
1704 0 0 if (defined $params[0]) { }
1710 1 0 if ($fallback)
1723 2478 2478 if (not ref $_[0] or ref $_[0] ne ref $_[1])
1727 24 4932 if $x->is_nan or $y->is_nan
1728 0 4932 if $x->is_finite and not $x->is_int or $y->is_finite and not $y->is_int
1747 5 2 if (not ref $_[0] or ref $_[0] ne ref $_[1])
1779 0 19 if (not ref $_[0] or ref $_[0] ne ref $_[1])
1802 0 17 if (not ref $_[0] or ref $_[0] ne ref $_[1])
1821 20 0 ref $_[0] ? :
1823 4 16 unless $x->{'sign'} =~ /^[+]/
1824 1 15 if $x->{'sign'} eq "+inf"
1825 2 13 if $x->is_zero or $x->is_one
1838 11 2 if ($LIB->_acmp($n, $n2) == 0)
1841 10 1 if ($LIB->_acmp($d, $d2) == 0)
1872 0 0 unless defined $b
1873 0 0 unless ref $b and $b->isa($class)
1875 0 0 if $x->is_nan or $y->is_nan or $b->is_nan
1878 0 0 if $y->{'sign'} =~ /^-/
1886 0 0 unless defined $b
1887 0 0 unless ref $b and $b->isa($class)
1889 0 0 if $x->is_nan or $y->is_nan or $b->is_nan
1892 0 0 if $y->{'sign'} =~ /^-/
1904 0 289 unless $xref
1905 0 289 if @_ < 1
1908 0 289 unless ref $y
1928 0 289 unless $xref
1929 0 289 if @_ < 1
1932 0 289 unless ref $y
1952 0 289 unless $xref
1953 0 289 if @_ < 1
1956 0 289 unless ref $y
1976 0 0 unless $xref
1996 0 0 if defined $downgrade and $x->is_int || $x->is_inf || $x->is_nan
2003 2 0 if defined $downgrade and $x->is_int || $x->is_inf || $x->is_nan
2010 2 0 if defined $downgrade and $x->is_int || $x->is_inf || $x->is_nan
2025 36 18 if (not ref $_[0] or ref $_[0] ne ref $_[1])
2029 0 54 unless ($x->{'sign'} =~ /^[+-]$/ and $y->{'sign'} =~ /^[+-]$/)
2031 0 0 if $x->{'sign'} eq $nan or $y->{'sign'} eq $nan
2033 0 0 if $x->{'sign'} eq $y->{'sign'} and $x->{'sign'} =~ /^[+-]inf$/
2035 0 0 if $x->{'sign'} eq "+inf"
2037 0 0 if $x->{'sign'} eq "-inf"
2039 0 0 if $y->{'sign'} eq "+inf"
2045 14 40 if $x->{'sign'} eq "+" and $y->{'sign'} eq "-"
2047 5 35 if $x->{'sign'} eq "-" and $y->{'sign'} eq "+"
2054 0 35 if $xz and $yz
2055 3 32 if $xz and $y->{'sign'} eq "+"
2056 0 32 if $yz and $x->{'sign'} eq "+"
2062 15 17 if $x->{'sign'} eq "-"
2072 0 50 if (not ref $_[0] or ref $_[0] ne ref $_[1])
2076 35 15 unless ($x->{'sign'} =~ /^[+-]$/ and $y->{'sign'} =~ /^[+-]$/)
2078 7 28 if $x->{'sign'} eq $nan or $y->{'sign'} eq $nan
2079 4 24 if $x->{'sign'} =~ /^[+-]inf$/ and $y->{'sign'} =~ /^[+-]inf$/
2080 12 12 if $x->{'sign'} =~ /^[+-]inf$/ and not $y->{'sign'} =~ /^[+-]inf$/
2094 0 10 unless $selfref
2095 0 10 unless @_ == 1
2106 0 0 unless $selfref
2107 0 0 unless @_ == 1
2110 0 0 defined $cmp && !$cmp ? :
2118 0 19 unless $selfref
2119 0 19 unless @_ == 1
2130 0 0 unless $selfref
2131 0 0 unless @_ == 1
2142 0 24 unless $selfref
2143 0 24 unless @_ == 1
2154 0 0 unless $selfref
2156 0 0 unless @_ == 1
2167 20 0 ref $_[0] ? :
2171 1 19 if ($x->is_nan)
2177 2 17 if ($x->is_inf)
2180 1 1 $x->is_negative ? :
2188 8 9 $LIB->_is_one($x->{'_d'}) ? :
2190 3 14 $x->{'sign'} eq '-' ? :
2194 883 0 ref $_[0] ? :
2196 0 883 if $x->isa("Math::BigInt")
2207 4 879 if ($x->is_inf) { }
2 877 elsif ($x->is_nan) { }
2214 4 873 if $x->is_neg
2226 3 0 ref $_[0] ? :
2228 0 3 if $x->isa("Math::BigFloat")
2239 0 3 if ($x->is_inf) { }
0 3 elsif ($x->is_nan) { }
2246 2 1 unless ($LIB->_is_one($x->{'_d'}))
2261 2 0 ref $_[0] ? :
2263 0 2 unless $x->is_int
2266 2 0 if $s eq "+"
2271 2 0 ref $_[0] ? :
2273 0 2 unless $x->is_int
2275 2 0 if $s eq "+"
2280 2 0 ref $_[0] ? :
2282 0 2 unless $x->is_int
2284 2 0 if $s eq "+"
2335 1 3 if ($param eq ":constant")
2349 2 6 if $_[0] =~ /^0_*[0-7]/
2357 0 3 if ($param eq "upgrade")
2364 1 2 if ($param eq "downgrade")
2371 0 2 if ($param eq "accuracy")
2378 0 2 if ($param eq "precision")
2385 0 2 if ($param eq "round_mode")
2392 2 0 if ($param =~ /^(lib|try|only)\z/)
2399 0 0 if ($param eq "with")
2416 2 17 if $lib_param ne ""