Branch Coverage

blib/lib/Math/BigRat.pm
Criterion Covered Total %
branch 538 808 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 ? :
236 1893 3530 if $_[1] =~ /^Math::Big(Int|Float)/
249 0 19671 if ($protoref)
253 1 19670 if (@_ < 1)
259 0 19670 if (@_ > 2)
268 1 19669 if (@_ == 1 and not defined $n or @_ == 2 and not defined $n && defined $d)
281 5828 13841 if (ref $n) { }
282 0 5828 unless $n->isa("Math::BigRat") or $n->isa("Math::BigInt") or $n->isa("Math::BigFloat")
287 5 13836 if (defined $d) { }
294 397 13439 if ($n =~ m[ ^ \s* (\S+) \s* / \s* (\S+) \s* $ ]x) { }
307 19262 407 unless (defined $d)
309 0 19262 if ($n->isa("Math::BigRat"))
310 0 0 if defined $downgrade and $n->is_int
314 333 18929 if ($n->is_nan)
318 563 18366 if ($n->is_inf)
322 5717 12649 if ($n->isa("Math::BigInt"))
326 1 5716 if defined $downgrade
330 12649 0 if ($n->isa("Math::BigFloat"))
336 747 11902 if ($e > 0) { }
880 11022 elsif ($e < 0) { }
344 852 28 unless ($LIB->_is_one($gcd))
351 5 12644 if defined $downgrade and $n->is_int
361 5 402 unless ref $d and $d->isa('Math::BigRat') || $d->isa('Math::BigInt') || $d->isa('Math::BigFloat')
368 3 404 if ($n->is_nan or $d->is_nan)
374 6 398 if ($n->is_zero)
375 0 6 if ($d->is_zero)
381 0 398 if ($d->is_zero)
392 10 388 if ($d < 0)
397 8 390 if ($n->is_inf)
398 1 7 if $d->is_inf
404 4 386 if $d->is_inf
405 0 386 if $d->is_zero
409 129 257 if ($n < 0) { }
416 0 386 if ($n->isa('Math::BigRat')) { }
418 0 0 if ($d->isa("Math::BigRat"))
437 0 0 if defined $downgrade and $self->is_int
463 0 0 if ($e > 0) { }
0 0 elsif ($e < 0) { }
473 0 386 if ($d->isa('Math::BigRat')) { }
497 0 0 if ($e > 0) { }
0 0 elsif ($e < 0) { }
530 24 362 if ($ediff > 0) { }
22 340 elsif ($ediff < 0) { }
544 0 0 if defined $downgrade and $self->is_int
556 0 1319 unless $selfref
563 0 1319 if defined $self->{'_a'}
564 0 1319 if defined $self->{'_p'}
577 344 193 unless $selfref
579 5 532 if ($_trap_nan)
583 7 525 if defined $downgrade
600 576 175 unless $selfref
603 351 400 defined $sign && substr($sign, 0, 1) eq '-' ? :
605 12 739 if ($_trap_inf)
609 7 732 if defined $downgrade
627 11 2 unless defined $sign and $sign eq "-"
629 1 12 if defined $downgrade
631 0 12 unless $selfref
647 1 61 if defined $downgrade
649 29 32 unless $selfref
666 6 6 if (@_ == 1 and ref $_[0] ne "HASH")
683 29743 0 ref $_[0] ? :
685 1200 28543 unless ($x->{'sign'} =~ /^[+-]$/)
692 7986 20557 if $x->{'sign'} ne "+"
694 26720 1823 if $LIB->_is_one($x->{'_d'})
699 8 0 ref $_[0] ? :
701 3 5 unless ($x->{'sign'} =~ /^[+-]$/)
708 1 4 if $x->{'sign'} ne "+"
714 745 24 ref $_[0] ? :
717 0 769 if (my $c = $LIB->_check($x->{'_n'}))
720 0 769 if (my $c = $LIB->_check($x->{'_d'}))
725 18 751 unless ($x->{'sign'} =~ /^[+-]$/)
726 2 16 if defined $downgrade
731 36 715 if ($LIB->_is_zero($x->{'_n'}))
732 3 33 if defined $downgrade
734 9 24 unless $LIB->_is_one($x->{'_d'})
739 216 499 if ($LIB->_is_one($x->{'_d'}))
740 11 205 if defined $downgrade
746 97 402 unless ($LIB->_is_one($gcd))
760 26 0 ref $_[0] ? :
762 0 26 if $x->modify("bneg")
766 24 2 unless $x->{'sign'} eq "+" and $LIB->_is_zero($x->{'_n'})
769 4 22 if defined $downgrade and $LIB->_is_one($x->{'_d'})
780 0 0 if ($_trap_nan)
784 0 0 unless defined $self->{'_d'}
785 0 0 unless defined $self->{'_n'}
796 0 0 if ($_trap_inf)
800 0 0 unless defined $self->{'_d'}
801 0 0 unless defined $self->{'_n'}
831 91 234 if (not ref $_[0] or ref $_[0] ne ref $_[1])
835 202 123 unless ($x->is_finite and $y->is_finite)
836 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('-')) { }
839 6 35 if $y->is_inf("-")
842 6 35 if $y->is_inf("+")
884 5 86 if (not ref $_[0] or ref $_[0] ne ref $_[1])
890 84 7 unless $x->{'sign'} eq "+" and $x->is_zero
893 75 16 unless $x->{'sign'} eq "+" and $x->is_zero
904 6 87 if (not ref $_[0] or ref $_[0] ne ref $_[1])
908 8 85 if $x->{'sign'} eq "NaN" or $y->{'sign'} eq "NaN"
911 13 72 if ($x->{'sign'} =~ /^[+-]inf$/ or $y->{'sign'} =~ /^[+-]inf$/)
912 0 13 if $x->is_zero or $y->is_zero
916 5 8 if $x->{'sign'} =~ /^\+/ and $y->{'sign'} =~ /^\+/
917 2 6 if $x->{'sign'} =~ /^-/ and $y->{'sign'} =~ /^-/
922 5 67 if ($x->is_zero)
923 1 4 if defined $downgrade
924 0 5 wantarray ? :
927 3 64 if ($y->is_zero)
928 0 3 defined $downgrade ? :
929 0 3 wantarray ? :
950 52 12 $x->{'sign'} eq $y->{'sign'} ? :
962 7 80 if (not ref $_[0] or ref $_[0] ne ref $_[1])
966 0 87 if $x->modify("bdiv")
974 5 82 if ($x->is_nan or $y->is_nan)
975 0 5 if ($wantarray) { }
976 0 0 if defined $downgrade
980 0 5 if defined $downgrade
990 11 71 if ($y->is_zero)
992 3 8 if ($wantarray)
995 3 8 if ($x->is_zero) { }
1001 0 8 if defined $downgrade and $quo->is_int
1003 0 3 if $wantarray and defined $downgrade and $rem->is_int
1005 3 5 $wantarray ? :
1012 0 71 if ($x->is_inf)
1014 0 0 if $wantarray
1015 0 0 if ($y->is_inf) { }
1018 0 0 $x->bcmp(0) == $y->bcmp(0) ? :
1022 0 0 if defined $downgrade and $quo->is_int
1024 0 0 if $wantarray and defined $downgrade and $rem->is_int
1026 0 0 $wantarray ? :
1033 2 69 if ($y->is_inf)
1035 0 2 if ($wantarray) { }
1036 0 0 if ($x->is_zero or $x->bcmp(0) == $y->bcmp(0)) { }
1043 0 0 if defined $downgrade and $quo->is_int
1045 0 0 if defined $downgrade and $rem->is_int
1049 2 0 if ($y->is_inf)
1050 0 2 if ($x->is_nan or $x->is_inf) { }
1051 0 0 if defined $downgrade
1054 0 2 if defined $downgrade
1065 3 66 if ($x->is_zero)
1066 0 0 $wantarray ? :
0 3 if defined $downgrade
1068 1 2 $wantarray ? :
1083 54 12 $x->{'sign'} eq $y->{'sign'} ? :
1086 6 60 if (wantarray) { }
1091 0 6 if defined $downgrade and $x->is_int
1092 0 6 if defined $downgrade and $rem->is_int
1105 0 21 if (not ref $_[0] or ref $_[0] ne ref $_[1])
1109 0 21 if $x->modify("bmod")
1114 2 19 if ($x->is_nan or $y->is_nan)
1120 0 19 if ($y->is_zero)
1121 0 0 if defined $downgrade
1128 0 19 if ($x->is_inf)
1135 0 19 if ($y->is_inf)
1136 0 0 if ($x->is_zero or $x->bcmp(0) == $y->bcmp(0)) { }
1137 0 0 if defined $downgrade and $x->is_int
1140 0 0 if defined $downgrade
1148 0 19 if ($x->is_zero)
1149 0 0 if defined $downgrade
1165 12 0 ref $_[0] ? :
1167 3 9 unless ($x->{'sign'} =~ /^[+-]$/)
1168 2 1 if defined $downgrade
1172 1 8 if ($x->{'sign'} eq '-') { }
1175 3 5 if ($LIB->_acmp($x->{'_n'}, $x->{'_d'}) < 0) { }
1189 13 0 ref $_[0] ? :
1191 3 10 unless ($x->{'sign'} =~ /^[+-]$/)
1192 2 1 if defined $downgrade
1196 3 7 if ($x->{'sign'} eq '-') { }
1197 2 1 if ($LIB->_acmp($x->{'_n'}, $x->{'_d'}) < 0) { }
1214 0 20 if $x->modify("binv")
1216 2 18 if $x->is_nan
1217 4 14 if $x->is_inf
1218 2 12 if $x->is_zero
1229 9820 0 ref $_[0] ? :
1232 9789 31 if $x->{'sign'} =~ /^[+-]$/ and $LIB->_is_one($x->{'_d'})
1238 649 0 ref $_[0] ? :
1240 73 576 if $x->{'sign'} eq "+" and $LIB->_is_zero($x->{'_n'})
1246 311 0 ref $_[0] ? :
1248 0 311 if @_ > 2
1250 218 93 if $sign ne "-"
1252 37 140 if $x->{'sign'} eq $sign and $LIB->_is_one($x->{'_n'}) and $LIB->_is_one($x->{'_d'})
1258 25 0 ref $_[0] ? :
1261 10 11 if $x->{'sign'} =~ /^[+-]$/ and ($LIB->_is_one($x->{'_d'}) and $LIB->_is_odd($x->{'_n'}))
1267 18 0 ref $_[0] ? :
1269 3 15 unless $x->{'sign'} =~ /^[+-]$/
1271 6 9 if $LIB->_is_one($x->{'_d'}) and $LIB->_is_even($x->{'_n'})
1279 39 0 ref $_[0] ? :
1282 15 24 unless $x->{'sign'} =~ /^[+-]$/
1290 35 0 ref $_[0] ? :
1293 9 26 if $x->{'sign'} eq "NaN"
1295 6 20 unless $x->{'sign'} =~ /^[+-]$/
1301 11 0 ref $_[0] ? :
1305 1 10 if $x->{'sign'} eq "NaN"
1306 1 9 if $x->{'sign'} eq "+inf"
1307 1 8 if $x->{'sign'} eq "-inf"
1319 0 16 unless $class
1321 2 14 if ($x->is_nan)
1322 1 1 if wantarray
1326 4 10 if ($x->is_inf)
1327 2 2 if wantarray
1336 5 5 unless wantarray
1348 0 14 unless $class
1350 1 13 if $x->is_nan
1363 5 0 ref $_[0] ? :
1365 0 5 unless $x->is_int
1370 11 0 ref $_[0] ? :
1372 0 11 unless $x->is_int
1380 24 0 ref $_[0] ? :
1382 10 14 if (not $x->{'sign'} =~ /^[+-]$/ or $LIB->_is_one($x->{'_d'}))
1385 2 8 if defined $downgrade
1391 8 6 if $x->{'sign'} eq "+"
1392 2 12 if $x->{'sign'} eq "-" and $LIB->_is_zero($x->{'_n'})
1393 1 13 if defined $downgrade
1398 52 0 ref $_[0] ? :
1400 24 28 if (not $x->{'sign'} =~ /^[+-]$/ or $LIB->_is_one($x->{'_d'}))
1403 2 22 if defined $downgrade
1409 11 17 if $x->{'sign'} eq "-"
1410 1 27 if defined $downgrade
1415 963 0 ref $_[0] ? :
1417 552 411 if (not $x->{'sign'} =~ /^[+-]$/ or $LIB->_is_one($x->{'_d'}))
1420 2 550 if defined $downgrade
1426 1 410 if $x->{'sign'} eq "-" and $LIB->_is_zero($x->{'_n'})
1427 1 410 if defined $downgrade
1432 13 0 ref $_[0] ? :
1435 3 10 if ($x->{'sign'} ne "+" or not $LIB->_is_one($x->{'_d'}))
1451 6 184 if (not ref $_[0] or ref $_[0] ne ref $_[1])
1455 0 190 if $x->modify("bpow")
1458 29 161 if $x->is_nan or $y->is_nan
1461 13 148 if ($x->is_inf('-')) { }
13 135 elsif ($x->is_inf('+')) { }
11 124 elsif ($y->is_inf('-')) { }
11 113 elsif ($y->is_inf('+')) { }
1462 6 7 if $y->is_negative
1463 1 6 if $y->is_zero
1464 2 4 if $y->is_odd
1467 6 7 if $y->is_negative
1468 1 6 if $y->is_zero
1471 1 10 if $x->is_one("-")
1472 3 7 if $x > -1 and $x < 1
1473 1 6 if $x->is_one("+")
1476 1 10 if $x->is_one("-")
1477 3 7 if $x > -1 and $x < 1
1478 1 6 if $x->is_one("+")
1482 11 102 if ($x->is_zero)
1483 1 10 if $y->is_zero
1484 5 5 if $y->is_negative
1490 20 82 if ($x->is_negative and not $y->is_int)
1491 0 20 if defined $upgrade
1496 20 62 if ($x->is_one("+") or $y->is_one)
1500 6 56 if ($x->is_one("-"))
1501 3 3 if $y->is_odd
1506 24 32 if $y->is_negative
1508 47 9 unless ($LIB->_is_one($y->{'_n'}))
1511 12 35 if $x->{'sign'} eq "-" and $LIB->_is_even($y->{'_n'})
1514 2 54 unless ($LIB->_is_one($y->{'_d'}))
1515 1 1 if $LIB->_is_two($y->{'_d'})
1532 0 20 if (not ref $_[0] and $_[0] =~ /^[A-Za-z]|::/) { }
1534 0 0 defined $_[2] ? :
1538 10 10 defined $_[1] ? :
1542 0 20 if $x->modify("blog")
1547 5 15 if $x->is_nan
1549 7 8 if (defined $base)
1550 0 7 unless ref $base
1551 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) { }
1554 0 0 if $x->is_inf or $x->is_zero
1557 0 2 if $x->is_one
1558 0 2 if $x == $base
1561 0 3 if $x == $base
1566 2 9 if ($x->is_inf) { }
2 7 elsif ($x->is_neg) { }
1 6 elsif ($x->is_one) { }
3 3 elsif ($x->is_zero) { }
1567 0 2 defined $base && $base < 1 ? :
1574 0 3 defined $base && $base < 1 ? :
1585 0 3 if ($x->numerator->is_one)
1589 2 1 if (defined &blessed($base) and $base->isa($class))
1590 0 2 if ($base->numerator->is_one)
1598 2 1 if defined $base
1609 0 3 $neg ? :
1617 1 0 if (not ref $_[0] or ref $_[0] ne ref $_[1])
1621 0 1 if $x->{'sign'} eq "+inf"
1622 0 1 if $x->{'sign'} eq "-inf"
1630 0 1 if $x->{'sign'} eq "NaN"
1633 1 0 if (scalar @params == 0) { }
1645 0 1 if $x->is_zero
1651 1 0 if ($scale <= 75) { }
1686 1 0 if (not $x_org->is_one) { }
1693 0 0 if (defined $params[0]) { }
1699 1 0 if ($fallback)
1712 2478 2478 if (not ref $_[0] or ref $_[0] ne ref $_[1])
1716 24 4932 if $x->is_nan or $y->is_nan
1717 0 4932 if $x->is_finite and not $x->is_int or $y->is_finite and not $y->is_int
1736 5 2 if (not ref $_[0] or ref $_[0] ne ref $_[1])
1768 0 19 if (not ref $_[0] or ref $_[0] ne ref $_[1])
1791 0 17 if (not ref $_[0] or ref $_[0] ne ref $_[1])
1810 20 0 ref $_[0] ? :
1812 4 16 unless $x->{'sign'} =~ /^[+]/
1813 1 15 if $x->{'sign'} eq "+inf"
1814 2 13 if $x->is_zero or $x->is_one
1827 11 2 if ($LIB->_acmp($n, $n2) == 0)
1830 10 1 if ($LIB->_acmp($d, $d2) == 0)
1861 0 0 unless defined $b
1862 0 0 unless ref $b and $b->isa($class)
1864 0 0 if $x->is_nan or $y->is_nan or $b->is_nan
1867 0 0 if $y->{'sign'} =~ /^-/
1875 0 0 unless defined $b
1876 0 0 unless ref $b and $b->isa($class)
1878 0 0 if $x->is_nan or $y->is_nan or $b->is_nan
1881 0 0 if $y->{'sign'} =~ /^-/
1893 0 289 unless $xref
1894 0 289 if @_ < 1
1897 0 289 unless ref $y
1917 0 289 unless $xref
1918 0 289 if @_ < 1
1921 0 289 unless ref $y
1941 0 289 unless $xref
1942 0 289 if @_ < 1
1945 0 289 unless ref $y
1965 0 0 unless $xref
1985 0 0 if defined $downgrade and $x->is_int || $x->is_inf || $x->is_nan
1992 2 0 if defined $downgrade and $x->is_int || $x->is_inf || $x->is_nan
1999 2 0 if defined $downgrade and $x->is_int || $x->is_inf || $x->is_nan
2014 36 18 if (not ref $_[0] or ref $_[0] ne ref $_[1])
2018 0 54 unless ($x->{'sign'} =~ /^[+-]$/ and $y->{'sign'} =~ /^[+-]$/)
2020 0 0 if $x->{'sign'} eq $nan or $y->{'sign'} eq $nan
2022 0 0 if $x->{'sign'} eq $y->{'sign'} and $x->{'sign'} =~ /^[+-]inf$/
2024 0 0 if $x->{'sign'} eq "+inf"
2026 0 0 if $x->{'sign'} eq "-inf"
2028 0 0 if $y->{'sign'} eq "+inf"
2034 14 40 if $x->{'sign'} eq "+" and $y->{'sign'} eq "-"
2036 5 35 if $x->{'sign'} eq "-" and $y->{'sign'} eq "+"
2043 0 35 if $xz and $yz
2044 3 32 if $xz and $y->{'sign'} eq "+"
2045 0 32 if $yz and $x->{'sign'} eq "+"
2051 15 17 if $x->{'sign'} eq "-"
2061 0 50 if (not ref $_[0] or ref $_[0] ne ref $_[1])
2065 35 15 unless ($x->{'sign'} =~ /^[+-]$/ and $y->{'sign'} =~ /^[+-]$/)
2067 7 28 if $x->{'sign'} eq $nan or $y->{'sign'} eq $nan
2068 4 24 if $x->{'sign'} =~ /^[+-]inf$/ and $y->{'sign'} =~ /^[+-]inf$/
2069 12 12 if $x->{'sign'} =~ /^[+-]inf$/ and not $y->{'sign'} =~ /^[+-]inf$/
2083 0 10 unless $selfref
2084 0 10 unless @_ == 1
2095 0 0 unless $selfref
2096 0 0 unless @_ == 1
2099 0 0 defined $cmp && !$cmp ? :
2107 0 19 unless $selfref
2108 0 19 unless @_ == 1
2119 0 0 unless $selfref
2120 0 0 unless @_ == 1
2131 0 24 unless $selfref
2132 0 24 unless @_ == 1
2143 0 0 unless $selfref
2145 0 0 unless @_ == 1
2156 20 0 ref $_[0] ? :
2160 1 19 if ($x->is_nan)
2166 2 17 if ($x->is_inf)
2169 1 1 $x->is_negative ? :
2177 8 9 $LIB->_is_one($x->{'_d'}) ? :
2179 3 14 $x->{'sign'} eq '-' ? :
2183 883 0 ref $_[0] ? :
2186 6 877 unless $x->{'sign'} =~ /^[+-]$/
2190 4 873 if $x->{'sign'} eq "-"
2200 0 3 unless ref $_[0]
2203 0 3 unless $x->{'sign'} =~ /^[+-]$/
2208 2 1 unless ($LIB->_is_one($x->{'_d'}))
2217 2 0 ref $_[0] ? :
2219 0 2 unless $x->is_int
2222 2 0 if $s eq "+"
2227 2 0 ref $_[0] ? :
2229 0 2 unless $x->is_int
2231 2 0 if $s eq "+"
2236 2 0 ref $_[0] ? :
2238 0 2 unless $x->is_int
2240 2 0 if $s eq "+"
2291 1 3 if ($param eq ":constant")
2305 2 6 if $_[0] =~ /^0_*[0-7]/
2313 0 3 if ($param eq "upgrade")
2320 1 2 if ($param eq "downgrade")
2327 0 2 if ($param eq "accuracy")
2334 0 2 if ($param eq "precision")
2341 0 2 if ($param eq "round_mode")
2348 2 0 if ($param =~ /^(lib|try|only)\z/)
2355 0 0 if ($param eq "with")
2372 2 17 if $lib_param ne ""