Cosmetic fix in comment.
[org-mode.git] / testing / lisp / test-ob-lob.el
blob10a83994730c24d25a7fceb445ec17cf5ac5bdf0
1 ;;; test-ob-lob.el --- test for ob-lob.el
3 ;; Copyright (c) 2010-2013 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 ((buf (current-buffer))
84 (string (buffer-string)))
85 (with-temp-buffer
86 (org-mode)
87 (insert string)
88 (let ((org-current-export-file buf))
89 (org-babel-exp-process-buffer))
90 (message (buffer-string))
91 (should (re-search-forward "^: 0" nil t))
92 (should (re-search-forward "call =2= stuck" nil t))
93 (should (re-search-forward
94 "exported =call_double(it=2)= because" nil t))
95 (should (re-search-forward "^=6= because" nil t))
96 (should (re-search-forward "results 8 should" nil t))
97 (should (re-search-forward "following 2\\*5==10= should" nil t))))))
99 (ert-deftest test-ob-lob/do-not-eval-lob-lines-in-example-blocks-on-export ()
100 (require 'ox)
101 (org-test-with-temp-text-in-file "
102 for export
103 #+begin_example
104 #+call: rubbish()
105 #+end_example"
106 (should (progn (org-export-execute-babel-code) t))))
109 (provide 'test-ob-lob)
111 ;;; test-ob-lob.el ends here