Skip to content

Commit

Permalink
t/overload_cross_class.t - skip Math::MPFR checks if $Math::MPFR::VER…
Browse files Browse the repository at this point in the history
…SION < 4.19
  • Loading branch information
sisyphus committed Aug 6, 2023
1 parent 36ed707 commit f4d5aa2
Showing 1 changed file with 55 additions and 63 deletions.
118 changes: 55 additions & 63 deletions t/overload_cross_class.t
Original file line number Diff line number Diff line change
Expand Up @@ -10,81 +10,73 @@ eval {require Math::MPFR;};


unless($@) {
if($Math::MPFR::VERSION <= 3.12) {
warn "\n Skipping tests - Math::MPFR version 3.13 (or later)\n" .
if($Math::MPFR::VERSION < 4.19) {
warn "\n Skipping tests - Math::MPFR version 4.19 (or later)\n" .
" is needed. We have only version $Math::MPFR::VERSION\n";
print "ok 1\n";
}
else {

if($Math::MPFR::VERSION >= 4.19) {
# Run the tests.
$op = Math::MPFR->new(100);
$op_pow = Math::MPFR->new(3.5);
$mpq = Math::GMPq->new(10075);

# Run the tests.
$op = Math::MPFR->new(100);
$op_pow = Math::MPFR->new(3.5);
$mpq = Math::GMPq->new(10075);

$rop = $mpq + $op;
if(ref($rop) eq 'Math::MPFR'){$ok .= 'a'}
else { warn "1a: ref: ", ref($rop), "\n"}
if($rop == 10175) {$ok .= 'b'}
else {warn "1b: \$rop: $rop\n"}

$rop = $mpq * $op;
if(ref($rop) eq 'Math::MPFR'){$ok .= 'c'}
else { warn "1c: ref: ", ref($rop), "\n"}
if($rop == 1007500) {$ok .= 'd'}
else {warn "1d: \$rop: $rop\n"}

$rop = $mpq - $op;
if(ref($rop) eq 'Math::MPFR'){$ok .= 'e'}
else { warn "1e: ref: ", ref($rop), "\n"}
if($rop == 9975) {$ok .= 'f'}
else {warn "1f: \$rop: $rop\n"}

$rop = $mpq / $op;
if(ref($rop) eq 'Math::MPFR'){$ok .= 'g'}
else { warn "1g: ref: ", ref($rop), "\n"}
if($rop == 100.75) {$ok .= 'h'}
else {warn "1h: \$rop: $rop\n"}

$mpq /= 100;
$mpq -= 0.75;

$rop = $mpq ** $op_pow;
if(ref($rop) eq 'Math::MPFR'){$ok .= 'i'}
else { warn "1i: ref: ", ref($rop), "\n"}
if($rop == 10000000) {$ok .= 'j'}
else {warn "1j: \$rop: $rop\n"}

my $ccount = Math::GMPq::_wrap_count();

for(1..100) {
$rop = $mpq + $op;
if(ref($rop) eq 'Math::MPFR'){$ok .= 'a'}
else { warn "1a: ref: ", ref($rop), "\n"}
if($rop == 10175) {$ok .= 'b'}
else {warn "1b: \$rop: $rop\n"}

$rop = $mpq * $op;
if(ref($rop) eq 'Math::MPFR'){$ok .= 'c'}
else { warn "1c: ref: ", ref($rop), "\n"}
if($rop == 1007500) {$ok .= 'd'}
else {warn "1d: \$rop: $rop\n"}

$rop = $mpq - $op;
if(ref($rop) eq 'Math::MPFR'){$ok .= 'e'}
else { warn "1e: ref: ", ref($rop), "\n"}
if($rop == 9975) {$ok .= 'f'}
else {warn "1f: \$rop: $rop\n"}

$rop = $mpq * $op;
$rop = $mpq / $op;
if(ref($rop) eq 'Math::MPFR'){$ok .= 'g'}
else { warn "1g: ref: ", ref($rop), "\n"}
if($rop == 100.75) {$ok .= 'h'}
else {warn "1h: \$rop: $rop\n"}
$rop = $mpq ** $op_pow;
}

$mpq /= 100;
$mpq -= 0.75;
my $ncount = Math::GMPq::_wrap_count();

$rop = $mpq ** $op_pow;
if(ref($rop) eq 'Math::MPFR'){$ok .= 'i'}
else { warn "1i: ref: ", ref($rop), "\n"}
if($rop == 10000000) {$ok .= 'j'}
else {warn "1j: \$rop: $rop\n"}

my $ccount = Math::GMPq::_wrap_count();

for(1..100) {
$rop = $mpq + $op;
$rop = $mpq - $op;
$rop = $mpq * $op;
$rop = $mpq / $op;
$rop = $mpq ** $op_pow;
}

my $ncount = Math::GMPq::_wrap_count();

if($ccount == $ncount) {$ok .= 'k'}
else {
warn "1k: \$ccount: $ccount \$ncount: $ncount\n";
warn "Looks like we have a memory leak\n" if $ncount > $ccount;
}

if($ok eq 'abcdefghijk') {print "ok 1\n"}
else {
warn "\$ok: $ok\n";
print "not ok 1\n";
}
if($ccount == $ncount) {$ok .= 'k'}
else {
warn "1k: \$ccount: $ccount \$ncount: $ncount\n";
warn "Looks like we have a memory leak\n" if $ncount > $ccount;
}

if($ok eq 'abcdefghijk') {print "ok 1\n"}
else {
warn "\nSkipping all tests, as some of these tests will fail.\n";
warn "Math-MPFR-4.19 or later is needed for all tests to PASS\n";
warn "We have only version $Math::MPFR::VERSION";
print "ok 1\n";
warn "\$ok: $ok\n";
print "not ok 1\n";
}
}
}
Expand Down

0 comments on commit f4d5aa2

Please sign in to comment.