diff options
author | Philipp Stephani <phst@google.com> | 2020-06-21 19:48:03 +0200 |
---|---|---|
committer | Philipp Stephani <phst@google.com> | 2021-02-24 13:00:42 +0100 |
commit | 11b2184c8d2a2b31af2eeab888d2fbd7044275fb (patch) | |
tree | a30ce6f435c1a437a89a12e112256cde1b7ee015 /test/lisp/use-package/use-package-tests.el | |
parent | ffa5f0397af87c7258f58082408281bf3a5a2deb (diff) | |
download | emacs-11b2184c8d2a2b31af2eeab888d2fbd7044275fb.tar.gz emacs-11b2184c8d2a2b31af2eeab888d2fbd7044275fb.tar.bz2 emacs-11b2184c8d2a2b31af2eeab888d2fbd7044275fb.zip |
Remove uses of deprecated ‘flet’ macro
Instead, use the non-deprecated ‘cl-flet’ and ‘cl-letf’ macros from the
‘cl-lib’ package.
This also allows us to remove the ‘plist-delete’ helper function, which was
only used to effectively un-deprecate ‘flet’.
Diffstat (limited to 'test/lisp/use-package/use-package-tests.el')
-rw-r--r-- | test/lisp/use-package/use-package-tests.el | 55 |
1 files changed, 21 insertions, 34 deletions
diff --git a/test/lisp/use-package/use-package-tests.el b/test/lisp/use-package/use-package-tests.el index 3825aa36487..0bb86513c44 100644 --- a/test/lisp/use-package/use-package-tests.el +++ b/test/lisp/use-package/use-package-tests.el @@ -22,7 +22,7 @@ ;;; Code: -(require 'cl) +(require 'cl-lib) (require 'ert) (require 'use-package) @@ -99,20 +99,6 @@ (bind-key "C-c C-u" #'fix-expansion emacs-lisp-mode-map) -(eval-when-compile - (defun plist-delete (plist property) - "Delete PROPERTY from PLIST" - (let (p) - (while plist - (if (not (eq property (car plist))) - (setq p (plist-put p (car plist) (nth 1 plist)))) - (setq plist (cddr plist))) - p)) - - ;; `cl-flet' does not work for some of the mocking we do below, while `flet' - ;; always does. - (setplist 'flet (plist-delete (symbol-plist 'flet) 'byte-obsolete-info))) - (ert-deftest use-package-test-recognize-function () (should (use-package-recognize-function nil t)) (should-not (use-package-recognize-function nil)) @@ -232,9 +218,9 @@ (require 'foo nil nil)))) (ert-deftest use-package-test-normalize/:ensure () - (flet ((norm (&rest args) - (apply #'use-package-normalize/:ensure - 'foopkg :ensure args))) + (cl-flet ((norm (&rest args) + (apply #'use-package-normalize/:ensure + 'foopkg :ensure args))) (should (equal (norm '(t)) '(t))) (should (equal (norm '(nil)) '(nil))) (should (equal (norm '(sym)) '(sym))) @@ -333,11 +319,11 @@ (ert-deftest use-package-test/:ensure-11 () (let (tried-to-install) - (flet ((use-package-ensure-elpa - (name ensure state &optional no-refresh) - (when ensure - (setq tried-to-install name))) - (require (&rest ignore))) + (cl-letf (((symbol-function #'use-package-ensure-elpa) + (lambda (name ensure state &optional no-refresh) + (when ensure + (setq tried-to-install name)))) + ((symbol-function #'require) #'ignore)) (use-package foo :ensure t) (should (eq tried-to-install 'foo))))) @@ -737,9 +723,9 @@ (add-to-list 'interpreter-mode-alist '("interp" . fun))))) (ert-deftest use-package-test-normalize/:mode () - (flet ((norm (&rest args) - (apply #'use-package-normalize/:mode - 'foopkg :mode args))) + (cl-flet ((norm (&rest args) + (apply #'use-package-normalize/:mode + 'foopkg :mode args))) (should (equal (norm '(".foo")) '((".foo" . foopkg)))) (should (equal (norm '(".foo" ".bar")) @@ -993,9 +979,9 @@ (load "foo" nil t)))))))) (ert-deftest use-package-test-normalize/:hook () - (flet ((norm (&rest args) - (apply #'use-package-normalize/:hook - 'foopkg :hook args))) + (cl-flet ((norm (&rest args) + (apply #'use-package-normalize/:hook + 'foopkg :hook args))) (should-error (norm nil)) (should (equal (norm '(bar)) '((bar . foopkg)))) @@ -1117,9 +1103,9 @@ (add-hook 'emacs-lisp-mode-hook #'(lambda nil (function)))))))) (ert-deftest use-package-test-normalize/:custom () - (flet ((norm (&rest args) - (apply #'use-package-normalize/:custom - 'foopkg :custom args))) + (cl-flet ((norm (&rest args) + (apply #'use-package-normalize/:custom + 'foopkg :custom args))) (should-error (norm nil)) (should-error (norm '(bar))) ;; (should-error (norm '((foo bar baz quux)))) @@ -1818,7 +1804,7 @@ `(bind-key "C-c C-r" #'org-ref-helm-insert-cite-link override-global-map nil))) (ert-deftest use-package-test/560 () - (flet ((executable-find (name))) + (cl-letf (((symbol-function #'executable-find) #'ignore)) (let (notmuch-command) (match-expansion (use-package notmuch @@ -1929,7 +1915,8 @@ (use-package-expand-minimally t) debug-on-error warnings) - (flet ((display-warning (_ msg _) (push msg warnings))) + (cl-letf (((symbol-function #'display-warning) + (lambda (_ msg _) (push msg warnings)))) (progn (macroexpand-1 '(use-package ediff :defer t (setq my-var t))) |