summaryrefslogtreecommitdiff
path: root/lisp/emacs-lisp
diff options
context:
space:
mode:
authorMichal Nazarewicz <mina86@mina86.com>2016-06-07 22:32:59 +0200
committerMichal Nazarewicz <mina86@mina86.com>2016-06-08 19:10:59 +0200
commit7715ee54b3588cfdef03b5d45aaf44b73b422ec6 (patch)
tree176ae2e58b9018e0b761aea2bd31e2161e6c0481 /lisp/emacs-lisp
parent027e6fbfe472bad1fd0464e070bc782c7e3e776a (diff)
downloademacs-7715ee54b3588cfdef03b5d45aaf44b73b422ec6.tar.gz
emacs-7715ee54b3588cfdef03b5d45aaf44b73b422ec6.tar.bz2
emacs-7715ee54b3588cfdef03b5d45aaf44b73b422ec6.zip
Remove ‘ert-with-function-mocked’ macro in favour of ‘cl-letf’ macro
* lisp/emacs-lisp/ert-x.el (ert-with-function-mocked): Remove macro in favour of ‘cl-letf’ macro which is more generic. All existing uses are migrated accordingly. The macro has not been included in an official release yet so it should be fine to delete it.
Diffstat (limited to 'lisp/emacs-lisp')
-rw-r--r--lisp/emacs-lisp/ert-x.el40
1 files changed, 0 insertions, 40 deletions
diff --git a/lisp/emacs-lisp/ert-x.el b/lisp/emacs-lisp/ert-x.el
index 67cb102a67c..2a2418fa7d2 100644
--- a/lisp/emacs-lisp/ert-x.el
+++ b/lisp/emacs-lisp/ert-x.el
@@ -285,46 +285,6 @@ BUFFER defaults to current buffer. Does not modify BUFFER."
(kill-buffer clone)))))))
-(defmacro ert-with-function-mocked (name mock &rest body)
- "Mocks function NAME with MOCK and run BODY.
-
-Once BODY finishes (be it normally by returning a value or
-abnormally by throwing or signaling), the old definition of
-function NAME is restored.
-
-BODY may further change the mock with `fset'.
-
-If MOCK is nil, the function NAME is mocked with a function
-`ert-fail'ing when called.
-
-For example:
-
- ;; Regular use, function is mocked inside the BODY:
- (should (eq 2 (+ 1 1)))
- (ert-with-function-mocked ((+ (lambda (a b) (- a b))))
- (should (eq 0 (+ 1 1))))
- (should (eq 2 (+ 1 1)))
-
- ;; Macro correctly recovers from a throw or signal:
- (should
- (catch 'done
- (ert-with-function-mocked ((+ (lambda (a b) (- a b))))
- (should (eq 0 (+ 1 1))))
- (throw 'done t)))
- (should (eq 2 (+ 1 1)))
-"
- (declare (indent 2))
- (let ((old-var (make-symbol "old-var"))
- (mock-var (make-symbol "mock-var")))
- `(let ((,old-var (symbol-function (quote ,name))) (,mock-var ,mock))
- (fset (quote ,name)
- (or ,mock-var (lambda (&rest _)
- (ert-fail (concat "`" ,(symbol-name name)
- "' unexpectedly called.")))))
- (unwind-protect
- (progn ,@body)
- (fset (quote ,name) ,old-var)))))
-
(provide 'ert-x)
;;; ert-x.el ends here