GNU bug report logs -
#40562
[patch] Treat records as arrays in ert object comparisons and add support for cl-structs
Previous Next
Reported by: Clément Pit-Claudel <cpitclaudel <at> gmail.com>
Date: Sat, 11 Apr 2020 20:36:01 UTC
Severity: normal
Tags: fixed, patch
Fixed in version 28.1
Done: Lars Ingebrigtsen <larsi <at> gnus.org>
Bug is archived. No further changes may be made.
Full log
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
Hi all,
With the introduction of native records ert lost the ability to peek inside structures when comparing unequal values:
(require 'ert)
(cl-defstruct xyz a b c)
(defvar xyz123 (make-xyz :a 1 :b 2 :c 3))
(defvar xyz143 (make-xyz :a 1 :b 4 :c 3))
(should (equal xyz123 xyz143))
Emacs 25 said this:
Test failed: ((should (equal xyz123 xyz143))
:form (equal [cl-struct-xyz 1 2 3 nil] [cl-struct-xyz 1 4 3 nil])
:value nil
:explanation (array-elt 2 (different-atoms (2 "#x2" "?") (4 "#x4" "?"))))
Emacs 26 says this:
Test failed: ((should (equal xyz123 xyz143))
:form (equal #s(xyz 1 2 3) #s(xyz 1 4 3))
:value nil
:explanation (different-atoms #s(xyz 1 2 3) #s(xyz 1 4 3)))
The first attached patch fixes this for all records. The second patch adds special support for cl-structs, to get this:
Test failed: ((should (equal xyz123 xyz143))
:form (equal #s(xyz 1 2 3) #s(xyz 1 4 3))
:value nil
:explanation (struct-field c (different-atoms (2 "#x2" "?") (4 "#x4" "?"))))
Clément.
[0001-lisp-emacs-lisp-ert.el-ert-explain-equal-rec-Treat-r.patch (text/x-patch, attachment)]
[0002-lisp-emacs-lisp-ert.el-ert-explain-equal-rec-Add-sup.patch (text/x-patch, attachment)]
This bug report was last modified 4 years and 278 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.