From b18e0cb1171c2fe68434f6afd772d7ad57c42b1d Mon Sep 17 00:00:00 2001 From: Eric Schulte Date: Tue, 28 Jun 2011 13:02:16 -0700 Subject: [PATCH] test: tests for expanding noweb references --- testing/examples/babel.org | 26 ++++++++++++++++++++++++++ testing/lisp/test-ob-tangle.el | 8 ++++++++ testing/lisp/test-ob.el | 7 +++++++ 3 files changed, 41 insertions(+) diff --git a/testing/examples/babel.org b/testing/examples/babel.org index cc73abc7f..f36dc3169 100644 --- a/testing/examples/babel.org +++ b/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 + <> + <> +#+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 diff --git a/testing/lisp/test-ob-tangle.el b/testing/lisp/test-ob-tangle.el index 74735931e..78737a032 100644 --- a/testing/lisp/test-ob-tangle.el +++ b/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 diff --git a/testing/lisp/test-ob.el b/testing/lisp/test-ob.el index b2f1b7d42..078b985b4 100644 --- a/testing/lisp/test-ob.el +++ b/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 -- 2.11.4.GIT