bug-gnu-emacs
[Top][All Lists]
Advanced

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

bug#40562: [patch] Treat records as arrays in ert object comparisons and


From: Clément Pit-Claudel
Subject: bug#40562: [patch] Treat records as arrays in ert object comparisons and add support for cl-structs
Date: Sat, 11 Apr 2020 16:34:57 -0400
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.4.1

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.

Attachment: 0001-lisp-emacs-lisp-ert.el-ert-explain-equal-rec-Treat-r.patch
Description: Text Data

Attachment: 0002-lisp-emacs-lisp-ert.el-ert-explain-equal-rec-Add-sup.patch
Description: Text Data


reply via email to

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