Skip to content

Commit

Permalink
docs: update limitation section
Browse files Browse the repository at this point in the history
The problem is actually inline functions.

Provides an example as to a workaround.
  • Loading branch information
Walheimat committed Jul 22, 2023
1 parent 16a1fa3 commit 7ee9851
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions README.org
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,19 @@ The main recipe is the following:

** Limitations

Currently functions defined in C and those derived from =cl-defstruct=
cannot be mocked.
Inline functions (those using =defsubst=) can't be mocked. If you're
using =cl-defstruct= you could pass option =:noinline= to keep slot
accessors mockable. This will make functions run slower, so you might
be better off creating a helper setup macro for your structs.

#+begin_src emacs-lisp
(cl-defstruct (horse (:noinline t))
"A horse with a name."
name)

(bydi ((:mock horse-name :return "no-name"))
(should (string= "no-name" (horse-name 'not-a-horse))))
#+end_src

Also confer variable =bydi-mock--never-mock= for a (incomplete) list of
functions that shouldn't be mocked because it will likely lead to
Expand Down

0 comments on commit 7ee9851

Please sign in to comment.