summaryrefslogtreecommitdiff
path: root/lisp/emacs-lisp
diff options
context:
space:
mode:
authorClément Pit-Claudel <clement.pitclaudel@live.com>2020-08-18 16:06:29 +0200
committerLars Ingebrigtsen <larsi@gnus.org>2020-08-18 16:06:35 +0200
commit82893e9e8e0dae5cbd3ae26a7ee92896fcadfdae (patch)
treef63565c98cbd11a7622f4a4f022f13eb29bbe287 /lisp/emacs-lisp
parent21c580566e348511a68968cd91215651f88a9336 (diff)
downloademacs-82893e9e8e0dae5cbd3ae26a7ee92896fcadfdae.tar.gz
emacs-82893e9e8e0dae5cbd3ae26a7ee92896fcadfdae.tar.bz2
emacs-82893e9e8e0dae5cbd3ae26a7ee92896fcadfdae.zip
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.
Diffstat (limited to 'lisp/emacs-lisp')
-rw-r--r--lisp/emacs-lisp/ert.el9
1 files changed, 8 insertions, 1 deletions
diff --git a/lisp/emacs-lisp/ert.el b/lisp/emacs-lisp/ert.el
index 764354b03b7..241eece05b6 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)))