1 ;;; test-org-macro.el --- Tests for org-macro.el
3 ;; Copyright (C) 2013 Nicolas Goaziou
5 ;; Author: Nicolas Goaziou <n.goaziou@gmail.com>
7 ;; This program is free software; you can redistribute it and/or modify
8 ;; it under the terms of the GNU General Public License as published by
9 ;; the Free Software Foundation, either version 3 of the License, or
10 ;; (at your option) any later version.
12 ;; This program is distributed in the hope that it will be useful,
13 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
14 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 ;; GNU General Public License for more details.
17 ;; You should have received a copy of the GNU General Public License
18 ;; along with this program. If not, see <http://www.gnu.org/licenses/>.
25 (ert-deftest test-org
/macro-replace-all
()
26 "Test `org-macro-replace-all' specifications."
31 (org-test-with-temp-text "#+MACRO: A B\n1 {{{A}}} 3"
32 (progn (org-macro-initialize-templates)
33 (org-macro-replace-all org-macro-templates
)
35 ;; Macro with arguments.
38 "#+MACRO: macro $1 $2\nsome text"
39 (org-test-with-temp-text "#+MACRO: macro $1 $2\n{{{macro(some,text)}}}"
40 (progn (org-macro-initialize-templates)
41 (org-macro-replace-all org-macro-templates
)
46 "#+MACRO: add (eval (+ $1 $2))\n3"
47 (org-test-with-temp-text "#+MACRO: add (eval (+ $1 $2))\n{{{add(1,2)}}}"
48 (progn (org-macro-initialize-templates)
49 (org-macro-replace-all org-macro-templates
)
54 "#+MACRO: in inner\n#+MACRO: out {{{in}}} outer\ninner outer"
55 (org-test-with-temp-text
56 "#+MACRO: in inner\n#+MACRO: out {{{in}}} outer\n{{{out}}}"
57 (progn (org-macro-initialize-templates)
58 (org-macro-replace-all org-macro-templates
)
60 ;; Error out when macro expansion is circular.
62 (org-test-with-temp-text
63 "#+MACRO: mac1 {{{mac2}}}\n#+MACRO: mac2 {{{mac1}}}\n{{{mac1}}}"
64 (org-macro-initialize-templates)
65 (org-macro-replace-all org-macro-templates
)))
66 ;; Macros in setup file.
70 (org-test-with-temp-text
71 (format "#+MACRO: other-macro success
72 #+SETUPFILE: \"%sexamples/macro-templates.org\"
73 {{{included-macro}}} {{{other-macro}}}"
75 (org-macro-initialize-templates)
76 (org-macro-replace-all org-macro-templates
)
80 (provide 'test-org-macro
)
81 ;;; test-org-macro.el ends here