org-export: Remove NOEXPAND optional argument from `org-export-as'
[org-mode.git] / testing / lisp / test-ob-lob.el
blob4e4f0fed26e096b8b6f9d2015d495ffdea48d591
1 ;;; test-ob-lob.el --- test for ob-lob.el
3 ;; Copyright (c) 2010-2012 Eric Schulte
4 ;; Authors: Eric Schulte
6 ;; This file is not part of GNU Emacs.
8 ;; This program is free software; you can redistribute it and/or modify
9 ;; it under the terms of the GNU General Public License as published by
10 ;; the Free Software Foundation, either version 3 of the License, or
11 ;; (at your option) any later version.
13 ;; This program is distributed in the hope that it will be useful,
14 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
15 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 ;; GNU General Public License for more details.
18 ;; You should have received a copy of the GNU General Public License
19 ;; along with this program. If not, see <http://www.gnu.org/licenses/>.
22 ;;; Tests
23 (org-babel-lob-ingest
24 (expand-file-name
25 "library-of-babel.org"
26 (expand-file-name
27 "babel"
28 (expand-file-name
29 "contrib"
30 (expand-file-name
31 ".."
32 (expand-file-name
33 ".."
34 (file-name-directory
35 (or load-file-name buffer-file-name))))))))
37 (ert-deftest test-ob-lob/ingest ()
38 "Test the ingestion of an org-mode file."
39 (should (< 0 (org-babel-lob-ingest
40 (expand-file-name "babel.org" org-test-example-dir)))))
42 (ert-deftest test-ob-lob/call-with-header-arguments ()
43 "Test the evaluation of a library of babel #+call: line."
44 (org-test-at-id "fab7e291-fde6-45fc-bf6e-a485b8bca2f0"
45 (move-beginning-of-line 1)
46 (forward-line 6)
47 (message (buffer-substring (point-at-bol) (point-at-eol)))
48 (should (string= "testing" (org-babel-lob-execute
49 (org-babel-lob-get-info))))
50 (forward-line 1)
51 (should (string= "testing" (caar (org-babel-lob-execute
52 (org-babel-lob-get-info)))))
53 (forward-line 1)
54 (should (string= "testing" (org-babel-lob-execute
55 (org-babel-lob-get-info))))
56 (forward-line 1)
57 (should (string= "testing" (caar (org-babel-lob-execute
58 (org-babel-lob-get-info)))))
59 (forward-line 1)
60 (should (string= "testing" (org-babel-lob-execute
61 (org-babel-lob-get-info))))
62 (forward-line 1)
63 (should (string= "testing" (caar (org-babel-lob-execute
64 (org-babel-lob-get-info)))))
65 (forward-line 1) (beginning-of-line) (forward-char 27)
66 (should (string= "testing" (org-babel-lob-execute
67 (org-babel-lob-get-info))))
68 (forward-line 1) (beginning-of-line) (forward-char 27)
69 (should (string= "testing" (caar (org-babel-lob-execute
70 (org-babel-lob-get-info)))))
71 (forward-line 1) (beginning-of-line)
72 (should (= 4 (org-babel-lob-execute (org-babel-lob-get-info))))
73 (forward-line 1)
74 (should (string= "testing" (org-babel-lob-execute
75 (org-babel-lob-get-info))))
76 (forward-line 1)
77 (should (string= "123" (org-babel-lob-execute (org-babel-lob-get-info))))))
79 (ert-deftest test-ob-lob/export-lob-lines ()
80 "Test the export of a variety of library babel call lines."
81 (org-test-at-id "72ddeed3-2d17-4c7f-8192-a575d535d3fc"
82 (org-narrow-to-subtree)
83 (let ((html (org-export-as-html nil nil nil 'string 'body-only)))
84 ;; check the location of each exported number
85 (with-temp-buffer
86 (insert html) (goto-char (point-min))
87 ;; 0 should be on a line by itself
88 (should (re-search-forward "0" nil t))
89 (should (string= "0" (buffer-substring (point-at-bol) (point-at-eol))))
90 ;; 2 should be in <code> tags
91 (should (re-search-forward "2" nil t))
92 (should (re-search-forward (regexp-quote "</code>") (point-at-eol) t))
93 (should (re-search-backward (regexp-quote "<code>") (point-at-bol) t))
94 ;; 4 should not be exported
95 (should (not (re-search-forward "4" nil t)))
96 ;; 6 should also be inline
97 (should (re-search-forward "6" nil t))
98 (should (re-search-forward (regexp-quote "</code>") (point-at-eol) t))
99 (should (re-search-backward (regexp-quote "<code>") (point-at-bol) t))
100 ;; 8 should not be quoted
101 (should (re-search-forward "8" nil t))
102 (should (not (= ?= (char-after (point)))))
103 (should (not (= ?= (char-before (- (point) 1)))))
104 ;; 10 should export
105 (should (re-search-forward "10" nil t))))))
107 (ert-deftest test-ob-lob/do-not-eval-lob-lines-in-example-blocks-on-export ()
108 (org-test-with-temp-text-in-file "
109 for export
110 #+begin_example
111 #+call: rubbish()
112 #+end_example"
113 (org-export-as-html nil)))
115 (provide 'test-ob-lob)
117 ;;; test-ob-lob.el ends here