From 4991f5a24486ff562184953e11728ca073bc6cc3 Mon Sep 17 00:00:00 2001 From: Tony Cook Date: Mon, 27 May 2024 12:03:04 +1000 Subject: [PATCH] POSIX: add simple bessel function tests --- ext/POSIX/t/math.t | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/ext/POSIX/t/math.t b/ext/POSIX/t/math.t index ce9090cb48e5..2332c0834a29 100644 --- a/ext/POSIX/t/math.t +++ b/ext/POSIX/t/math.t @@ -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 <