From: "Štěpán Němec" <stepnem@gmail.com>
To: "Clément Pit-Claudel" <cpitclaudel@gmail.com>
Cc: lars <lars@nocrew.org>, 40562@debbugs.gnu.org
Subject: bug#40562: [patch] Treat records as arrays in ert object comparisons and add support for cl-structs
Date: Sun, 12 Apr 2020 01:26:41 +0200 [thread overview]
Message-ID: <87a73heh8u.fsf@gmail.com> (raw)
In-Reply-To: <d2503db8-006e-10d4-4cd6-846d5ffb1626@gmail.com> ("Clément Pit-Claudel"'s message of "Sat, 11 Apr 2020 16:34:57 -0400")
On Sat, 11 Apr 2020 16:34:57 -0400
Clément Pit-Claudel wrote:
[...]
> (defvar xyz123 (make-xyz :a 1 :b 2 :c 3))
> (defvar xyz143 (make-xyz :a 1 :b 4 :c 3))
[...]
> The first attached patch fixes this for all records.
Seems like a nice addition.
> 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" "?"))))
^gotcha
> lisp/emacs-lisp/ert.el | 7 +++++++
> 1 file changed, 7 insertions(+)
>
> diff --git a/lisp/emacs-lisp/ert.el b/lisp/emacs-lisp/ert.el
> index 74202183cc..e3666a84c0 100644
> --- a/lisp/emacs-lisp/ert.el
> +++ b/lisp/emacs-lisp/ert.el
> @@ -515,6 +515,13 @@ ert--explain-equal-rec
> `(cdr ,cdr-x)
> (cl-assert (equal a b) t)
> nil))))))))
> + ((pred cl-struct-p)
> + (cl-loop for slot in (cdr (cl-struct-slot-info (type-of a)))
> + for ai across a
^^^^^^^^^^^^^^^
This is incorrect, as witnessed by your very example (`c' instead of
`b'). Records are accessible with `aref', but the first slot is the type
descriptor, so you're making an off-by-one error here.
> + 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)
Thanks,
Štěpán
next prev parent reply other threads:[~2020-04-11 23:26 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-11 20:34 bug#40562: [patch] Treat records as arrays in ert object comparisons and add support for cl-structs Clément Pit-Claudel
2020-04-11 23:26 ` Štěpán Němec [this message]
2020-04-12 3:06 ` Clément Pit-Claudel
2020-04-12 9:24 ` Štěpán Němec
2020-04-12 15:50 ` Clément Pit-Claudel
2020-04-25 21:27 ` Clément Pit-Claudel
2020-08-08 13:02 ` Lars Ingebrigtsen
2020-08-18 14:07 ` Lars Ingebrigtsen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87a73heh8u.fsf@gmail.com \
--to=stepnem@gmail.com \
--cc=40562@debbugs.gnu.org \
--cc=cpitclaudel@gmail.com \
--cc=lars@nocrew.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.