Skip to content

Commit 94d3607

Browse files
committed
POSIX: add simple bessel function tests
1 parent 3352d0b commit 94d3607

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

ext/POSIX/t/math.t

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,4 +296,30 @@ SKIP: {
296296
ok(signbit(copysign(NAN, -1.0)), "signbit(copysign(NAN, -1.0)))");
297297
}
298298

299+
SKIP: {
300+
# win32 msvcrt and ucrt both have these as _j0() etc, but might
301+
# not make them visible in the headers
302+
$Config{d_j0} || $^O eq "MSWin32"
303+
or skip "No bessel functions", 1;
304+
# just in case j0 etc ends up being called without a prototype
305+
is_float(j0(0.5), 0.938469807240813, "j0");
306+
is_float(j1(0.5), 0.242268457674874, "j1");
307+
is_float(jn(1, 0.5), j1(0.5), "jn");
308+
is_float(y0(0.5), -0.444518733506707, "y0");
309+
is_float(y1(0.5), -1.47147239267024, "y1");
310+
is_float(yn(1, 0.5), y1(0.5), "yn");
311+
}
312+
313+
sub is_float {
314+
my ($left, $right, $note) = @_;
315+
316+
my $ok = ok(abs($left - $right) < 0.00001, $note);
317+
unless ($ok) {
318+
diag <<EOS;
319+
Expected: $left
320+
Got: $right
321+
EOS
322+
}
323+
}
324+
299325
done_testing();

0 commit comments

Comments
 (0)