leto / math--gsl

Perl interface to the GNU Scientific Library
http://leto.net/code/Math-GSL
33 stars 25 forks source link

Fix failing test TEST_RT66882 in t/SF.t #204

Open hakonhagland opened 4 years ago

hakonhagland commented 4 years ago

See previous discussion in #176. I open a new issue here since the discussion in #176 also involved another failing test and I think it is becoming difficult to get an overview.

So this issue is about the first failed test for perl 5.20.1 on FreeBSD, it says:

t/SF.t           (Wstat: 0 Tests: 1074 Failed: 1)
  Failed test:  22

It I try run the SF.t test by it self:

$ prove -lv  t/SF.t
[...]
ok 22 - gsl_sf_fermi_dirac_m1_e(10.0, $r) ?= 0.999954602131298, # TODO loss of precision on Perls with DUSELONGDOUBLE
# res= +-0, eps=2.21777808290173e-17
# 
[...]

So test #22 in SF.t seems to be this one TEST_RT66882:

sub TEST_RT66882 : Tests {
    # This test was losing a small amount of precision with
    # perls that have DUSELONGDOUBLE, so give it some leeway
    # Where is the loss of precision coming from? Is it a bug in Perl, GSL or Math::GSL ?
    # A beer if you figure it out.
    # why doesn't $TODO work here?
    local $TODO = "loss of precision on Perls with DUSELONGDOUBLE";

    # additional diagnostics
    local %ENV; $ENV{DEBUG} = 1;
    my $results = {
        'gsl_sf_fermi_dirac_m1_e(10.0, $r)' => 0.9999546021312975656,
    };
    verify_results($results, 'Math::GSL::SF', 1e-16);
}

The RT ticket: Fails on perls compiled with -Duselongdouble. The strange thing is that it is already a TODO test and as the comment says "why doesn't $TODO work here?"

I sent an email to the cpantester Slaven Rezic regarding this failed test, and I got the following response:

Hello Håkon,

The full output of this test case is
# result->err: 2.21777808290172611e-19
# result->val: 0.99995460213129761
# expected   : 0.999954602131297566
# difference : 4.401860820291148e-17
# unexpected error of 2.18408273738942189e-17
not ok 22 - gsl_sf_fermi_dirac_m1_e(10.0, $r) ?= 0.99995460213129761,
# res= +-4.401860820291148e-17, eps=2.21777808290172611e-17 # TODO loss of precision on Perls with DUSELONGDOUBLE
#   Failed (TODO) test 'gsl_sf_fermi_dirac_m1_e(10.0, $r) ?= 0.99995460213129761,
# res= +-4.401860820291148e-17, eps=2.21777808290172611e-17'
#   at t/SF.t line 43.
#   (in Math::GSL::SF::Test->TEST_RT66882)
#     '4.401860820291148e-17'
#         <=
#     '2.21777808290172611e-17'

So there's a "TODO" indication, but IMHO on the wrong line --- it should be on the the same line as the corresponding "not ok".

Some tests later there's a TODO indication which works:
not ok 1073 - gsl_sf_bessel_kl_scaled_array(1,1) lives  # TODO gsl_sf_bessel_kl_scaled_array is missing
#   Failed (TODO) test 'gsl_sf_bessel_kl_scaled_array(1,1) lives '
#   at t/SF.t line 1341.
#   (in Math::GSL::SF::Test->TEST_ZBESSEL_ARRAYS)
# died: Undefined subroutine &Math::GSL::SF::gsl_sf_bessel_kl_scaled_array called at t/SF.t line 1340.

Regards,
    Slaven