From 74c1a75906c6143b2060c03923c919332a905f84 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Thu, 1 Jan 1970 00:00:00 +0000 Subject: [PATCH] Patch the tests so they don't use absolute float equality. --- ocaml-calendar/test_ftime.ml | 5 +++-- ocaml-calendar/test_time.ml | 7 ++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/ocaml-calendar/test_ftime.ml b/ocaml-calendar/test_ftime.ml index fcddc3a..de60db8 100644 --- a/ocaml-calendar/test_ftime.ml +++ b/ocaml-calendar/test_ftime.ml @@ -49,8 +49,9 @@ test (is_am (make (- 34) 0 0.)) "is_am (- 34) 0 0";; test (not (is_am (make 34 0 0.))) "not (is_pm 34 0 0)";; let one_two_three = Period.make 1 2 3.;; -test (Period.to_seconds one_two_three = 3723.) "Period.to_seconds";; -test (Period.to_minutes one_two_three = 62.05) "Period.to_minutes";; +let eq f1 f2 = abs_float (f1 -. f2) < 1e-5;; +test (eq (Period.to_seconds one_two_three) 3723.) "Period.to_seconds";; +test (eq (Period.to_minutes one_two_three) 62.05) "Period.to_minutes";; test (Utils.Float.equal (Period.to_hours (Period.make 1 3 0.1)) 1.050028) "Period.to_hours";; diff --git a/ocaml-calendar/test_time.ml b/ocaml-calendar/test_time.ml index 4c034d9..775ac04 100644 --- a/ocaml-calendar/test_time.ml +++ b/ocaml-calendar/test_time.ml @@ -28,8 +28,9 @@ test (minute (make 20 10 0) = 10) "minute";; test (second (make 20 10 5) = 5) "second";; let one_two_three = make 1 2 3;; +let eq f1 f2 = abs_float (f1 -. f2) < 1e-5;; test (to_seconds one_two_three = 3723) "to_seconds";; -test (to_minutes one_two_three = 62.05) "to_minutes";; +test (eq (to_minutes one_two_three) 62.05) "to_minutes";; test (to_hours (make 1 3 0) = 1.05) "to_hours";; test (from_seconds 3723 = from_minutes 62.05) "from_seconds; from_minutes";; test (from_hours 1.05 = make 1 3 0) "from_hours";; @@ -44,8 +45,8 @@ test (not (is_am (make 34 0 0))) "not (is_pm 34 0 0)";; let one_two_three = Period.make 1 2 3;; test (Period.to_seconds one_two_three = 3723) "Period.to_seconds";; -test (Period.to_minutes one_two_three = 62.05) "Period.to_minutes";; -test (Period.to_hours (Period.make 1 3 0) = 1.05) "Period.to_hours";; +test (eq (Period.to_minutes one_two_three) 62.05) "Period.to_minutes";; +test (eq (Period.to_hours (Period.make 1 3 0)) 1.05) "Period.to_hours";; let ok = nb_ok ();; let bug = nb_bug ();; -- 1.8.3.1