From 660e30b39c021ab7d1003d79f2e0debe1cba450c Mon Sep 17 00:00:00 2001 From: Eric Schulte Date: Mon, 30 Jan 2012 08:51:17 -0700 Subject: [PATCH] inline src block tests by Martyn Jago * testing/lisp/test-ob.el (test-org-babel/inline-src_blk-preceded-punct): Inline src block tests by Martyn Jago. --- testing/lisp/test-ob.el | 69 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) diff --git a/testing/lisp/test-ob.el b/testing/lisp/test-ob.el index c819facf2..e7e1eea8a 100644 --- a/testing/lisp/test-ob.el +++ b/testing/lisp/test-ob.el @@ -588,6 +588,75 @@ on two lines (org-babel-balanced-split ":a 1 :b [2 3] :c (4 :d (5 6))" '((32 9) . 58))))) +(ert-deftest test-org-babel/inline-src_blk-preceded-punct () + "Test inline source block where preceded by punctuation" + + ;; inline-src-blk preceded by point + (let ((test-line ".src_emacs-lisp[ :results verbatim ]{ \"x\" }")) + (org-test-with-temp-text + test-line + (forward-char 1) + (org-ctrl-c-ctrl-c) + (should (string= (concat test-line " =\"x\"=") + (buffer-substring-no-properties + (point-min) (point-max)))))) + + ;; inline-src-blk preceded by equality + (let ((test-line "=src_emacs-lisp[ :results verbatim ]{ \"x\" }")) + (org-test-with-temp-text + test-line + (forward-char 1) + (org-ctrl-c-ctrl-c) + (should (string= (concat test-line " =\"x\"=") + (buffer-substring-no-properties + (point-min) (point-max)))))) + + ;; inline-src-blk enclosed within parenthesis + (let ((test-line "(src_emacs-lisp[ :results verbatim ]{ \"x\" }")) + (org-test-with-temp-text + (concat test-line ")") + (forward-char 1) + (org-ctrl-c-ctrl-c) + (should (string= (concat test-line " =\"x\"=)" ) + (buffer-substring-no-properties + (point-min) (point-max)))))) + + ;; inline-src-blk enclosed within parenthesis + (let ((test-line "{src_emacs-lisp[ :results verbatim ]{ \"x\" }")) + (org-test-with-temp-text + (concat test-line "}") + (forward-char 1) + (org-ctrl-c-ctrl-c) + (should (string= (concat test-line " =\"x\"=}") + (buffer-substring-no-properties + (point-min) (point-max))))))) + +(ert-deftest test-org-babel/inline-src_blk-preceded-by-letter () + "Test inline source block invalid where preceded by letter" + + ;; inline-src-blk preceded by letter + (org-test-with-temp-text + "asrc_emacs-lisp[ :results verbatim ]{ \"x\" }" + (forward-char 1) + (let ((error-result + (should-error + (org-ctrl-c-ctrl-c)))) + (should (equal `(error "C-c C-c can do nothing useful at this location") + error-result))))) + +(ert-deftest test-org-babel/inline-src_blk-preceded-by-number () + "Test inline source block invalid where preceded by number" + + ;; inline-src-blk preceded by number + (org-test-with-temp-text + "0src_emacs-lisp[ :results verbatim ]{ \"x\" }" + (forward-char 1) + (let ((error-result + (should-error + (org-ctrl-c-ctrl-c)))) + (should (equal `(error "C-c C-c can do nothing useful at this location") + error-result))))) + (provide 'test-ob) ;;; test-ob ends here