Ver Fonte

test: tests for expanding noweb references

Eric Schulte há 13 anos atrás
pai
commit
b18e0cb117
3 ficheiros alterados com 41 adições e 0 exclusões
  1. 26 0
      testing/examples/babel.org
  2. 8 0
      testing/lisp/test-ob-tangle.el
  3. 7 0
      testing/lisp/test-ob.el

+ 26 - 0
testing/examples/babel.org

@@ -244,3 +244,29 @@ an = sign.
 #+begin_src sh :noweb-ref fullest-disk
   |awk '{print $2}'
 #+end_src
+* resolving sub-trees as references
+  :PROPERTIES:
+  :ID:       2409e8ba-7b5f-4678-8888-e48aa02d8cb4
+  :results:  silent
+  :END:
+
+#+begin_src emacs-lisp :var text=d4faa7b3-072b-4dcf-813c-dd7141c633f3
+  (length text)
+#+end_src
+
+#+begin_src org :noweb yes
+  <<simple-subtree>>
+  <<d4faa7b3-072b-4dcf-813c-dd7141c633f3>>
+#+end_src
+
+** simple subtree with custom ID
+   :PROPERTIES:
+   :CUSTOM_ID: simple-subtree
+   :END:
+this is simple
+
+** simple subtree with global ID
+   :PROPERTIES:
+   :ID:       d4faa7b3-072b-4dcf-813c-dd7141c633f3
+   :END:
+has length 14

+ 8 - 0
testing/lisp/test-ob-tangle.el

@@ -69,6 +69,14 @@
 	(should (re-search-forward (regexp-quote tangled) nil t)))
       (delete-file "babel.sh"))))
 
+(ert-deftest ob-tangle/expand-headers-as-noweb-references ()
+  "Test that references to headers are expanded during noweb expansion."
+  (org-test-at-id "2409e8ba-7b5f-4678-8888-e48aa02d8cb4"
+    (org-babel-next-src-block 2)
+    (let ((expanded (org-babel-expand-noweb-references)))
+      (should (string-match (regexp-quote "simple") expanded))
+      (should (string-match (regexp-quote "length 14") expanded)))))
+
 (provide 'test-ob-tangle)
 
 ;;; test-ob-tangle.el ends here

+ 7 - 0
testing/lisp/test-ob.el

@@ -206,6 +206,13 @@
       (should(equal '(:result-type . output) (assoc :result-type params)))
       (should(equal '(num . 9) (cdr (assoc :var params)))))))
 
+(ert-deftest test-org-babel/parse-header-args ()
+  (org-test-at-id "2409e8ba-7b5f-4678-8888-e48aa02d8cb4"
+    (should (string-match (regexp-quote "this is simple")
+			  (org-babel-ref-resolve "simple-subtree")))
+    (org-babel-next-src-block)
+    (should (= 14 (org-babel-execute-src-block)))))
+
 (provide 'test-ob)
 
 ;;; test-ob ends here