emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
blob db3b7c847841cb2a75828400a06f29802ccd428b 3859 bytes (raw)
name: testing/lisp/test-ob-lob.el 	 # note: path name is non-authoritative(*)

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
 
;;; test-ob-lob.el --- test for ob-lob.el

;; Copyright (c) 2010-2013 Eric Schulte
;; Authors: Eric Schulte

;; This file is not part of GNU Emacs.

;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.

;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;; GNU General Public License for more details.

;; You should have received a copy of the GNU General Public License
;; along with this program.  If not, see <http://www.gnu.org/licenses/>.

\f
;;; Tests
(org-babel-lob-ingest
 (expand-file-name
  "library-of-babel.org"
  (expand-file-name
   "doc"
    (expand-file-name
     ".."
     (expand-file-name
      ".."
      (file-name-directory
       (or load-file-name buffer-file-name)))))))

(ert-deftest test-ob-lob/ingest ()
  "Test the ingestion of an org-mode file."
  (should (< 0 (org-babel-lob-ingest
		(expand-file-name "babel.org" org-test-example-dir)))))

(ert-deftest test-ob-lob/call-with-header-arguments ()
  "Test the evaluation of a library of babel #+call: line."
  (org-test-at-id "fab7e291-fde6-45fc-bf6e-a485b8bca2f0"
    (move-beginning-of-line 1)
    (forward-line 6)
    (message (buffer-substring (point-at-bol) (point-at-eol)))
    (should (string= "testing" (org-babel-lob-execute
				(org-babel-lob-get-info))))
    (forward-line 1)
    (should (string= "testing" (caar (org-babel-lob-execute
				      (org-babel-lob-get-info)))))
    (forward-line 1)
    (should (string= "testing" (org-babel-lob-execute
    				(org-babel-lob-get-info))))
    (forward-line 1)
    (should (string= "testing" (caar (org-babel-lob-execute
    				      (org-babel-lob-get-info)))))
    (forward-line 1)
    (should (string= "testing" (org-babel-lob-execute
				(org-babel-lob-get-info))))
    (forward-line 1)
    (should (string= "testing" (caar (org-babel-lob-execute
    				      (org-babel-lob-get-info)))))
    (forward-line 1) (beginning-of-line) (forward-char 27)
    (should (string= "testing" (org-babel-lob-execute
				(org-babel-lob-get-info))))
    (forward-line 1) (beginning-of-line) (forward-char 27)
    (should (string= "testing" (caar (org-babel-lob-execute
				      (org-babel-lob-get-info)))))
    (forward-line 1) (beginning-of-line)
    (should (= 4 (org-babel-lob-execute (org-babel-lob-get-info))))
    (forward-line 1)
    (should (string= "testing" (org-babel-lob-execute
				(org-babel-lob-get-info))))
    (forward-line 1)
    (should (string= "123" (org-babel-lob-execute (org-babel-lob-get-info))))))

(ert-deftest test-ob-lob/export-lob-lines ()
  "Test the export of a variety of library babel call lines."
  (org-test-at-id "72ddeed3-2d17-4c7f-8192-a575d535d3fc"
    (org-narrow-to-subtree)
    (let ((buf (current-buffer))
	  (string (buffer-string)))
      (with-temp-buffer
	(org-mode)
	(insert string)
	(let ((org-current-export-file buf))
	  (org-babel-exp-process-buffer))
	(message (buffer-string))
	(should (re-search-forward "^: 0" nil t))
	(should (re-search-forward "call =2= stuck" nil t))
	(should (re-search-forward
		 "exported =call_double(it=2)= because" nil t))
	(should (re-search-forward "^=6= because" nil t))
	(should (re-search-forward "results 8 should" nil t))
	(should (re-search-forward "following 2\\*5==10= should" nil t))))))

(ert-deftest test-ob-lob/do-not-eval-lob-lines-in-example-blocks-on-export ()
  (require 'ox)
  (org-test-with-temp-text-in-file "
for export
#+begin_example
#+call: rubbish()
#+end_example"
    (should (progn (org-export-execute-babel-code) t))))


(provide 'test-ob-lob)

;;; test-ob-lob.el ends here

debug log:

solving db3b7c8 ...
found db3b7c8 in https://git.savannah.gnu.org/cgit/emacs/org-mode.git

(*) Git path names are given by the tree(s) the blob belongs to.
    Blobs themselves have no identifier aside from the hash of its contents.^

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).