mirror of
https://github.com/masscollaborationlabs/emacs.git
synced 2025-07-07 12:49:38 +00:00
Add many more tests
This commit is contained in:
parent
f5b034154f
commit
cd4790b3df
1 changed files with 548 additions and 116 deletions
|
@ -27,7 +27,12 @@
|
||||||
|
|
||||||
(setq use-package-always-ensure nil
|
(setq use-package-always-ensure nil
|
||||||
use-package-verbose nil
|
use-package-verbose nil
|
||||||
use-package-expand-minimally t)
|
use-package-expand-minimally t
|
||||||
|
max-lisp-eval-depth 8000)
|
||||||
|
|
||||||
|
;; (let ((byte-compile-current-file nil)) (expand-minimally ())
|
||||||
|
(fset 'insert-expansion
|
||||||
|
[?\C-\M- ?\M-w ?\M-: ?\M-p ?\C-e ?\C-b ?\C-b ?\C-\M-b ?\C-y ?\C-\M-k return ?\C-\M- ?\M-w C-return ?\C-z ?\C-n ?\C-f ?\C-y ?\C-\M-k])
|
||||||
|
|
||||||
(defmacro expand-minimally (form)
|
(defmacro expand-minimally (form)
|
||||||
`(let ((use-package-verbose nil)
|
`(let ((use-package-verbose nil)
|
||||||
|
@ -321,9 +326,23 @@
|
||||||
(unless nil
|
(unless nil
|
||||||
(require 'foo nil 'nil)))))
|
(require 'foo nil 'nil)))))
|
||||||
|
|
||||||
;; (ert-deftest use-package-test/:requires ()
|
(ert-deftest use-package-test/:requires ()
|
||||||
;; (should (equal (macroexpand (use-package))
|
(match-expansion
|
||||||
;; '())))
|
(use-package foo :requires bar)
|
||||||
|
`(progn
|
||||||
|
(when (not (member nil (mapcar #'featurep '(bar))))
|
||||||
|
(require 'foo nil 'nil))))
|
||||||
|
|
||||||
|
(let ((byte-compile-current-file t))
|
||||||
|
(match-expansion
|
||||||
|
(use-package foo :requires bar)
|
||||||
|
`(progn
|
||||||
|
(when (not (member nil (mapcar #'featurep '(bar))))
|
||||||
|
(eval-and-compile
|
||||||
|
(eval-when-compile
|
||||||
|
(with-demoted-errors "Cannot load foo: %S" nil
|
||||||
|
(load "foo" nil t))))
|
||||||
|
(require 'foo nil 'nil))))))
|
||||||
|
|
||||||
(ert-deftest use-package-test/:load-path ()
|
(ert-deftest use-package-test/:load-path ()
|
||||||
(match-expansion
|
(match-expansion
|
||||||
|
@ -337,6 +356,22 @@
|
||||||
"bar" user-emacs-directory)))))
|
"bar" user-emacs-directory)))))
|
||||||
(require 'foo nil 'nil)))
|
(require 'foo nil 'nil)))
|
||||||
|
|
||||||
|
(let ((byte-compile-current-file t))
|
||||||
|
(match-expansion
|
||||||
|
(use-package foo :load-path "bar")
|
||||||
|
`(progn
|
||||||
|
(eval-and-compile
|
||||||
|
(add-to-list 'load-path
|
||||||
|
,(pred (apply-partially
|
||||||
|
#'string=
|
||||||
|
(expand-file-name
|
||||||
|
"bar" user-emacs-directory)))))
|
||||||
|
(eval-and-compile
|
||||||
|
(eval-when-compile
|
||||||
|
(with-demoted-errors "Cannot load foo: %S" nil
|
||||||
|
(load "foo" nil t))))
|
||||||
|
(require 'foo nil 'nil))))
|
||||||
|
|
||||||
(match-expansion
|
(match-expansion
|
||||||
(use-package foo :load-path ("bar" "quux"))
|
(use-package foo :load-path ("bar" "quux"))
|
||||||
`(progn
|
`(progn
|
||||||
|
@ -371,77 +406,197 @@
|
||||||
"quux" user-emacs-directory)))))
|
"quux" user-emacs-directory)))))
|
||||||
(require 'foo nil 'nil))))
|
(require 'foo nil 'nil))))
|
||||||
|
|
||||||
;; (ert-deftest use-package-test/:no-require ()
|
(ert-deftest use-package-test/:no-require ()
|
||||||
;; (match-expansion
|
(match-expansion
|
||||||
;; (use-package foo :no-require t)
|
(use-package foo :no-require t)
|
||||||
;; `nil)
|
`(progn))
|
||||||
|
|
||||||
;; (let ((byte-compile-current-file t))
|
(match-expansion
|
||||||
;; (match-expansion
|
(use-package foo :no-require t :config (config))
|
||||||
;; (use-package foo :no-require t)
|
`(progn
|
||||||
;; `'nil)))
|
(config)
|
||||||
|
t))
|
||||||
|
|
||||||
|
(let ((byte-compile-current-file t))
|
||||||
|
(match-expansion
|
||||||
|
(use-package foo :no-require t)
|
||||||
|
`(progn
|
||||||
|
(eval-and-compile
|
||||||
|
(eval-when-compile
|
||||||
|
(with-demoted-errors "Cannot load foo: %S" nil nil)))))))
|
||||||
|
|
||||||
(ert-deftest use-package-test-normalize/:bind ()
|
(ert-deftest use-package-test-normalize/:bind ()
|
||||||
|
(flet ((norm (&rest args)
|
||||||
|
(apply #'use-package-normalize-binder
|
||||||
|
'foopkg :bind args)))
|
||||||
(let ((good-values '(:map map-sym
|
(let ((good-values '(:map map-sym
|
||||||
("str" . sym) ("str" . "str")
|
("str" . sym) ("str" . "str")
|
||||||
([vec] . sym) ([vec] . "str"))))
|
([vec] . sym) ([vec] . "str"))))
|
||||||
(should (equal (use-package-normalize-binder
|
(should (equal (norm good-values) good-values)))
|
||||||
'foopkg :bind good-values)
|
(should-error (norm '("foo")))
|
||||||
good-values)))
|
(should-error (norm '("foo" . 99)))
|
||||||
(should-error (use-package-normalize-binder
|
(should-error (norm '(99 . sym)))))
|
||||||
'foopkg :bind '("foo")))
|
|
||||||
(should-error (use-package-normalize-binder
|
|
||||||
'foopkg :bind '("foo" . 99)))
|
|
||||||
(should-error (use-package-normalize-binder
|
|
||||||
'foopkg :bind '(99 . sym))))
|
|
||||||
|
|
||||||
;; (ert-deftest use-package-test/:bind ()
|
(ert-deftest use-package-test/:bind ()
|
||||||
;; (should (equal (macroexpand (use-package))
|
(match-expansion
|
||||||
;; '())))
|
(use-package foo :bind ("C-k" . key))
|
||||||
|
`(progn
|
||||||
|
(unless (fboundp 'key)
|
||||||
|
(autoload #'key "foo" nil t))
|
||||||
|
(ignore
|
||||||
|
(bind-keys :package foo ("C-k" . key))))))
|
||||||
|
|
||||||
;; (ert-deftest use-package-test/:bind* ()
|
(ert-deftest use-package-test/:bind* ()
|
||||||
;; (should (equal (macroexpand (use-package))
|
(match-expansion
|
||||||
;; '())))
|
(use-package foo :bind* ("C-k" . key))
|
||||||
|
`(progn
|
||||||
|
(unless (fboundp 'key)
|
||||||
|
(autoload #'key "foo" nil t))
|
||||||
|
(ignore
|
||||||
|
(bind-keys* :package foo ("C-k" . key))))))
|
||||||
|
|
||||||
;; (ert-deftest use-package-test/:bind-keymap ()
|
(ert-deftest use-package-test/:bind-keymap ()
|
||||||
;; (should (equal (macroexpand (use-package))
|
(match-expansion
|
||||||
;; '())))
|
(use-package foo :bind-keymap ("C-k" . key))
|
||||||
|
`(progn
|
||||||
|
(ignore
|
||||||
|
(bind-key "C-k"
|
||||||
|
#'(lambda ()
|
||||||
|
(interactive)
|
||||||
|
(use-package-autoload-keymap 'key 'foo nil)))))))
|
||||||
|
|
||||||
;; (ert-deftest use-package-test/:bind-keymap* ()
|
(ert-deftest use-package-test/:bind-keymap* ()
|
||||||
;; (should (equal (macroexpand (use-package))
|
(match-expansion
|
||||||
;; '())))
|
(use-package foo :bind-keymap* ("C-k" . key))
|
||||||
|
`(progn
|
||||||
|
(ignore
|
||||||
|
(bind-key* "C-k"
|
||||||
|
#'(lambda ()
|
||||||
|
(interactive)
|
||||||
|
(use-package-autoload-keymap 'key 'foo t)))))))
|
||||||
|
|
||||||
;; (ert-deftest use-package-test/:interpreter ()
|
(ert-deftest use-package-test/:interpreter ()
|
||||||
;; (should (equal (macroexpand (use-package))
|
(match-expansion
|
||||||
;; '())))
|
(use-package foo :interpreter "interp")
|
||||||
|
`(progn
|
||||||
|
(unless (fboundp 'foo)
|
||||||
|
(autoload #'foo "foo" nil t))
|
||||||
|
(ignore
|
||||||
|
(add-to-list 'interpreter-mode-alist
|
||||||
|
'("interp" . foo)))))
|
||||||
|
|
||||||
|
(match-expansion
|
||||||
|
(use-package foo :interpreter ("interp" . fun))
|
||||||
|
`(progn
|
||||||
|
(unless (fboundp 'fun)
|
||||||
|
(autoload #'fun "foo" nil t))
|
||||||
|
(ignore
|
||||||
|
(add-to-list 'interpreter-mode-alist
|
||||||
|
'("interp" . fun))))))
|
||||||
|
|
||||||
(ert-deftest use-package-test-normalize/:mode ()
|
(ert-deftest use-package-test-normalize/:mode ()
|
||||||
(should (equal (use-package-normalize-mode 'foopkg :mode '(".foo"))
|
(flet ((norm (&rest args)
|
||||||
|
(apply #'use-package-normalize/:mode
|
||||||
|
'foopkg :mode args)))
|
||||||
|
(should (equal (norm '(".foo"))
|
||||||
'((".foo" . foopkg))))
|
'((".foo" . foopkg))))
|
||||||
(should (equal (use-package-normalize-mode 'foopkg :mode '(".foo" ".bar"))
|
(should (equal (norm '(".foo" ".bar"))
|
||||||
'((".foo" . foopkg) (".bar" . foopkg))))
|
'((".foo" . foopkg) (".bar" . foopkg))))
|
||||||
(should (equal (use-package-normalize-mode 'foopkg :mode '((".foo" ".bar")))
|
(should (equal (norm '((".foo" ".bar")))
|
||||||
'((".foo" . foopkg) (".bar" . foopkg))))
|
'((".foo" . foopkg) (".bar" . foopkg))))
|
||||||
(should (equal (use-package-normalize-mode 'foopkg :mode '((".foo")))
|
(should (equal (norm '((".foo")))
|
||||||
'((".foo" . foopkg))))
|
'((".foo" . foopkg))))
|
||||||
(should (equal (use-package-normalize-mode 'foopkg :mode '((".foo" . foo) (".bar" . bar)))
|
(should (equal (norm '((".foo" . foo) (".bar" . bar)))
|
||||||
'((".foo" . foo) (".bar" . bar)))))
|
'((".foo" . foo) (".bar" . bar))))))
|
||||||
|
|
||||||
;; (ert-deftest use-package-test/:mode ()
|
(ert-deftest use-package-test/:mode ()
|
||||||
;; (should (equal (macroexpand (use-package))
|
(match-expansion
|
||||||
;; '())))
|
(use-package foo :mode "interp")
|
||||||
|
`(progn
|
||||||
|
(unless (fboundp 'foo)
|
||||||
|
(autoload #'foo "foo" nil t))
|
||||||
|
(ignore
|
||||||
|
(add-to-list 'auto-mode-alist
|
||||||
|
'("interp" . foo)))))
|
||||||
|
|
||||||
;; (ert-deftest use-package-test/:magic ()
|
(match-expansion
|
||||||
;; (should (equal (macroexpand (use-package))
|
(use-package foo :mode ("interp" . fun))
|
||||||
;; '())))
|
`(progn
|
||||||
|
(unless (fboundp 'fun)
|
||||||
|
(autoload #'fun "foo" nil t))
|
||||||
|
(ignore
|
||||||
|
(add-to-list 'auto-mode-alist
|
||||||
|
'("interp" . fun))))))
|
||||||
|
|
||||||
;; (ert-deftest use-package-test/:magic-fallback ()
|
(ert-deftest use-package-test/:magic ()
|
||||||
;; (should (equal (macroexpand (use-package))
|
(match-expansion
|
||||||
;; '())))
|
(use-package foo :magic "interp")
|
||||||
|
`(progn
|
||||||
|
(unless (fboundp 'foo)
|
||||||
|
(autoload #'foo "foo" nil t))
|
||||||
|
(ignore
|
||||||
|
(add-to-list 'magic-mode-alist
|
||||||
|
'("interp" . foo)))))
|
||||||
|
|
||||||
;; (ert-deftest use-package-test/:commands ()
|
(match-expansion
|
||||||
;; (should (equal (macroexpand (use-package))
|
(use-package foo :magic ("interp" . fun))
|
||||||
;; '())))
|
`(progn
|
||||||
|
(unless (fboundp 'fun)
|
||||||
|
(autoload #'fun "foo" nil t))
|
||||||
|
(ignore
|
||||||
|
(add-to-list 'magic-mode-alist
|
||||||
|
'("interp" . fun))))))
|
||||||
|
|
||||||
|
(ert-deftest use-package-test/:magic-fallback ()
|
||||||
|
(match-expansion
|
||||||
|
(use-package foo :magic-fallback "interp")
|
||||||
|
`(progn
|
||||||
|
(unless (fboundp 'foo)
|
||||||
|
(autoload #'foo "foo" nil t))
|
||||||
|
(ignore
|
||||||
|
(add-to-list 'magic-fallback-mode-alist
|
||||||
|
'("interp" . foo)))))
|
||||||
|
|
||||||
|
(match-expansion
|
||||||
|
(use-package foo :magic-fallback ("interp" . fun))
|
||||||
|
`(progn
|
||||||
|
(unless (fboundp 'fun)
|
||||||
|
(autoload #'fun "foo" nil t))
|
||||||
|
(ignore
|
||||||
|
(add-to-list 'magic-fallback-mode-alist
|
||||||
|
'("interp" . fun))))))
|
||||||
|
|
||||||
|
(ert-deftest use-package-test/:commands ()
|
||||||
|
(match-expansion
|
||||||
|
(use-package foo :commands bar)
|
||||||
|
`(progn
|
||||||
|
(unless (fboundp 'bar)
|
||||||
|
(autoload #'bar "foo" nil t))))
|
||||||
|
|
||||||
|
(match-expansion
|
||||||
|
(use-package foo :commands (bar quux))
|
||||||
|
`(progn
|
||||||
|
(unless (fboundp 'bar)
|
||||||
|
(autoload #'bar "foo" nil t))
|
||||||
|
(unless (fboundp 'quux)
|
||||||
|
(autoload #'quux "foo" nil t))))
|
||||||
|
|
||||||
|
(let ((byte-compile-current-file t))
|
||||||
|
(match-expansion
|
||||||
|
(use-package foo :commands (bar quux))
|
||||||
|
`(progn
|
||||||
|
(eval-and-compile
|
||||||
|
(eval-when-compile
|
||||||
|
(with-demoted-errors "Cannot load foo: %S" nil
|
||||||
|
(load "foo" nil t))))
|
||||||
|
(unless (fboundp 'bar)
|
||||||
|
(autoload #'bar "foo" nil t))
|
||||||
|
(eval-when-compile
|
||||||
|
(declare-function bar "foo"))
|
||||||
|
(unless (fboundp 'quux)
|
||||||
|
(autoload #'quux "foo" nil t))
|
||||||
|
(eval-when-compile
|
||||||
|
(declare-function quux "foo"))))))
|
||||||
|
|
||||||
(ert-deftest use-package-test/:defines ()
|
(ert-deftest use-package-test/:defines ()
|
||||||
(match-expansion
|
(match-expansion
|
||||||
|
@ -508,28 +663,54 @@
|
||||||
(config)
|
(config)
|
||||||
t))))))
|
t))))))
|
||||||
|
|
||||||
;; (ert-deftest use-package-test/:defer ()
|
(ert-deftest use-package-test/:defer ()
|
||||||
;; (should (equal (macroexpand (use-package))
|
(match-expansion
|
||||||
;; '())))
|
(use-package foo)
|
||||||
|
`(progn
|
||||||
|
(require 'foo nil 'nil)))
|
||||||
|
|
||||||
|
(let ((byte-compile-current-file t))
|
||||||
|
(match-expansion
|
||||||
|
(use-package foo)
|
||||||
|
`(progn
|
||||||
|
(eval-and-compile
|
||||||
|
(eval-when-compile
|
||||||
|
(with-demoted-errors "Cannot load foo: %S" nil
|
||||||
|
(load "foo" nil t))))
|
||||||
|
(require 'foo nil 'nil))))
|
||||||
|
|
||||||
|
(match-expansion
|
||||||
|
(use-package foo :defer t)
|
||||||
|
`(progn))
|
||||||
|
|
||||||
|
(let ((byte-compile-current-file t))
|
||||||
|
(match-expansion
|
||||||
|
(use-package foo :defer t)
|
||||||
|
`(progn
|
||||||
|
(eval-and-compile
|
||||||
|
(eval-when-compile
|
||||||
|
(with-demoted-errors "Cannot load foo: %S" nil
|
||||||
|
(load "foo" nil t))))))))
|
||||||
|
|
||||||
(ert-deftest use-package-test-normalize/:hook ()
|
(ert-deftest use-package-test-normalize/:hook ()
|
||||||
(should-error (use-package-normalize/:hook 'foopkg :hook nil))
|
(flet ((norm (&rest args)
|
||||||
(should (equal (use-package-normalize/:hook 'foopkg :hook '(bar))
|
(apply #'use-package-normalize/:hook
|
||||||
|
'foopkg :hook args)))
|
||||||
|
(should-error (norm nil))
|
||||||
|
(should (equal (norm '(bar))
|
||||||
'((bar . foopkg))))
|
'((bar . foopkg))))
|
||||||
(should (equal (use-package-normalize/:hook 'foopkg :hook '((bar . baz)))
|
(should (equal (norm '((bar . baz)))
|
||||||
'((bar . baz))))
|
'((bar . baz))))
|
||||||
(should (equal (use-package-normalize/:hook 'foopkg :hook '(((bar baz) . quux)))
|
(should (equal (norm '(((bar baz) . quux)))
|
||||||
'(((bar baz) . quux))))
|
'(((bar baz) . quux))))
|
||||||
(should (equal (use-package-normalize/:hook 'foopkg :hook '(bar baz))
|
(should (equal (norm '(bar baz))
|
||||||
'(((bar baz) . foopkg))))
|
'(((bar baz) . foopkg))))
|
||||||
(should (equal (use-package-normalize/:hook 'foopkg :hook '((bar baz) (quux bow)))
|
(should (equal (norm '((bar baz) (quux bow)))
|
||||||
'(((bar baz) . foopkg) ((quux bow) . foopkg))))
|
'(((bar baz) . foopkg) ((quux bow) . foopkg))))
|
||||||
(should (equal (use-package-normalize/:hook 'foopkg :hook '((bar . baz) (quux . bow)))
|
(should (equal (norm '((bar . baz) (quux . bow)))
|
||||||
'((bar . baz) (quux . bow))))
|
'((bar . baz) (quux . bow))))
|
||||||
(should (equal (use-package-normalize/:hook 'foopkg :hook '(((bar1 bar2) . baz)
|
(should (equal (norm '(((bar1 bar2) . baz) ((quux1 quux2) . bow)))
|
||||||
((quux1 quux2) . bow)))
|
'(((bar1 bar2) . baz) ((quux1 quux2) . bow))))))
|
||||||
'(((bar1 bar2) . baz)
|
|
||||||
((quux1 quux2) . bow)))))
|
|
||||||
|
|
||||||
(ert-deftest use-package-test/:hook ()
|
(ert-deftest use-package-test/:hook ()
|
||||||
(let ((byte-compile-current-file t))
|
(let ((byte-compile-current-file t))
|
||||||
|
@ -557,42 +738,227 @@
|
||||||
(bind-keys :package foo ("C-a" . key))))))))
|
(bind-keys :package foo ("C-a" . key))))))))
|
||||||
|
|
||||||
(ert-deftest use-package-test-normalize/:custom ()
|
(ert-deftest use-package-test-normalize/:custom ()
|
||||||
(should-error (use-package-normalize/:custom 'foopkg :custom nil))
|
(flet ((norm (&rest args)
|
||||||
(should-error (use-package-normalize/:custom 'foopkg :custom '(bar)))
|
(apply #'use-package-normalize/:custom
|
||||||
;; (should-error (use-package-normalize/:custom 'foopkg :custom '((foo bar baz quux))))
|
'foopkg :custom args)))
|
||||||
(should (equal (use-package-normalize/:custom 'foopkg :custom '(foo bar))
|
(should-error (norm nil))
|
||||||
'((foo bar))))
|
(should-error (norm '(bar)))
|
||||||
;; (should-error (use-package-normalize/:custom 'foopkg :custom '(foo bar baz)))
|
;; (should-error (norm '((foo bar baz quux))))
|
||||||
;; (should (equal (use-package-normalize/:custom 'foopkg :custom '(foo bar "baz"))
|
(should (equal (norm '(foo bar)) '((foo bar))))
|
||||||
|
;; (should-error (norm '(foo bar baz)))
|
||||||
|
;; (should (equal (norm '(foo bar "baz"))
|
||||||
;; '((foo bar baz))))
|
;; '((foo bar baz))))
|
||||||
)
|
))
|
||||||
|
|
||||||
;; (ert-deftest use-package-test/:custom ()
|
(ert-deftest use-package-test/:custom ()
|
||||||
;; (should (equal (macroexpand (use-package))
|
(match-expansion
|
||||||
;; '())))
|
(use-package foo :custom (foo bar))
|
||||||
|
`(progn
|
||||||
|
(customize-set-variable 'foo bar "Customized with use-package foo")
|
||||||
|
(require 'foo nil 'nil))))
|
||||||
|
|
||||||
;; (ert-deftest use-package-test/:custom-face ()
|
(ert-deftest use-package-test/:custom-face ()
|
||||||
;; (should (equal (macroexpand (use-package))
|
(match-expansion
|
||||||
;; '())))
|
(use-package foo :custom-face (foo ((t (:background "#e4edfc")))))
|
||||||
|
`(progn
|
||||||
|
(custom-set-faces '(foo ((t (:background "#e4edfc")))))
|
||||||
|
(require 'foo nil 'nil))))
|
||||||
|
|
||||||
;; (ert-deftest use-package-test/:init ()
|
(ert-deftest use-package-test/:init ()
|
||||||
;; (should (equal (macroexpand (use-package))
|
(match-expansion
|
||||||
;; '())))
|
(use-package foo :init (init))
|
||||||
|
`(progn
|
||||||
|
(init)
|
||||||
|
(require 'foo nil 'nil)))
|
||||||
|
|
||||||
|
(let ((byte-compile-current-file t))
|
||||||
|
(match-expansion
|
||||||
|
(use-package foo :init (init))
|
||||||
|
`(progn
|
||||||
|
(eval-and-compile
|
||||||
|
(eval-when-compile
|
||||||
|
(with-demoted-errors "Cannot load foo: %S" nil
|
||||||
|
(load "foo" nil t))))
|
||||||
|
(init)
|
||||||
|
(require 'foo nil 'nil)))))
|
||||||
|
|
||||||
(ert-deftest use-package-test/:after ()
|
(ert-deftest use-package-test/:after ()
|
||||||
(match-expansion
|
(match-expansion
|
||||||
(use-package foo :after bar)
|
(use-package foo :after bar)
|
||||||
`(progn
|
`(progn
|
||||||
|
(eval-after-load 'bar
|
||||||
|
'(require 'foo nil t))))
|
||||||
|
|
||||||
|
(let ((byte-compile-current-file t))
|
||||||
|
(match-expansion
|
||||||
|
(use-package foo :after bar)
|
||||||
|
`(progn
|
||||||
|
(eval-and-compile
|
||||||
|
(eval-when-compile
|
||||||
|
(with-demoted-errors "Cannot load foo: %S" nil
|
||||||
|
(load "foo" nil t))))
|
||||||
(eval-after-load 'bar
|
(eval-after-load 'bar
|
||||||
'(require 'foo nil t)))))
|
'(require 'foo nil t)))))
|
||||||
|
|
||||||
;; (ert-deftest use-package-test/:demand ()
|
(match-expansion
|
||||||
;; (should (equal (macroexpand (use-package))
|
(use-package foo :after (bar quux))
|
||||||
;; '())))
|
`(progn
|
||||||
|
(eval-after-load 'quux
|
||||||
|
'(eval-after-load 'bar
|
||||||
|
'(require 'foo nil t)))))
|
||||||
|
|
||||||
;; (ert-deftest use-package-test/:config ()
|
(match-expansion
|
||||||
;; (should (equal (macroexpand (use-package))
|
(use-package foo :after (:all bar quux))
|
||||||
;; '())))
|
`(progn
|
||||||
|
(eval-after-load 'quux
|
||||||
|
'(eval-after-load 'bar
|
||||||
|
'(require 'foo nil t)))))
|
||||||
|
|
||||||
|
(match-expansion
|
||||||
|
(use-package foo :after (:any bar quux))
|
||||||
|
`(progn
|
||||||
|
(progn
|
||||||
|
(eval-after-load 'bar
|
||||||
|
'(require 'foo nil t))
|
||||||
|
(eval-after-load 'quux
|
||||||
|
'(require 'foo nil t)))))
|
||||||
|
|
||||||
|
(match-expansion
|
||||||
|
(use-package foo :after (:all (:any bar quux) bow))
|
||||||
|
`(progn
|
||||||
|
(eval-after-load 'bow
|
||||||
|
'(progn
|
||||||
|
(eval-after-load 'bar
|
||||||
|
'(require 'foo nil t))
|
||||||
|
(eval-after-load 'quux
|
||||||
|
'(require 'foo nil t))))))
|
||||||
|
|
||||||
|
(match-expansion
|
||||||
|
(use-package foo :after (:any (:all bar quux) bow))
|
||||||
|
`(progn
|
||||||
|
(progn
|
||||||
|
(eval-after-load 'quux
|
||||||
|
'(eval-after-load 'bar
|
||||||
|
'(require 'foo nil t)))
|
||||||
|
(eval-after-load 'bow
|
||||||
|
'(require 'foo nil t)))))
|
||||||
|
|
||||||
|
(match-expansion
|
||||||
|
(use-package foo :after (:all (:any bar quux) (:any bow baz)))
|
||||||
|
`(progn
|
||||||
|
(progn
|
||||||
|
(eval-after-load 'bow
|
||||||
|
'(progn
|
||||||
|
(eval-after-load 'bar
|
||||||
|
'(require 'foo nil t))
|
||||||
|
(eval-after-load 'quux
|
||||||
|
'(require 'foo nil t))))
|
||||||
|
(eval-after-load 'baz
|
||||||
|
'(progn
|
||||||
|
(eval-after-load 'bar
|
||||||
|
'(require 'foo nil t))
|
||||||
|
(eval-after-load 'quux
|
||||||
|
'(require 'foo nil t)))))))
|
||||||
|
|
||||||
|
(match-expansion
|
||||||
|
(use-package foo :after (:any (:all bar quux) (:all bow baz)))
|
||||||
|
`(progn
|
||||||
|
(progn
|
||||||
|
(eval-after-load 'quux
|
||||||
|
'(eval-after-load 'bar
|
||||||
|
'(require 'foo nil t)))
|
||||||
|
(eval-after-load 'baz
|
||||||
|
'(eval-after-load 'bow
|
||||||
|
'(require 'foo nil t))))))
|
||||||
|
|
||||||
|
(match-expansion
|
||||||
|
(use-package foo :after (:any (:all bar quux) (:any bow baz)))
|
||||||
|
`(progn
|
||||||
|
(progn
|
||||||
|
(eval-after-load 'quux
|
||||||
|
'(eval-after-load 'bar
|
||||||
|
'(require 'foo nil t)))
|
||||||
|
(progn
|
||||||
|
(eval-after-load 'bow
|
||||||
|
'(require 'foo nil t))
|
||||||
|
(eval-after-load 'baz
|
||||||
|
'(require 'foo nil t)))))))
|
||||||
|
|
||||||
|
(ert-deftest use-package-test/:demand ()
|
||||||
|
(match-expansion
|
||||||
|
(use-package foo :demand t)
|
||||||
|
`(progn
|
||||||
|
(require 'foo nil 'nil)))
|
||||||
|
|
||||||
|
(let ((byte-compile-current-file t))
|
||||||
|
(match-expansion
|
||||||
|
(use-package foo :demand t)
|
||||||
|
`(progn
|
||||||
|
(eval-and-compile
|
||||||
|
(eval-when-compile
|
||||||
|
(with-demoted-errors "Cannot load foo: %S" nil
|
||||||
|
(load "foo" nil t))))
|
||||||
|
(require 'foo nil 'nil))))
|
||||||
|
|
||||||
|
(match-expansion
|
||||||
|
(use-package foo :demand t :config (config))
|
||||||
|
`(progn
|
||||||
|
(require 'foo nil 'nil)
|
||||||
|
(config)
|
||||||
|
t))
|
||||||
|
|
||||||
|
(let ((byte-compile-current-file t))
|
||||||
|
(match-expansion
|
||||||
|
(use-package foo :demand t :config (config))
|
||||||
|
`(progn
|
||||||
|
(eval-and-compile
|
||||||
|
(eval-when-compile
|
||||||
|
(with-demoted-errors "Cannot load foo: %S" nil
|
||||||
|
(load "foo" nil t))))
|
||||||
|
(require 'foo nil 'nil)
|
||||||
|
(config)
|
||||||
|
t))))
|
||||||
|
|
||||||
|
(ert-deftest use-package-test/:config ()
|
||||||
|
(match-expansion
|
||||||
|
(use-package foo :config (config))
|
||||||
|
`(progn
|
||||||
|
(require 'foo nil 'nil)
|
||||||
|
(config)
|
||||||
|
t))
|
||||||
|
|
||||||
|
(let ((byte-compile-current-file t))
|
||||||
|
(match-expansion
|
||||||
|
(use-package foo :config (config))
|
||||||
|
`(progn
|
||||||
|
(eval-and-compile
|
||||||
|
(eval-when-compile
|
||||||
|
(with-demoted-errors "Cannot load foo: %S" nil
|
||||||
|
(load "foo" nil t))))
|
||||||
|
(require 'foo nil 'nil)
|
||||||
|
(config)
|
||||||
|
t)))
|
||||||
|
|
||||||
|
(match-expansion
|
||||||
|
(use-package foo :defer t :config (config))
|
||||||
|
`(progn
|
||||||
|
(eval-after-load 'foo
|
||||||
|
'(progn
|
||||||
|
(config)
|
||||||
|
t))))
|
||||||
|
|
||||||
|
(let ((byte-compile-current-file t))
|
||||||
|
(match-expansion
|
||||||
|
(use-package foo :defer t :config (config))
|
||||||
|
`(progn
|
||||||
|
(eval-and-compile
|
||||||
|
(eval-when-compile
|
||||||
|
(with-demoted-errors "Cannot load foo: %S" nil
|
||||||
|
(load "foo" nil t))))
|
||||||
|
(eval-after-load 'foo
|
||||||
|
'(progn
|
||||||
|
(config)
|
||||||
|
t))))))
|
||||||
|
|
||||||
(ert-deftest use-package-test-normalize/:diminish ()
|
(ert-deftest use-package-test-normalize/:diminish ()
|
||||||
(should (equal (use-package-normalize-diminish 'foopkg :diminish nil)
|
(should (equal (use-package-normalize-diminish 'foopkg :diminish nil)
|
||||||
|
@ -606,9 +972,35 @@
|
||||||
(should (equal (use-package-normalize-diminish 'foopkg :diminish '(foo . "bar"))
|
(should (equal (use-package-normalize-diminish 'foopkg :diminish '(foo . "bar"))
|
||||||
'((foo . "bar")))))
|
'((foo . "bar")))))
|
||||||
|
|
||||||
;; (ert-deftest use-package-test/:diminish ()
|
(ert-deftest use-package-test/:diminish ()
|
||||||
;; (should (equal (macroexpand (use-package))
|
(match-expansion
|
||||||
;; '())))
|
(use-package foo :diminish nil)
|
||||||
|
`(progn
|
||||||
|
(require 'foo nil 'nil)
|
||||||
|
(if (fboundp 'diminish)
|
||||||
|
(diminish 'foo-mode))))
|
||||||
|
|
||||||
|
(match-expansion
|
||||||
|
(use-package foo :diminish bar)
|
||||||
|
`(progn
|
||||||
|
(require 'foo nil 'nil)
|
||||||
|
(if (fboundp 'diminish)
|
||||||
|
(diminish 'bar))))
|
||||||
|
|
||||||
|
(match-expansion
|
||||||
|
(use-package foo :diminish "bar")
|
||||||
|
`(progn
|
||||||
|
(require 'foo nil 'nil)
|
||||||
|
(if (fboundp 'diminish)
|
||||||
|
(diminish 'foo-mode "bar"))))
|
||||||
|
|
||||||
|
|
||||||
|
(match-expansion
|
||||||
|
(use-package foo :diminish (foo . "bar"))
|
||||||
|
`(progn
|
||||||
|
(require 'foo nil 'nil)
|
||||||
|
(if (fboundp 'diminish)
|
||||||
|
(diminish 'foo "bar")))))
|
||||||
|
|
||||||
(ert-deftest use-package-test-normalize/:delight ()
|
(ert-deftest use-package-test-normalize/:delight ()
|
||||||
(should (equal `((foo-mode nil foo))
|
(should (equal `((foo-mode nil foo))
|
||||||
|
@ -623,19 +1015,59 @@
|
||||||
(use-package-normalize/:delight 'foo :delight '("abc"))))
|
(use-package-normalize/:delight 'foo :delight '("abc"))))
|
||||||
(should (equal `((foo-mode (:eval 1) foo))
|
(should (equal `((foo-mode (:eval 1) foo))
|
||||||
(use-package-normalize/:delight 'foo :delight '('(:eval 1)))))
|
(use-package-normalize/:delight 'foo :delight '('(:eval 1)))))
|
||||||
(should (equal `((a-mode nil foo)
|
(should (equal (use-package-normalize/:delight 'foo :delight '((a-mode) (b-mode " b")))
|
||||||
(b-mode " b" foo))
|
`((a-mode nil foo) (b-mode " b" foo))))
|
||||||
(use-package-normalize/:delight 'foo :delight '((a-mode)
|
|
||||||
(b-mode " b")))))
|
|
||||||
(should-error (use-package-normalize/:delight 'foo :delight '((:eval 1)))))
|
(should-error (use-package-normalize/:delight 'foo :delight '((:eval 1)))))
|
||||||
|
|
||||||
;; (ert-deftest use-package-test/:delight ()
|
(ert-deftest use-package-test/:delight ()
|
||||||
;; (should (equal (macroexpand (use-package))
|
(match-expansion
|
||||||
;; '())))
|
(use-package foo :delight)
|
||||||
|
`(progn
|
||||||
|
(require 'foo nil 'nil)
|
||||||
|
(if (fboundp 'delight)
|
||||||
|
(delight '((foo-mode nil foo))))))
|
||||||
|
|
||||||
|
(should-error
|
||||||
|
(match-expansion
|
||||||
|
(use-package foo :delight nil)
|
||||||
|
`(progn
|
||||||
|
(require 'foo nil 'nil)
|
||||||
|
(if (fboundp 'diminish)
|
||||||
|
(diminish 'foo-mode)))))
|
||||||
|
|
||||||
|
(match-expansion
|
||||||
|
(use-package foo :delight bar)
|
||||||
|
`(progn
|
||||||
|
(require 'foo nil 'nil)
|
||||||
|
(if (fboundp 'delight)
|
||||||
|
(delight '((bar nil foo))))))
|
||||||
|
|
||||||
|
(match-expansion
|
||||||
|
(use-package foo :delight "bar")
|
||||||
|
`(progn
|
||||||
|
(require 'foo nil 'nil)
|
||||||
|
(if (fboundp 'delight)
|
||||||
|
(delight '((foo-mode "bar" foo))))))
|
||||||
|
|
||||||
|
(should-error
|
||||||
|
(match-expansion
|
||||||
|
(use-package foo :delight (foo . "bar"))
|
||||||
|
`(progn
|
||||||
|
(require 'foo nil 'nil)
|
||||||
|
(if (fboundp 'diminish)
|
||||||
|
(diminish 'foo "bar")))))
|
||||||
|
|
||||||
|
(match-expansion
|
||||||
|
(use-package foo :delight (foo "bar"))
|
||||||
|
`(progn
|
||||||
|
(require 'foo nil 'nil)
|
||||||
|
(if (fboundp 'delight)
|
||||||
|
(delight '((foo "bar" foo)))))))
|
||||||
|
|
||||||
;; Local Variables:
|
;; Local Variables:
|
||||||
;; indent-tabs-mode: nil
|
;; indent-tabs-mode: nil
|
||||||
;; no-byte-compile: t
|
;; no-byte-compile: t
|
||||||
;; no-update-autoloads: t
|
;; no-update-autoloads: t
|
||||||
;; End:
|
;; End:
|
||||||
|
|
||||||
;;; use-package-tests.el ends here
|
;;; use-package-tests.el ends here
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue