emacs/test/lisp/use-package/use-package-tests.el

81 lines
3.3 KiB
EmacsLisp
Raw Normal View History

2014-02-12 22:30:12 +01:00
;;; use-package-tests.el --- Tests for use-package.el
;; This program is free software; you can redistribute it and/or
;; modify it under the terms of the GNU General Public License as
;; published by the Free Software Foundation; either version 2, or (at
;; your option) any later version.
;; This program is distributed in the hope that it will be useful, but
;; WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
;; General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs; see the file COPYING. If not, write to the
;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
;; Boston, MA 02111-1307, USA.
;;; Commentary:
;;
;;; Code:
(require 'ert)
(require 'use-package)
(ert-deftest use-package-normalize-binder ()
(let ((good-values '(:map map-sym
("str" . sym) ("str" . "str")
([vec] . sym) ([vec] . "str"))))
(should (equal (use-package-normalize-binder
'foopkg :bind good-values)
good-values)))
(should-error (use-package-normalize-binder
'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-normalize-mode ()
(should (equal (use-package-normalize-mode 'foopkg :mode '(".foo"))
'((".foo" . foopkg))))
(should (equal (use-package-normalize-mode 'foopkg :mode '(".foo" ".bar"))
'((".foo" . foopkg) (".bar" . foopkg))))
(should (equal (use-package-normalize-mode 'foopkg :mode '((".foo" ".bar")))
'((".foo" . foopkg) (".bar" . foopkg))))
(should (equal (use-package-normalize-mode 'foopkg :mode '((".foo")))
'((".foo" . foopkg))))
(should (equal (use-package-normalize-mode 'foopkg :mode '((".foo" . foo) (".bar" . bar)))
'((".foo" . foo) (".bar" . bar)))))
2014-02-12 22:30:12 +01:00
(ert-deftest use-package-normalize-delight ()
(should (equal `((foo-mode nil foo))
(use-package-normalize/:delight 'foo :delight nil)))
(should (equal `((foo-mode nil foo-mode))
(use-package-normalize/:delight 'foo-mode :delight nil)))
(should (equal `((bar-mode nil foo))
(use-package-normalize/:delight 'foo :delight '(bar-mode))))
(should (equal `((bar-mode nil :major))
(use-package-normalize/:delight 'foo :delight '((bar-mode nil :major)))))
(should (equal `((foo-mode "abc" foo))
(use-package-normalize/:delight 'foo :delight '("abc"))))
(should (equal `((foo-mode (:eval 1) foo))
(use-package-normalize/:delight 'foo :delight '('(:eval 1)))))
(should (equal `((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))))
)
2014-02-12 22:30:12 +01:00
;; Local Variables:
;; indent-tabs-mode: nil
;; no-byte-compile: t
;; no-update-autoloads: t
2014-02-12 22:30:12 +01:00
;; End:
;;; use-package-tests.el ends here