Re: master e4df903f6b5 2/2: ; Fix last change
Eli Zaretskii <[email protected]> Mon, 03 Aug 2026 14:11:03 +0300
| Newsgroups | gmane.emacs.devel |
|---|---|
| Message-ID | <[email protected]> |
> From: Richard Stallman <[email protected]> > Cc: [email protected], [email protected] > Date: Mon, 03 Aug 2026 00:05:56 -0400 > > > I like this idea. We could add the following macro to ERT: > > > --8<---------------cut here---------------start------------->8--- > > (defmacro ert-with-forced-function-value (name value &rest body) > > "Bind function NAME to return always VALUE, and evaluate BODY." > > (declare (indent 2) (debug (functionp sexp body))) > > `(cl-letf (((symbol-function ',name) (lambda (&rest _) ,value))) > > ,@body)) > > --8<---------------cut here---------------end--------------->8--- > > What I had in mind is to use a special mechanism to force a certain function's > value to VALUE, without ever altering a symbol's function definition. > > It would be evidently unclean to use this mechanism in ordinary code, > and the point is that we would not accept code to do so. The function's mock might need some non-trivial logic or side effects, in which case simply forcing the value will not be enough. What we need is a solid infrastructure for mocking a function. No good test suite can do without something like that, so we should have it as well. IME, it is never as trivial as forcing the value.