0
0
Fork 1
mirror of https://git.savannah.gnu.org/git/emacs/org-mode.git synced 2024-09-06 13:42:53 +00:00
org-mode/testing/lisp/test-ob.el
Eric Schulte 9ba9ef99a6 babel: now allows multi-line header arguments with #+headers: before code block
for example, from the test of this functionality
* multi-line header arguments
  :PROPERTIES:
  :ID:       b77c8857-6c76-4ea9-8a61-ddc2648d96c4
  :END:

  (map 'list #'list numbers letters)

| 1 | a |
| 2 | b |
| 3 | c |
| 4 | d |
| 5 | e |
| 6 | f |
| 7 | g |

* lisp/ob.el (org-babel-multi-line-header-regexp): new variable for
  matching header lines preceding code blocks

  (org-babel-src-name-w-name-regexp): now includes possible header
  lines between source name and code block

  (org-babel-get-src-block-info): now also collecting header arguments
  from preceding header lines

  (org-babel-src-block-names): updated match-string to reflect new
  value of org-babel-src-name-w-name-regexp

  (org-babel-merge-params): fixed error in variable string regexp
2010-10-21 13:05:59 +01:00

69 lines
2.4 KiB
EmacsLisp
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

;;; test-ob.el --- tests for ob.el
;; Copyright (c) 2010 Eric Schulte
;; Authors: Eric Schulte
;; Released under the GNU General Public License version 3
;; see: http://www.gnu.org/licenses/gpl-3.0.html
;;;; Comments:
;; Template test file for Org-mode tests
;;; Code:
(let ((load-path (cons (expand-file-name
".." (file-name-directory
(or load-file-name buffer-file-name)))
load-path)))
(require 'org-test)
(require 'org-test-ob-consts))
;;; ob-get-src-block-info
(ert-deftest test-org-babel/get-src-block-info-language ()
(org-test-at-marker nil org-test-file-ob-anchor
(let ((info (org-babel-get-src-block-info)))
(should (string= "emacs-lisp" (nth 0 info))))))
(ert-deftest test-org-babel/get-src-block-info-body ()
(org-test-at-marker nil org-test-file-ob-anchor
(let ((info (org-babel-get-src-block-info)))
(should (string-match (regexp-quote org-test-file-ob-anchor)
(nth 1 info))))))
(ert-deftest test-org-babel/get-src-block-info-tangle ()
(org-test-at-marker nil org-test-file-ob-anchor
(let ((info (org-babel-get-src-block-info)))
(should (string= "no" (cdr (assoc :tangle (nth 2 info))))))))
(ert-deftest test-org-babel/elisp-in-header-arguments ()
"Test execution of elisp forms in header arguments."
;; at the babel.org:elisp-forms-in-header-arguments header
(org-test-at-id "22d67284-bf14-4cdc-8319-f4bd876829d7"
(org-babel-next-src-block)
(let ((info (org-babel-get-src-block-info)))
(should (= 4 (org-babel-execute-src-block))))))
(ert-deftest test-org-babel/simple-named-code-block ()
"Test that simple named code blocks can be evaluated."
(org-test-at-id "0d82b52d-1bb9-4916-816b-2c67c8108dbb"
(org-babel-next-src-block 1)
(should (= 42 (org-babel-execute-src-block)))))
(ert-deftest test-org-babel/simple-variable-resolution ()
"Test that simple variable resolution is working."
(org-test-at-id "f68821bc-7f49-4389-85b5-914791ee3718"
(org-babel-next-src-block 2)
(should (= 4 (org-babel-execute-src-block)))))
(ert-deftest test-org-babel/multi-line-header-arguments ()
"Test that multi-line header arguments and can be read."
(org-test-at-id "b77c8857-6c76-4ea9-8a61-ddc2648d96c4"
(org-babel-next-src-block)
(let ((results (org-babel-execute-src-block)))
(should (equal 'a (cadr (assoc 1 results))))
(should (equal 'd (cadr (assoc 4 results)))))))
(provide 'test-ob)
;;; test-ob ends here