aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
authorStefan Kangas2021-10-21 19:53:00 +0200
committerStefan Kangas2021-10-31 03:02:32 +0100
commit54b8ec4e6fb1eeac049e7bd68372e78c180fe8e4 (patch)
treeebcb91138aae1c7f7234f0540b9f275c22f19655 /lisp
parent8227d1273e2b82dbed14c0cba06959083d377745 (diff)
downloademacs-54b8ec4e6fb1eeac049e7bd68372e78c180fe8e4.tar.gz
emacs-54b8ec4e6fb1eeac049e7bd68372e78c180fe8e4.zip
Remove workaround for fixed Bug#6581 from ert
* lisp/emacs-lisp/ert.el (ert-equal-including-properties): Make into obsolete function alias for 'equal-including-properties'. * test/src/editfns-tests.el (format-properties): * test/lisp/emacs-lisp/ert-x-tests.el (ert-propertized-string) (ert-test-run-tests-interactively-2): Don't use above obsolete name. (ert--explain-equal-including-properties-rec): New function. (ert--explain-equal-including-properties): Use as an explainer for 'equal-including-properties' now that Bug#6581 is fixed. * test/lisp/emacs-lisp/ert-tests.el (ert-test-explain-equal-string-properties): Expand test. (ert-test-equal-including-properties): Merge test into above expanded test.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/emacs-lisp/ert.el55
1 files changed, 20 insertions, 35 deletions
diff --git a/lisp/emacs-lisp/ert.el b/lisp/emacs-lisp/ert.el
index f7cf1e4289a..aff38040271 100644
--- a/lisp/emacs-lisp/ert.el
+++ b/lisp/emacs-lisp/ert.el
@@ -89,24 +89,6 @@ Use nil for no limit (caution: backtrace lines can be very long)."
89 :background "red3")) 89 :background "red3"))
90 "Face used for unexpected results in the ERT results buffer.") 90 "Face used for unexpected results in the ERT results buffer.")
91 91
92
93;;; Copies/reimplementations of cl functions.
94
95;; FIXME: Bug#6581 is fixed, so this should be deleted.
96(defun ert-equal-including-properties (a b)
97 "Return t if A and B have similar structure and contents.
98
99This is like `equal-including-properties' except that it compares
100the property values of text properties structurally (by
101recursing) rather than with `eq'. Perhaps this is what
102`equal-including-properties' should do in the first place; see
103Emacs bug 6581 at URL `https://debbugs.gnu.org/cgi/bugreport.cgi?bug=6581'."
104 ;; This implementation is inefficient. Rather than making it
105 ;; efficient, let's hope bug 6581 gets fixed so that we can delete
106 ;; it altogether.
107 (not (ert--explain-equal-including-properties a b)))
108
109
110;;; Defining and locating tests. 92;;; Defining and locating tests.
111 93
112;; The data structure that represents a test case. 94;; The data structure that represents a test case.
@@ -467,7 +449,7 @@ Errors during evaluation are caught and handled like nil."
467 449
468(defun ert--explain-equal-rec (a b) 450(defun ert--explain-equal-rec (a b)
469 "Return a programmer-readable explanation of why A and B are not `equal'. 451 "Return a programmer-readable explanation of why A and B are not `equal'.
470Returns nil if they are." 452Return nil if they are."
471 (if (not (eq (type-of a) (type-of b))) 453 (if (not (eq (type-of a) (type-of b)))
472 `(different-types ,a ,b) 454 `(different-types ,a ,b)
473 (pcase a 455 (pcase a
@@ -600,14 +582,9 @@ If SUFFIXP is non-nil, returns a suffix of S, otherwise a prefix."
600 (t 582 (t
601 (substring s 0 len))))) 583 (substring s 0 len)))))
602 584
603;; TODO(ohler): Once bug 6581 is fixed, rename this to 585(defun ert--explain-equal-including-properties-rec (a b)
604;; `ert--explain-equal-including-properties-rec' and add a fast-path 586 "Return explanation of why A and B are not `equal-including-properties'.
605;; wrapper like `ert--explain-equal'. 587Return nil if they are."
606(defun ert--explain-equal-including-properties (a b)
607 "Explainer function for `ert-equal-including-properties'.
608
609Returns a programmer-readable explanation of why A and B are not
610`ert-equal-including-properties', or nil if they are."
611 (if (not (equal a b)) 588 (if (not (equal a b))
612 (ert--explain-equal a b) 589 (ert--explain-equal a b)
613 (cl-assert (stringp a) t) 590 (cl-assert (stringp a) t)
@@ -629,15 +606,17 @@ Returns a programmer-readable explanation of why A and B are not
629 ,(ert--abbreviate-string 606 ,(ert--abbreviate-string
630 (substring-no-properties a (1+ i)) 607 (substring-no-properties a (1+ i))
631 10 nil)))) 608 10 nil))))
632 ;; TODO(ohler): Get `equal-including-properties' fixed in 609 finally (cl-assert (equal-including-properties a b) t))))
633 ;; Emacs, delete `ert-equal-including-properties', and
634 ;; re-enable this assertion.
635 ;;finally (cl-assert (equal-including-properties a b) t)
636 )))
637(put 'ert-equal-including-properties
638 'ert-explainer
639 'ert--explain-equal-including-properties)
640 610
611(defun ert--explain-equal-including-properties (a b)
612 "Explainer function for `equal-including-properties'."
613 ;; Do a quick comparison in C to avoid running our expensive
614 ;; comparison when possible.
615 (if (equal-including-properties a b)
616 nil
617 (ert--explain-equal-including-properties-rec a b)))
618(put 'equal-including-properties 'ert-explainer
619 'ert--explain-equal-including-properties)
641 620
642;;; Implementation of `ert-info'. 621;;; Implementation of `ert-info'.
643 622
@@ -2787,6 +2766,12 @@ TRANSFORM will be called to get from before to after."
2787(defvar ert-unload-hook ()) 2766(defvar ert-unload-hook ())
2788(add-hook 'ert-unload-hook #'ert--unload-function) 2767(add-hook 'ert-unload-hook #'ert--unload-function)
2789 2768
2769;;; Obsolete
2770
2771(define-obsolete-function-alias 'ert-equal-including-properties
2772 #'equal-including-properties "29.1")
2773(put 'ert-equal-including-properties 'ert-explainer
2774 'ert--explain-equal-including-properties)
2790 2775
2791(provide 'ert) 2776(provide 'ert)
2792 2777