From 80609802666933476bde6207149207acb0547350 Mon Sep 17 00:00:00 2001 From: Simon Cruanes Date: Mon, 14 May 2018 18:09:39 -0500 Subject: [PATCH] test(float): add some tests for FP min/max --- src/core/CCFloat.ml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/core/CCFloat.ml b/src/core/CCFloat.ml index 93d90c4f..6edd5feb 100644 --- a/src/core/CCFloat.ml +++ b/src/core/CCFloat.ml @@ -58,6 +58,20 @@ let max (x : t) y = | _, FP_nan -> x | _ -> if x > y then x else y +(*$T + max nan 1. = 1. + min nan 1. = 1. + max 1. nan = 1. + min 1. nan = 1. +*) + +(*$Q + Q.(pair float float) (fun (x,y) -> \ + is_nan x || is_nan y || (min x y <= x && min x y <= y)) + Q.(pair float float) (fun (x,y) -> \ + is_nan x || is_nan y || (max x y >= x && max x y >= y)) + *) + let equal (a:float) b = a=b let hash : t -> int = Hashtbl.hash