1 ;;; subr-tests.el --- Tests for subr.el
3 ;; Copyright (C) 2015 Free Software Foundation, Inc.
5 ;; Author: Oleh Krehel <ohwoeowho@gmail.com>
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is free software: you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation, either version 3 of the License, or
13 ;; (at your option) any later version.
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
31 (ert-deftest let-when-compile ()
33 (should (equal (macroexpand '(let-when-compile ((foo (+ 2 3)))
34 (setq bar (eval-when-compile (+ foo foo)))
35 (setq boo (eval-when-compile (* foo foo)))))
38 (setq boo (quote 25)))))
39 ;; bad case: `eval-when-compile' omitted, byte compiler should catch this
40 (should (equal (macroexpand
41 '(let-when-compile ((foo (+ 2 3)))
42 (setq bar (+ foo foo))
43 (setq boo (eval-when-compile (* foo foo)))))
45 (setq bar (+ foo foo))
46 (setq boo (quote 25)))))
47 ;; something practical
48 (should (equal (macroexpand
49 '(let-when-compile ((keywords '("true" "false")))
50 (font-lock-add-keywords
52 `((,(eval-when-compile
53 (format "\\<%s\\>" (regexp-opt keywords)))
54 0 font-lock-keyword-face)))))
55 '(font-lock-add-keywords
59 "\\<\\(?:\\(?:fals\\|tru\\)e\\)\\>")
61 (0 font-lock-keyword-face))))))))
64 ;;; subr-tests.el ends here