summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCharles Berry <ccberry@ucsd.edu>2015-01-31 11:05:18 -0800
committerCharles Berry <ccberry@ucsd.edu>2015-01-31 11:05:18 -0800
commitf9ab1e8ab6b5b6604e838ac992ad51a594ed7130 (patch)
treed1c9ce015b5b9752bbd13554f6489fac9c6a54b6
parenta752684bf0368ddea1f6480157e770c0dd57b7a5 (diff)
downloadorg-mode-f9ab1e8ab6b5b6604e838ac992ad51a594ed7130.tar.gz
testing/lisp/test-ob.el: Add `test-ob/remove-inline-result'
* testing/lisp/test-ob.el (test-ob/remove-inline-result): Check that whitespace in `src_emacs-lisp{1} {{{results(=1=)}}}.' is removed by `org-babel-remove-inline-result', and that whitespace following the macro (if any) is left intact.
-rw-r--r--testing/lisp/test-ob.el41
1 files changed, 41 insertions, 0 deletions
diff --git a/testing/lisp/test-ob.el b/testing/lisp/test-ob.el
index 3051990..c5b5756 100644
--- a/testing/lisp/test-ob.el
+++ b/testing/lisp/test-ob.el
@@ -758,6 +758,47 @@ on two lines
": 2"
(buffer-substring-no-properties (point-at-bol) (point-at-eol))))))
+(ert-deftest test-ob/remove-inline-result ()
+ "Test `org-babel-remove-inline-result' honors whitespace."
+ (let*
+ ((inline-sb "src_emacs-lisp{(+ 1 2)}")
+ (inline-res " {{{results(=3=)}}}")
+ (inline-sb-dot (concat inline-sb "."))
+ (inline-sb-res-dot (concat inline-sb inline-res ".")))
+ (org-test-with-temp-text
+ ;; Insert inline_src_block followed by dot.
+ inline-sb-dot
+ ;; Insert result before dot.
+ (org-babel-execute-maybe)
+ (should (string= inline-sb-res-dot
+ (buffer-substring-no-properties
+ (point-at-bol) (point-at-eol))))
+ ;; Delete whitespace and result.
+ (org-babel-remove-inline-result)
+ (should (string= inline-sb-dot
+ (buffer-substring-no-properties
+ (point-at-bol) (point-at-eol))))
+ ;; Add whitespace and result before dot.
+ (search-forward inline-sb)
+ (insert " " inline-res)
+ (goto-char (point-at-bol))
+ ;; Remove whitespace and result.
+ (org-babel-remove-inline-result)
+ (should (string= inline-sb-dot
+ (buffer-substring-no-properties
+ (point-at-bol) (point-at-eol))))
+ ;; Add whitespace before dot.
+ (search-forward inline-sb)
+ (insert " ")
+ (goto-char (point-at-bol))
+ ;; Add result before whitespace.
+ (org-babel-execute-maybe)
+ ;; Remove result - leave trailing whitespace and dot.
+ (org-babel-remove-inline-result)
+ (should (string= (concat inline-sb " .")
+ (buffer-substring-no-properties
+ (point-at-bol) (point-at-eol)))))))
+
(defun test-ob-verify-result-and-removed-result (result buffer-text)
"Test helper function to test `org-babel-remove-result'.
A temp buffer is populated with BUFFER-TEXT, the first block is executed,