diff options
| author | Philipp Stephani | 2020-06-21 19:48:03 +0200 |
|---|---|---|
| committer | Philipp Stephani | 2021-02-24 13:00:42 +0100 |
| commit | 11b2184c8d2a2b31af2eeab888d2fbd7044275fb (patch) | |
| tree | a30ce6f435c1a437a89a12e112256cde1b7ee015 | |
| parent | ffa5f0397af87c7258f58082408281bf3a5a2deb (diff) | |
| download | emacs-11b2184c8d2a2b31af2eeab888d2fbd7044275fb.tar.gz 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’.
| -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 @@ | |||
| 22 | 22 | ||
| 23 | ;;; Code: | 23 | ;;; Code: |
| 24 | 24 | ||
| 25 | (require 'cl) | 25 | (require 'cl-lib) |
| 26 | (require 'ert) | 26 | (require 'ert) |
| 27 | (require 'use-package) | 27 | (require 'use-package) |
| 28 | 28 | ||
| @@ -99,20 +99,6 @@ | |||
| 99 | 99 | ||
| 100 | (bind-key "C-c C-u" #'fix-expansion emacs-lisp-mode-map) | 100 | (bind-key "C-c C-u" #'fix-expansion emacs-lisp-mode-map) |
| 101 | 101 | ||
| 102 | (eval-when-compile | ||
| 103 | (defun plist-delete (plist property) | ||
| 104 | "Delete PROPERTY from PLIST" | ||
| 105 | (let (p) | ||
| 106 | (while plist | ||
| 107 | (if (not (eq property (car plist))) | ||
| 108 | (setq p (plist-put p (car plist) (nth 1 plist)))) | ||
| 109 | (setq plist (cddr plist))) | ||
| 110 | p)) | ||
| 111 | |||
| 112 | ;; `cl-flet' does not work for some of the mocking we do below, while `flet' | ||
| 113 | ;; always does. | ||
| 114 | (setplist 'flet (plist-delete (symbol-plist 'flet) 'byte-obsolete-info))) | ||
| 115 | |||
| 116 | (ert-deftest use-package-test-recognize-function () | 102 | (ert-deftest use-package-test-recognize-function () |
| 117 | (should (use-package-recognize-function nil t)) | 103 | (should (use-package-recognize-function nil t)) |
| 118 | (should-not (use-package-recognize-function nil)) | 104 | (should-not (use-package-recognize-function nil)) |
| @@ -232,9 +218,9 @@ | |||
| 232 | (require 'foo nil nil)))) | 218 | (require 'foo nil nil)))) |
| 233 | 219 | ||
| 234 | (ert-deftest use-package-test-normalize/:ensure () | 220 | (ert-deftest use-package-test-normalize/:ensure () |
| 235 | (flet ((norm (&rest args) | 221 | (cl-flet ((norm (&rest args) |
| 236 | (apply #'use-package-normalize/:ensure | 222 | (apply #'use-package-normalize/:ensure |
| 237 | 'foopkg :ensure args))) | 223 | 'foopkg :ensure args))) |
| 238 | (should (equal (norm '(t)) '(t))) | 224 | (should (equal (norm '(t)) '(t))) |
| 239 | (should (equal (norm '(nil)) '(nil))) | 225 | (should (equal (norm '(nil)) '(nil))) |
| 240 | (should (equal (norm '(sym)) '(sym))) | 226 | (should (equal (norm '(sym)) '(sym))) |
| @@ -333,11 +319,11 @@ | |||
| 333 | 319 | ||
| 334 | (ert-deftest use-package-test/:ensure-11 () | 320 | (ert-deftest use-package-test/:ensure-11 () |
| 335 | (let (tried-to-install) | 321 | (let (tried-to-install) |
| 336 | (flet ((use-package-ensure-elpa | 322 | (cl-letf (((symbol-function #'use-package-ensure-elpa) |
| 337 | (name ensure state &optional no-refresh) | 323 | (lambda (name ensure state &optional no-refresh) |
| 338 | (when ensure | 324 | (when ensure |
| 339 | (setq tried-to-install name))) | 325 | (setq tried-to-install name)))) |
| 340 | (require (&rest ignore))) | 326 | ((symbol-function #'require) #'ignore)) |
| 341 | (use-package foo :ensure t) | 327 | (use-package foo :ensure t) |
| 342 | (should (eq tried-to-install 'foo))))) | 328 | (should (eq tried-to-install 'foo))))) |
| 343 | 329 | ||
| @@ -737,9 +723,9 @@ | |||
| 737 | (add-to-list 'interpreter-mode-alist '("interp" . fun))))) | 723 | (add-to-list 'interpreter-mode-alist '("interp" . fun))))) |
| 738 | 724 | ||
| 739 | (ert-deftest use-package-test-normalize/:mode () | 725 | (ert-deftest use-package-test-normalize/:mode () |
| 740 | (flet ((norm (&rest args) | 726 | (cl-flet ((norm (&rest args) |
| 741 | (apply #'use-package-normalize/:mode | 727 | (apply #'use-package-normalize/:mode |
| 742 | 'foopkg :mode args))) | 728 | 'foopkg :mode args))) |
| 743 | (should (equal (norm '(".foo")) | 729 | (should (equal (norm '(".foo")) |
| 744 | '((".foo" . foopkg)))) | 730 | '((".foo" . foopkg)))) |
| 745 | (should (equal (norm '(".foo" ".bar")) | 731 | (should (equal (norm '(".foo" ".bar")) |
| @@ -993,9 +979,9 @@ | |||
| 993 | (load "foo" nil t)))))))) | 979 | (load "foo" nil t)))))))) |
| 994 | 980 | ||
| 995 | (ert-deftest use-package-test-normalize/:hook () | 981 | (ert-deftest use-package-test-normalize/:hook () |
| 996 | (flet ((norm (&rest args) | 982 | (cl-flet ((norm (&rest args) |
| 997 | (apply #'use-package-normalize/:hook | 983 | (apply #'use-package-normalize/:hook |
| 998 | 'foopkg :hook args))) | 984 | 'foopkg :hook args))) |
| 999 | (should-error (norm nil)) | 985 | (should-error (norm nil)) |
| 1000 | (should (equal (norm '(bar)) | 986 | (should (equal (norm '(bar)) |
| 1001 | '((bar . foopkg)))) | 987 | '((bar . foopkg)))) |
| @@ -1117,9 +1103,9 @@ | |||
| 1117 | (add-hook 'emacs-lisp-mode-hook #'(lambda nil (function)))))))) | 1103 | (add-hook 'emacs-lisp-mode-hook #'(lambda nil (function)))))))) |
| 1118 | 1104 | ||
| 1119 | (ert-deftest use-package-test-normalize/:custom () | 1105 | (ert-deftest use-package-test-normalize/:custom () |
| 1120 | (flet ((norm (&rest args) | 1106 | (cl-flet ((norm (&rest args) |
| 1121 | (apply #'use-package-normalize/:custom | 1107 | (apply #'use-package-normalize/:custom |
| 1122 | 'foopkg :custom args))) | 1108 | 'foopkg :custom args))) |
| 1123 | (should-error (norm nil)) | 1109 | (should-error (norm nil)) |
| 1124 | (should-error (norm '(bar))) | 1110 | (should-error (norm '(bar))) |
| 1125 | ;; (should-error (norm '((foo bar baz quux)))) | 1111 | ;; (should-error (norm '((foo bar baz quux)))) |
| @@ -1818,7 +1804,7 @@ | |||
| 1818 | `(bind-key "C-c C-r" #'org-ref-helm-insert-cite-link override-global-map nil))) | 1804 | `(bind-key "C-c C-r" #'org-ref-helm-insert-cite-link override-global-map nil))) |
| 1819 | 1805 | ||
| 1820 | (ert-deftest use-package-test/560 () | 1806 | (ert-deftest use-package-test/560 () |
| 1821 | (flet ((executable-find (name))) | 1807 | (cl-letf (((symbol-function #'executable-find) #'ignore)) |
| 1822 | (let (notmuch-command) | 1808 | (let (notmuch-command) |
| 1823 | (match-expansion | 1809 | (match-expansion |
| 1824 | (use-package notmuch | 1810 | (use-package notmuch |
| @@ -1929,7 +1915,8 @@ | |||
| 1929 | (use-package-expand-minimally t) | 1915 | (use-package-expand-minimally t) |
| 1930 | debug-on-error | 1916 | debug-on-error |
| 1931 | warnings) | 1917 | warnings) |
| 1932 | (flet ((display-warning (_ msg _) (push msg warnings))) | 1918 | (cl-letf (((symbol-function #'display-warning) |
| 1919 | (lambda (_ msg _) (push msg warnings)))) | ||
| 1933 | (progn | 1920 | (progn |
| 1934 | (macroexpand-1 | 1921 | (macroexpand-1 |
| 1935 | '(use-package ediff :defer t (setq my-var t))) | 1922 | '(use-package ediff :defer t (setq my-var t))) |