summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAchim Gratz <Stromeko@Stromeko.DE>2013-06-23 19:20:36 +0200
committerAchim Gratz <Stromeko@Stromeko.DE>2013-06-23 19:35:15 +0200
commit36d9a7a4e376c3add4f7c5bd70ba39fab7dbb1c5 (patch)
tree1b1f43c288d68f1ebd93b3f1988e1aa192643242
parent8cbbbe16a516ee4e9614f30972b6f6c7c14126a6 (diff)
downloadorg-mode-36d9a7a4e376c3add4f7c5bd70ba39fab7dbb1c5.tar.gz
testing: provide tests for header-args[:lang] properties
-rw-r--r--testing/examples/ob-header-arg-defaults.org126
-rw-r--r--testing/lisp/test-ob-header-arg-defaults.el77
2 files changed, 203 insertions, 0 deletions
diff --git a/testing/examples/ob-header-arg-defaults.org b/testing/examples/ob-header-arg-defaults.org
new file mode 100644
index 0000000..997152e
--- /dev/null
+++ b/testing/examples/ob-header-arg-defaults.org
@@ -0,0 +1,126 @@
+#+TITLE: Tests for default header arguments to Babel source blocks
+#+OPTIONS: ^:nil
+#+PROPERTY: var t1="go1" t3="go3_clobbered"
+#+PROPERTY: var+ t2="go2" t3="go3"
+#+PROPERTY: header-args :var t1="gh1" t2="gh2_clobbered"
+#+PROPERTY: header-args+ :var t4="gh4" t2="gh2" :var end=9
+#+PROPERTY: header-args:emacs-lisp :var t1="ge1" t4="ge4_clobbered"
+#+PROPERTY: header-args:emacs-lisp+ :var t4="ge4" :var t5="ge5"
+#+PROPERTY: header-args:emacs-lisp+ :results silent :noweb yes
+
+#+NAME: showvar
+#+BEGIN_SRC emacs-lisp :execute no
+ (mapconcat (lambda (n)
+ (let* ((n (string (+ 48 n)))
+ (p (intern (concat "t" n))))
+ (if (boundp p) (eval p) (concat "--" n))))
+ (number-sequence 1 end)
+ "/")
+#+END_SRC
+
+* Global property
+ :PROPERTIES:
+ :ID: 3fdadb69-5d15-411e-aad0-f7860cdd7816
+ :END:
+
+| Global | t1 | t2 | t3 | t4 | t5 | t6 | t7 | t8 | t9 |
+|------------------------+-----+-----+-----+-----+-----+-----+-----+-----+-----|
+| var property | go1 | go2 | go3 | --- | --- | --- | --- | --- | --- |
+| header-args | gh1 | gh2 | --- | gh4 | --- | --- | --- | --- | --- |
+| header-args:emacs-lisp | ge1 | --- | --- | ge4 | ge5 | --- | --- | --- | --- |
+|------------------------+-----+-----+-----+-----+-----+-----+-----+-----+-----|
+| Result | ge1 | gh2 | go3 | ge4 | ge5 | --6 | --7 | --8 | --9 |
+
+#+CALL: showvar() :results silent
+#+BEGIN_SRC emacs-lisp :var end=7
+<<showvar>>
+#+END_SRC
+
+* Tree property
+** Overwrite
+ :PROPERTIES:
+ :ID: a9cdfeda-9f31-4bb5-b694-2cf452f07dfd
+ :var: t6="to6"
+ :header-args: :var t7="th7"
+ :header-args:emacs-lisp: :var t8="te8"
+ :header-args:emacs-lisp+: :results silent :noweb yes :var end=9
+ :END:
+
+| Global | t1 | t2 | t3 | t4 | t5 | t6 | t7 | t8 | t9 |
+|------------------------+-----+-----+-----+-----+-----+-----+-----+-----+-----|
+| var property | go1 | go2 | go3 | --- | --- | --- | --- | --- | --- |
+| header-args | gh1 | gh2 | --- | gh4 | --- | --- | --- | --- | --- |
+| header-args:emacs-lisp | ge1 | --- | --- | ge4 | ge5 | --- | --- | --- | --- |
+|------------------------+-----+-----+-----+-----+-----+-----+-----+-----+-----|
+| Tree | t1 | t2 | t3 | t4 | t5 | t6 | t7 | t8 | t9 |
+|------------------------+-----+-----+-----+-----+-----+-----+-----+-----+-----|
+| var property | --- | --- | --- | --- | --- | to6 | --- | --- | --- |
+| header-args | --- | --- | --- | --- | --- | --- | th7 | --- | --- |
+| header-args:emacs-lisp | --- | --- | --- | --- | --- | --- | --- | te8 | --- |
+|------------------------+-----+-----+-----+-----+-----+-----+-----+-----+-----|
+| Result #+CALL | go1 | go2 | go3 | --4 | --5 | --- | th7 | te8 | --9 |
+| Result noweb | --1 | --2 | --3 | --4 | --5 | to6 | th7 | te8 | --9 |
+
+#+CALL: showvar() :results silent
+#+BEGIN_SRC emacs-lisp
+<<showvar>>
+#+END_SRC
+
+** Accumulate
+ :PROPERTIES:
+ :ID: 1d97d258-fd50-4107-a095-e4625bffc57b
+ :var+: t1="to1"
+ :var+: t6="to6"
+ :header-args+: :var t2="th2" t3="th3"
+ :header-args:emacs-lisp+: :var t5="te5" end=8
+ :END:
+
+| Global | t1 | t2 | t3 | t4 | t5 | t6 | t7 | t8 | t9 |
+|-------------------------+-----+-----+-----+-----+-----+-----+-----+-----+-----|
+| var property | go1 | go2 | go3 | --- | --- | --- | --- | --- | --- |
+| header-args | gh1 | gh2 | --- | gh4 | --- | --- | --- | --- | --- |
+| header-args:emacs-lisp | ge1 | --- | --- | ge4 | ge5 | --- | --- | --- | --- |
+|-------------------------+-----+-----+-----+-----+-----+-----+-----+-----+-----|
+| Tree | t1 | t2 | t3 | t4 | t5 | t6 | t7 | t8 | t9 |
+|-------------------------+-----+-----+-----+-----+-----+-----+-----+-----+-----|
+| var+ property | to1 | --- | --- | --- | --- | to6 | --- | --- | --- |
+| header-args+ | --- | th2 | th3 | --- | --- | --- | --- | --- | --- |
+| header-args:emacs-lisp+ | --- | --- | --- | --- | te5 | --- | --- | --- | --- |
+|-------------------------+-----+-----+-----+-----+-----+-----+-----+-----+-----|
+| Result #+CALL | ge1 | th2 | th3 | ge4 | te5 | --6 | --7 | --8 | --9 |
+| Result noweb | ge1 | th2 | th3 | ge4 | te5 | to6 | --7 | --8 | --9 |
+
+#+CALL: showvar(end=6) :results silent
+#+BEGIN_SRC emacs-lisp
+<<showvar>>
+#+END_SRC
+
+** Complex
+ :PROPERTIES:
+ :ID: fa0e912d-d9b4-47b0-9f9e-1cbb39f7cbc2
+ :var: t1="to1"
+ :var+: t6="to6"
+ :header-args+: :var t2="th2"
+ :header-args:emacs-lisp: :var t5="te5" end=7
+ :header-args:emacs-lisp+: :results silent :noweb yes :var end=9
+ :END:
+
+| Global | t1 | t2 | t3 | t4 | t5 | t6 | t7 | t8 | t9 |
+|------------------------+-----+-----+-----+-----+-----+-----+-----+-----+-----|
+| var property | go1 | go2 | go3 | --- | --- | --- | --- | --- | --- |
+| header-args | gh1 | gh2 | --- | gh4 | --- | --- | --- | --- | --- |
+| header-args:emacs-lisp | ge1 | --- | --- | ge4 | ge5 | --- | --- | --- | --- |
+|------------------------+-----+-----+-----+-----+-----+-----+-----+-----+-----|
+| Tree | t1 | t2 | t3 | t4 | t5 | t6 | t7 | t8 | t9 |
+|------------------------+-----+-----+-----+-----+-----+-----+-----+-----+-----|
+| var property | to1 | --- | --- | --- | --- | to6 | --- | --- | --- |
+| header-args+ | --- | th2 | --- | --- | --- | --- | --- | --- | --- |
+| header-args:emacs-lisp | --- | --- | --- | --- | te5 | --- | --- | --- | --- |
+|------------------------+-----+-----+-----+-----+-----+-----+-----+-----+-----|
+| Result #+CALL | gh1 | th2 | go3 | gh4 | te5 | --6 | --7 | --8 | --9 |
+| Result noweb | gh1 | th2 | --3 | gh4 | te5 | to6 | --7 | --8 | --9 |
+
+#+CALL: showvar(end=6) :results silent
+#+BEGIN_SRC emacs-lisp
+<<showvar>>
+#+END_SRC
diff --git a/testing/lisp/test-ob-header-arg-defaults.el b/testing/lisp/test-ob-header-arg-defaults.el
new file mode 100644
index 0000000..d4a51dd
--- /dev/null
+++ b/testing/lisp/test-ob-header-arg-defaults.el
@@ -0,0 +1,77 @@
+;;; test-ob-header-arg-defaults.el --- tests for default header args from properties
+
+;; Copyright (c) 2013 Achim Gratz
+;; Authors: Achim Gratz
+
+;; 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/>.
+
+;;; Code:
+
+(ert-deftest test-ob-header-arg-defaults/global/call ()
+ (org-test-at-id "3fdadb69-5d15-411e-aad0-f7860cdd7816"
+ (org-babel-next-src-block 1)
+ (forward-line -1)
+ (should (equal "ge1/gh2/go3/ge4/ge5/--6/--7/--8/--9"
+ (org-babel-lob-execute (org-babel-lob-get-info))))))
+
+(ert-deftest test-ob-header-arg-defaults/global/noweb ()
+ (org-test-at-id "3fdadb69-5d15-411e-aad0-f7860cdd7816"
+ (org-babel-next-src-block 1)
+ (should (equal "ge1/gh2/go3/ge4/ge5/--6/--7"
+ (org-babel-execute-src-block)))))
+
+(ert-deftest test-ob-header-arg-defaults/tree/overwrite/call ()
+ (org-test-at-id "a9cdfeda-9f31-4bb5-b694-2cf452f07dfd"
+ (org-babel-next-src-block 1)
+ (forward-line -1)
+ (should (equal "go1/go2/go3/--4/--5/--6/th7/te8/--9"
+ (org-babel-lob-execute (org-babel-lob-get-info))))))
+
+(ert-deftest test-ob-header-arg-defaults/tree/overwrite/noweb ()
+ (org-test-at-id "a9cdfeda-9f31-4bb5-b694-2cf452f07dfd"
+ (org-babel-next-src-block 1)
+ (should (equal "--1/--2/--3/--4/--5/to6/th7/te8/--9"
+ (org-babel-execute-src-block)))))
+
+(ert-deftest test-ob-header-arg-defaults/tree/accumulate/call ()
+ (org-test-at-id "1d97d258-fd50-4107-a095-e4625bffc57b"
+ (org-babel-next-src-block 1)
+ (forward-line -1)
+ (should (equal "ge1/th2/th3/ge4/te5/--6"
+ (org-babel-lob-execute (org-babel-lob-get-info))))))
+
+(ert-deftest test-ob-header-arg-defaults/tree/accumulate/noweb ()
+ (org-test-at-id "1d97d258-fd50-4107-a095-e4625bffc57b"
+ (org-babel-next-src-block 1)
+ (should (equal "ge1/th2/th3/ge4/te5/to6/--7/--8"
+ (org-babel-execute-src-block)))))
+
+(ert-deftest test-ob-header-arg-defaults/tree/complex/call ()
+ (org-test-at-id "fa0e912d-d9b4-47b0-9f9e-1cbb39f7cbc2"
+ (org-babel-next-src-block 1)
+ (forward-line -1)
+ (should (equal "gh1/th2/go3/gh4/te5/--6"
+ (org-babel-lob-execute (org-babel-lob-get-info))))))
+
+(ert-deftest test-ob-header-arg-defaults/tree/complex/noweb ()
+ (org-test-at-id "fa0e912d-d9b4-47b0-9f9e-1cbb39f7cbc2"
+ (org-babel-next-src-block 1)
+ (should (equal "gh1/th2/--3/gh4/te5/to6/--7/--8/--9"
+ (org-babel-execute-src-block)))))
+
+(provide 'test-ob-header-arg-defaults)
+
+;;; test-ob-header-arg-defaults.el ends here