Empty elements in EMACSLOADPATH now stand for the default
[bpt/emacs.git] / test / automated / add-log-tests.el
CommitLineData
694569fc
MY
1;;; add-log-tests.el --- Test suite for add-log.
2
3;; Copyright (C) 2013 Free Software Foundation, Inc.
4
5;; Author: Masatake YAMATO <yamato@redhat.com>
6;; Keywords: vc tools
7
8;; This file is part of GNU Emacs.
9
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.
14
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.
19
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/>.
22
23;;; Code:
24
771b2fc3 25(require 'ert)
694569fc
MY
26(require 'add-log)
27
28(defmacro add-log-current-defun-deftest (name doc major-mode
29 content marker expected-defun)
30 "Generate an ert test for mode-own `add-log-current-defun-function'.
31Run `add-log-current-defun' at the point where MARKER specifies in a
32buffer which content is CONTENT under MAJOR-MODE. Then it compares the
33result with EXPECTED-DEFUN."
34 (let ((xname (intern (concat "add-log-current-defun-test-"
35 (symbol-name name)
36 ))))
37 `(ert-deftest ,xname ()
38 ,doc
39 (with-temp-buffer
40 (insert ,content)
41 (goto-char (point-min))
42 (funcall ',major-mode)
43 (should (equal (when (search-forward ,marker nil t)
44 (replace-match "" nil t)
45 (add-log-current-defun))
46 ,expected-defun))))))
47
48(add-log-current-defun-deftest
49 sh-func1
50 "Test sh-current-defun-name can find function."
51 sh-mode "
52function foo
53{
54 ><
55}" "><" "foo")
56
57(add-log-current-defun-deftest
58 sh-func2
59 "Test sh-current-defun-name can find function."
60 sh-mode "
61foo()
62{
63 ><
64}" "><" "foo")
65
66(add-log-current-defun-deftest
67 sh-func3
68 "Test sh-current-defun-name can find function."
69 sh-mode "
70function foo()
71{
72 ><
73}" "><" "foo")
74
75(add-log-current-defun-deftest
76 sh-var
54ac5d47 77 "Test sh-current-defun-name can find variable definition."
694569fc
MY
78 sh-mode "
79PATH=a:/ab:/usr/abc
80DIR=/pr><oc"
81"><" "DIR")
82
83(provide 'add-log-tests)
84
85;;; add-log-tests.el ends here