Branch Coverage

blib/lib/Math/BigRat.pm
Criterion Covered Total %
branch 542 796 68.0


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 24 $_[2] ? :
85 0 0 $_[2] ? :
88 0 29 $_[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 2273 3540 if $_[1] =~ /^Math::Big(Int|Float)/
243 0 19871 if ($protoref)
247 1 19870 if (@_ < 1)
253 0 19870 if (@_ > 2)
262 1 19869 if (@_ == 1 and not defined $n or @_ == 2 and not defined $n && defined $d)
275 6018 13851 if (ref $n) { }
276 0 6018 unless $n->isa("Math::BigRat") or $n->isa("Math::BigInt") or $n->isa("Math::BigFloat")
281 5 13846 if (defined $d) { }
288 397 13449 if ($n =~ m[ ^ \s* (\S+) \s* / \s* (\S+) \s* $ ]x) { }
301 19462 407 unless (defined $d)
303 0 19462 if ($n->isa("Math::BigRat"))
304 0 0 if defined $downgrade and $n->is_int
309 333 19129 if ($n->is_nan)
313 595 18534 if ($n->is_inf)
317 5875 12659 if ($n->isa("Math::BigInt"))
322 1 5874 if defined $downgrade
326 12659 0 if ($n->isa("Math::BigFloat"))
332 747 11912 if ($e > 0) { }
880 11032 elsif ($e < 0) { }
341 852 28 unless ($LIB->_is_one($gcd))
348 5 12654 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 608 175 unless $selfref
601 355 428 defined $sign && substr($sign, 0, 1) eq '-' ? :
603 12 771 if ($_trap_inf)
607 7 764 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")
681 29743 0 ref $_[0] ? :
683 1200 28543 unless ($x->{'sign'} =~ /^[+-]$/)
690 7986 20557 if $x->{'sign'} ne "+"
692 26720 1823 if $LIB->_is_one($x->{'_d'})
697 8 0 ref $_[0] ? :
699 3 5 unless ($x->{'sign'} =~ /^[+-]$/)
706 1 4 if $x->{'sign'} ne "+"
712 755 24 ref $_[0] ? :
715 0 779 if (my $c = $LIB->_check($x->{'_n'}))
718 0 779 if (my $c = $LIB->_check($x->{'_d'}))
723 18 761 unless ($x->{'sign'} =~ /^[+-]$/)
724 2 16 if defined $downgrade
729 46 715 if ($LIB->_is_zero($x->{'_n'}))
730 3 43 if defined $downgrade
732 9 34 unless $LIB->_is_one($x->{'_d'})
737 216 499 if ($LIB->_is_one($x->{'_d'}))
738 11 205 if defined $downgrade
744 97 402 unless ($LIB->_is_one($gcd))
758 26 0 ref $_[0] ? :
760 0 26 if $x->modify("bneg")
764 24 2 unless $x->{'sign'} eq "+" and $LIB->_is_zero($x->{'_n'})
767 4 22 if defined $downgrade and $LIB->_is_one($x->{'_d'})
780 91 239 if (not ref $_[0] or ref $_[0] ne ref $_[1])
784 202 128 unless ($x->is_finite and $y->is_finite)
785 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('-')) { }
788 6 35 if $y->is_inf("-")
791 6 35 if $y->is_inf("+")
833 10 86 if (not ref $_[0] or ref $_[0] ne ref $_[1])
839 84 12 unless $x->{'sign'} eq "+" and $x->is_zero
842 75 21 unless $x->{'sign'} eq "+" and $x->is_zero
853 6 87 if (not ref $_[0] or ref $_[0] ne ref $_[1])
857 8 85 if $x->{'sign'} eq "NaN" or $y->{'sign'} eq "NaN"
860 13 72 if ($x->{'sign'} =~ /^[+-]inf$/ or $y->{'sign'} =~ /^[+-]inf$/)
861 0 13 if $x->is_zero or $y->is_zero
865 5 8 if $x->{'sign'} =~ /^\+/ and $y->{'sign'} =~ /^\+/
866 2 6 if $x->{'sign'} =~ /^-/ and $y->{'sign'} =~ /^-/
871 5 67 if ($x->is_zero)
872 1 4 if defined $downgrade
873 0 5 wantarray ? :
876 3 64 if ($y->is_zero)
877 0 3 defined $downgrade ? :
878 0 3 wantarray ? :
899 52 12 $x->{'sign'} eq $y->{'sign'} ? :
911 7 80 if (not ref $_[0] or ref $_[0] ne ref $_[1])
915 0 87 if $x->modify("bdiv")
923 5 82 if ($x->is_nan or $y->is_nan)
924 0 5 if ($wantarray) { }
925 0 0 if defined $downgrade
929 0 5 if defined $downgrade
939 11 71 if ($y->is_zero)
941 3 8 if ($wantarray)
944 3 8 if ($x->is_zero) { }
950 0 8 if defined $downgrade and $quo->is_int
952 0 3 if $wantarray and defined $downgrade and $rem->is_int
954 3 5 $wantarray ? :
961 0 71 if ($x->is_inf)
963 0 0 if $wantarray
964 0 0 if ($y->is_inf) { }
967 0 0 $x->bcmp(0) == $y->bcmp(0) ? :
971 0 0 if defined $downgrade and $quo->is_int
973 0 0 if $wantarray and defined $downgrade and $rem->is_int
975 0 0 $wantarray ? :
982 2 69 if ($y->is_inf)
984 0 2 if ($wantarray) { }
985 0 0 if ($x->is_zero or $x->bcmp(0) == $y->bcmp(0)) { }
992 0 0 if defined $downgrade and $quo->is_int
994 0 0 if defined $downgrade and $rem->is_int
998 2 0 if ($y->is_inf)
999 0 2 if ($x->is_nan or $x->is_inf) { }
1000 0 0 if defined $downgrade
1003 0 2 if defined $downgrade
1014 3 66 if ($x->is_zero)
1015 0 0 $wantarray ? :
0 3 if defined $downgrade
1017 1 2 $wantarray ? :
1032 54 12 $x->{'sign'} eq $y->{'sign'} ? :
1035 6 60 if (wantarray) { }
1040 0 6 if defined $downgrade and $x->is_int
1041 0 6 if defined $downgrade and $rem->is_int
1054 0 21 if (not ref $_[0] or ref $_[0] ne ref $_[1])
1058 0 21 if $x->modify("bmod")
1063 2 19 if ($x->is_nan or $y->is_nan)
1069 0 19 if ($y->is_zero)
1070 0 0 if defined $downgrade
1077 0 19 if ($x->is_inf)
1084 0 19 if ($y->is_inf)
1085 0 0 if ($x->is_zero or $x->bcmp(0) == $y->bcmp(0)) { }
1086 0 0 if defined $downgrade and $x->is_int
1089 0 0 if defined $downgrade
1097 0 19 if ($x->is_zero)
1098 0 0 if defined $downgrade
1114 12 0 ref $_[0] ? :
1116 3 9 unless ($x->{'sign'} =~ /^[+-]$/)
1117 2 1 if defined $downgrade
1121 1 8 if ($x->{'sign'} eq '-') { }
1124 3 5 if ($LIB->_acmp($x->{'_n'}, $x->{'_d'}) < 0) { }
1138 13 0 ref $_[0] ? :
1140 3 10 unless ($x->{'sign'} =~ /^[+-]$/)
1141 2 1 if defined $downgrade
1145 3 7 if ($x->{'sign'} eq '-') { }
1146 2 1 if ($LIB->_acmp($x->{'_n'}, $x->{'_d'}) < 0) { }
1163 0 20 if $x->modify("binv")
1165 2 18 if $x->is_nan
1166 4 14 if $x->is_inf
1167 2 12 if $x->is_zero
1178 9820 0 ref $_[0] ? :
1181 9789 31 if $x->{'sign'} =~ /^[+-]$/ and $LIB->_is_one($x->{'_d'})
1187 659 0 ref $_[0] ? :
1189 83 576 if $x->{'sign'} eq "+" and $LIB->_is_zero($x->{'_n'})
1195 311 0 ref $_[0] ? :
1197 0 311 if @_ > 2
1199 218 93 if $sign ne "-"
1201 37 140 if $x->{'sign'} eq $sign and $LIB->_is_one($x->{'_n'}) and $LIB->_is_one($x->{'_d'})
1207 25 0 ref $_[0] ? :
1210 10 11 if $x->{'sign'} =~ /^[+-]$/ and ($LIB->_is_one($x->{'_d'}) and $LIB->_is_odd($x->{'_n'}))
1216 18 0 ref $_[0] ? :
1218 3 15 unless $x->{'sign'} =~ /^[+-]$/
1220 6 9 if $LIB->_is_one($x->{'_d'}) and $LIB->_is_even($x->{'_n'})
1228 39 0 ref $_[0] ? :
1231 15 24 unless $x->{'sign'} =~ /^[+-]$/
1239 35 0 ref $_[0] ? :
1242 9 26 if $x->{'sign'} eq "NaN"
1244 6 20 unless $x->{'sign'} =~ /^[+-]$/
1250 11 0 ref $_[0] ? :
1254 1 10 if $x->{'sign'} eq "NaN"
1255 1 9 if $x->{'sign'} eq "+inf"
1256 1 8 if $x->{'sign'} eq "-inf"
1268 0 16 unless $class
1270 2 14 if ($x->is_nan)
1271 1 1 if wantarray
1275 4 10 if ($x->is_inf)
1276 2 2 if wantarray
1285 5 5 unless wantarray
1297 0 14 unless $class
1299 1 13 if $x->is_nan
1312 5 0 ref $_[0] ? :
1314 0 5 unless $x->is_int
1319 11 0 ref $_[0] ? :
1321 0 11 unless $x->is_int
1329 24 0 ref $_[0] ? :
1331 10 14 if (not $x->{'sign'} =~ /^[+-]$/ or $LIB->_is_one($x->{'_d'}))
1334 2 8 if defined $downgrade
1340 8 6 if $x->{'sign'} eq "+"
1341 2 12 if $x->{'sign'} eq "-" and $LIB->_is_zero($x->{'_n'})
1342 1 13 if defined $downgrade
1347 52 0 ref $_[0] ? :
1349 24 28 if (not $x->{'sign'} =~ /^[+-]$/ or $LIB->_is_one($x->{'_d'}))
1352 2 22 if defined $downgrade
1358 11 17 if $x->{'sign'} eq "-"
1359 1 27 if defined $downgrade
1364 963 0 ref $_[0] ? :
1366 552 411 if (not $x->{'sign'} =~ /^[+-]$/ or $LIB->_is_one($x->{'_d'}))
1369 2 550 if defined $downgrade
1375 1 410 if $x->{'sign'} eq "-" and $LIB->_is_zero($x->{'_n'})
1376 1 410 if defined $downgrade
1381 13 0 ref $_[0] ? :
1384 3 10 if ($x->{'sign'} ne "+" or not $LIB->_is_one($x->{'_d'}))
1400 6 184 if (not ref $_[0] or ref $_[0] ne ref $_[1])
1404 0 190 if $x->modify("bpow")
1407 29 161 if $x->is_nan or $y->is_nan
1410 13 148 if ($x->is_inf('-')) { }
13 135 elsif ($x->is_inf('+')) { }
11 124 elsif ($y->is_inf('-')) { }
11 113 elsif ($y->is_inf('+')) { }
1411 6 7 if $y->is_negative
1412 1 6 if $y->is_zero
1413 2 4 if $y->is_odd
1416 6 7 if $y->is_negative
1417 1 6 if $y->is_zero
1420 1 10 if $x->is_one("-")
1421 3 7 if $x > -1 and $x < 1
1422 1 6 if $x->is_one("+")
1425 1 10 if $x->is_one("-")
1426 3 7 if $x > -1 and $x < 1
1427 1 6 if $x->is_one("+")
1431 11 102 if ($x->is_zero)
1432 1 10 if $y->is_zero
1433 5 5 if $y->is_negative
1439 20 82 if ($x->is_negative and not $y->is_int)
1440 0 20 if defined $upgrade
1445 20 62 if ($x->is_one("+") or $y->is_one)
1449 6 56 if ($x->is_one("-"))
1450 3 3 if $y->is_odd
1455 24 32 if $y->is_negative
1457 47 9 unless ($LIB->_is_one($y->{'_n'}))
1460 12 35 if $x->{'sign'} eq "-" and $LIB->_is_even($y->{'_n'})
1463 2 54 unless ($LIB->_is_one($y->{'_d'}))
1464 1 1 if $LIB->_is_two($y->{'_d'})
1481 0 20 if (not ref $_[0] and $_[0] =~ /^[A-Za-z]|::/) { }
1483 0 0 defined $_[2] ? :
1487 10 10 defined $_[1] ? :
1491 0 20 if $x->modify("blog")
1496 5 15 if $x->is_nan
1498 7 8 if (defined $base)
1499 0 7 unless ref $base
1500 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) { }
1503 0 0 if $x->is_inf or $x->is_zero
1506 0 2 if $x->is_one
1507 0 2 if $x == $base
1510 0 3 if $x == $base
1515 2 9 if ($x->is_inf) { }
2 7 elsif ($x->is_neg) { }
1 6 elsif ($x->is_one) { }
3 3 elsif ($x->is_zero) { }
1516 0 2 defined $base && $base < 1 ? :
1523 0 3 defined $base && $base < 1 ? :
1534 0 3 if ($x->numerator->is_one)
1538 2 1 if (defined &blessed($base) and $base->isa($class))
1539 0 2 if ($base->numerator->is_one)
1547 2 1 if defined $base
1558 0 3 $neg ? :
1566 1 0 if (not ref $_[0] or ref $_[0] ne ref $_[1])
1570 0 1 if $x->{'sign'} eq "+inf"
1571 0 1 if $x->{'sign'} eq "-inf"
1579 0 1 if $x->{'sign'} eq "NaN"
1582 1 0 if (scalar @params == 0) { }
1594 0 1 if $x->is_zero
1600 1 0 if ($scale <= 75) { }
1635 1 0 if (not $x_org->is_one) { }
1642 0 0 if (defined $params[0]) { }
1648 1 0 if ($fallback)
1661 2478 2478 if (not ref $_[0] or ref $_[0] ne ref $_[1])
1665 24 4932 if $x->is_nan or $y->is_nan
1666 0 4932 if $x->is_finite and not $x->is_int or $y->is_finite and not $y->is_int
1685 5 2 if (not ref $_[0] or ref $_[0] ne ref $_[1])
1717 0 19 if (not ref $_[0] or ref $_[0] ne ref $_[1])
1740 0 17 if (not ref $_[0] or ref $_[0] ne ref $_[1])
1759 20 0 ref $_[0] ? :
1761 4 16 unless $x->{'sign'} =~ /^[+]/
1762 1 15 if $x->{'sign'} eq "+inf"
1763 2 13 if $x->is_zero or $x->is_one
1776 11 2 if ($LIB->_acmp($n, $n2) == 0)
1779 10 1 if ($LIB->_acmp($d, $d2) == 0)
1810 0 0 unless defined $b
1811 0 0 unless ref $b and $b->isa($class)
1813 0 0 if $x->is_nan or $y->is_nan or $b->is_nan
1816 0 0 if $y->{'sign'} =~ /^-/
1824 0 0 unless defined $b
1825 0 0 unless ref $b and $b->isa($class)
1827 0 0 if $x->is_nan or $y->is_nan or $b->is_nan
1830 0 0 if $y->{'sign'} =~ /^-/
1842 0 289 unless $xref
1843 0 289 if @_ < 1
1846 0 289 unless ref $y
1866 0 289 unless $xref
1867 0 289 if @_ < 1
1870 0 289 unless ref $y
1890 0 289 unless $xref
1891 0 289 if @_ < 1
1894 0 289 unless ref $y
1914 0 0 unless $xref
1934 0 0 if defined $downgrade and $x->is_int || $x->is_inf || $x->is_nan
1941 2 0 if defined $downgrade and $x->is_int || $x->is_inf || $x->is_nan
1948 2 0 if defined $downgrade and $x->is_int || $x->is_inf || $x->is_nan
1963 136 18 if (not ref $_[0] or ref $_[0] ne ref $_[1])
1967 16 138 unless ($x->{'sign'} =~ /^[+-]$/ and $y->{'sign'} =~ /^[+-]$/)
1969 0 16 if $x->{'sign'} eq $nan or $y->{'sign'} eq $nan
1971 16 0 if $x->{'sign'} eq $y->{'sign'} and $x->{'sign'} =~ /^[+-]inf$/
1973 0 0 if $x->{'sign'} eq "+inf"
1975 0 0 if $x->{'sign'} eq "-inf"
1977 0 0 if $y->{'sign'} eq "+inf"
1983 14 124 if $x->{'sign'} eq "+" and $y->{'sign'} eq "-"
1985 11 113 if $x->{'sign'} eq "-" and $y->{'sign'} eq "+"
1992 55 58 if $xz and $yz
1993 3 55 if $xz and $y->{'sign'} eq "+"
1994 0 55 if $yz and $x->{'sign'} eq "+"
2000 18 37 if $x->{'sign'} eq "-"
2010 0 50 if (not ref $_[0] or ref $_[0] ne ref $_[1])
2014 35 15 unless ($x->{'sign'} =~ /^[+-]$/ and $y->{'sign'} =~ /^[+-]$/)
2016 7 28 if $x->{'sign'} eq $nan or $y->{'sign'} eq $nan
2017 4 24 if $x->{'sign'} =~ /^[+-]inf$/ and $y->{'sign'} =~ /^[+-]inf$/
2018 12 12 if $x->{'sign'} =~ /^[+-]inf$/ and not $y->{'sign'} =~ /^[+-]inf$/
2032 0 10 unless $selfref
2033 0 10 unless @_ == 1
2044 0 0 unless $selfref
2045 0 0 unless @_ == 1
2048 0 0 defined $cmp && !$cmp ? :
2056 0 24 unless $selfref
2057 0 24 unless @_ == 1
2068 0 0 unless $selfref
2069 0 0 unless @_ == 1
2080 0 29 unless $selfref
2081 0 29 unless @_ == 1
2092 0 0 unless $selfref
2094 0 0 unless @_ == 1
2105 20 0 ref $_[0] ? :
2109 1 19 if ($x->is_nan)
2115 2 17 if ($x->is_inf)
2118 1 1 $x->is_negative ? :
2126 8 9 $LIB->_is_one($x->{'_d'}) ? :
2128 3 14 $x->{'sign'} eq '-' ? :
2132 883 0 ref $_[0] ? :
2135 6 877 unless $x->{'sign'} =~ /^[+-]$/
2139 4 873 if $x->{'sign'} eq "-"
2149 0 3 unless ref $_[0]
2152 0 3 unless $x->{'sign'} =~ /^[+-]$/
2157 2 1 unless ($LIB->_is_one($x->{'_d'}))
2166 2 0 ref $_[0] ? :
2168 0 2 unless $x->is_int
2171 2 0 if $s eq "+"
2176 2 0 ref $_[0] ? :
2178 0 2 unless $x->is_int
2180 2 0 if $s eq "+"
2185 2 0 ref $_[0] ? :
2187 0 2 unless $x->is_int
2189 2 0 if $s eq "+"
2240 1 3 if ($param eq ":constant")
2254 2 6 if $_[0] =~ /^0_*[0-7]/
2262 0 3 if ($param eq "upgrade")
2269 1 2 if ($param eq "downgrade")
2276 0 2 if ($param eq "accuracy")
2283 0 2 if ($param eq "precision")
2290 0 2 if ($param eq "round_mode")
2297 2 0 if ($param =~ /^(lib|try|only)\z/)
2304 0 0 if ($param eq "with")
2321 2 17 if $lib_param ne ""