emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 82893e9 1/2: Fix ert ability to peek inside structures when compa


From: Lars Ingebrigtsen
Subject: master 82893e9 1/2: Fix ert ability to peek inside structures when comparing unequal values
Date: Tue, 18 Aug 2020 10:45:41 -0400 (EDT)

branch: master
commit 82893e9e8e0dae5cbd3ae26a7ee92896fcadfdae
Author: Clément Pit-Claudel <clement.pitclaudel@live.com>
Commit: Lars Ingebrigtsen <larsi@gnus.org>

    Fix ert ability to peek inside structures when comparing unequal values
    
    * lisp/emacs-lisp/ert.el (ert--explain-equal-rec): Treat records
    as arrays (bug#40562).  Also add support for cl-structs.
---
 lisp/emacs-lisp/ert.el | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/lisp/emacs-lisp/ert.el b/lisp/emacs-lisp/ert.el
index 764354b..241eece 100644
--- a/lisp/emacs-lisp/ert.el
+++ b/lisp/emacs-lisp/ert.el
@@ -515,7 +515,14 @@ Returns nil if they are."
                        `(cdr ,cdr-x)
                      (cl-assert (equal a b) t)
                      nil))))))))
-      ((pred arrayp)
+      ((pred cl-struct-p)
+       (cl-loop for slot in (cl-struct-slot-info (type-of a))
+                for ai across a
+                for bi across b
+                for xf = (ert--explain-equal-rec ai bi)
+                do (when xf (cl-return `(struct-field ,(car slot) ,xf)))
+                finally (cl-assert (equal a b) t)))
+      ((or (pred arrayp) (pred recordp))
        ;; For mixed unibyte/multibyte string comparisons, make both multibyte.
        (when (and (stringp a)
                   (xor (multibyte-string-p a) (multibyte-string-p b)))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]