Update copyright years.
[org-mode.git] / testing / lisp / test-ob-lob.el
blob229e3ddaf28e203186a11830126ea4319ce71d75
1 ;;; test-ob-lob.el --- test for ob-lob.el
3 ;; Copyright (c) 2010-2014 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 "doc"
28 (expand-file-name
29 ".."
30 (expand-file-name
31 ".."
32 (file-name-directory
33 (or load-file-name buffer-file-name)))))))
35 (ert-deftest test-ob-lob/ingest ()
36 "Test the ingestion of an org-mode file."
37 (should (< 0 (org-babel-lob-ingest
38 (expand-file-name "babel.org" org-test-example-dir)))))
40 (ert-deftest test-ob-lob/call-with-header-arguments ()
41 "Test the evaluation of a library of babel #+call: line."
42 (org-test-at-id "fab7e291-fde6-45fc-bf6e-a485b8bca2f0"
43 (move-beginning-of-line 1)
44 (forward-line 6)
45 (message (buffer-substring (point-at-bol) (point-at-eol)))
46 (should (string= "testing" (org-babel-lob-execute
47 (org-babel-lob-get-info))))
48 (forward-line 1)
49 (should (string= "testing" (caar (org-babel-lob-execute
50 (org-babel-lob-get-info)))))
51 (forward-line 1)
52 (should (string= "testing" (org-babel-lob-execute
53 (org-babel-lob-get-info))))
54 (forward-line 1)
55 (should (string= "testing" (caar (org-babel-lob-execute
56 (org-babel-lob-get-info)))))
57 (forward-line 1)
58 (should (string= "testing" (org-babel-lob-execute
59 (org-babel-lob-get-info))))
60 (forward-line 1)
61 (should (string= "testing" (caar (org-babel-lob-execute
62 (org-babel-lob-get-info)))))
63 (forward-line 1) (beginning-of-line) (forward-char 27)
64 (should (string= "testing" (org-babel-lob-execute
65 (org-babel-lob-get-info))))
66 (forward-line 1) (beginning-of-line) (forward-char 27)
67 (should (string= "testing" (caar (org-babel-lob-execute
68 (org-babel-lob-get-info)))))
69 (forward-line 1) (beginning-of-line)
70 (should (= 4 (org-babel-lob-execute (org-babel-lob-get-info))))
71 (forward-line 1)
72 (should (string= "testing" (org-babel-lob-execute
73 (org-babel-lob-get-info))))
74 (forward-line 1)
75 (should (string= "123" (org-babel-lob-execute (org-babel-lob-get-info))))))
77 (ert-deftest test-ob-lob/export-lob-lines ()
78 "Test the export of a variety of library babel call lines."
79 (org-test-at-id "72ddeed3-2d17-4c7f-8192-a575d535d3fc"
80 (org-narrow-to-subtree)
81 (let ((buf (current-buffer))
82 (string (buffer-string)))
83 (with-temp-buffer
84 (org-mode)
85 (insert string)
86 (let ((org-current-export-file buf))
87 (org-babel-exp-process-buffer))
88 (message (buffer-string))
89 (goto-char (point-min))
90 (should (re-search-forward "^: 0" nil t))
91 (should (re-search-forward "call =2= stuck" nil t))
92 (should (re-search-forward
93 "exported =call_double(it=2)= because" nil t))
94 (should (re-search-forward "^=6= because" nil t))
95 (should (re-search-forward "results 8 should" nil t))
96 (should (re-search-forward "following 2\\*5==10= should" nil t))))))
98 (ert-deftest test-ob-lob/do-not-eval-lob-lines-in-example-blocks-on-export ()
99 (require 'ox)
100 (org-test-with-temp-text-in-file "
101 for export
102 #+begin_example
103 #+call: rubbish()
104 #+end_example"
105 (should (progn (org-export-execute-babel-code) t))))
108 (provide 'test-ob-lob)
110 ;;; test-ob-lob.el ends here