Change defgeneric so it doesn't completely redefine the function
[emacs.git] / test / automated / subr-tests.el
blobd29efc6f3307ce15c18943b9c24bf71051ed03b5
1 ;;; subr-tests.el --- Tests for subr.el
3 ;; Copyright (C) 2015 Free Software Foundation, Inc.
5 ;; Author: Oleh Krehel <ohwoeowho@gmail.com>
6 ;; Keywords:
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/>.
23 ;;; Commentary:
27 ;;; Code:
29 (require 'ert)
31 (ert-deftest let-when-compile ()
32 ;; good case
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)))))
36 '(progn
37 (setq bar (quote 10))
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)))))
44 '(progn
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
51 'c++-mode
52 `((,(eval-when-compile
53 (format "\\<%s\\>" (regexp-opt keywords)))
54 0 font-lock-keyword-face)))))
55 '(font-lock-add-keywords
56 (quote c++-mode)
57 (list
58 (cons (quote
59 "\\<\\(?:\\(?:fals\\|tru\\)e\\)\\>")
60 (quote
61 (0 font-lock-keyword-face))))))))
63 (provide 'subr-tests)
64 ;;; subr-tests.el ends here