I'd like to mock a function for a unit test that I'm writing. I want the mocked function to count how many times it was called but I'm having issues related to the scope of the count variable.
Here is an example of what I'm trying to do:
;; Assumes lexical-binding is t (defvar example-settings nil) (defun function-to-test () (funcall (car example-settings))) (let* ((function-to-mock-call-cnt 0) (example-settings '((lambda () (setq function-to-mock-call-cnt (1+ function-to-mock-call-cnt)))))) (function-to-test) function-to-mock-call-cnt)
However, this fails with the error void-variable.
Can someone help me understand why this doesn't work?