[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 7c17bd2a6d 1/2: New time-equal-p test
From: |
Paul Eggert |
Subject: |
master 7c17bd2a6d 1/2: New time-equal-p test |
Date: |
Thu, 14 Apr 2022 22:10:00 -0400 (EDT) |
branch: master
commit 7c17bd2a6d8d7cf710051cd7ca00260c1e557609
Author: Paul Eggert <eggert@cs.ucla.edu>
Commit: Paul Eggert <eggert@cs.ucla.edu>
New time-equal-p test
* test/src/timefns-tests.el (time-equal-p-NaN-NaN): New test.
---
src/timefns.c | 3 ++-
test/src/timefns-tests.el | 4 ++++
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/src/timefns.c b/src/timefns.c
index 6cfb787af8..b061be0a78 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 1b49e0622f..e7c464472d 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