From: Paul Eggert Date: Fri, 15 Apr 2022 02:03:41 +0000 (-0700) Subject: New time-equal-p test X-Git-Tag: emacs-29.0.90~1931^2~563 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=7c17bd2a6d8d7cf710051cd7ca00260c1e557609;p=emacs.git New time-equal-p test * test/src/timefns-tests.el (time-equal-p-NaN-NaN): New test. --- diff --git a/src/timefns.c b/src/timefns.c index 6cfb787af8f..b061be0a786 100644 --- a/src/timefns.c +++ b/src/timefns.c @@ -1221,7 +1221,8 @@ time_cmp (Lisp_Object a, Lisp_Object b) /* Compare nil to nil correctly, and handle other eq values quicker while we're at it. Compare here rather than earlier, to handle - NaNs and check formats. */ + NaNs. This means (time-equal-p X X) does not signal an error if + X is not a valid time value, but that's OK. */ if (EQ (a, b)) return 0; diff --git a/test/src/timefns-tests.el b/test/src/timefns-tests.el index 1b49e0622f5..e7c464472d0 100644 --- a/test/src/timefns-tests.el +++ b/test/src/timefns-tests.el @@ -169,6 +169,10 @@ a fixed place on the right and are padded on the left." (ert-deftest time-equal-p-nil-nil () (should (time-equal-p nil nil))) +(ert-deftest time-equal-p-NaN-NaN () + (let ((x 0.0e+NaN)) + (should (not (time-equal-p x x))))) + (ert-deftest time-arith-tests () (let ((time-values (list 0 -1 1 0.0 -0.0 -1.0 1.0 most-negative-fixnum most-positive-fixnum