diff options
author | Michal Nazarewicz <mina86@mina86.com> | 2016-06-07 22:32:59 +0200 |
---|---|---|
committer | Michal Nazarewicz <mina86@mina86.com> | 2016-06-08 19:10:59 +0200 |
commit | 7715ee54b3588cfdef03b5d45aaf44b73b422ec6 (patch) | |
tree | 176ae2e58b9018e0b761aea2bd31e2161e6c0481 /test/lisp | |
parent | 027e6fbfe472bad1fd0464e070bc782c7e3e776a (diff) | |
download | emacs-7715ee54b3588cfdef03b5d45aaf44b73b422ec6.tar.gz |
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 'test/lisp')
-rw-r--r-- | test/lisp/calendar/icalendar-tests.el | 3 | ||||
-rw-r--r-- | test/lisp/emacs-lisp/ert-x-tests.el | 43 | ||||
-rw-r--r-- | test/lisp/gnus/message-tests.el | 2 | ||||
-rw-r--r-- | test/lisp/vc/vc-bzr-tests.el | 3 |
4 files changed, 3 insertions, 48 deletions
diff --git a/test/lisp/calendar/icalendar-tests.el b/test/lisp/calendar/icalendar-tests.el index 20d88349bbc..6db4222697e 100644 --- a/test/lisp/calendar/icalendar-tests.el +++ b/test/lisp/calendar/icalendar-tests.el @@ -32,7 +32,6 @@ ;;; Code: (require 'ert) -(require 'ert-x) (require 'icalendar) ;; ====================================================================== @@ -64,7 +63,7 @@ (hash (format "%d" (abs (sxhash entry-full)))) (contents "DTSTART:19640630T070100\nblahblah") (username (or user-login-name "UNKNOWN_USER"))) - (ert-with-function-mocked current-time (lambda () '(1 2 3)) + (cl-letf (((symbol-function 'current-time) (lambda () '(1 2 3)))) (should (= 77 icalendar--uid-count)) (should (string= (concat "xxx-123-77-" hash "-" username "-19640630") (icalendar--create-uid entry-full contents))) diff --git a/test/lisp/emacs-lisp/ert-x-tests.el b/test/lisp/emacs-lisp/ert-x-tests.el index a2665e7c390..ef8642aebfb 100644 --- a/test/lisp/emacs-lisp/ert-x-tests.el +++ b/test/lisp/emacs-lisp/ert-x-tests.el @@ -275,49 +275,6 @@ desired effect." (should (equal (c x) (lisp x)))))) -(defun ert--dummy-id (a) - "Identity function. Used for tests only." - a) - -(ert-deftest ert-with-function-mocked () - (let ((mock-id (lambda (_) 21))) - (should (eq 42 (ert--dummy-id 42))) - - (ert-with-function-mocked ert--dummy-id nil - (fset 'ert--dummy-id mock-id) - (should (eq 21 (ert--dummy-id 42)))) - (should (eq 42 (ert--dummy-id 42))) - - (ert-with-function-mocked ert--dummy-id mock-id - (should (eq 21 (ert--dummy-id 42)))) - (should (eq 42 (ert--dummy-id 42))) - - (should - (catch 'exit - (ert-with-function-mocked ert--dummy-id mock-id - (should (eq 21 (ert--dummy-id 42)))) - (throw 'exit t))) - (should (eq 42 (ert--dummy-id 42))) - - (should - (string= "Foo" - (condition-case err - (progn - (ert-with-function-mocked ert--dummy-id mock-id - (should (eq 21 (ert--dummy-id 42)))) - (user-error "Foo")) - (user-error (cadr err))))) - (should (eq 42 (ert--dummy-id 42))) - - (should - (string= "`ert--dummy-id' unexpectedly called." - (condition-case err - (ert-with-function-mocked ert--dummy-id nil - (ert--dummy-id 42)) - (ert-test-failed (cadr err))))) - (should (eq 42 (ert--dummy-id 42))))) - - (provide 'ert-x-tests) ;;; ert-x-tests.el ends here diff --git a/test/lisp/gnus/message-tests.el b/test/lisp/gnus/message-tests.el index ae34f24d741..13c15e33b27 100644 --- a/test/lisp/gnus/message-tests.el +++ b/test/lisp/gnus/message-tests.el @@ -57,7 +57,7 @@ (ert-deftest message-strip-subject-trailing-was () - (ert-with-function-mocked message-talkative-question nil + (cl-letf (((symbol-function 'message-talkative-question) nil)) (with-temp-buffer (let ((no-was "Re: Foo ") (with-was "Re: Foo \t (was: Bar ) ") diff --git a/test/lisp/vc/vc-bzr-tests.el b/test/lisp/vc/vc-bzr-tests.el index 98d176ca1ee..f27e6588cf2 100644 --- a/test/lisp/vc/vc-bzr-tests.el +++ b/test/lisp/vc/vc-bzr-tests.el @@ -25,7 +25,6 @@ ;;; Code: (require 'ert) -(require 'ert-x) (require 'vc-bzr) (require 'vc-dir) @@ -102,7 +101,7 @@ (while (vc-dir-busy) (sit-for 0.1)) (vc-dir-mark-all-files t) - (ert-with-function-mocked y-or-n-p (lambda (_) t) + (cl-letf (((symbol-function 'y-or-n-p) (lambda (_) t))) (vc-next-action nil)) (should (get-buffer "*vc-log*"))) (delete-directory homedir t)))) |