aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorMichal Nazarewicz2016-06-07 22:32:59 +0200
committerMichal Nazarewicz2016-06-08 19:10:59 +0200
commit7715ee54b3588cfdef03b5d45aaf44b73b422ec6 (patch)
tree176ae2e58b9018e0b761aea2bd31e2161e6c0481 /test
parent027e6fbfe472bad1fd0464e070bc782c7e3e776a (diff)
downloademacs-7715ee54b3588cfdef03b5d45aaf44b73b422ec6.tar.gz
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 'test')
-rw-r--r--test/lisp/calendar/icalendar-tests.el3
-rw-r--r--test/lisp/emacs-lisp/ert-x-tests.el43
-rw-r--r--test/lisp/gnus/message-tests.el2
-rw-r--r--test/lisp/vc/vc-bzr-tests.el3
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 @@
32;;; Code: 32;;; Code:
33 33
34(require 'ert) 34(require 'ert)
35(require 'ert-x)
36(require 'icalendar) 35(require 'icalendar)
37 36
38;; ====================================================================== 37;; ======================================================================
@@ -64,7 +63,7 @@
64 (hash (format "%d" (abs (sxhash entry-full)))) 63 (hash (format "%d" (abs (sxhash entry-full))))
65 (contents "DTSTART:19640630T070100\nblahblah") 64 (contents "DTSTART:19640630T070100\nblahblah")
66 (username (or user-login-name "UNKNOWN_USER"))) 65 (username (or user-login-name "UNKNOWN_USER")))
67 (ert-with-function-mocked current-time (lambda () '(1 2 3)) 66 (cl-letf (((symbol-function 'current-time) (lambda () '(1 2 3))))
68 (should (= 77 icalendar--uid-count)) 67 (should (= 77 icalendar--uid-count))
69 (should (string= (concat "xxx-123-77-" hash "-" username "-19640630") 68 (should (string= (concat "xxx-123-77-" hash "-" username "-19640630")
70 (icalendar--create-uid entry-full contents))) 69 (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."
275 (should (equal (c x) (lisp x)))))) 275 (should (equal (c x) (lisp x))))))
276 276
277 277
278(defun ert--dummy-id (a)
279 "Identity function. Used for tests only."
280 a)
281
282(ert-deftest ert-with-function-mocked ()
283 (let ((mock-id (lambda (_) 21)))
284 (should (eq 42 (ert--dummy-id 42)))
285
286 (ert-with-function-mocked ert--dummy-id nil
287 (fset 'ert--dummy-id mock-id)
288 (should (eq 21 (ert--dummy-id 42))))
289 (should (eq 42 (ert--dummy-id 42)))
290
291 (ert-with-function-mocked ert--dummy-id mock-id
292 (should (eq 21 (ert--dummy-id 42))))
293 (should (eq 42 (ert--dummy-id 42)))
294
295 (should
296 (catch 'exit
297 (ert-with-function-mocked ert--dummy-id mock-id
298 (should (eq 21 (ert--dummy-id 42))))
299 (throw 'exit t)))
300 (should (eq 42 (ert--dummy-id 42)))
301
302 (should
303 (string= "Foo"
304 (condition-case err
305 (progn
306 (ert-with-function-mocked ert--dummy-id mock-id
307 (should (eq 21 (ert--dummy-id 42))))
308 (user-error "Foo"))
309 (user-error (cadr err)))))
310 (should (eq 42 (ert--dummy-id 42)))
311
312 (should
313 (string= "`ert--dummy-id' unexpectedly called."
314 (condition-case err
315 (ert-with-function-mocked ert--dummy-id nil
316 (ert--dummy-id 42))
317 (ert-test-failed (cadr err)))))
318 (should (eq 42 (ert--dummy-id 42)))))
319
320
321(provide 'ert-x-tests) 278(provide 'ert-x-tests)
322 279
323;;; ert-x-tests.el ends here 280;;; 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 @@
57 57
58 58
59(ert-deftest message-strip-subject-trailing-was () 59(ert-deftest message-strip-subject-trailing-was ()
60 (ert-with-function-mocked message-talkative-question nil 60 (cl-letf (((symbol-function 'message-talkative-question) nil))
61 (with-temp-buffer 61 (with-temp-buffer
62 (let ((no-was "Re: Foo ") 62 (let ((no-was "Re: Foo ")
63 (with-was "Re: Foo \t (was: Bar ) ") 63 (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 @@
25;;; Code: 25;;; Code:
26 26
27(require 'ert) 27(require 'ert)
28(require 'ert-x)
29(require 'vc-bzr) 28(require 'vc-bzr)
30(require 'vc-dir) 29(require 'vc-dir)
31 30
@@ -102,7 +101,7 @@
102 (while (vc-dir-busy) 101 (while (vc-dir-busy)
103 (sit-for 0.1)) 102 (sit-for 0.1))
104 (vc-dir-mark-all-files t) 103 (vc-dir-mark-all-files t)
105 (ert-with-function-mocked y-or-n-p (lambda (_) t) 104 (cl-letf (((symbol-function 'y-or-n-p) (lambda (_) t)))
106 (vc-next-action nil)) 105 (vc-next-action nil))
107 (should (get-buffer "*vc-log*"))) 106 (should (get-buffer "*vc-log*")))
108 (delete-directory homedir t)))) 107 (delete-directory homedir t))))