testing/*: Inline result tests modified to follow current schema
* test/examples/babel.org: Miscellaneous fixes for new inline src block schema. Return a scalar to avoid unwanted error. Return a raw result from `src_emacs-lisp' to make checking results cleaner than dealing with `results' macro. * testing/lisp/test-ob-exp.el: Wrap some expected results in `{{{results(' and ')}}}' and drop `=%s=' formatting of others. * testing/lisp/test-ob-lob.el: Wrap some expected results in `{{{results(' and ')}}}'. * testing/lisp/test-ob.el: Wrap some expected results in `{{{results(' and ')}}}'. * testing/lisp/test-ob.el (test-org-babel/org-babel-get-inline-src-block-matches, test-org-babel/inline-src_blk-results-silent): Tests of inline src block matches (and `org-ctrl-ctrl-c') conform to the `:begin' and `:end' properties of `org-element-context'. * testing/lisp/test-ob.el (test-org-babel/inline-src_blk-default-results-replace-line-1, test-org-babel/inline-src_blk-default-results-replace-line-2): Inline results are self replacing.
This commit is contained in:
parent
85ff663ce4
commit
90e18aed9c
|
@ -352,7 +352,7 @@ Second
|
|||
(push 2 *evaluation-collector*)
|
||||
#+end_src
|
||||
|
||||
Third src_emacs-lisp{(push 3 *evaluation-collector*)}
|
||||
Third src_emacs-lisp{(car (push 3 *evaluation-collector*))}
|
||||
|
||||
Fourth
|
||||
#+call: foo-for-order-of-evaluation(4)
|
||||
|
@ -406,8 +406,8 @@ Note: Just export of a property can be done with a macro: {{{property(a)}}}.
|
|||
#+NAME: src_block_location_elisp-sect-call
|
||||
#+CALL: src_block_location_elisp()
|
||||
|
||||
- sect inline call_src_block_location_shell()
|
||||
- sect inline call_src_block_location_elisp()
|
||||
- sect inline call_src_block_location_shell()[:results raw]
|
||||
- sect inline call_src_block_location_elisp()[:results raw]
|
||||
|
||||
*** subsection
|
||||
:PROPERTIES:
|
||||
|
@ -421,8 +421,8 @@ Note: Just export of a property can be done with a macro: {{{property(a)}}}.
|
|||
#+NAME: src_block_location_elisp-sub0-call
|
||||
#+CALL: src_block_location_elisp()
|
||||
|
||||
- sub0 inline call_src_block_location_shell()
|
||||
- sub0 inline call_src_block_location_elisp()
|
||||
- sub0 inline call_src_block_location_shell()[:results raw]
|
||||
- sub0 inline call_src_block_location_elisp()[:results raw]
|
||||
|
||||
#+NAME: src_block_location_shell-sub1-call
|
||||
#+CALL: src_block_location_shell(c=5, e=6)
|
||||
|
@ -430,8 +430,8 @@ Note: Just export of a property can be done with a macro: {{{property(a)}}}.
|
|||
#+NAME: src_block_location_elisp-sub1-call
|
||||
#+CALL: src_block_location_elisp(c=5, e=6)
|
||||
|
||||
- sub1 inline call_src_block_location_shell(c=5, e=6)
|
||||
- sub1 inline call_src_block_location_elisp(c=5, e=6)
|
||||
- sub1 inline call_src_block_location_shell(c=5, e=6)[:results raw]
|
||||
- sub1 inline call_src_block_location_elisp(c=5, e=6)[:results raw]
|
||||
|
||||
**** function definition
|
||||
|
||||
|
|
|
@ -93,7 +93,8 @@ Current buffer is a copy of the original buffer."
|
|||
(message \"expanded1\")" ";; noweb-no-start
|
||||
<<noweb-example1>>" ";; noweb-2-yes-start
|
||||
(message \"expanded2\")
|
||||
(message \"expanded2\")" ";; noweb-tangle-start
|
||||
(message \"expanded2\")"
|
||||
";; noweb-tangle-start
|
||||
<<noweb-example1>>
|
||||
<<noweb-example2>>")
|
||||
(org-test-at-id "eb1f6498-5bd9-45e0-9c56-50717053e7b7"
|
||||
|
@ -190,9 +191,9 @@ a table."
|
|||
(ert-deftest ob-exp/exports-inline ()
|
||||
(should
|
||||
(string-match
|
||||
(regexp-quote "Here is one in the middle =1= of a line.
|
||||
Here is one at the end of a line. =2=
|
||||
=3= Here is one at the beginning of a line.")
|
||||
(regexp-quote "Here is one in the middle {{{results(=1=)}}} of a line.
|
||||
Here is one at the end of a line. {{{results(=2=)}}}
|
||||
{{{results(=3=)}}} Here is one at the beginning of a line.")
|
||||
(org-test-at-id "54cb8dc3-298c-4883-a933-029b3c9d4b18"
|
||||
(org-narrow-to-subtree)
|
||||
(let ((org-babel-inline-result-wrap "=%s="))
|
||||
|
@ -214,13 +215,13 @@ Here is one at the end of a line. =2=
|
|||
(org-export-execute-babel-code)
|
||||
(buffer-string))))
|
||||
(should
|
||||
(string-match "\\`src_emacs-lisp\\(?:\\[]\\)?{(\\+ 1 1)} =2=$"
|
||||
(string-match "\\`src_emacs-lisp\\(?:\\[]\\)?{(\\+ 1 1)} {{{results(=2=)}}}$"
|
||||
(org-test-with-temp-text
|
||||
"src_emacs-lisp[:exports both]{(+ 1 1)}"
|
||||
(org-export-execute-babel-code)
|
||||
(buffer-string))))
|
||||
(should
|
||||
(string-match "\\`=2=$"
|
||||
(string-match "\\`{{{results(=2=)}}}$"
|
||||
(org-test-with-temp-text
|
||||
"src_emacs-lisp[:exports results :results scalar]{(+ 1 1)}"
|
||||
(org-export-execute-babel-code)
|
||||
|
@ -246,7 +247,7 @@ Here is one at the end of a line. =2=
|
|||
(regexp-quote "Here is one in the middle src_sh[]{echo 1} of a line.
|
||||
Here is one at the end of a line. src_sh[]{echo 2}
|
||||
src_sh[]{echo 3} Here is one at the beginning of a line.
|
||||
Here is one that is also evaluated: src_sh[]{echo 4} =4=")
|
||||
Here is one that is also evaluated: src_sh[]{echo 4} {{{results(=4=)}}}")
|
||||
nil t)
|
||||
(org-test-at-id "cd54fc88-1b6b-45b6-8511-4d8fa7fc8076"
|
||||
(org-narrow-to-subtree)
|
||||
|
@ -259,7 +260,7 @@ evaluated."
|
|||
(let ((org-babel-inline-result-wrap "=%s=")
|
||||
(org-export-babel-evaluate t))
|
||||
(should
|
||||
(string-match "\\`=2=$"
|
||||
(string-match "\\`{{{results(src_emacs-lisp\\[\\]{2})}}}$"
|
||||
(org-test-with-temp-text
|
||||
"src_emacs-lisp[:exports results :results code]{(+ 1 1)}"
|
||||
(org-export-execute-babel-code)
|
||||
|
@ -270,7 +271,7 @@ evaluated."
|
|||
be evaluated."
|
||||
(let ((org-export-babel-evaluate t))
|
||||
(should
|
||||
(string-match "\\`src_emacs-lisp\\(?:\\[]\\)?{2}$"
|
||||
(string-match "{{{results(src_emacs-lisp\\(?:\\[[: a-zA-Z]+]\\)?{2})}}}$"
|
||||
(org-test-with-temp-text
|
||||
(concat "src_emacs-lisp[:exports results :results code "
|
||||
":results_switches \":exports code\"]{(+ 1 1)}")
|
||||
|
@ -281,7 +282,7 @@ be evaluated."
|
|||
(let ((org-export-babel-evaluate t))
|
||||
(should
|
||||
(string-match (concat "\\`src_emacs-lisp\\(?:\\[]\\)?{(\\+ 1 1)} "
|
||||
"src_emacs-lisp\\(?:\\[]\\)?{2}$")
|
||||
"{{{results(src_emacs-lisp\\[ :exports code\\]{2})}}}$")
|
||||
(org-test-with-temp-text
|
||||
(concat "src_emacs-lisp[:exports both :results code "
|
||||
":results_switches \":exports code\"]{(+ 1 1)}")
|
||||
|
@ -310,7 +311,6 @@ be evaluated."
|
|||
(org-test-at-id "cc5fbc20-bca5-437a-a7b8-2b4d7a03f820"
|
||||
(org-narrow-to-subtree)
|
||||
(let* ((case-fold-search nil)
|
||||
(org-babel-inline-result-wrap "=%s=")
|
||||
(result (org-test-with-expanded-babel-code (buffer-string)))
|
||||
(sect "a:1, b:0, c:3, d:0, e:0")
|
||||
(sub0 "a:1, b:2, c:4, d:0, e:0")
|
||||
|
@ -321,27 +321,27 @@ be evaluated."
|
|||
result))
|
||||
(should (string-match (concat "_elisp-sect-call\n: elisp " sect "\n")
|
||||
result))
|
||||
(should (string-match (concat "\n- sect inline =shell " sect "=\n")
|
||||
(should (string-match (concat "\n- sect inline shell " sect "\n")
|
||||
result))
|
||||
(should (string-match (concat "\n- sect inline =elisp " sect "=\n")
|
||||
(should (string-match (concat "\n- sect inline elisp " sect "\n")
|
||||
result))
|
||||
;; entry "subsection", call without arguments
|
||||
(should (string-match (concat "_shell-sub0-call\n: shell " sub0 "\n")
|
||||
result))
|
||||
(should (string-match (concat "_elisp-sub0-call\n: elisp " sub0 "\n")
|
||||
result))
|
||||
(should (string-match (concat "\n- sub0 inline =shell " sub0 "=\n")
|
||||
(should (string-match (concat "\n- sub0 inline shell " sub0 "\n")
|
||||
result))
|
||||
(should (string-match (concat "\n- sub0 inline =elisp " sub0 "=\n")
|
||||
(should (string-match (concat "\n- sub0 inline elisp " sub0 "\n")
|
||||
result))
|
||||
;; entry "subsection", call with arguments
|
||||
(should (string-match (concat "_shell-sub1-call\n: shell " sub1 "\n")
|
||||
result))
|
||||
(should (string-match (concat "_elisp-sub1-call\n: elisp " sub1 "\n")
|
||||
result))
|
||||
(should (string-match (concat "\n- sub1 inline =shell " sub1 "=\n")
|
||||
(should (string-match (concat "\n- sub1 inline shell " sub1 "\n")
|
||||
result))
|
||||
(should (string-match (concat "\n- sub1 inline =elisp " sub1 "=\n")
|
||||
(should (string-match (concat "\n- sub1 inline elisp " sub1 "\n")
|
||||
result))
|
||||
;; entry "function definition"
|
||||
(should (string-match (concat "_location_shell\n: shell " func "\n")
|
||||
|
|
|
@ -91,12 +91,12 @@
|
|||
(message (buffer-string))
|
||||
(goto-char (point-min))
|
||||
(should (re-search-forward "^: 0" nil t))
|
||||
(should (re-search-forward "call =2= stuck" nil t))
|
||||
(should (re-search-forward "call {{{results(=2=)}}} stuck" nil t))
|
||||
(should (re-search-forward
|
||||
"exported =call_double(it=2)= because" nil t))
|
||||
(should (re-search-forward "^=6= because" nil t))
|
||||
(should (re-search-forward "^{{{results(=6=)}}} because" nil t))
|
||||
(should (re-search-forward "results 8 should" nil t))
|
||||
(should (re-search-forward "following 2\\*5==10= should" nil t)))))))
|
||||
(should (re-search-forward "following 2\\*5={{{results(=10=)}}} should" nil t)))))))
|
||||
|
||||
(ert-deftest test-ob-lob/do-not-eval-lob-lines-in-example-blocks-on-export ()
|
||||
(require 'ox)
|
||||
|
|
|
@ -275,14 +275,14 @@ this is simple"
|
|||
(should (fboundp 'org-babel-get-inline-src-block-matches))
|
||||
(should (re-search-forward "src_" nil t)) ;; 1
|
||||
(should (org-babel-get-inline-src-block-matches))
|
||||
(should (re-search-forward "}" nil (point-at-bol))) ;; 1
|
||||
(should (re-search-forward " b" nil (point-at-bol))) ;; 1
|
||||
(should-not (org-babel-get-inline-src-block-matches))
|
||||
(should (re-search-forward "in" nil t)) ;; 2
|
||||
(should-not (org-babel-get-inline-src-block-matches))
|
||||
(should (re-search-forward "echo" nil t)) ;; 2
|
||||
(should (org-babel-get-inline-src-block-matches))
|
||||
(should (re-search-forward "blocks" nil t)) ;; 3
|
||||
(backward-char 8) ;; 3
|
||||
(backward-char 7) ;; 3
|
||||
(should (org-babel-get-inline-src-block-matches))
|
||||
(forward-char 1) ;;3
|
||||
(should-not (org-babel-get-inline-src-block-matches))
|
||||
|
@ -301,18 +301,18 @@ this is simple"
|
|||
test-line
|
||||
(goto-char (point-min)) (org-ctrl-c-ctrl-c)
|
||||
(should (string=
|
||||
(concat test-line " =1=")
|
||||
(concat test-line " {{{results(=1=)}}}")
|
||||
(buffer-substring-no-properties (point-at-bol) (point-at-eol))))
|
||||
(forward-char) (org-ctrl-c-ctrl-c)
|
||||
(should (string=
|
||||
(concat test-line " =1= =1=")
|
||||
(concat test-line " {{{results(=1=)}}}")
|
||||
(buffer-substring-no-properties (point-at-bol) (point-at-eol))))
|
||||
(re-search-forward "1}")
|
||||
(should-error (org-ctrl-c-ctrl-c))
|
||||
(backward-char) ;; last char of block body
|
||||
(re-search-forward "{{{")
|
||||
;;(should-error (org-ctrl-c-ctrl-c))
|
||||
(backward-char 4) ;; last char of block body
|
||||
(org-ctrl-c-ctrl-c)
|
||||
(should (string=
|
||||
(concat test-line " =1= =1= =1=")
|
||||
(concat test-line " {{{results(=1=)}}}")
|
||||
(buffer-substring-no-properties (point-at-bol) (point-at-eol)))))
|
||||
;; src_ follows space line 1...
|
||||
(let ((test-line " src_emacs-lisp{ 1 }"))
|
||||
|
@ -321,14 +321,15 @@ this is simple"
|
|||
(should-error (org-ctrl-c-ctrl-c))
|
||||
(forward-char) (org-ctrl-c-ctrl-c)
|
||||
(should (string=
|
||||
(concat test-line " =1=")
|
||||
(concat test-line " {{{results(=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=")
|
||||
(concat test-line " {{{results(=1=)}}}")
|
||||
(buffer-substring-no-properties (point-at-bol) (point-at-eol))))
|
||||
(forward-char)
|
||||
(should-error (org-ctrl-c-ctrl-c))))))
|
||||
(forward-char 6)
|
||||
(should-error (org-ctrl-c-ctrl-c))
|
||||
))))
|
||||
|
||||
(ert-deftest test-org-babel/inline-src_blk-default-results-replace-line-2 ()
|
||||
;; src_ at bol line 2...
|
||||
|
@ -343,10 +344,9 @@ this is simple"
|
|||
(should-error (org-ctrl-c-ctrl-c))
|
||||
(forward-char) (org-ctrl-c-ctrl-c)
|
||||
(should (string=
|
||||
(concat test-line " =x=")
|
||||
(concat test-line " {{{results(=x=)}}}")
|
||||
(buffer-substring-no-properties
|
||||
(point-at-bol) (point-at-eol))))))
|
||||
|
||||
(let ((test-line "Some text prior to block src_emacs-lisp{ \"y\" }")
|
||||
(org-babel-inline-result-wrap "=%s="))
|
||||
(org-test-with-temp-text
|
||||
|
@ -355,13 +355,13 @@ this is simple"
|
|||
(insert (concat "\n" test-line " end"))
|
||||
(re-search-backward "src") (org-ctrl-c-ctrl-c)
|
||||
(should (string=
|
||||
(concat test-line " =y= end")
|
||||
(concat test-line " {{{results(=y=)}}} end")
|
||||
(buffer-substring-no-properties (point-at-bol) (point-at-eol))))
|
||||
(re-search-forward "\" ") (org-ctrl-c-ctrl-c)
|
||||
(should (string=
|
||||
(concat test-line " =y= =y= end")
|
||||
(concat test-line " {{{results(=y=)}}} end")
|
||||
(buffer-substring-no-properties (point-at-bol) (point-at-eol))))
|
||||
(forward-char)
|
||||
(forward-char 3)
|
||||
(should-error (org-ctrl-c-ctrl-c)))))
|
||||
|
||||
(ert-deftest test-org-babel/inline-src_blk-manual-results-replace ()
|
||||
|
@ -371,15 +371,14 @@ this is simple"
|
|||
(concat "\n" test-line)
|
||||
(should-error (org-ctrl-c-ctrl-c))
|
||||
(goto-char (point-max))
|
||||
(should-error (org-ctrl-c-ctrl-c))
|
||||
(org-ctrl-c-ctrl-c)
|
||||
(beginning-of-line)
|
||||
(should-error (org-ctrl-c-ctrl-c))
|
||||
(forward-char) (org-ctrl-c-ctrl-c)
|
||||
(should (string=
|
||||
(concat test-line " =x=")
|
||||
(concat test-line " {{{results(=x=)}}}")
|
||||
(buffer-substring-no-properties
|
||||
(point-at-bol) (point-at-eol))))))
|
||||
|
||||
(let ((test-line (concat " Some text prior to block "
|
||||
"src_emacs-lisp[:results replace]{ \"y\" }"))
|
||||
(org-babel-inline-result-wrap "=%s="))
|
||||
|
@ -388,13 +387,13 @@ this is simple"
|
|||
(insert (concat "\n" test-line " end"))
|
||||
(re-search-backward "src") (org-ctrl-c-ctrl-c)
|
||||
(should (string=
|
||||
(concat test-line " =y= end")
|
||||
(concat test-line " {{{results(=y=)}}} end")
|
||||
(buffer-substring-no-properties (point-at-bol) (point-at-eol))))
|
||||
(re-search-forward "\" ") (org-ctrl-c-ctrl-c)
|
||||
(should (string=
|
||||
(concat test-line " =y= =y= end")
|
||||
(concat test-line " {{{results(=y=)}}} end")
|
||||
(buffer-substring-no-properties (point-at-bol) (point-at-eol))))
|
||||
(forward-char)
|
||||
(forward-char 3)
|
||||
(should-error (org-ctrl-c-ctrl-c)))))
|
||||
|
||||
(ert-deftest test-org-babel/inline-src_blk-results-silent ()
|
||||
|
@ -403,9 +402,7 @@ this is simple"
|
|||
(org-ctrl-c-ctrl-c)
|
||||
(should (string= test-line
|
||||
(buffer-substring-no-properties
|
||||
(point-at-bol) (point-at-eol))))
|
||||
(end-of-buffer)
|
||||
(should-error (org-ctrl-c-ctrl-c))))
|
||||
(point-at-bol) (point-at-eol))))))
|
||||
(let ((test-line (concat " Some text prior to block src_emacs-lisp"
|
||||
"[ :results silent ]{ \"y\" }")))
|
||||
(org-test-with-temp-text
|
||||
|
@ -420,7 +417,7 @@ this is simple"
|
|||
(should (string= (concat test-line " end")
|
||||
(buffer-substring-no-properties
|
||||
(point-at-bol) (point-at-eol))))
|
||||
(forward-char)
|
||||
(forward-char 2)
|
||||
(should-error (org-ctrl-c-ctrl-c)))))
|
||||
|
||||
(ert-deftest test-org-babel/inline-src_blk-results-raw ()
|
||||
|
@ -440,7 +437,7 @@ this is simple"
|
|||
(should (string= (concat test-line " the the end")
|
||||
(buffer-substring-no-properties
|
||||
(point-at-bol) (point-at-eol))))
|
||||
(forward-char)
|
||||
(forward-char 2)
|
||||
(should-error (org-ctrl-c-ctrl-c)))))
|
||||
|
||||
(ert-deftest test-org-babel/inline-src_blk-results-file ()
|
||||
|
@ -448,7 +445,7 @@ this is simple"
|
|||
(org-test-with-temp-text
|
||||
test-line
|
||||
(org-ctrl-c-ctrl-c)
|
||||
(should (string= (concat test-line " [[file:~/test-file]]")
|
||||
(should (string= (concat test-line " {{{results([[file:~/test-file]])}}}")
|
||||
(buffer-substring-no-properties
|
||||
(point-min) (point-max)))))))
|
||||
|
||||
|
@ -458,7 +455,7 @@ this is simple"
|
|||
(org-test-with-temp-text
|
||||
test-line
|
||||
(org-ctrl-c-ctrl-c)
|
||||
(should (string= (concat test-line " =\"x\"=")
|
||||
(should (string= (concat test-line " {{{results(=\"x\"=)}}}")
|
||||
(buffer-substring-no-properties
|
||||
(point-min) (point-max)))))))
|
||||
|
||||
|
@ -468,7 +465,7 @@ this is simple"
|
|||
(org-test-with-temp-text
|
||||
test-line
|
||||
(org-ctrl-c-ctrl-c)
|
||||
(should (string= (concat test-line " =\"x\"=")
|
||||
(should (string= (concat test-line " {{{results(=\"x\"=)}}}")
|
||||
(buffer-substring-no-properties
|
||||
(point-min) (point-max)))))))
|
||||
|
||||
|
|
Loading…
Reference in New Issue