From 8fb995b9e360270b6a4d7b7732a127a6234eba23 Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Sat, 7 Jul 2018 22:19:21 -0600 Subject: [PATCH] Make min and max handle bignums * src/data.c (minmax_driver): Handle bignums. * test/src/data-tests.el (data-tests-minmax): New test. --- src/data.c | 4 ++-- test/src/data-tests.el | 7 +++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/data.c b/src/data.c index 2e366b5313f..7ded8366e32 100644 --- a/src/data.c +++ b/src/data.c @@ -3119,11 +3119,11 @@ minmax_driver (ptrdiff_t nargs, Lisp_Object *args, enum Arith_Comparison comparison) { Lisp_Object accum = args[0]; - CHECK_FIXNUM_OR_FLOAT_COERCE_MARKER (accum); + CHECK_NUMBER_COERCE_MARKER (accum); for (ptrdiff_t argnum = 1; argnum < nargs; argnum++) { Lisp_Object val = args[argnum]; - CHECK_FIXNUM_OR_FLOAT_COERCE_MARKER (val); + CHECK_NUMBER_COERCE_MARKER (val); if (!NILP (arithcompare (val, accum, comparison))) accum = val; else if (FLOATP (val) && isnan (XFLOAT_DATA (val))) diff --git a/test/src/data-tests.el b/test/src/data-tests.el index 561b7bd9ca6..4565cfb3877 100644 --- a/test/src/data-tests.el +++ b/test/src/data-tests.el @@ -590,4 +590,11 @@ comparing the subr with a much slower lisp implementation." (ert-deftest data-tests-logcount () (should (= (logcount (read "#xffffffffffffffffffffffffffffffff")) 128))) +(ert-deftest data-tests-minmax () + (let ((a (- most-negative-fixnum 1)) + (b (+ most-positive-fixnum 1)) + (c 0)) + (should (= (min a b c) a)) + (should (= (max a b c) b)))) + ;;; data-tests.el ends here -- 2.39.2