Browse Source

test for customizable code block export

Eric Schulte 13 years ago
parent
commit
4ce9b8044c
3 changed files with 37 additions and 3 deletions
  1. 10 0
      testing/examples/babel.org
  2. 23 1
      testing/lisp/test-ob-exp.el
  3. 4 2
      testing/lisp/test-ob.el

+ 10 - 0
testing/examples/babel.org

@@ -278,3 +278,13 @@ src_sh{echo "One"} block at start of line
  One spaced block in  src_sh{ echo "middle" } of line
 src_sh{echo 2} blocks on the src_emacs-lisp{"same"} line
  Inline block with src_sh[:results silent]{ echo "parameters" }.
+* exporting a code block with a name
+  :PROPERTIES:
+  :ID:       b02ddd8a-eeb8-42ab-8664-8a759e6f43d9
+  :END:
+
+exporting a code block with a name
+#+name: qux
+#+begin_src sh :foo "baz"
+  echo bar
+#+end_src

+ 23 - 1
testing/lisp/test-ob-exp.el

@@ -194,7 +194,29 @@ elements in the final html."
 		  "<pre class=\"example\">"
 		  "code block results"
 		  "</pre>"))))))
-      
+
+(ert-deftest ob-exp/export-with-name ()
+  (let ((org-babel-exp-code-template
+	 "=%name=\n#+BEGIN_SRC %lang%flags\nbody\n#+END_SRC"))
+    (org-test-at-id "b02ddd8a-eeb8-42ab-8664-8a759e6f43d9"
+      (org-narrow-to-subtree)
+      (let ((ascii (org-export-as-ascii nil nil nil 'string 'body-only)))
+	(should (string-match "qux" ascii))))))
+
+(ert-deftest ob-exp/export-with-header-argument ()
+  (let ((org-babel-exp-code-template
+	 "
+| header  | value    |
+|---------+----------|
+| foo     | %foo     |
+| results | %results |
+#+BEGIN_SRC %lang%flags\nbody\n#+END_SRC"))
+    (org-test-at-id "b02ddd8a-eeb8-42ab-8664-8a759e6f43d9"
+      (org-narrow-to-subtree)
+      (let ((ascii (org-export-as-ascii nil nil nil 'string 'body-only)))
+	(should (string-match "baz" ascii))
+	(should (string-match "replace" ascii))))))
+
 (provide 'test-ob-exp)
 
 ;;; test-ob-exp.el ends here

+ 4 - 2
testing/lisp/test-ob.el

@@ -628,7 +628,7 @@ on two lines
       (check-eval "never-export" nil)
       (check-eval "no-export" nil))))
 
-(ert-deftest test-ob/noweb-expansion ()
+(ert-deftest test-ob/noweb-expansion-1 ()
   (org-test-with-temp-text "#+begin_src sh :results output :tangle yes
   <<foo>>
 #+end_src
@@ -637,7 +637,9 @@ on two lines
 #+begin_src sh
   bar
 #+end_src"
-    (should (string= (org-babel-expand-noweb-references) "bar")))
+    (should (string= (org-babel-expand-noweb-references) "bar"))))
+
+(ert-deftest test-ob/noweb-expansion-2 ()
   (org-test-with-temp-text "#+begin_src sh :results output :tangle yes
   <<foo>>
 #+end_src