|
@@ -148,12 +148,10 @@
|
|
#+begin_src emacs-lisp
|
|
#+begin_src emacs-lisp
|
|
prop
|
|
prop
|
|
#+end_src"
|
|
#+end_src"
|
|
-
|
|
|
|
- (progn
|
|
|
|
- (goto-char (point-min))
|
|
|
|
- (org-babel-next-src-block)
|
|
|
|
- (let ((info (org-babel-get-src-block-info)))
|
|
|
|
- (should (= 42 (org-babel-execute-src-block)))))))
|
|
|
|
|
|
+ (goto-char (point-min))
|
|
|
|
+ (org-babel-next-src-block)
|
|
|
|
+ (let ((info (org-babel-get-src-block-info)))
|
|
|
|
+ (should (= 42 (org-babel-execute-src-block))))))
|
|
|
|
|
|
(ert-deftest test-org-babel/simple-named-code-block ()
|
|
(ert-deftest test-org-babel/simple-named-code-block ()
|
|
"Test that simple named code blocks can be evaluated."
|
|
"Test that simple named code blocks can be evaluated."
|
|
@@ -163,10 +161,8 @@
|
|
#+begin_src emacs-lisp
|
|
#+begin_src emacs-lisp
|
|
42
|
|
42
|
|
#+end_src"
|
|
#+end_src"
|
|
-
|
|
|
|
- (progn
|
|
|
|
- (org-babel-next-src-block 1)
|
|
|
|
- (should (= 42 (org-babel-execute-src-block))))))
|
|
|
|
|
|
+ (org-babel-next-src-block 1)
|
|
|
|
+ (should (= 42 (org-babel-execute-src-block)))))
|
|
|
|
|
|
(ert-deftest test-org-babel/simple-variable-resolution ()
|
|
(ert-deftest test-org-babel/simple-variable-resolution ()
|
|
"Test that simple variable resolution is working."
|
|
"Test that simple variable resolution is working."
|
|
@@ -181,13 +177,12 @@
|
|
(length four)
|
|
(length four)
|
|
#+end_src"
|
|
#+end_src"
|
|
|
|
|
|
- (progn
|
|
|
|
- (org-babel-next-src-block 2)
|
|
|
|
- (should (= 4 (org-babel-execute-src-block)))
|
|
|
|
- (forward-line 5)
|
|
|
|
- (should (string= ": 4" (buffer-substring
|
|
|
|
- (point-at-bol)
|
|
|
|
- (point-at-eol)))))))
|
|
|
|
|
|
+ (org-babel-next-src-block 2)
|
|
|
|
+ (should (= 4 (org-babel-execute-src-block)))
|
|
|
|
+ (forward-line 5)
|
|
|
|
+ (should (string= ": 4" (buffer-substring
|
|
|
|
+ (point-at-bol)
|
|
|
|
+ (point-at-eol))))))
|
|
|
|
|
|
(ert-deftest test-org-babel/multi-line-header-arguments ()
|
|
(ert-deftest test-org-babel/multi-line-header-arguments ()
|
|
"Test that multi-line header arguments and can be read."
|
|
"Test that multi-line header arguments and can be read."
|
|
@@ -202,11 +197,10 @@
|
|
(my-map 'list #'list numbers letters)
|
|
(my-map 'list #'list numbers letters)
|
|
#+end_src"
|
|
#+end_src"
|
|
|
|
|
|
- (progn
|
|
|
|
- (org-babel-next-src-block)
|
|
|
|
- (let ((results (org-babel-execute-src-block)))
|
|
|
|
- (should(equal 'a (cadr (assoc 1 results))))
|
|
|
|
- (should(equal 'd (cadr (assoc 4 results))))))))
|
|
|
|
|
|
+ (org-babel-next-src-block)
|
|
|
|
+ (let ((results (org-babel-execute-src-block)))
|
|
|
|
+ (should(equal 'a (cadr (assoc 1 results))))
|
|
|
|
+ (should(equal 'd (cadr (assoc 4 results)))))))
|
|
|
|
|
|
(ert-deftest test-org-babel/parse-header-args ()
|
|
(ert-deftest test-org-babel/parse-header-args ()
|
|
(org-test-with-temp-text-in-file "
|
|
(org-test-with-temp-text-in-file "
|
|
@@ -215,17 +209,16 @@
|
|
the body
|
|
the body
|
|
#+end_src"
|
|
#+end_src"
|
|
|
|
|
|
- (progn
|
|
|
|
- (org-babel-next-src-block)
|
|
|
|
- (let* ((info (org-babel-get-src-block-info))
|
|
|
|
- (params (nth 2 info)))
|
|
|
|
- (message "%S" params)
|
|
|
|
- (should(equal "example-lang" (nth 0 info)))
|
|
|
|
- (should(string= "the body" (org-babel-trim (nth 1 info))))
|
|
|
|
- (should-not (member '(:session\ \ \ \ ) params))
|
|
|
|
- (should(equal '(:session) (assoc :session params)))
|
|
|
|
- (should(equal '(:result-type . output) (assoc :result-type params)))
|
|
|
|
- (should(equal '(num . 9) (cdr (assoc :var params))))))))
|
|
|
|
|
|
+ (org-babel-next-src-block)
|
|
|
|
+ (let* ((info (org-babel-get-src-block-info))
|
|
|
|
+ (params (nth 2 info)))
|
|
|
|
+ (message "%S" params)
|
|
|
|
+ (should (equal "example-lang" (nth 0 info)))
|
|
|
|
+ (should (string= "the body" (org-babel-trim (nth 1 info))))
|
|
|
|
+ (should-not (member '(:session\ \ \ \ ) params))
|
|
|
|
+ (should (equal '(:session) (assoc :session params)))
|
|
|
|
+ (should (equal '(:result-type . output) (assoc :result-type params)))
|
|
|
|
+ (should (equal '(num . 9) (cdr (assoc :var params)))))))
|
|
|
|
|
|
(ert-deftest test-org-babel/parse-header-args2 ()
|
|
(ert-deftest test-org-babel/parse-header-args2 ()
|
|
(org-test-with-temp-text-in-file "
|
|
(org-test-with-temp-text-in-file "
|
|
@@ -247,20 +240,19 @@
|
|
:END:
|
|
:END:
|
|
this is simple"
|
|
this is simple"
|
|
|
|
|
|
- (progn
|
|
|
|
- (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))))))
|
|
|
|
|
|
+ (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)))))
|
|
|
|
|
|
(ert-deftest test-org-babel/inline-src-blocks ()
|
|
(ert-deftest test-org-babel/inline-src-blocks ()
|
|
(org-test-at-id "54cb8dc3-298c-4883-a933-029b3c9d4b18"
|
|
(org-test-at-id "54cb8dc3-298c-4883-a933-029b3c9d4b18"
|
|
(macrolet ((at-next (&rest body)
|
|
(macrolet ((at-next (&rest body)
|
|
- `(progn
|
|
|
|
- (move-end-of-line 1)
|
|
|
|
- (re-search-forward org-babel-inline-src-block-regexp nil t)
|
|
|
|
- (goto-char (match-beginning 1))
|
|
|
|
- (save-match-data ,@body))))
|
|
|
|
|
|
+ `(progn
|
|
|
|
+ (move-end-of-line 1)
|
|
|
|
+ (re-search-forward org-babel-inline-src-block-regexp nil t)
|
|
|
|
+ (goto-char (match-beginning 1))
|
|
|
|
+ (save-match-data ,@body))))
|
|
(at-next (should (equal 1 (org-babel-execute-src-block))))
|
|
(at-next (should (equal 1 (org-babel-execute-src-block))))
|
|
(at-next (should (equal 2 (org-babel-execute-src-block))))
|
|
(at-next (should (equal 2 (org-babel-execute-src-block))))
|
|
(at-next (should (equal 3 (org-babel-execute-src-block)))))))
|
|
(at-next (should (equal 3 (org-babel-execute-src-block)))))))
|
|
@@ -309,19 +301,19 @@ this is simple"
|
|
(buffer-substring-no-properties (point-at-bol) (point-at-eol)))))
|
|
(buffer-substring-no-properties (point-at-bol) (point-at-eol)))))
|
|
;; src_ follows space line 1...
|
|
;; src_ follows space line 1...
|
|
(let ((test-line " src_emacs-lisp{ 1 }"))
|
|
(let ((test-line " src_emacs-lisp{ 1 }"))
|
|
- (org-test-with-temp-text
|
|
|
|
- test-line
|
|
|
|
- (should-error (org-ctrl-c-ctrl-c))
|
|
|
|
- (forward-char) (org-ctrl-c-ctrl-c)
|
|
|
|
- (should (string=
|
|
|
|
- (concat test-line " =1=")
|
|
|
|
- (buffer-substring-no-properties (point-at-bol) (point-at-eol))))
|
|
|
|
- (re-search-forward "{ 1 ") (org-ctrl-c-ctrl-c)
|
|
|
|
- (should (string=
|
|
|
|
- (concat test-line " =1= =1=")
|
|
|
|
- (buffer-substring-no-properties (point-at-bol) (point-at-eol))))
|
|
|
|
- (forward-char)
|
|
|
|
- (should-error (org-ctrl-c-ctrl-c)))))
|
|
|
|
|
|
+ (org-test-with-temp-text
|
|
|
|
+ test-line
|
|
|
|
+ (should-error (org-ctrl-c-ctrl-c))
|
|
|
|
+ (forward-char) (org-ctrl-c-ctrl-c)
|
|
|
|
+ (should (string=
|
|
|
|
+ (concat test-line " =1=")
|
|
|
|
+ (buffer-substring-no-properties (point-at-bol) (point-at-eol))))
|
|
|
|
+ (re-search-forward "{ 1 ") (org-ctrl-c-ctrl-c)
|
|
|
|
+ (should (string=
|
|
|
|
+ (concat test-line " =1= =1=")
|
|
|
|
+ (buffer-substring-no-properties (point-at-bol) (point-at-eol))))
|
|
|
|
+ (forward-char)
|
|
|
|
+ (should-error (org-ctrl-c-ctrl-c))))))
|
|
|
|
|
|
(ert-deftest test-org-babel/inline-src_blk-default-results-replace-line-2 ()
|
|
(ert-deftest test-org-babel/inline-src_blk-default-results-replace-line-2 ()
|
|
;; src_ at bol line 2...
|
|
;; src_ at bol line 2...
|
|
@@ -346,14 +338,14 @@ this is simple"
|
|
(insert (concat "\n" test-line " end"))
|
|
(insert (concat "\n" test-line " end"))
|
|
(re-search-backward "src") (org-ctrl-c-ctrl-c)
|
|
(re-search-backward "src") (org-ctrl-c-ctrl-c)
|
|
(should (string=
|
|
(should (string=
|
|
- (concat test-line " =y= end")
|
|
|
|
- (buffer-substring-no-properties (point-at-bol) (point-at-eol))))
|
|
|
|
|
|
+ (concat test-line " =y= end")
|
|
|
|
+ (buffer-substring-no-properties (point-at-bol) (point-at-eol))))
|
|
(re-search-forward "\" ") (org-ctrl-c-ctrl-c)
|
|
(re-search-forward "\" ") (org-ctrl-c-ctrl-c)
|
|
(should (string=
|
|
(should (string=
|
|
(concat test-line " =y= =y= end")
|
|
(concat test-line " =y= =y= end")
|
|
- (buffer-substring-no-properties (point-at-bol) (point-at-eol))))
|
|
|
|
|
|
+ (buffer-substring-no-properties (point-at-bol) (point-at-eol))))
|
|
(forward-char)
|
|
(forward-char)
|
|
- (should-error (org-ctrl-c-ctrl-c))))))
|
|
|
|
|
|
+ (should-error (org-ctrl-c-ctrl-c)))))
|
|
|
|
|
|
(ert-deftest test-org-babel/inline-src_blk-manual-results-replace ()
|
|
(ert-deftest test-org-babel/inline-src_blk-manual-results-replace ()
|
|
(let ((test-line " src_emacs-lisp[:results replace]{ \"x\" }"))
|
|
(let ((test-line " src_emacs-lisp[:results replace]{ \"x\" }"))
|
|
@@ -637,15 +629,15 @@ on two lines
|
|
|
|
|
|
(ert-deftest test-ob/eval-header-argument ()
|
|
(ert-deftest test-ob/eval-header-argument ()
|
|
(flet ((check-eval (eval runp)
|
|
(flet ((check-eval (eval runp)
|
|
- (org-test-with-temp-text (format "#+begin_src emacs-lisp :eval %s
|
|
|
|
|
|
+ (org-test-with-temp-text (format "#+begin_src emacs-lisp :eval %s
|
|
(setq foo :evald)
|
|
(setq foo :evald)
|
|
#+end_src" eval)
|
|
#+end_src" eval)
|
|
- (let ((foo :not-run))
|
|
|
|
- (if runp
|
|
|
|
- (progn (should (org-babel-execute-src-block))
|
|
|
|
- (should (eq foo :evald)))
|
|
|
|
- (progn (should-not (org-babel-execute-src-block))
|
|
|
|
- (should-not (eq foo :evald))))))))
|
|
|
|
|
|
+ (let ((foo :not-run))
|
|
|
|
+ (if runp
|
|
|
|
+ (progn (should (org-babel-execute-src-block))
|
|
|
|
+ (should (eq foo :evald)))
|
|
|
|
+ (progn (should-not (org-babel-execute-src-block))
|
|
|
|
+ (should-not (eq foo :evald))))))))
|
|
(check-eval "never" nil)
|
|
(check-eval "never" nil)
|
|
(check-eval "no" nil)
|
|
(check-eval "no" nil)
|
|
(check-eval "never-export" t)
|
|
(check-eval "never-export" t)
|
|
@@ -700,55 +692,50 @@ on two lines
|
|
#+begin_src emacs-lisp
|
|
#+begin_src emacs-lisp
|
|
;;
|
|
;;
|
|
#+end_src"
|
|
#+end_src"
|
|
- (progn
|
|
|
|
- (org-babel-next-src-block)
|
|
|
|
- (org-ctrl-c-ctrl-c)
|
|
|
|
- (should (re-search-forward "\\#\\+results:" nil t))
|
|
|
|
- (forward-line)
|
|
|
|
- (should
|
|
|
|
- (string=
|
|
|
|
- ""
|
|
|
|
- (buffer-substring-no-properties (point-at-bol) (point-at-eol))))))
|
|
|
|
|
|
+ (org-babel-next-src-block)
|
|
|
|
+ (org-ctrl-c-ctrl-c)
|
|
|
|
+ (should (re-search-forward "\\#\\+results:" nil t))
|
|
|
|
+ (forward-line)
|
|
|
|
+ (should
|
|
|
|
+ (string=
|
|
|
|
+ ""
|
|
|
|
+ (buffer-substring-no-properties (point-at-bol) (point-at-eol)))))
|
|
(org-test-with-temp-text-in-file "
|
|
(org-test-with-temp-text-in-file "
|
|
#+begin_src emacs-lisp
|
|
#+begin_src emacs-lisp
|
|
\"some text\";;
|
|
\"some text\";;
|
|
#+end_src"
|
|
#+end_src"
|
|
-
|
|
|
|
- (progn
|
|
|
|
- (org-babel-next-src-block)
|
|
|
|
- (org-ctrl-c-ctrl-c)
|
|
|
|
- (should (re-search-forward "\\#\\+results:" nil t))
|
|
|
|
- (forward-line)
|
|
|
|
- (should
|
|
|
|
- (string=
|
|
|
|
- ": some text"
|
|
|
|
- (buffer-substring-no-properties (point-at-bol) (point-at-eol)))))))
|
|
|
|
|
|
+ (org-babel-next-src-block)
|
|
|
|
+ (org-ctrl-c-ctrl-c)
|
|
|
|
+ (should (re-search-forward "\\#\\+results:" nil t))
|
|
|
|
+ (forward-line)
|
|
|
|
+ (should
|
|
|
|
+ (string=
|
|
|
|
+ ": some text"
|
|
|
|
+ (buffer-substring-no-properties (point-at-bol) (point-at-eol))))))
|
|
|
|
|
|
(ert-deftest test-ob/commented-last-block-line-with-var ()
|
|
(ert-deftest test-ob/commented-last-block-line-with-var ()
|
|
(org-test-with-temp-text-in-file "
|
|
(org-test-with-temp-text-in-file "
|
|
#+begin_src emacs-lisp :var a=1
|
|
#+begin_src emacs-lisp :var a=1
|
|
;;
|
|
;;
|
|
#+end_src"
|
|
#+end_src"
|
|
- (progn
|
|
|
|
- (org-babel-next-src-block)
|
|
|
|
- (org-ctrl-c-ctrl-c)
|
|
|
|
- (re-search-forward "\\#\\+results:" nil t)
|
|
|
|
- (forward-line)
|
|
|
|
- (should (string=
|
|
|
|
- ""
|
|
|
|
- (buffer-substring-no-properties (point-at-bol) (point-at-eol))))))
|
|
|
|
|
|
+ (org-babel-next-src-block)
|
|
|
|
+ (org-ctrl-c-ctrl-c)
|
|
|
|
+ (re-search-forward "\\#\\+results:" nil t)
|
|
|
|
+ (forward-line)
|
|
|
|
+ (should (string=
|
|
|
|
+ ""
|
|
|
|
+ (buffer-substring-no-properties (point-at-bol) (point-at-eol)))))
|
|
(org-test-with-temp-text-in-file "
|
|
(org-test-with-temp-text-in-file "
|
|
#+begin_src emacs-lisp :var a=2
|
|
#+begin_src emacs-lisp :var a=2
|
|
2;;
|
|
2;;
|
|
#+end_src"
|
|
#+end_src"
|
|
- (progn
|
|
|
|
- (org-babel-next-src-block)
|
|
|
|
- (org-ctrl-c-ctrl-c)
|
|
|
|
- (re-search-forward "\\#\\+results:" nil t)
|
|
|
|
- (forward-line)
|
|
|
|
- (should (string=
|
|
|
|
- ": 2"
|
|
|
|
- (buffer-substring-no-properties (point-at-bol) (point-at-eol)))))))
|
|
|
|
|
|
+ (org-babel-next-src-block)
|
|
|
|
+ (org-ctrl-c-ctrl-c)
|
|
|
|
+ (re-search-forward "\\#\\+results:" nil t)
|
|
|
|
+ (forward-line)
|
|
|
|
+ (should (string=
|
|
|
|
+ ": 2"
|
|
|
|
+ (buffer-substring-no-properties (point-at-bol) (point-at-eol))))))
|
|
|
|
|
|
(defun test-ob-verify-result-and-removed-result (result buffer-text)
|
|
(defun test-ob-verify-result-and-removed-result (result buffer-text)
|
|
"Test helper function to test `org-babel-remove-result'.
|
|
"Test helper function to test `org-babel-remove-result'.
|
|
@@ -759,18 +746,17 @@ The block is actually executed /twice/ to ensure result
|
|
replacement happens correctly."
|
|
replacement happens correctly."
|
|
(org-test-with-temp-text
|
|
(org-test-with-temp-text
|
|
buffer-text
|
|
buffer-text
|
|
- (progn
|
|
|
|
- (org-babel-next-src-block) (org-ctrl-c-ctrl-c) (org-ctrl-c-ctrl-c)
|
|
|
|
- (should (re-search-forward "\\#\\+results:" nil t))
|
|
|
|
- (forward-line)
|
|
|
|
- (should (string= result
|
|
|
|
- (buffer-substring-no-properties
|
|
|
|
- (point-at-bol)
|
|
|
|
- (- (point-max) 16))))
|
|
|
|
- (org-babel-previous-src-block) (org-babel-remove-result)
|
|
|
|
- (should (string= buffer-text
|
|
|
|
- (buffer-substring-no-properties
|
|
|
|
- (point-min) (point-max)))))))
|
|
|
|
|
|
+ (org-babel-next-src-block) (org-ctrl-c-ctrl-c) (org-ctrl-c-ctrl-c)
|
|
|
|
+ (should (re-search-forward "\\#\\+results:" nil t))
|
|
|
|
+ (forward-line)
|
|
|
|
+ (should (string= result
|
|
|
|
+ (buffer-substring-no-properties
|
|
|
|
+ (point-at-bol)
|
|
|
|
+ (- (point-max) 16))))
|
|
|
|
+ (org-babel-previous-src-block) (org-babel-remove-result)
|
|
|
|
+ (should (string= buffer-text
|
|
|
|
+ (buffer-substring-no-properties
|
|
|
|
+ (point-min) (point-max))))))
|
|
|
|
|
|
(ert-deftest test-ob/org-babel-remove-result--results-default ()
|
|
(ert-deftest test-ob/org-babel-remove-result--results-default ()
|
|
"Test `org-babel-remove-result' with default :results."
|
|
"Test `org-babel-remove-result' with default :results."
|
|
@@ -778,7 +764,7 @@ replacement happens correctly."
|
|
(test-ob-verify-result-and-removed-result
|
|
(test-ob-verify-result-and-removed-result
|
|
"\n"
|
|
"\n"
|
|
(concat
|
|
(concat
|
|
-"* org-babel-remove-result
|
|
|
|
|
|
+ "* org-babel-remove-result
|
|
#+begin_src " language "
|
|
#+begin_src " language "
|
|
#+end_src
|
|
#+end_src
|
|
|
|
|
|
@@ -793,7 +779,7 @@ replacement happens correctly."
|
|
- 3
|
|
- 3
|
|
- (quote (4 5))"
|
|
- (quote (4 5))"
|
|
|
|
|
|
-"* org-babel-remove-result
|
|
|
|
|
|
+ "* org-babel-remove-result
|
|
#+begin_src emacs-lisp :results list
|
|
#+begin_src emacs-lisp :results list
|
|
'(1 2 3 '(4 5))
|
|
'(1 2 3 '(4 5))
|
|
#+end_src
|
|
#+end_src
|
|
@@ -805,7 +791,7 @@ replacement happens correctly."
|
|
If not inserted correctly then the second evaluation will fail
|
|
If not inserted correctly then the second evaluation will fail
|
|
trying to find the :END: marker."
|
|
trying to find the :END: marker."
|
|
(org-test-with-temp-text
|
|
(org-test-with-temp-text
|
|
- "- indented
|
|
|
|
|
|
+ "- indented
|
|
#+begin_src sh :results file wrap
|
|
#+begin_src sh :results file wrap
|
|
echo test.txt
|
|
echo test.txt
|
|
#+end_src"
|
|
#+end_src"
|
|
@@ -834,7 +820,7 @@ trying to find the :END: marker."
|
|
(test-ob-verify-result-and-removed-result
|
|
(test-ob-verify-result-and-removed-result
|
|
": \"I /am/ working!\""
|
|
": \"I /am/ working!\""
|
|
|
|
|
|
-"* org-babel-remove-result
|
|
|
|
|
|
+ "* org-babel-remove-result
|
|
#+begin_src emacs-lisp :results pp
|
|
#+begin_src emacs-lisp :results pp
|
|
\"I /am/ working!\")
|
|
\"I /am/ working!\")
|
|
#+end_src
|
|
#+end_src
|
|
@@ -855,26 +841,24 @@ trying to find the :END: marker."
|
|
#+begin_src emacs-lisp :var a=1
|
|
#+begin_src emacs-lisp :var a=1
|
|
;;
|
|
;;
|
|
#+end_src"
|
|
#+end_src"
|
|
- (progn
|
|
|
|
- (org-babel-next-src-block)
|
|
|
|
- (org-ctrl-c-ctrl-c)
|
|
|
|
- (re-search-forward "\\#\\+results:" nil t)
|
|
|
|
- (forward-line)
|
|
|
|
- (should (string=
|
|
|
|
- ""
|
|
|
|
- (buffer-substring-no-properties (point-at-bol) (point-at-eol))))))
|
|
|
|
|
|
+ (org-babel-next-src-block)
|
|
|
|
+ (org-ctrl-c-ctrl-c)
|
|
|
|
+ (re-search-forward "\\#\\+results:" nil t)
|
|
|
|
+ (forward-line)
|
|
|
|
+ (should (string=
|
|
|
|
+ ""
|
|
|
|
+ (buffer-substring-no-properties (point-at-bol) (point-at-eol)))))
|
|
(org-test-with-temp-text-in-file "
|
|
(org-test-with-temp-text-in-file "
|
|
#+begin_src emacs-lisp :var a=2
|
|
#+begin_src emacs-lisp :var a=2
|
|
2;;
|
|
2;;
|
|
#+end_src"
|
|
#+end_src"
|
|
- (progn
|
|
|
|
- (org-babel-next-src-block)
|
|
|
|
- (org-ctrl-c-ctrl-c)
|
|
|
|
- (re-search-forward "\\#\\+results:" nil t)
|
|
|
|
- (forward-line)
|
|
|
|
- (should (string=
|
|
|
|
- ": 2"
|
|
|
|
- (buffer-substring-no-properties (point-at-bol) (point-at-eol)))))))
|
|
|
|
|
|
+ (org-babel-next-src-block)
|
|
|
|
+ (org-ctrl-c-ctrl-c)
|
|
|
|
+ (re-search-forward "\\#\\+results:" nil t)
|
|
|
|
+ (forward-line)
|
|
|
|
+ (should (string=
|
|
|
|
+ ": 2"
|
|
|
|
+ (buffer-substring-no-properties (point-at-bol) (point-at-eol))))))
|
|
|
|
|
|
(defun test-ob-verify-result-and-removed-result (result buffer-text)
|
|
(defun test-ob-verify-result-and-removed-result (result buffer-text)
|
|
"Test helper function to test `org-babel-remove-result'.
|
|
"Test helper function to test `org-babel-remove-result'.
|
|
@@ -885,18 +869,17 @@ The block is actually executed /twice/ to ensure result
|
|
replacement happens correctly."
|
|
replacement happens correctly."
|
|
(org-test-with-temp-text
|
|
(org-test-with-temp-text
|
|
buffer-text
|
|
buffer-text
|
|
- (progn
|
|
|
|
- (org-babel-next-src-block) (org-ctrl-c-ctrl-c) (org-ctrl-c-ctrl-c)
|
|
|
|
- (should (re-search-forward "\\#\\+results:" nil t))
|
|
|
|
- (forward-line)
|
|
|
|
- (should (string= result
|
|
|
|
- (buffer-substring-no-properties
|
|
|
|
- (point-at-bol)
|
|
|
|
- (- (point-max) 16))))
|
|
|
|
- (org-babel-previous-src-block) (org-babel-remove-result)
|
|
|
|
- (should (string= buffer-text
|
|
|
|
- (buffer-substring-no-properties
|
|
|
|
- (point-min) (point-max)))))))
|
|
|
|
|
|
+ (org-babel-next-src-block) (org-ctrl-c-ctrl-c) (org-ctrl-c-ctrl-c)
|
|
|
|
+ (should (re-search-forward "\\#\\+results:" nil t))
|
|
|
|
+ (forward-line)
|
|
|
|
+ (should (string= result
|
|
|
|
+ (buffer-substring-no-properties
|
|
|
|
+ (point-at-bol)
|
|
|
|
+ (- (point-max) 16))))
|
|
|
|
+ (org-babel-previous-src-block) (org-babel-remove-result)
|
|
|
|
+ (should (string= buffer-text
|
|
|
|
+ (buffer-substring-no-properties
|
|
|
|
+ (point-min) (point-max))))))
|
|
|
|
|
|
(ert-deftest test-ob/org-babel-remove-result--results-default ()
|
|
(ert-deftest test-ob/org-babel-remove-result--results-default ()
|
|
"Test `org-babel-remove-result' with default :results."
|
|
"Test `org-babel-remove-result' with default :results."
|
|
@@ -904,7 +887,7 @@ replacement happens correctly."
|
|
(test-ob-verify-result-and-removed-result
|
|
(test-ob-verify-result-and-removed-result
|
|
"\n"
|
|
"\n"
|
|
(concat
|
|
(concat
|
|
-"* org-babel-remove-result
|
|
|
|
|
|
+ "* org-babel-remove-result
|
|
#+begin_src " language "
|
|
#+begin_src " language "
|
|
#+end_src
|
|
#+end_src
|
|
|
|
|
|
@@ -919,7 +902,7 @@ replacement happens correctly."
|
|
- 3
|
|
- 3
|
|
- (quote (4 5))"
|
|
- (quote (4 5))"
|
|
|
|
|
|
-"* org-babel-remove-result
|
|
|
|
|
|
+ "* org-babel-remove-result
|
|
#+begin_src emacs-lisp :results list
|
|
#+begin_src emacs-lisp :results list
|
|
'(1 2 3 '(4 5))
|
|
'(1 2 3 '(4 5))
|
|
#+end_src
|
|
#+end_src
|
|
@@ -933,7 +916,7 @@ replacement happens correctly."
|
|
hello there
|
|
hello there
|
|
:END:"
|
|
:END:"
|
|
|
|
|
|
- "* org-babel-remove-result
|
|
|
|
|
|
+ "* org-babel-remove-result
|
|
|
|
|
|
#+begin_src emacs-lisp :results wrap
|
|
#+begin_src emacs-lisp :results wrap
|
|
\"hello there\"
|
|
\"hello there\"
|
|
@@ -950,7 +933,7 @@ hello there
|
|
content
|
|
content
|
|
#+END_SRC"
|
|
#+END_SRC"
|
|
|
|
|
|
-"* org-babel-remove-result
|
|
|
|
|
|
+ "* org-babel-remove-result
|
|
#+begin_src emacs-lisp :results org
|
|
#+begin_src emacs-lisp :results org
|
|
\"* heading
|
|
\"* heading
|
|
** subheading
|
|
** subheading
|
|
@@ -966,7 +949,7 @@ content\"
|
|
<head><body></body></head>
|
|
<head><body></body></head>
|
|
#+END_HTML"
|
|
#+END_HTML"
|
|
|
|
|
|
-"* org-babel-remove-result
|
|
|
|
|
|
+ "* org-babel-remove-result
|
|
#+begin_src emacs-lisp :results html
|
|
#+begin_src emacs-lisp :results html
|
|
\"<head><body></body></head>\"
|
|
\"<head><body></body></head>\"
|
|
#+end_src
|
|
#+end_src
|
|
@@ -982,7 +965,7 @@ Line 2
|
|
Line 3
|
|
Line 3
|
|
#+END_LaTeX"
|
|
#+END_LaTeX"
|
|
|
|
|
|
-"* org-babel-remove-result
|
|
|
|
|
|
+ "* org-babel-remove-result
|
|
#+begin_src emacs-lisp :results latex
|
|
#+begin_src emacs-lisp :results latex
|
|
\"Line 1
|
|
\"Line 1
|
|
Line 2
|
|
Line 2
|
|
@@ -999,7 +982,7 @@ Line 3\"
|
|
\"I am working!\"
|
|
\"I am working!\"
|
|
#+END_SRC"
|
|
#+END_SRC"
|
|
|
|
|
|
-"* org-babel-remove-result
|
|
|
|
|
|
+ "* org-babel-remove-result
|
|
#+begin_src emacs-lisp :results code
|
|
#+begin_src emacs-lisp :results code
|
|
(message \"I am working!\")
|
|
(message \"I am working!\")
|
|
#+end_src
|
|
#+end_src
|
|
@@ -1011,7 +994,7 @@ Line 3\"
|
|
(test-ob-verify-result-and-removed-result
|
|
(test-ob-verify-result-and-removed-result
|
|
": \"I /am/ working!\""
|
|
": \"I /am/ working!\""
|
|
|
|
|
|
-"* org-babel-remove-result
|
|
|
|
|
|
+ "* org-babel-remove-result
|
|
#+begin_src emacs-lisp :results pp
|
|
#+begin_src emacs-lisp :results pp
|
|
\"I /am/ working!\")
|
|
\"I /am/ working!\")
|
|
#+end_src
|
|
#+end_src
|
|
@@ -1022,11 +1005,11 @@ Line 3\"
|
|
(org-test-with-temp-text "Block two has a space after the name.
|
|
(org-test-with-temp-text "Block two has a space after the name.
|
|
|
|
|
|
#+name: foo
|
|
#+name: foo
|
|
- #+begin_src emacs-lisp
|
|
|
|
|
|
+ #+begin_src emacs-lisp
|
|
1
|
|
1
|
|
#+end_src emacs-lisp
|
|
#+end_src emacs-lisp
|
|
|
|
|
|
-#+name: foo
|
|
|
|
|
|
+#+name: foo
|
|
#+begin_src emacs-lisp
|
|
#+begin_src emacs-lisp
|
|
2
|
|
2
|
|
#+end_src
|
|
#+end_src
|
|
@@ -1060,8 +1043,8 @@ Line 3\"
|
|
(org-test-with-temp-text "#+BEGIN_SRC emacs-lisp
|
|
(org-test-with-temp-text "#+BEGIN_SRC emacs-lisp
|
|
\(+ 1 2)
|
|
\(+ 1 2)
|
|
#+END_SRC\n\n\n"
|
|
#+END_SRC\n\n\n"
|
|
- (progn (org-babel-execute-src-block)
|
|
|
|
- (buffer-string))))))
|
|
|
|
|
|
+ (org-babel-execute-src-block)
|
|
|
|
+ (buffer-string)))))
|
|
|
|
|
|
(ert-deftest test-ob/results-in-narrowed-buffer ()
|
|
(ert-deftest test-ob/results-in-narrowed-buffer ()
|
|
"Test block execution in a narrowed buffer."
|
|
"Test block execution in a narrowed buffer."
|
|
@@ -1072,19 +1055,17 @@ Line 3\"
|
|
"#+BEGIN_SRC emacs-lisp\n(+ 1 2)\n#+END_SRC\n\n#+RESULTS:\n: 3"
|
|
"#+BEGIN_SRC emacs-lisp\n(+ 1 2)\n#+END_SRC\n\n#+RESULTS:\n: 3"
|
|
(org-test-with-temp-text
|
|
(org-test-with-temp-text
|
|
"#+BEGIN_SRC emacs-lisp\n(+ 1 2)\n#+END_SRC\n\nParagraph"
|
|
"#+BEGIN_SRC emacs-lisp\n(+ 1 2)\n#+END_SRC\n\nParagraph"
|
|
- (progn
|
|
|
|
- (narrow-to-region (point) (save-excursion (forward-line 3) (point)))
|
|
|
|
- (org-babel-execute-src-block)
|
|
|
|
- (org-trim (buffer-string))))))
|
|
|
|
|
|
+ (narrow-to-region (point) (save-excursion (forward-line 3) (point)))
|
|
|
|
+ (org-babel-execute-src-block)
|
|
|
|
+ (org-trim (buffer-string)))))
|
|
(should
|
|
(should
|
|
(equal
|
|
(equal
|
|
"#+NAME: test\n#+BEGIN_SRC emacs-lisp\n(+ 1 2)\n#+END_SRC\n\n#+RESULTS: test\n: 3"
|
|
"#+NAME: test\n#+BEGIN_SRC emacs-lisp\n(+ 1 2)\n#+END_SRC\n\n#+RESULTS: test\n: 3"
|
|
(org-test-with-temp-text
|
|
(org-test-with-temp-text
|
|
"#+NAME: test\n#+BEGIN_SRC emacs-lisp\n(+ 1 2)\n#+END_SRC\n\nParagraph"
|
|
"#+NAME: test\n#+BEGIN_SRC emacs-lisp\n(+ 1 2)\n#+END_SRC\n\nParagraph"
|
|
- (progn
|
|
|
|
- (narrow-to-region (point) (save-excursion (forward-line 4) (point)))
|
|
|
|
- (org-babel-execute-src-block)
|
|
|
|
- (org-trim (buffer-string))))))
|
|
|
|
|
|
+ (narrow-to-region (point) (save-excursion (forward-line 4) (point)))
|
|
|
|
+ (org-babel-execute-src-block)
|
|
|
|
+ (org-trim (buffer-string)))))
|
|
;; Results in visible part of buffer, should be updated here.
|
|
;; Results in visible part of buffer, should be updated here.
|
|
(should
|
|
(should
|
|
(equal
|
|
(equal
|
|
@@ -1105,10 +1086,9 @@ Line 3\"
|
|
: 4
|
|
: 4
|
|
|
|
|
|
Paragraph"
|
|
Paragraph"
|
|
- (progn
|
|
|
|
- (narrow-to-region (point) (save-excursion (forward-line 7) (point)))
|
|
|
|
- (org-babel-execute-src-block)
|
|
|
|
- (org-trim (buffer-string))))))
|
|
|
|
|
|
+ (narrow-to-region (point) (save-excursion (forward-line 7) (point)))
|
|
|
|
+ (org-babel-execute-src-block)
|
|
|
|
+ (org-trim (buffer-string)))))
|
|
;; Results in invisible part of buffer, should be updated there.
|
|
;; Results in invisible part of buffer, should be updated there.
|
|
(org-test-with-temp-text
|
|
(org-test-with-temp-text
|
|
"#+NAME: test
|
|
"#+NAME: test
|
|
@@ -1120,12 +1100,11 @@ Paragraph"
|
|
: 4
|
|
: 4
|
|
|
|
|
|
Paragraph"
|
|
Paragraph"
|
|
- (progn
|
|
|
|
- (narrow-to-region (point) (save-excursion (forward-line 4) (point)))
|
|
|
|
- (org-babel-execute-src-block)
|
|
|
|
- (should-not (re-search-forward "^#\\+RESULTS:" nil t))
|
|
|
|
- (widen)
|
|
|
|
- (should (should (re-search-forward "^: 3" nil t))))))
|
|
|
|
|
|
+ (narrow-to-region (point) (save-excursion (forward-line 4) (point)))
|
|
|
|
+ (org-babel-execute-src-block)
|
|
|
|
+ (should-not (re-search-forward "^#\\+RESULTS:" nil t))
|
|
|
|
+ (widen)
|
|
|
|
+ (should (should (re-search-forward "^: 3" nil t)))))
|
|
|
|
|
|
|
|
|
|
(provide 'test-ob)
|
|
(provide 'test-ob)
|