aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
authorLars Ingebrigtsen2022-01-13 09:48:15 +0100
committerLars Ingebrigtsen2022-01-13 09:49:19 +0100
commit9c31be6dc31f10efcfb8dc76053e8bf3f62eef2c (patch)
treed7d7381ee7a9d74d355e8957e0b7334f6df48f28 /lisp
parentd30fde6b0ccc02eada1f43e0b4cc1873e42f14d2 (diff)
downloademacs-9c31be6dc31f10efcfb8dc76053e8bf3f62eef2c.tar.gz
emacs-9c31be6dc31f10efcfb8dc76053e8bf3f62eef2c.zip
Make ert explainers work on function aliases
* lisp/emacs-lisp/ert.el: New function. (ert--expand-should-1): Use it (bug#53178).
Diffstat (limited to 'lisp')
-rw-r--r--lisp/emacs-lisp/ert.el17
1 files changed, 11 insertions, 6 deletions
diff --git a/lisp/emacs-lisp/ert.el b/lisp/emacs-lisp/ert.el
index e31ebf5f7bb..9c6b0e15bbe 100644
--- a/lisp/emacs-lisp/ert.el
+++ b/lisp/emacs-lisp/ert.el
@@ -335,15 +335,20 @@ It should only be stopped when ran from inside `ert--run-test-internal'."
335 (unless (eql ,value ',default-value) 335 (unless (eql ,value ',default-value)
336 (list :value ,value)) 336 (list :value ,value))
337 (unless (eql ,value ',default-value) 337 (unless (eql ,value ',default-value)
338 (let ((-explainer- 338 (when-let ((-explainer-
339 (and (symbolp ',fn-name) 339 (ert--get-explainer ',fn-name)))
340 (get ',fn-name 'ert-explainer)))) 340 (list :explanation
341 (when -explainer- 341 (apply -explainer- ,args)))))
342 (list :explanation
343 (apply -explainer- ,args))))))
344 value) 342 value)
345 ,value)))))))) 343 ,value))))))))
346 344
345(defun ert--get-explainer (fn-name)
346 (when (symbolp fn-name)
347 (cl-loop for fn in (cons fn-name (function-alias-p fn-name))
348 for explainer = (get fn 'ert-explainer)
349 when explainer
350 return explainer)))
351
347(defun ert--expand-should (whole form inner-expander) 352(defun ert--expand-should (whole form inner-expander)
348 "Helper function for the `should' macro and its variants. 353 "Helper function for the `should' macro and its variants.
349 354