aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Wiegley2017-12-01 11:07:08 -0800
committerJohn Wiegley2017-12-01 11:07:08 -0800
commitcd4790b3df8a7707431cb397db603b7bcce6275d (patch)
tree09c067e1a9037f384a310937bb9ab480283269e0
parentf5b034154f8fa2bab0375e34143de9d462ee1232 (diff)
downloademacs-cd4790b3df8a7707431cb397db603b7bcce6275d.tar.gz
emacs-cd4790b3df8a7707431cb397db603b7bcce6275d.zip
Add many more tests
-rw-r--r--test/lisp/use-package/use-package-tests.el670
1 files changed, 551 insertions, 119 deletions
diff --git a/test/lisp/use-package/use-package-tests.el b/test/lisp/use-package/use-package-tests.el
index 66a4af30b52..7c860f568a0 100644
--- a/test/lisp/use-package/use-package-tests.el
+++ b/test/lisp/use-package/use-package-tests.el
@@ -27,7 +27,12 @@
27 27
28(setq use-package-always-ensure nil 28(setq use-package-always-ensure nil
29 use-package-verbose nil 29 use-package-verbose nil
30 use-package-expand-minimally t) 30 use-package-expand-minimally t
31 max-lisp-eval-depth 8000)
32
33;; (let ((byte-compile-current-file nil)) (expand-minimally ())
34(fset 'insert-expansion
35 [?\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])
31 36
32(defmacro expand-minimally (form) 37(defmacro expand-minimally (form)
33 `(let ((use-package-verbose nil) 38 `(let ((use-package-verbose nil)
@@ -321,9 +326,23 @@
321 (unless nil 326 (unless nil
322 (require 'foo nil 'nil))))) 327 (require 'foo nil 'nil)))))
323 328
324;; (ert-deftest use-package-test/:requires () 329(ert-deftest use-package-test/:requires ()
325;; (should (equal (macroexpand (use-package)) 330 (match-expansion
326;; '()))) 331 (use-package foo :requires bar)
332 `(progn
333 (when (not (member nil (mapcar #'featurep '(bar))))
334 (require 'foo nil 'nil))))
335
336 (let ((byte-compile-current-file t))
337 (match-expansion
338 (use-package foo :requires bar)
339 `(progn
340 (when (not (member nil (mapcar #'featurep '(bar))))
341 (eval-and-compile
342 (eval-when-compile
343 (with-demoted-errors "Cannot load foo: %S" nil
344 (load "foo" nil t))))
345 (require 'foo nil 'nil))))))
327 346
328(ert-deftest use-package-test/:load-path () 347(ert-deftest use-package-test/:load-path ()
329 (match-expansion 348 (match-expansion
@@ -337,6 +356,22 @@
337 "bar" user-emacs-directory))))) 356 "bar" user-emacs-directory)))))
338 (require 'foo nil 'nil))) 357 (require 'foo nil 'nil)))
339 358
359 (let ((byte-compile-current-file t))
360 (match-expansion
361 (use-package foo :load-path "bar")
362 `(progn
363 (eval-and-compile
364 (add-to-list 'load-path
365 ,(pred (apply-partially
366 #'string=
367 (expand-file-name
368 "bar" user-emacs-directory)))))
369 (eval-and-compile
370 (eval-when-compile
371 (with-demoted-errors "Cannot load foo: %S" nil
372 (load "foo" nil t))))
373 (require 'foo nil 'nil))))
374
340 (match-expansion 375 (match-expansion
341 (use-package foo :load-path ("bar" "quux")) 376 (use-package foo :load-path ("bar" "quux"))
342 `(progn 377 `(progn
@@ -371,77 +406,197 @@
371 "quux" user-emacs-directory))))) 406 "quux" user-emacs-directory)))))
372 (require 'foo nil 'nil)))) 407 (require 'foo nil 'nil))))
373 408
374;; (ert-deftest use-package-test/:no-require () 409(ert-deftest use-package-test/:no-require ()
375;; (match-expansion 410 (match-expansion
376;; (use-package foo :no-require t) 411 (use-package foo :no-require t)
377;; `nil) 412 `(progn))
413
414 (match-expansion
415 (use-package foo :no-require t :config (config))
416 `(progn
417 (config)
418 t))
378 419
379;; (let ((byte-compile-current-file t)) 420 (let ((byte-compile-current-file t))
380;; (match-expansion 421 (match-expansion
381;; (use-package foo :no-require t) 422 (use-package foo :no-require t)
382;; `'nil))) 423 `(progn
424 (eval-and-compile
425 (eval-when-compile
426 (with-demoted-errors "Cannot load foo: %S" nil nil)))))))
383 427
384(ert-deftest use-package-test-normalize/:bind () 428(ert-deftest use-package-test-normalize/:bind ()
385 (let ((good-values '(:map map-sym 429 (flet ((norm (&rest args)
386 ("str" . sym) ("str" . "str") 430 (apply #'use-package-normalize-binder
387 ([vec] . sym) ([vec] . "str")))) 431 'foopkg :bind args)))
388 (should (equal (use-package-normalize-binder 432 (let ((good-values '(:map map-sym
389 'foopkg :bind good-values) 433 ("str" . sym) ("str" . "str")
390 good-values))) 434 ([vec] . sym) ([vec] . "str"))))
391 (should-error (use-package-normalize-binder 435 (should (equal (norm good-values) good-values)))
392 'foopkg :bind '("foo"))) 436 (should-error (norm '("foo")))
393 (should-error (use-package-normalize-binder 437 (should-error (norm '("foo" . 99)))
394 'foopkg :bind '("foo" . 99))) 438 (should-error (norm '(99 . sym)))))
395 (should-error (use-package-normalize-binder 439
396 'foopkg :bind '(99 . sym)))) 440(ert-deftest use-package-test/:bind ()
397 441 (match-expansion
398;; (ert-deftest use-package-test/:bind () 442 (use-package foo :bind ("C-k" . key))
399;; (should (equal (macroexpand (use-package)) 443 `(progn
400;; '()))) 444 (unless (fboundp 'key)
445 (autoload #'key "foo" nil t))
446 (ignore
447 (bind-keys :package foo ("C-k" . key))))))
401 448
402;; (ert-deftest use-package-test/:bind* () 449(ert-deftest use-package-test/:bind* ()
403;; (should (equal (macroexpand (use-package)) 450 (match-expansion
404;; '()))) 451 (use-package foo :bind* ("C-k" . key))
452 `(progn
453 (unless (fboundp 'key)
454 (autoload #'key "foo" nil t))
455 (ignore
456 (bind-keys* :package foo ("C-k" . key))))))
405 457
406;; (ert-deftest use-package-test/:bind-keymap () 458(ert-deftest use-package-test/:bind-keymap ()
407;; (should (equal (macroexpand (use-package)) 459 (match-expansion
408;; '()))) 460 (use-package foo :bind-keymap ("C-k" . key))
461 `(progn
462 (ignore
463 (bind-key "C-k"
464 #'(lambda ()
465 (interactive)
466 (use-package-autoload-keymap 'key 'foo nil)))))))
409 467
410;; (ert-deftest use-package-test/:bind-keymap* () 468(ert-deftest use-package-test/:bind-keymap* ()
411;; (should (equal (macroexpand (use-package)) 469 (match-expansion
412;; '()))) 470 (use-package foo :bind-keymap* ("C-k" . key))
471 `(progn
472 (ignore
473 (bind-key* "C-k"
474 #'(lambda ()
475 (interactive)
476 (use-package-autoload-keymap 'key 'foo t)))))))
413 477
414;; (ert-deftest use-package-test/:interpreter () 478(ert-deftest use-package-test/:interpreter ()
415;; (should (equal (macroexpand (use-package)) 479 (match-expansion
416;; '()))) 480 (use-package foo :interpreter "interp")
481 `(progn
482 (unless (fboundp 'foo)
483 (autoload #'foo "foo" nil t))
484 (ignore
485 (add-to-list 'interpreter-mode-alist
486 '("interp" . foo)))))
487
488 (match-expansion
489 (use-package foo :interpreter ("interp" . fun))
490 `(progn
491 (unless (fboundp 'fun)
492 (autoload #'fun "foo" nil t))
493 (ignore
494 (add-to-list 'interpreter-mode-alist
495 '("interp" . fun))))))
417 496
418(ert-deftest use-package-test-normalize/:mode () 497(ert-deftest use-package-test-normalize/:mode ()
419 (should (equal (use-package-normalize-mode 'foopkg :mode '(".foo")) 498 (flet ((norm (&rest args)
420 '((".foo" . foopkg)))) 499 (apply #'use-package-normalize/:mode
421 (should (equal (use-package-normalize-mode 'foopkg :mode '(".foo" ".bar")) 500 'foopkg :mode args)))
422 '((".foo" . foopkg) (".bar" . foopkg)))) 501 (should (equal (norm '(".foo"))
423 (should (equal (use-package-normalize-mode 'foopkg :mode '((".foo" ".bar"))) 502 '((".foo" . foopkg))))
424 '((".foo" . foopkg) (".bar" . foopkg)))) 503 (should (equal (norm '(".foo" ".bar"))
425 (should (equal (use-package-normalize-mode 'foopkg :mode '((".foo"))) 504 '((".foo" . foopkg) (".bar" . foopkg))))
426 '((".foo" . foopkg)))) 505 (should (equal (norm '((".foo" ".bar")))
427 (should (equal (use-package-normalize-mode 'foopkg :mode '((".foo" . foo) (".bar" . bar))) 506 '((".foo" . foopkg) (".bar" . foopkg))))
428 '((".foo" . foo) (".bar" . bar))))) 507 (should (equal (norm '((".foo")))
429 508 '((".foo" . foopkg))))
430;; (ert-deftest use-package-test/:mode () 509 (should (equal (norm '((".foo" . foo) (".bar" . bar)))
431;; (should (equal (macroexpand (use-package)) 510 '((".foo" . foo) (".bar" . bar))))))
432;; '()))) 511
512(ert-deftest use-package-test/:mode ()
513 (match-expansion
514 (use-package foo :mode "interp")
515 `(progn
516 (unless (fboundp 'foo)
517 (autoload #'foo "foo" nil t))
518 (ignore
519 (add-to-list 'auto-mode-alist
520 '("interp" . foo)))))
433 521
434;; (ert-deftest use-package-test/:magic () 522 (match-expansion
435;; (should (equal (macroexpand (use-package)) 523 (use-package foo :mode ("interp" . fun))
436;; '()))) 524 `(progn
525 (unless (fboundp 'fun)
526 (autoload #'fun "foo" nil t))
527 (ignore
528 (add-to-list 'auto-mode-alist
529 '("interp" . fun))))))
437 530
438;; (ert-deftest use-package-test/:magic-fallback () 531(ert-deftest use-package-test/:magic ()
439;; (should (equal (macroexpand (use-package)) 532 (match-expansion
440;; '()))) 533 (use-package foo :magic "interp")
534 `(progn
535 (unless (fboundp 'foo)
536 (autoload #'foo "foo" nil t))
537 (ignore
538 (add-to-list 'magic-mode-alist
539 '("interp" . foo)))))
441 540
442;; (ert-deftest use-package-test/:commands () 541 (match-expansion
443;; (should (equal (macroexpand (use-package)) 542 (use-package foo :magic ("interp" . fun))
444;; '()))) 543 `(progn
544 (unless (fboundp 'fun)
545 (autoload #'fun "foo" nil t))
546 (ignore
547 (add-to-list 'magic-mode-alist
548 '("interp" . fun))))))
549
550(ert-deftest use-package-test/:magic-fallback ()
551 (match-expansion
552 (use-package foo :magic-fallback "interp")
553 `(progn
554 (unless (fboundp 'foo)
555 (autoload #'foo "foo" nil t))
556 (ignore
557 (add-to-list 'magic-fallback-mode-alist
558 '("interp" . foo)))))
559
560 (match-expansion
561 (use-package foo :magic-fallback ("interp" . fun))
562 `(progn
563 (unless (fboundp 'fun)
564 (autoload #'fun "foo" nil t))
565 (ignore
566 (add-to-list 'magic-fallback-mode-alist
567 '("interp" . fun))))))
568
569(ert-deftest use-package-test/:commands ()
570 (match-expansion
571 (use-package foo :commands bar)
572 `(progn
573 (unless (fboundp 'bar)
574 (autoload #'bar "foo" nil t))))
575
576 (match-expansion
577 (use-package foo :commands (bar quux))
578 `(progn
579 (unless (fboundp 'bar)
580 (autoload #'bar "foo" nil t))
581 (unless (fboundp 'quux)
582 (autoload #'quux "foo" nil t))))
583
584 (let ((byte-compile-current-file t))
585 (match-expansion
586 (use-package foo :commands (bar quux))
587 `(progn
588 (eval-and-compile
589 (eval-when-compile
590 (with-demoted-errors "Cannot load foo: %S" nil
591 (load "foo" nil t))))
592 (unless (fboundp 'bar)
593 (autoload #'bar "foo" nil t))
594 (eval-when-compile
595 (declare-function bar "foo"))
596 (unless (fboundp 'quux)
597 (autoload #'quux "foo" nil t))
598 (eval-when-compile
599 (declare-function quux "foo"))))))
445 600
446(ert-deftest use-package-test/:defines () 601(ert-deftest use-package-test/:defines ()
447 (match-expansion 602 (match-expansion
@@ -508,28 +663,54 @@
508 (config) 663 (config)
509 t)))))) 664 t))))))
510 665
511;; (ert-deftest use-package-test/:defer () 666(ert-deftest use-package-test/:defer ()
512;; (should (equal (macroexpand (use-package)) 667 (match-expansion
513;; '()))) 668 (use-package foo)
669 `(progn
670 (require 'foo nil 'nil)))
671
672 (let ((byte-compile-current-file t))
673 (match-expansion
674 (use-package foo)
675 `(progn
676 (eval-and-compile
677 (eval-when-compile
678 (with-demoted-errors "Cannot load foo: %S" nil
679 (load "foo" nil t))))
680 (require 'foo nil 'nil))))
681
682 (match-expansion
683 (use-package foo :defer t)
684 `(progn))
685
686 (let ((byte-compile-current-file t))
687 (match-expansion
688 (use-package foo :defer t)
689 `(progn
690 (eval-and-compile
691 (eval-when-compile
692 (with-demoted-errors "Cannot load foo: %S" nil
693 (load "foo" nil t))))))))
514 694
515(ert-deftest use-package-test-normalize/:hook () 695(ert-deftest use-package-test-normalize/:hook ()
516 (should-error (use-package-normalize/:hook 'foopkg :hook nil)) 696 (flet ((norm (&rest args)
517 (should (equal (use-package-normalize/:hook 'foopkg :hook '(bar)) 697 (apply #'use-package-normalize/:hook
518 '((bar . foopkg)))) 698 'foopkg :hook args)))
519 (should (equal (use-package-normalize/:hook 'foopkg :hook '((bar . baz))) 699 (should-error (norm nil))
520 '((bar . baz)))) 700 (should (equal (norm '(bar))
521 (should (equal (use-package-normalize/:hook 'foopkg :hook '(((bar baz) . quux))) 701 '((bar . foopkg))))
522 '(((bar baz) . quux)))) 702 (should (equal (norm '((bar . baz)))
523 (should (equal (use-package-normalize/:hook 'foopkg :hook '(bar baz)) 703 '((bar . baz))))
524 '(((bar baz) . foopkg)))) 704 (should (equal (norm '(((bar baz) . quux)))
525 (should (equal (use-package-normalize/:hook 'foopkg :hook '((bar baz) (quux bow))) 705 '(((bar baz) . quux))))
526 '(((bar baz) . foopkg) ((quux bow) . foopkg)))) 706 (should (equal (norm '(bar baz))
527 (should (equal (use-package-normalize/:hook 'foopkg :hook '((bar . baz) (quux . bow))) 707 '(((bar baz) . foopkg))))
528 '((bar . baz) (quux . bow)))) 708 (should (equal (norm '((bar baz) (quux bow)))
529 (should (equal (use-package-normalize/:hook 'foopkg :hook '(((bar1 bar2) . baz) 709 '(((bar baz) . foopkg) ((quux bow) . foopkg))))
530 ((quux1 quux2) . bow))) 710 (should (equal (norm '((bar . baz) (quux . bow)))
531 '(((bar1 bar2) . baz) 711 '((bar . baz) (quux . bow))))
532 ((quux1 quux2) . bow))))) 712 (should (equal (norm '(((bar1 bar2) . baz) ((quux1 quux2) . bow)))
713 '(((bar1 bar2) . baz) ((quux1 quux2) . bow))))))
533 714
534(ert-deftest use-package-test/:hook () 715(ert-deftest use-package-test/:hook ()
535 (let ((byte-compile-current-file t)) 716 (let ((byte-compile-current-file t))
@@ -557,42 +738,227 @@
557 (bind-keys :package foo ("C-a" . key)))))))) 738 (bind-keys :package foo ("C-a" . key))))))))
558 739
559(ert-deftest use-package-test-normalize/:custom () 740(ert-deftest use-package-test-normalize/:custom ()
560 (should-error (use-package-normalize/:custom 'foopkg :custom nil)) 741 (flet ((norm (&rest args)
561 (should-error (use-package-normalize/:custom 'foopkg :custom '(bar))) 742 (apply #'use-package-normalize/:custom
562 ;; (should-error (use-package-normalize/:custom 'foopkg :custom '((foo bar baz quux)))) 743 'foopkg :custom args)))
563 (should (equal (use-package-normalize/:custom 'foopkg :custom '(foo bar)) 744 (should-error (norm nil))
564 '((foo bar)))) 745 (should-error (norm '(bar)))
565 ;; (should-error (use-package-normalize/:custom 'foopkg :custom '(foo bar baz))) 746 ;; (should-error (norm '((foo bar baz quux))))
566 ;; (should (equal (use-package-normalize/:custom 'foopkg :custom '(foo bar "baz")) 747 (should (equal (norm '(foo bar)) '((foo bar))))
567 ;; '((foo bar baz)))) 748 ;; (should-error (norm '(foo bar baz)))
568 ) 749 ;; (should (equal (norm '(foo bar "baz"))
569 750 ;; '((foo bar baz))))
570;; (ert-deftest use-package-test/:custom () 751 ))
571;; (should (equal (macroexpand (use-package)) 752
572;; '()))) 753(ert-deftest use-package-test/:custom ()
754 (match-expansion
755 (use-package foo :custom (foo bar))
756 `(progn
757 (customize-set-variable 'foo bar "Customized with use-package foo")
758 (require 'foo nil 'nil))))
573 759
574;; (ert-deftest use-package-test/:custom-face () 760(ert-deftest use-package-test/:custom-face ()
575;; (should (equal (macroexpand (use-package)) 761 (match-expansion
576;; '()))) 762 (use-package foo :custom-face (foo ((t (:background "#e4edfc")))))
763 `(progn
764 (custom-set-faces '(foo ((t (:background "#e4edfc")))))
765 (require 'foo nil 'nil))))
577 766
578;; (ert-deftest use-package-test/:init () 767(ert-deftest use-package-test/:init ()
579;; (should (equal (macroexpand (use-package)) 768 (match-expansion
580;; '()))) 769 (use-package foo :init (init))
770 `(progn
771 (init)
772 (require 'foo nil 'nil)))
773
774 (let ((byte-compile-current-file t))
775 (match-expansion
776 (use-package foo :init (init))
777 `(progn
778 (eval-and-compile
779 (eval-when-compile
780 (with-demoted-errors "Cannot load foo: %S" nil
781 (load "foo" nil t))))
782 (init)
783 (require 'foo nil 'nil)))))
581 784
582(ert-deftest use-package-test/:after () 785(ert-deftest use-package-test/:after ()
583 (match-expansion 786 (match-expansion
584 (use-package foo :after bar) 787 (use-package foo :after bar)
585 `(progn 788 `(progn
586 (eval-after-load 'bar 789 (eval-after-load 'bar
587 '(require 'foo nil t))))) 790 '(require 'foo nil t))))
588 791
589;; (ert-deftest use-package-test/:demand () 792 (let ((byte-compile-current-file t))
590;; (should (equal (macroexpand (use-package)) 793 (match-expansion
591;; '()))) 794 (use-package foo :after bar)
795 `(progn
796 (eval-and-compile
797 (eval-when-compile
798 (with-demoted-errors "Cannot load foo: %S" nil
799 (load "foo" nil t))))
800 (eval-after-load 'bar
801 '(require 'foo nil t)))))
592 802
593;; (ert-deftest use-package-test/:config () 803 (match-expansion
594;; (should (equal (macroexpand (use-package)) 804 (use-package foo :after (bar quux))
595;; '()))) 805 `(progn
806 (eval-after-load 'quux
807 '(eval-after-load 'bar
808 '(require 'foo nil t)))))
809
810 (match-expansion
811 (use-package foo :after (:all bar quux))
812 `(progn
813 (eval-after-load 'quux
814 '(eval-after-load 'bar
815 '(require 'foo nil t)))))
816
817 (match-expansion
818 (use-package foo :after (:any bar quux))
819 `(progn
820 (progn
821 (eval-after-load 'bar
822 '(require 'foo nil t))
823 (eval-after-load 'quux
824 '(require 'foo nil t)))))
825
826 (match-expansion
827 (use-package foo :after (:all (:any bar quux) bow))
828 `(progn
829 (eval-after-load 'bow
830 '(progn
831 (eval-after-load 'bar
832 '(require 'foo nil t))
833 (eval-after-load 'quux
834 '(require 'foo nil t))))))
835
836 (match-expansion
837 (use-package foo :after (:any (:all bar quux) bow))
838 `(progn
839 (progn
840 (eval-after-load 'quux
841 '(eval-after-load 'bar
842 '(require 'foo nil t)))
843 (eval-after-load 'bow
844 '(require 'foo nil t)))))
845
846 (match-expansion
847 (use-package foo :after (:all (:any bar quux) (:any bow baz)))
848 `(progn
849 (progn
850 (eval-after-load 'bow
851 '(progn
852 (eval-after-load 'bar
853 '(require 'foo nil t))
854 (eval-after-load 'quux
855 '(require 'foo nil t))))
856 (eval-after-load 'baz
857 '(progn
858 (eval-after-load 'bar
859 '(require 'foo nil t))
860 (eval-after-load 'quux
861 '(require 'foo nil t)))))))
862
863 (match-expansion
864 (use-package foo :after (:any (:all bar quux) (:all bow baz)))
865 `(progn
866 (progn
867 (eval-after-load 'quux
868 '(eval-after-load 'bar
869 '(require 'foo nil t)))
870 (eval-after-load 'baz
871 '(eval-after-load 'bow
872 '(require 'foo nil t))))))
873
874 (match-expansion
875 (use-package foo :after (:any (:all bar quux) (:any bow baz)))
876 `(progn
877 (progn
878 (eval-after-load 'quux
879 '(eval-after-load 'bar
880 '(require 'foo nil t)))
881 (progn
882 (eval-after-load 'bow
883 '(require 'foo nil t))
884 (eval-after-load 'baz
885 '(require 'foo nil t)))))))
886
887(ert-deftest use-package-test/:demand ()
888 (match-expansion
889 (use-package foo :demand t)
890 `(progn
891 (require 'foo nil 'nil)))
892
893 (let ((byte-compile-current-file t))
894 (match-expansion
895 (use-package foo :demand t)
896 `(progn
897 (eval-and-compile
898 (eval-when-compile
899 (with-demoted-errors "Cannot load foo: %S" nil
900 (load "foo" nil t))))
901 (require 'foo nil 'nil))))
902
903 (match-expansion
904 (use-package foo :demand t :config (config))
905 `(progn
906 (require 'foo nil 'nil)
907 (config)
908 t))
909
910 (let ((byte-compile-current-file t))
911 (match-expansion
912 (use-package foo :demand t :config (config))
913 `(progn
914 (eval-and-compile
915 (eval-when-compile
916 (with-demoted-errors "Cannot load foo: %S" nil
917 (load "foo" nil t))))
918 (require 'foo nil 'nil)
919 (config)
920 t))))
921
922(ert-deftest use-package-test/:config ()
923 (match-expansion
924 (use-package foo :config (config))
925 `(progn
926 (require 'foo nil 'nil)
927 (config)
928 t))
929
930 (let ((byte-compile-current-file t))
931 (match-expansion
932 (use-package foo :config (config))
933 `(progn
934 (eval-and-compile
935 (eval-when-compile
936 (with-demoted-errors "Cannot load foo: %S" nil
937 (load "foo" nil t))))
938 (require 'foo nil 'nil)
939 (config)
940 t)))
941
942 (match-expansion
943 (use-package foo :defer t :config (config))
944 `(progn
945 (eval-after-load 'foo
946 '(progn
947 (config)
948 t))))
949
950 (let ((byte-compile-current-file t))
951 (match-expansion
952 (use-package foo :defer t :config (config))
953 `(progn
954 (eval-and-compile
955 (eval-when-compile
956 (with-demoted-errors "Cannot load foo: %S" nil
957 (load "foo" nil t))))
958 (eval-after-load 'foo
959 '(progn
960 (config)
961 t))))))
596 962
597(ert-deftest use-package-test-normalize/:diminish () 963(ert-deftest use-package-test-normalize/:diminish ()
598 (should (equal (use-package-normalize-diminish 'foopkg :diminish nil) 964 (should (equal (use-package-normalize-diminish 'foopkg :diminish nil)
@@ -606,9 +972,35 @@
606 (should (equal (use-package-normalize-diminish 'foopkg :diminish '(foo . "bar")) 972 (should (equal (use-package-normalize-diminish 'foopkg :diminish '(foo . "bar"))
607 '((foo . "bar"))))) 973 '((foo . "bar")))))
608 974
609;; (ert-deftest use-package-test/:diminish () 975(ert-deftest use-package-test/:diminish ()
610;; (should (equal (macroexpand (use-package)) 976 (match-expansion
611;; '()))) 977 (use-package foo :diminish nil)
978 `(progn
979 (require 'foo nil 'nil)
980 (if (fboundp 'diminish)
981 (diminish 'foo-mode))))
982
983 (match-expansion
984 (use-package foo :diminish bar)
985 `(progn
986 (require 'foo nil 'nil)
987 (if (fboundp 'diminish)
988 (diminish 'bar))))
989
990 (match-expansion
991 (use-package foo :diminish "bar")
992 `(progn
993 (require 'foo nil 'nil)
994 (if (fboundp 'diminish)
995 (diminish 'foo-mode "bar"))))
996
997
998 (match-expansion
999 (use-package foo :diminish (foo . "bar"))
1000 `(progn
1001 (require 'foo nil 'nil)
1002 (if (fboundp 'diminish)
1003 (diminish 'foo "bar")))))
612 1004
613(ert-deftest use-package-test-normalize/:delight () 1005(ert-deftest use-package-test-normalize/:delight ()
614 (should (equal `((foo-mode nil foo)) 1006 (should (equal `((foo-mode nil foo))
@@ -623,19 +1015,59 @@
623 (use-package-normalize/:delight 'foo :delight '("abc")))) 1015 (use-package-normalize/:delight 'foo :delight '("abc"))))
624 (should (equal `((foo-mode (:eval 1) foo)) 1016 (should (equal `((foo-mode (:eval 1) foo))
625 (use-package-normalize/:delight 'foo :delight '('(:eval 1))))) 1017 (use-package-normalize/:delight 'foo :delight '('(:eval 1)))))
626 (should (equal `((a-mode nil foo) 1018 (should (equal (use-package-normalize/:delight 'foo :delight '((a-mode) (b-mode " b")))
627 (b-mode " b" foo)) 1019 `((a-mode nil foo) (b-mode " b" foo))))
628 (use-package-normalize/:delight 'foo :delight '((a-mode)
629 (b-mode " b")))))
630 (should-error (use-package-normalize/:delight 'foo :delight '((:eval 1))))) 1020 (should-error (use-package-normalize/:delight 'foo :delight '((:eval 1)))))
631 1021
632;; (ert-deftest use-package-test/:delight () 1022(ert-deftest use-package-test/:delight ()
633;; (should (equal (macroexpand (use-package)) 1023 (match-expansion
634;; '()))) 1024 (use-package foo :delight)
1025 `(progn
1026 (require 'foo nil 'nil)
1027 (if (fboundp 'delight)
1028 (delight '((foo-mode nil foo))))))
1029
1030 (should-error
1031 (match-expansion
1032 (use-package foo :delight nil)
1033 `(progn
1034 (require 'foo nil 'nil)
1035 (if (fboundp 'diminish)
1036 (diminish 'foo-mode)))))
1037
1038 (match-expansion
1039 (use-package foo :delight bar)
1040 `(progn
1041 (require 'foo nil 'nil)
1042 (if (fboundp 'delight)
1043 (delight '((bar nil foo))))))
1044
1045 (match-expansion
1046 (use-package foo :delight "bar")
1047 `(progn
1048 (require 'foo nil 'nil)
1049 (if (fboundp 'delight)
1050 (delight '((foo-mode "bar" foo))))))
1051
1052 (should-error
1053 (match-expansion
1054 (use-package foo :delight (foo . "bar"))
1055 `(progn
1056 (require 'foo nil 'nil)
1057 (if (fboundp 'diminish)
1058 (diminish 'foo "bar")))))
1059
1060 (match-expansion
1061 (use-package foo :delight (foo "bar"))
1062 `(progn
1063 (require 'foo nil 'nil)
1064 (if (fboundp 'delight)
1065 (delight '((foo "bar" foo)))))))
635 1066
636;; Local Variables: 1067;; Local Variables:
637;; indent-tabs-mode: nil 1068;; indent-tabs-mode: nil
638;; no-byte-compile: t 1069;; no-byte-compile: t
639;; no-update-autoloads: t 1070;; no-update-autoloads: t
640;; End: 1071;; End:
1072
641;;; use-package-tests.el ends here 1073;;; use-package-tests.el ends here