add ffi tests using f64

This commit is contained in:
Bennet Bleßmann
2025-01-20 23:00:03 +01:00
committed by Bennet Bleßmann
parent f91aedcc2f
commit 9d8906da30
4 changed files with 129 additions and 0 deletions

View File

@@ -0,0 +1,16 @@
:- use_module(library(os)).
:- use_module(library(ffi)).
test :-
getenv("ffi_f64_minus_zero_LIB", LIB),
use_foreign_module(LIB, ['ffi_f64_minus_zero'([], f64), 'signum'([f64], f64)]),
ffi:'ffi_f64_minus_zero'(N),
A is max(0.0, N),
B is max(N, 0.0),
ffi:'signum'(A, SA),
ffi:'signum'(B, SB),
write((SA, SB)),
-1.0 is SA, % incorrect, based on https://www.swi-prolog.org/pldoc/man?function=max/2 -0.0 is less than 0.0 so A and B should be 0.0 for which signum should be 1
1.0 is SB.
:- initialization(test).

10
tests-pl/ffi_f64_nan.pl Normal file
View File

@@ -0,0 +1,10 @@
:- use_module(library(os)).
:- use_module(library(ffi)).
test :-
getenv("ffi_f64_nan_LIB", LIB),
use_foreign_module(LIB, ['ffi_f64_nan'([], f64)]),
ffi:'ffi_f64_nan'(N),
_ is round(N).
:- initialization(test).