Skip to content

Commit

Permalink
POSIX: add simple bessel function tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tonycoz committed Jun 3, 2024
1 parent 3352d0b commit 94d3607
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions ext/POSIX/t/math.t
Original file line number Diff line number Diff line change
Expand Up @@ -296,4 +296,30 @@ SKIP: {
ok(signbit(copysign(NAN, -1.0)), "signbit(copysign(NAN, -1.0)))");
}

SKIP: {
# win32 msvcrt and ucrt both have these as _j0() etc, but might
# not make them visible in the headers
$Config{d_j0} || $^O eq "MSWin32"
or skip "No bessel functions", 1;
# just in case j0 etc ends up being called without a prototype
is_float(j0(0.5), 0.938469807240813, "j0");
is_float(j1(0.5), 0.242268457674874, "j1");
is_float(jn(1, 0.5), j1(0.5), "jn");
is_float(y0(0.5), -0.444518733506707, "y0");
is_float(y1(0.5), -1.47147239267024, "y1");
is_float(yn(1, 0.5), y1(0.5), "yn");
}

sub is_float {
my ($left, $right, $note) = @_;

my $ok = ok(abs($left - $right) < 0.00001, $note);
unless ($ok) {
diag <<EOS;
Expected: $left
Got: $right
EOS
}
}

done_testing();

0 comments on commit 94d3607

Please sign in to comment.