From fad58ca8c221def75093463e917f66fc006f3df5 Mon Sep 17 00:00:00 2001 From: Mathieu Lirzin Date: Mon, 26 Mar 2018 16:39:13 +0200 Subject: job-specifier: Preserve '%find-best-next' arguments exactness MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The behavior of the 'min' procedure which converts its parameters to inexact numbers when at least one of them is inexact was causing '%find-best-next' to always return real numbers. * src/mcron/job-specifier.scm (%find-best-next): Preserve the exactness of numbers in NEXT-LIST. * tests/job-specifier.scm ("%find-best-next: exact"): New test. Reported-by: Ludovic Courtès --- tests/job-specifier.scm | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/job-specifier.scm b/tests/job-specifier.scm index 889530b..48a46de 100644 --- a/tests/job-specifier.scm +++ b/tests/job-specifier.scm @@ -16,7 +16,8 @@ ;;; You should have received a copy of the GNU General Public License ;;; along with GNU Mcron. If not, see . -(use-modules (srfi srfi-64) +(use-modules (ice-9 match) + (srfi srfi-64) (mcron job-specifier)) (test-begin "job-specifier") @@ -40,4 +41,12 @@ (test-assert "range: reverse boundaries" (range 10 3)) +(define %find-best-next (@@ (mcron job-specifier) %find-best-next)) + +(test-assert "%find-best-next: exact" + ;; Ensure that '%find-best-next' preserves the exactness of the numbers + ;; inside the NEXT-LIST argument. + (match (pk 'match (%find-best-next 1 '(0 2))) + ((a . b) (and (exact? a) (exact? b))))) + (test-end) -- cgit v1.2.3