1 ;;; test-ob.el --- tests for ob.el
3 ;; Copyright (c) 2010-2015 Eric Schulte
4 ;; Authors: Eric Schulte, Martyn Jago
6 ;; This file is not part of GNU Emacs.
8 ;; This program is free software; you can redistribute it and/or modify
9 ;; it under the terms of the GNU General Public License as published by
10 ;; the Free Software Foundation, either version 3 of the License, or
11 ;; (at your option) any later version.
13 ;; This program is distributed in the hope that it will be useful,
14 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
15 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 ;; GNU General Public License for more details.
18 ;; You should have received a copy of the GNU General Public License
19 ;; along with this program. If not, see <http://www.gnu.org/licenses/>.
23 (ert-deftest test-org-babel
/indented-cached-org-bracket-link
()
24 "When the result of a source block is a cached indented link it
25 should still return the link."
27 (let ((default-directory temporary-file-directory
))
28 (org-test-with-temp-text
31 #+<point>BEGIN_SRC emacs-lisp :file test.txt :cache yes
34 ;; Execute twice as the first time creates the cache.
35 (org-babel-execute-src-block)
36 (string= (concat default-directory
"test.txt")
37 (org-babel-execute-src-block))))))
39 (ert-deftest test-org-babel
/multi-line-header-regexp
()
40 (should(equal "^[ \t]*#\\+headers?:[ \t]*\\([^\n]*\\)$"
41 org-babel-multi-line-header-regexp
))
42 ;;TODO can be optimised - and what about blah4 blah5 blah6?
44 org-babel-multi-line-header-regexp
45 " \t #+headers: blah1 blah2 blah3 \t\n\t\n blah4 blah5 blah6 \n"))
48 "blah1 blah2 blah3 \t"
51 " \t #+headers: blah1 blah2 blah3 \t\n\t\n blah4 blah5 blah6 \n")))
53 ;;TODO Check - should this fail?
55 (not (org-test-string-exact-match
56 org-babel-multi-line-header-regexp
57 " \t #+headers : blah1 blah2 blah3 \t\n\t\n blah4 blah5 blah6 \n"))))
59 (ert-deftest test-org-babel
/src-block-regexp
()
62 "#+begin_src language -n-r-a-b -c :argument-1 yes :argument-2 no\n"
63 "echo this is a test\n"
64 "echo Currently in ' $PWD\n"
67 (flags "-n-r-a-b -c ")
68 (arguments ":argument-1 yes :argument-2 no")
69 (body "echo this is a test\necho Currently in ' $PWD\n"))
70 (should (string-match org-babel-src-block-regexp test-block
))
71 (should (string-match org-babel-src-block-regexp
(upcase test-block
)))
72 (should (equal language
(match-string 2 test-block
)))
73 ;;TODO Consider refactoring
74 (should (equal flags
(match-string 3 test-block
)))
75 (should (equal arguments
(match-string 4 test-block
)))
76 (should (equal body
(match-string 5 test-block
)))
78 (should (org-test-string-exact-match
79 org-babel-src-block-regexp
80 (replace-regexp-in-string flags
"" test-block
)))
82 (should (org-test-string-exact-match
83 org-babel-src-block-regexp
84 (replace-regexp-in-string arguments
"" test-block
)))
85 ;; should be valid with no body
86 (should (org-test-string-exact-match
87 org-babel-src-block-regexp
88 (replace-regexp-in-string body
"" test-block
)))))
90 (ert-deftest test-org-babel
/get-header
()
91 (should (not (org-babel-get-header
92 org-babel-default-header-args
:doesnt-exist
)))
93 (should(equal '((:session .
"none"))
95 org-babel-default-header-args
:session
)))
96 (should(equal '((:session .
"none"))
98 org-babel-default-header-args
:session nil
)))
99 (should (not (org-babel-get-header
100 org-babel-default-header-args
:SESSION
)))
101 (should (equal '((:tangle .
"no"))
102 (org-babel-get-header
103 org-babel-default-header-args
:tangle
)))
104 ;; with OTHERS option
105 (should (equal org-babel-default-header-args
106 (org-babel-get-header
107 org-babel-default-header-args
:doesnt-exist
'others
)))
108 (should (equal org-babel-default-header-args
109 (org-babel-get-header
110 org-babel-default-header-args nil
'others
)))
113 (org-babel-get-header
114 org-babel-default-header-args
:noweb
'others
)))))
116 (ert-deftest test-org-babel
/default-inline-header-args
()
118 '((:session .
"none")
119 (:results .
"replace")
120 (:exports .
"results")
122 org-babel-default-inline-header-args
)))
124 (ert-deftest ob-test
/org-babel-combine-header-arg-lists
()
125 (let ((results (org-babel-combine-header-arg-lists
128 (baz .
((foo bar
) (baz)))
129 (qux .
((foo bar baz qux
)))
130 (quux .
((foo bar
))))
134 (dolist (pair '((foo .
:any
)
138 (qux .
((foo bar baz qux
)))))
139 (should (equal (cdr pair
)
140 (cdr (assoc (car pair
) results
)))))))
142 ;;; ob-get-src-block-info
143 (ert-deftest test-org-babel
/get-src-block-info-language
()
144 (org-test-at-marker nil org-test-file-ob-anchor
145 (let ((info (org-babel-get-src-block-info)))
146 (should (string= "emacs-lisp" (nth 0 info
))))))
148 (ert-deftest test-org-babel
/get-src-block-info-body
()
149 (org-test-at-marker nil org-test-file-ob-anchor
150 (let ((info (org-babel-get-src-block-info)))
151 (should (string-match (regexp-quote org-test-file-ob-anchor
)
154 (ert-deftest test-org-babel
/get-src-block-info-tangle
()
155 (org-test-at-marker nil org-test-file-ob-anchor
156 (let ((info (org-babel-get-src-block-info)))
157 (should (string= "no" (cdr (assoc :tangle
(nth 2 info
))))))))
159 (ert-deftest test-org-babel
/elisp-in-header-arguments
()
160 "Test execution of elisp forms in header arguments."
161 (org-test-with-temp-text-in-file "
163 * elisp forms in header arguments
167 #+begin_src emacs-lisp
170 (goto-char (point-min))
171 (org-babel-next-src-block)
172 (let ((info (org-babel-get-src-block-info)))
173 (should (= 42 (org-babel-execute-src-block))))))
175 (ert-deftest test-org-babel
/simple-named-code-block
()
176 "Test that simple named code blocks can be evaluated."
177 (org-test-with-temp-text-in-file "
179 #+name: i-have-a-name
180 #+begin_src emacs-lisp
183 (org-babel-next-src-block 1)
184 (should (= 42 (org-babel-execute-src-block)))))
186 (ert-deftest test-org-babel
/simple-variable-resolution
()
187 "Test that simple variable resolution is working."
188 (org-test-with-temp-text-in-file "
191 #+begin_src emacs-lisp
195 #+begin_src emacs-lisp :var four=four
199 (org-babel-next-src-block 2)
200 (should (= 4 (org-babel-execute-src-block)))
202 (should (string= ": 4" (buffer-substring
206 (ert-deftest test-org-babel
/multi-line-header-arguments
()
207 "Test that multi-line header arguments and can be read."
208 (org-test-with-temp-text-in-file "
210 #+headers: :var letters='(a b c d e f g)
211 #+begin_src emacs-lisp :var numbers='(1 2 3 4 5 6 7)
213 (defalias 'my-map (if (org-version-check \"24.2.50\" \"cl\" :predicate)
216 (my-map 'list #'list numbers letters)
219 (org-babel-next-src-block)
220 (let ((results (org-babel-execute-src-block)))
221 (should(equal 'a
(cadr (assoc 1 results
))))
222 (should(equal 'd
(cadr (assoc 4 results
)))))))
224 (ert-deftest test-org-babel
/parse-header-args
()
225 (org-test-with-temp-text-in-file "
227 #+begin_src example-lang :session :results output :var num=9
231 (org-babel-next-src-block)
232 (let* ((info (org-babel-get-src-block-info))
233 (params (nth 2 info
)))
234 (message "%S" params
)
235 (should (equal "example-lang" (nth 0 info
)))
236 (should (string= "the body" (org-babel-trim (nth 1 info
))))
237 (should-not (member '(:session\ \ \ \
) params
))
238 (should (equal '(:session
) (assoc :session params
)))
239 (should (equal '(:result-type . output
) (assoc :result-type params
)))
240 (should (equal '(num .
9) (cdr (assoc :var params
)))))))
242 (ert-deftest test-org-babel
/parse-header-args2
()
243 (org-test-with-temp-text-in-file "
245 * resolving sub-trees as references
247 #+begin_src emacs-lisp :var text=d4faa7b3-072b-4dcf-813c-dd7141c633f3
251 #+begin_src org :noweb yes
253 <<d4faa7b3-072b-4dcf-813c-dd7141c633f3>>
256 ** simple subtree with custom ID
258 :CUSTOM_ID: simple-subtree
262 (should (string-match (regexp-quote "this is simple")
263 (org-babel-ref-resolve "simple-subtree")))
264 (org-babel-next-src-block)
265 (should (= 14 (org-babel-execute-src-block)))))
267 (ert-deftest test-org-babel
/inline-src-blocks
()
270 (org-test-with-temp-text
271 "In the middle <point>src_emacs-lisp{(+ 0 1)} of a line"
272 (org-babel-execute-src-block))))
275 (org-test-with-temp-text
276 "One at the end of a line: <point>src_emacs-lisp{(+ 1 1)}"
277 (org-babel-execute-src-block))))
280 (org-test-with-temp-text
281 "src_emacs-lisp{(+ 2 1)} at the beginning of a line."
282 (org-babel-execute-src-block))))
285 (org-test-with-temp-text
286 "In the middle <point>src_emacs-lisp[:results silent\
287 :exports code]{(+ 3 1)} of a line"
288 (org-babel-execute-src-block))))
291 (org-test-with-temp-text
292 "One at the end of a line: <point>src_emacs-lisp[:results silent\
293 :exports code]{(+ 4 1)}"
294 (org-babel-execute-src-block))))
297 (org-test-with-temp-text
298 "src_emacs-lisp[:results silent :exports code]{(+ 5 1)}\
299 at the beginning of a line."
300 (org-babel-execute-src-block))))
303 (org-test-with-temp-text
304 "One also evaluated: <point>src_emacs-lisp[:exports both\
305 :results silent]{(+ 6 1)}"
306 (org-babel-execute-src-block)))))
308 (ert-deftest test-org-babel
/org-babel-get-inline-src-block-matches
()
309 (flet ((test-at-id (id)
312 (let ((test-point (point)))
313 (should (fboundp 'org-babel-get-inline-src-block-matches
))
314 (should (re-search-forward "src_" nil t
)) ;; 1
315 (should (org-babel-get-inline-src-block-matches))
316 (should (re-search-forward " b" nil
(point-at-bol))) ;; 1
317 (should-not (org-babel-get-inline-src-block-matches))
318 (should (re-search-forward "in" nil t
)) ;; 2
319 (should-not (org-babel-get-inline-src-block-matches))
320 (should (re-search-forward "echo" nil t
)) ;; 2
321 (should (org-babel-get-inline-src-block-matches))
322 (should (re-search-forward "blocks" nil t
)) ;; 3
323 (backward-char 7) ;; 3
324 (should (org-babel-get-inline-src-block-matches))
326 (should-not (org-babel-get-inline-src-block-matches))
327 (should (re-search-forward ":results" nil t
)) ;; 4
328 (should (org-babel-get-inline-src-block-matches))
330 (should-not (org-babel-get-inline-src-block-matches))))))
331 (test-at-id "0D0983D4-DE33-400A-8A05-A225A567BC74")
332 (test-at-id "d55dada7-de0e-4340-8061-787cccbedee5")))
334 (ert-deftest test-org-babel
/inline-src_blk-default-results-replace-line-1
()
335 (let ((test-line "src_sh{echo 1}")
336 (org-babel-inline-result-wrap "=%s="))
337 ;; src_ at bol line 1...
338 (org-test-with-temp-text
340 (goto-char (point-min)) (org-babel-execute-maybe)
342 (concat test-line
" {{{results(=1=)}}}")
343 (buffer-substring-no-properties (point-at-bol) (point-at-eol))))
344 (forward-char) (org-babel-execute-maybe)
346 (concat test-line
" {{{results(=1=)}}}")
347 (buffer-substring-no-properties (point-at-bol) (point-at-eol))))
348 (re-search-forward "{{{")
349 ;;(should-error (org-ctrl-c-ctrl-c))
350 (backward-char 4) ;; last char of block body
351 (org-babel-execute-maybe)
353 (concat test-line
" {{{results(=1=)}}}")
354 (buffer-substring-no-properties (point-at-bol) (point-at-eol)))))
355 ;; src_ follows space line 1...
356 (let ((test-line " src_emacs-lisp{ 1 }"))
357 (org-test-with-temp-text
359 (should-error (org-ctrl-c-ctrl-c))
360 (forward-char) (org-babel-execute-maybe)
362 (concat test-line
" {{{results(=1=)}}}")
363 (buffer-substring-no-properties (point-at-bol) (point-at-eol))))
364 (re-search-forward "{ 1 ") (org-babel-execute-maybe)
366 (concat test-line
" {{{results(=1=)}}}")
367 (buffer-substring-no-properties (point-at-bol) (point-at-eol))))
369 (should-error (org-ctrl-c-ctrl-c))
372 (ert-deftest test-org-babel
/inline-src_blk-default-results-replace-line-2
()
373 ;; src_ at bol line 2...
374 (let ((test-line " src_emacs-lisp{ \"x\" }")
375 (org-babel-inline-result-wrap "=%s="))
376 (org-test-with-temp-text
377 (concat "\n" test-line
)
378 (should-error (org-ctrl-c-ctrl-c))
379 (goto-char (point-min))
380 (should-error (org-ctrl-c-ctrl-c))
382 (should-error (org-ctrl-c-ctrl-c))
383 (forward-char) (org-babel-execute-maybe)
385 (concat test-line
" {{{results(=x=)}}}")
386 (buffer-substring-no-properties
387 (point-at-bol) (point-at-eol))))))
388 (let ((test-line "Some text prior to block src_emacs-lisp{ \"y\" }")
389 (org-babel-inline-result-wrap "=%s="))
390 (org-test-with-temp-text
392 (goto-char (point-max))
393 (insert (concat "\n" test-line
" end"))
394 (re-search-backward "src") (org-babel-execute-maybe)
396 (concat test-line
" {{{results(=y=)}}} end")
397 (buffer-substring-no-properties (point-at-bol) (point-at-eol))))
398 (re-search-forward "\" ") (org-babel-execute-maybe)
400 (concat test-line
" {{{results(=y=)}}} end")
401 (buffer-substring-no-properties (point-at-bol) (point-at-eol))))
403 (should-error (org-ctrl-c-ctrl-c)))))
405 (ert-deftest test-org-babel
/inline-src_blk-manual-results-replace
()
406 (let ((test-line " src_emacs-lisp[:results replace]{ \"x\" }")
407 (org-babel-inline-result-wrap "=%s="))
408 (org-test-with-temp-text
409 (concat "\n" test-line
)
410 (should-error (org-ctrl-c-ctrl-c))
411 (goto-char (point-max))
412 (org-babel-execute-maybe)
414 (should-error (org-ctrl-c-ctrl-c))
415 (forward-char) (org-babel-execute-maybe)
417 (concat test-line
" {{{results(=x=)}}}")
418 (buffer-substring-no-properties
419 (point-at-bol) (point-at-eol))))))
420 (let ((test-line (concat " Some text prior to block "
421 "src_emacs-lisp[:results replace]{ \"y\" }"))
422 (org-babel-inline-result-wrap "=%s="))
423 (org-test-with-temp-text test-line
424 (goto-char (point-max))
425 (insert (concat "\n" test-line
" end"))
426 (re-search-backward "src") (org-babel-execute-maybe)
428 (concat test-line
" {{{results(=y=)}}} end")
429 (buffer-substring-no-properties (point-at-bol) (point-at-eol))))
430 (re-search-forward "\" ") (org-babel-execute-maybe)
432 (concat test-line
" {{{results(=y=)}}} end")
433 (buffer-substring-no-properties (point-at-bol) (point-at-eol))))
435 (should-error (org-ctrl-c-ctrl-c)))))
437 (ert-deftest test-org-babel
/inline-src_blk-results-silent
()
438 (let ((test-line "src_emacs-lisp[ :results silent ]{ \"x\" }"))
439 (org-test-with-temp-text test-line
440 (org-babel-execute-maybe)
441 (should (string= test-line
442 (buffer-substring-no-properties
443 (point-at-bol) (point-at-eol))))))
444 (let ((test-line (concat " Some text prior to block src_emacs-lisp"
445 "[ :results silent ]{ \"y\" }")))
446 (org-test-with-temp-text
448 (goto-char (point-max))
449 (insert (concat "\n" test-line
" end"))
450 (re-search-backward "src_") (org-babel-execute-maybe)
451 (should (string= (concat test-line
" end")
452 (buffer-substring-no-properties
453 (point-at-bol) (point-at-eol))))
454 (re-search-forward "\" ") (org-babel-execute-maybe)
455 (should (string= (concat test-line
" end")
456 (buffer-substring-no-properties
457 (point-at-bol) (point-at-eol))))
459 (should-error (org-ctrl-c-ctrl-c)))))
461 (ert-deftest test-org-babel
/inline-src_blk-results-raw
()
462 (let ((test-line "src_emacs-lisp[ :results raw ]{ \"x\" }"))
463 (org-test-with-temp-text test-line
464 (org-babel-execute-maybe)
465 (should (string= (concat test-line
" x")
467 (let ((test-line (concat " Some text prior to block "
468 "src_emacs-lisp[ :results raw ]{ \"the\" }")))
469 (org-test-with-temp-text (concat test-line
" end")
470 (re-search-forward "src_") (org-babel-execute-maybe)
471 (should (string= (concat test-line
" the end")
472 (buffer-substring-no-properties
473 (point-at-bol) (point-at-eol))))
474 (re-search-forward "\" ") (org-babel-execute-maybe)
475 (should (string= (concat test-line
" the the end")
476 (buffer-substring-no-properties
477 (point-at-bol) (point-at-eol))))
479 (should-error (org-ctrl-c-ctrl-c)))))
481 (ert-deftest test-org-babel
/inline-src_blk-results-file
()
482 (let ((test-line "src_emacs-lisp[ :results file ]{ \"~/test-file\" }"))
483 (org-test-with-temp-text
485 (org-babel-execute-maybe)
486 (should (string= (concat test-line
" {{{results([[file:~/test-file]])}}}")
487 (buffer-substring-no-properties
488 (point-min) (point-max)))))))
490 (ert-deftest test-org-babel
/inline-src_blk-results-scalar
()
491 (let ((test-line "src_emacs-lisp[ :results scalar ]{ \"x\" }")
492 (org-babel-inline-result-wrap "=%s="))
493 (org-test-with-temp-text
495 (org-babel-execute-maybe)
496 (should (string= (concat test-line
" {{{results(=\"x\"=)}}}")
497 (buffer-substring-no-properties
498 (point-min) (point-max)))))))
500 (ert-deftest test-org-babel
/inline-src_blk-results-verbatim
()
501 (let ((test-line "src_emacs-lisp[ :results verbatim ]{ \"x\" }")
502 (org-babel-inline-result-wrap "=%s="))
503 (org-test-with-temp-text
505 (org-babel-execute-maybe)
506 (should (string= (concat test-line
" {{{results(=\"x\"=)}}}")
507 (buffer-substring-no-properties
508 (point-min) (point-max)))))))
510 (ert-deftest test-org-babel
/combining-scalar-and-raw-result-types
()
511 (org-test-with-temp-text-in-file "
513 #+begin_src sh :results scalar
514 echo \"[[file:./cv.cls]]\"
520 #+begin_src sh :results raw scalar
521 echo \"[[file:./cv.cls]]\"
524 (flet ((next-result ()
525 (org-babel-next-src-block)
526 (org-babel-execute-src-block)
527 (goto-char (org-babel-where-is-src-block-result))
529 (goto-char (point-min))
531 (should (org-babel-in-example-or-verbatim))
533 (should (not (org-babel-in-example-or-verbatim))))))
535 (ert-deftest test-org-babel
/no-defaut-value-for-var
()
536 "Test that the absence of a default value for a variable DOES THROW
538 (org-test-at-id "f2df5ba6-75fa-4e6b-8441-65ed84963627"
539 (org-babel-next-src-block)
541 (should-error (org-babel-execute-src-block) :type
'error
)))
545 "Variable \"x\" must be assigned a default value")
548 (ert-deftest test-org-babel
/just-one-results-block
()
549 "Test that evaluating two times the same code block does not result in a
550 duplicate results block."
551 (org-test-with-temp-text "#+begin_src sh\necho Hello\n#+end_src\n"
552 (org-babel-execute-src-block)
553 (org-babel-execute-src-block) ; second code block execution
554 (should (search-forward "Hello")) ; the string inside the source code block
555 (should (search-forward "Hello")) ; the same string in the results block
556 (should-error (search-forward "Hello"))))
558 (ert-deftest test-org-babel
/nested-code-block
()
559 "Test nested code blocks inside code blocks don't cause problems."
561 (string= "#+begin_src emacs-lisp\n 'foo\n#+end_src"
562 (org-test-with-temp-text "#+begin_src org :results silent
563 ,#+begin_src emacs-lisp
567 (let ((org-edit-src-content-indentation 2)
568 (org-src-preserve-indentation nil
))
569 (org-babel-execute-src-block))))))
571 (ert-deftest test-org-babel
/partial-nested-code-block
()
572 "Test nested code blocks inside code blocks don't cause problems."
573 (org-test-with-temp-text "#+begin_src org :results silent
574 ,#+begin_src emacs-lisp
576 (should (string= "#+begin_src emacs-lisp" (org-babel-execute-src-block)))))
578 (ert-deftest test-ob
/does-not-replace-a-block-with-the-results
()
579 (org-test-with-temp-text "#+NAME: foo
580 #+BEGIN_SRC emacs-lisp
583 (org-babel-next-src-block 1)
584 (should (eq 'foo
(org-babel-execute-src-block)))
585 (goto-char (point-min))
586 (org-babel-next-src-block 1)
587 (should (looking-at org-babel-src-block-regexp
))))
589 (ert-deftest test-ob
/catches-all-references
()
590 (org-test-with-temp-text "
591 #+NAME: literal-example
597 #+NAME: read-literal-example
598 #+BEGIN_SRC emacs-lisp :var x=literal-example
599 (concatenate 'string x \" for me.\")
601 (org-babel-next-src-block 1)
602 (should (string= (org-babel-execute-src-block)
603 "A literal example\non two lines\n for me."))))
605 (ert-deftest test-ob
/resolve-code-blocks-before-data-blocks
()
606 (org-test-with-temp-text "
611 #+begin_src emacs-lisp
615 #+begin_src emacs-lisp :var foo=foo
618 (org-babel-next-src-block 2)
619 (should (string= (org-babel-execute-src-block) "baz"))))
621 (ert-deftest test-ob
/do-not-resolve-to-partial-names-data
()
622 (org-test-with-temp-text "
631 #+begin_src emacs-lisp :var x=base
634 (org-babel-next-src-block 1)
635 (should (equal (org-babel-execute-src-block) '((3) (4))))))
637 (ert-deftest test-ob
/do-not-resolve-to-partial-names-code
()
638 (org-test-with-temp-text "
640 #+begin_src emacs-lisp
645 #+begin_src emacs-lisp
649 #+begin_src emacs-lisp :var x=base
652 (org-babel-next-src-block 3)
653 (should (equal (org-babel-execute-src-block) "foo"))))
655 (ert-deftest test-ob
/allow-spaces-around-
=-in-var-specs
()
656 (org-test-with-temp-text "#+begin_src emacs-lisp :var a = 1 b = 2 c= 3 d =4
660 (should (= 10 (org-babel-execute-src-block)))))
662 (ert-deftest test-ob
/org-babel-update-intermediate
()
663 (org-test-with-temp-text "#+name: foo
664 #+begin_src emacs-lisp
671 #+begin_src emacs-lisp :var it=foo
674 (let ((org-babel-update-intermediate nil
))
675 (goto-char (point-min))
676 (org-babel-next-src-block 2)
677 (should (= 3 (org-babel-execute-src-block)))
678 (goto-char (point-min))
680 (should (looking-at ": 4")))
681 (let ((org-babel-update-intermediate t
))
682 (goto-char (point-min))
683 (org-babel-next-src-block 2)
684 (should (= 3 (org-babel-execute-src-block)))
685 (goto-char (point-min))
687 (should (looking-at ": 2")))))
689 (ert-deftest test-ob
/eval-header-argument
()
690 (flet ((check-eval (eval runp
)
691 (org-test-with-temp-text (format "#+begin_src emacs-lisp :eval %s
694 (let ((foo :not-run
))
696 (progn (should (org-babel-execute-src-block))
697 (should (eq foo
:evald
)))
698 (progn (should-not (org-babel-execute-src-block))
699 (should-not (eq foo
:evald
))))))))
700 (check-eval "never" nil
)
701 (check-eval "no" nil
)
702 (check-eval "never-export" t
)
703 (check-eval "no-export" t
)
704 (let ((org-babel-exp-reference-buffer (current-buffer)))
705 (check-eval "never" nil
)
706 (check-eval "no" nil
)
707 (check-eval "never-export" nil
)
708 (check-eval "no-export" nil
))))
710 (ert-deftest test-ob
/noweb-expansion-1
()
711 (org-test-with-temp-text "#+begin_src sh :results output :tangle yes
719 (should (string= (org-babel-expand-noweb-references) "bar"))))
721 (ert-deftest test-ob
/noweb-expansion-2
()
722 (org-test-with-temp-text "#+begin_src sh :results output :tangle yes
727 #+begin_src sh :noweb-sep \"\"
731 #+begin_src sh :noweb-ref foo :noweb-sep \"\"
734 (should (string= (org-babel-expand-noweb-references) "barbaz"))))
736 (ert-deftest test-ob
/splitting-variable-lists-in-references
()
737 (org-test-with-temp-text ""
738 (should (= 1 (length (org-babel-ref-split-args
739 "a=\"this, no work\""))))
740 (should (= 2 (length (org-babel-ref-split-args
741 "a=\"this, no work\", b=1"))))))
743 (ert-deftest test-ob
/org-babel-balanced-split
()
745 '(":a 1" "b [2 3]" "c (4 :d (5 6))")
746 (org-babel-balanced-split ":a 1 :b [2 3] :c (4 :d (5 6))"
749 (ert-deftest test-ob
/commented-last-block-line-no-var
()
750 (org-test-with-temp-text-in-file "
751 #+begin_src emacs-lisp
754 (org-babel-next-src-block)
755 (org-babel-execute-maybe)
756 (should (re-search-forward "\\#\\+results:" nil t
))
761 (buffer-substring-no-properties (point-at-bol) (point-at-eol)))))
762 (org-test-with-temp-text-in-file "
763 #+begin_src emacs-lisp
766 (org-babel-next-src-block)
767 (org-babel-execute-maybe)
768 (should (re-search-forward "\\#\\+results:" nil t
))
773 (buffer-substring-no-properties (point-at-bol) (point-at-eol))))))
775 (ert-deftest test-ob
/commented-last-block-line-with-var
()
776 (org-test-with-temp-text-in-file "
777 #+begin_src emacs-lisp :var a=1
780 (org-babel-next-src-block)
781 (org-babel-execute-maybe)
782 (re-search-forward "\\#\\+results:" nil t
)
786 (buffer-substring-no-properties (point-at-bol) (point-at-eol)))))
787 (org-test-with-temp-text-in-file "
788 #+begin_src emacs-lisp :var a=2
791 (org-babel-next-src-block)
792 (org-babel-execute-maybe)
793 (re-search-forward "\\#\\+results:" nil t
)
797 (buffer-substring-no-properties (point-at-bol) (point-at-eol))))))
799 (ert-deftest test-ob
/org-babel-insert-result--improper-lists
()
800 "Test `org-babel-insert-result' with improper lists."
801 ;; Do not error when output is an improper list.
803 (org-test-with-temp-text
805 <point>#+BEGIN_SRC emacs-lisp
809 (org-babel-execute-maybe) t
)))
811 (ert-deftest test-ob
/remove-inline-result
()
812 "Test `org-babel-remove-inline-result' honors whitespace."
814 ((inline-sb "src_emacs-lisp{(+ 1 2)}")
815 (inline-res " {{{results(=3=)}}}")
816 (inline-sb-dot (concat inline-sb
"."))
817 (inline-sb-res-dot (concat inline-sb inline-res
".")))
818 (org-test-with-temp-text
819 ;; Insert inline_src_block followed by dot.
821 ;; Insert result before dot.
822 (org-babel-execute-maybe)
823 (should (string= inline-sb-res-dot
824 (buffer-substring-no-properties
825 (point-at-bol) (point-at-eol))))
826 ;; Delete whitespace and result.
827 (org-babel-remove-inline-result)
828 (should (string= inline-sb-dot
829 (buffer-substring-no-properties
830 (point-at-bol) (point-at-eol))))
831 ;; Add whitespace and result before dot.
832 (search-forward inline-sb
)
833 (insert " " inline-res
)
834 (goto-char (point-at-bol))
835 ;; Remove whitespace and result.
836 (org-babel-remove-inline-result)
837 (should (string= inline-sb-dot
838 (buffer-substring-no-properties
839 (point-at-bol) (point-at-eol))))
840 ;; Add whitespace before dot.
841 (search-forward inline-sb
)
843 (goto-char (point-at-bol))
844 ;; Add result before whitespace.
845 (org-babel-execute-maybe)
846 ;; Remove result - leave trailing whitespace and dot.
847 (org-babel-remove-inline-result)
848 (should (string= (concat inline-sb
" .")
849 (buffer-substring-no-properties
850 (point-at-bol) (point-at-eol)))))))
852 (defun test-ob-verify-result-and-removed-result (result buffer-text
)
853 "Test helper function to test `org-babel-remove-result'.
854 A temp buffer is populated with BUFFER-TEXT, the first block is executed,
855 and the result of execution is verified against RESULT.
857 The block is actually executed /twice/ to ensure result
858 replacement happens correctly."
859 (org-test-with-temp-text
861 (org-babel-next-src-block) (org-babel-execute-maybe) (org-babel-execute-maybe)
862 (should (re-search-forward "\\#\\+results:" nil t
))
864 (should (string= result
865 (buffer-substring-no-properties
867 (- (point-max) 16))))
868 (org-babel-previous-src-block) (org-babel-remove-result)
869 (should (string= buffer-text
870 (buffer-substring-no-properties
871 (point-min) (point-max))))))
873 (ert-deftest test-ob
/org-babel-remove-result--results-default
()
874 "Test `org-babel-remove-result' with default :results."
875 (mapcar (lambda (language)
876 (test-ob-verify-result-and-removed-result
879 "* org-babel-remove-result
880 #+begin_src " language
"
884 '("sh" "emacs-lisp")))
886 (ert-deftest test-ob
/org-babel-remove-result--results-list
()
887 "Test `org-babel-remove-result' with :results list."
888 (test-ob-verify-result-and-removed-result
894 "* org-babel-remove-result
895 #+begin_src emacs-lisp :results list
901 (ert-deftest test-ob
/org-babel-results-indented-wrap
()
902 "Ensure that wrapped results are inserted correction when indented.
903 If not inserted correctly then the second evaluation will fail
904 trying to find the :END: marker."
905 (org-test-with-temp-text
907 #+begin_src sh :results file wrap
910 (org-babel-next-src-block 1)
911 (org-babel-execute-src-block)
912 (org-babel-execute-src-block)))
914 (ert-deftest test-ob
/file-desc-header-argument
()
915 "Test that the :file-desc header argument is used."
916 (org-test-with-temp-text "#+begin_src emacs-lisp :results file :file-desc bar
920 #+begin_src emacs-lisp :results file :file-desc
923 (org-babel-execute-src-block)
924 (org-babel-next-src-block 1)
925 (org-babel-execute-src-block)
926 (goto-char (point-min))
927 (should (search-forward "[[file:foo][bar]]" nil t
))
928 (should (search-forward "[[file:foo][foo]]" nil t
))))
930 (ert-deftest test-ob
/org-babel-remove-result--results-pp
()
931 "Test `org-babel-remove-result' with :results pp."
932 (test-ob-verify-result-and-removed-result
933 ": \"I /am/ working!\""
935 "* org-babel-remove-result
936 #+begin_src emacs-lisp :results pp
942 (ert-deftest test-org-babel
/inline-src_blk-preceded-punct-preceded-by-point
()
943 (let ((test-line ".src_emacs-lisp[ :results verbatim ]{ \"x\" }")
944 (org-babel-inline-result-wrap "=%s="))
945 (org-test-with-temp-text
948 (org-babel-execute-maybe)
949 (should (re-search-forward "=\"x\"=" nil t
))
952 (ert-deftest test-ob
/commented-last-block-line-with-var
()
953 (org-test-with-temp-text-in-file "
954 #+begin_src emacs-lisp :var a=1
957 (org-babel-next-src-block)
958 (org-babel-execute-maybe)
959 (re-search-forward "\\#\\+results:" nil t
)
963 (buffer-substring-no-properties (point-at-bol) (point-at-eol)))))
964 (org-test-with-temp-text-in-file "
965 #+begin_src emacs-lisp :var a=2
968 (org-babel-next-src-block)
969 (org-babel-execute-maybe)
970 (re-search-forward "\\#\\+results:" nil t
)
974 (buffer-substring-no-properties (point-at-bol) (point-at-eol))))))
976 (defun test-ob-verify-result-and-removed-result (result buffer-text
)
977 "Test helper function to test `org-babel-remove-result'.
978 A temp buffer is populated with BUFFER-TEXT, the first block is executed,
979 and the result of execution is verified against RESULT.
981 The block is actually executed /twice/ to ensure result
982 replacement happens correctly."
983 (org-test-with-temp-text
985 (org-babel-next-src-block) (org-babel-execute-maybe) (org-babel-execute-maybe)
986 (should (re-search-forward "\\#\\+results:" nil t
))
988 (should (string= result
989 (buffer-substring-no-properties
991 (- (point-max) 16))))
992 (org-babel-previous-src-block) (org-babel-remove-result)
993 (should (string= buffer-text
994 (buffer-substring-no-properties
995 (point-min) (point-max))))))
997 (ert-deftest test-ob
/org-babel-remove-result--results-default
()
998 "Test `org-babel-remove-result' with default :results."
999 (mapcar (lambda (language)
1000 (test-ob-verify-result-and-removed-result
1003 "* org-babel-remove-result
1004 #+begin_src " language
"
1008 '("sh" "emacs-lisp")))
1010 (ert-deftest test-ob
/org-babel-remove-result--results-list
()
1011 "Test `org-babel-remove-result' with :results list."
1012 (test-ob-verify-result-and-removed-result
1018 "* org-babel-remove-result
1019 #+begin_src emacs-lisp :results list
1025 (ert-deftest test-ob
/org-babel-remove-result--results-wrap
()
1026 "Test `org-babel-remove-result' with :results wrap."
1027 (test-ob-verify-result-and-removed-result
1032 "* org-babel-remove-result
1034 #+begin_src emacs-lisp :results wrap
1040 (ert-deftest test-ob
/org-babel-remove-result--results-org
()
1041 "Test `org-babel-remove-result' with :results org."
1042 (test-ob-verify-result-and-removed-result
1049 "* org-babel-remove-result
1050 #+begin_src emacs-lisp :results org
1058 (ert-deftest test-ob
/org-babel-remove-result--results-html
()
1059 "Test `org-babel-remove-result' with :results html."
1060 (test-ob-verify-result-and-removed-result
1062 <head><body></body></head>
1065 "* org-babel-remove-result
1066 #+begin_src emacs-lisp :results html
1067 \"<head><body></body></head>\"
1072 (ert-deftest test-ob
/org-babel-remove-result--results-latex
()
1073 "Test `org-babel-remove-result' with :results latex."
1074 (test-ob-verify-result-and-removed-result
1081 "* org-babel-remove-result
1082 #+begin_src emacs-lisp :results latex
1090 (ert-deftest test-ob
/org-babel-remove-result--results-code
()
1091 "Test `org-babel-remove-result' with :results code."
1093 (test-ob-verify-result-and-removed-result
1094 "#+BEGIN_SRC emacs-lisp
1098 "* org-babel-remove-result
1099 #+begin_src emacs-lisp :results code
1100 (message \"I am working!\")
1105 (ert-deftest test-ob
/org-babel-remove-result--results-pp
()
1106 "Test `org-babel-remove-result' with :results pp."
1107 (test-ob-verify-result-and-removed-result
1108 ": \"I /am/ working!\""
1110 "* org-babel-remove-result
1111 #+begin_src emacs-lisp :results pp
1112 \"I /am/ working!\")
1117 (ert-deftest test-ob
/results-do-not-replace-code-blocks
()
1118 (org-test-with-temp-text "Block two has a space after the name.
1121 #+begin_src emacs-lisp
1126 #+begin_src emacs-lisp
1131 #+begin_src emacs-lisp
1138 (dolist (num '(1 2 3))
1139 ;; execute the block
1140 (goto-char (point-min))
1141 (org-babel-next-src-block num
) (org-babel-execute-src-block)
1142 ;; check the results
1143 (goto-char (point-max))
1144 (move-beginning-of-line 0)
1145 (should (looking-at (format ": %d" num
))))))
1147 (ert-deftest test-ob
/blocks-with-spaces
()
1148 "Test expansion of blocks followed by blank lines."
1150 (equal "#+BEGIN_SRC emacs-lisp
1156 (org-test-with-temp-text "#+BEGIN_SRC emacs-lisp
1159 (let ((org-babel-next-src-block "RESULTS"))
1160 (org-babel-execute-src-block))
1163 (ert-deftest test-ob
/results-in-narrowed-buffer
()
1164 "Test block execution in a narrowed buffer."
1165 ;; If results don't exist, they should be inserted in visible part
1169 "#+BEGIN_SRC emacs-lisp\n(+ 1 2)\n#+END_SRC\n\n#+RESULTS:\n: 3"
1170 (org-test-with-temp-text
1171 "#+BEGIN_SRC emacs-lisp\n(+ 1 2)\n#+END_SRC\n\nParagraph"
1172 (narrow-to-region (point) (save-excursion (forward-line 3) (point)))
1173 (let ((org-babel-results-keyword "RESULTS"))
1174 (org-babel-execute-src-block))
1175 (org-trim (buffer-string)))))
1178 "#+NAME: test\n#+BEGIN_SRC emacs-lisp\n(+ 1 2)\n#+END_SRC\n\n#+RESULTS: test\n: 3"
1179 (org-test-with-temp-text
1180 "#+NAME: test\n#+BEGIN_SRC emacs-lisp\n(+ 1 2)\n#+END_SRC\n\nParagraph"
1181 (narrow-to-region (point) (save-excursion (forward-line 4) (point)))
1182 (let ((org-babel-results-keyword "RESULTS"))
1183 (org-babel-execute-src-block))
1184 (org-trim (buffer-string)))))
1185 ;; Results in visible part of buffer, should be updated here.
1189 #+BEGIN_SRC emacs-lisp
1195 (org-test-with-temp-text
1197 #+BEGIN_SRC emacs-lisp
1205 (narrow-to-region (point) (save-excursion (forward-line 7) (point)))
1206 (let ((org-babel-results-keyword "RESULTS"))
1207 (org-babel-execute-src-block))
1208 (org-trim (buffer-string)))))
1209 ;; Results in invisible part of buffer, should be updated there.
1210 (org-test-with-temp-text
1212 #+BEGIN_SRC emacs-lisp
1220 (narrow-to-region (point) (save-excursion (forward-line 4) (point)))
1221 (let ((org-babel-results-keyword "RESULTS"))
1222 (org-babel-execute-src-block))
1223 (should-not (re-search-forward "^#\\+RESULTS:" nil t
))
1225 (should (should (re-search-forward "^: 3" nil t
)))))
1227 (ert-deftest test-ob
/specific-colnames
()
1228 "Test passing specific column names."
1230 (equal "#+name: input-table
1236 #+begin_src sh :var data=input-table :exports results :colnames '(Rev Author)
1247 (org-test-with-temp-text
1248 "#+name: input-table
1254 #+begin_src sh :var data=input-table :exports results :colnames '(Rev Author)
1258 ;; we should find a code block
1259 (should (re-search-forward org-babel-src-block-regexp nil t
))
1260 (goto-char (match-beginning 0))
1261 ;; now that we've located the code block, it may be evaluated
1262 (let ((org-babel-execute-src-block "RESULTS"))
1263 (org-babel-execute-src-block))
1266 (ert-deftest test-ob
/location-of-header-arg-eval
()
1267 "Test location of header argument evaluation."
1268 (org-test-with-temp-text "
1270 #+begin_src emacs-lisp :var pt=(point)
1274 #+name: bottom-block
1275 #+begin_src emacs-lisp :var pt=top-block()
1279 ;; the value of the second block should be greater than the first
1281 (< (progn (re-search-forward org-babel-src-block-regexp nil t
)
1282 (goto-char (match-beginning 0))
1283 (prog1 (save-match-data (org-babel-execute-src-block))
1284 (goto-char (match-end 0))))
1285 (progn (re-search-forward org-babel-src-block-regexp nil t
)
1286 (goto-char (match-beginning 0))
1287 (org-babel-execute-src-block))))))
1289 (ert-deftest test-ob
/preserve-results-indentation
()
1290 "Preserve indentation when executing a src block."
1293 (org-test-with-temp-text
1294 " #+begin_src emacs-lisp\n (+ 1 1)\n #+end_src"
1295 (org-babel-execute-src-block)
1297 (let ((case-fold-search t
)) (search-forward "#+results:"))
1298 ;; Check if both #+RESULTS: keyword and actual results are
1299 ;; indented by 2 columns.
1300 (list (org-get-indentation)
1301 (progn (forward-line) (org-get-indentation)))))))
1303 (ert-deftest test-ob
/safe-header-args
()
1304 "Detect safe and unsafe header args."
1305 (let ((safe-args '((:cache .
"foo")
1306 (:results .
"output")
1309 (unsafe-args '((:eval .
"yes")
1310 (:results .
"output file")
1312 (malformed-args '((bar .
"foo")
1315 (safe-p (org-babel-header-args-safe-fn org-babel-safe-header-args
)))
1316 (dolist (arg safe-args
)
1317 (should (org-babel-one-header-arg-safe-p arg org-babel-safe-header-args
)))
1318 (dolist (arg unsafe-args
)
1319 (should (not (org-babel-one-header-arg-safe-p arg org-babel-safe-header-args
))))
1320 (dolist (arg malformed-args
)
1321 (should (not (org-babel-one-header-arg-safe-p arg org-babel-safe-header-args
))))
1322 (should (not (funcall safe-p
(append safe-args unsafe-args
))))))
1324 (ert-deftest test-ob
/noweb-expansions-in-cache
()
1325 "Ensure that noweb expansions are expanded before caching."
1326 (let ((noweb-expansions-in-cache-var 0))
1327 (org-test-with-temp-text "
1329 #+begin_src emacs-lisp
1334 #+begin_src emacs-lisp :noweb yes :cache yes
1335 (setq noweb-expansions-in-cache-var
1336 (+ 1 noweb-expansions-in-cache-var))
1337 (concat <<foo>> \" check noweb expansions\")
1340 ;; run the second block to create the cache
1341 (goto-char (point-min))
1342 (re-search-forward (regexp-quote "#+name: bar"))
1343 (should (string= "I said check noweb expansions"
1344 (org-babel-execute-src-block)))
1345 (should (= noweb-expansions-in-cache-var
1))
1346 ;; change the value of the first block
1347 (goto-char (point-min))
1348 (re-search-forward (regexp-quote "said"))
1349 (goto-char (match-beginning 0))
1351 (re-search-forward (regexp-quote "#+name: bar"))
1352 (should (string= "I haven't said check noweb expansions"
1353 (org-babel-execute-src-block)))
1354 (should (= noweb-expansions-in-cache-var
2)))))
1356 (ert-deftest test-org-babel
/file-ext-and-output-dir
()
1357 (org-test-at-id "93573e1d-6486-442e-b6d0-3fedbdc37c9b"
1358 (org-babel-next-src-block)
1359 (should (equal "file-ext-basic.txt"
1360 (cdr (assq :file
(nth 2 (org-babel-get-src-block-info t
))))))
1361 (org-babel-next-src-block)
1362 (should (equal "foo/file-ext-dir-relative.txt"
1363 (cdr (assq :file
(nth 2 (org-babel-get-src-block-info t
))))))
1364 (org-babel-next-src-block)
1365 (should (equal "foo/file-ext-dir-relative-slash.txt"
1366 (cdr (assq :file
(nth 2 (org-babel-get-src-block-info t
))))))
1367 (org-babel-next-src-block)
1368 (should (equal "/tmp/file-ext-dir-absolute.txt"
1369 (cdr (assq :file
(nth 2 (org-babel-get-src-block-info t
))))))
1370 (org-babel-next-src-block)
1371 (should (equal "foo.bar"
1372 (cdr (assq :file
(nth 2 (org-babel-get-src-block-info t
))))))
1373 (org-babel-next-src-block)
1374 (should (equal "xxx/foo.bar"
1375 (cdr (assq :file
(nth 2 (org-babel-get-src-block-info t
))))))
1378 (ert-deftest test-org-babel
/script-escape
()
1379 ;; Delimited lists of numbers
1380 (should (equal '(1 2 3)
1381 (org-babel-script-escape "[1 2 3]")))
1382 (should (equal '(1 2 3)
1383 (org-babel-script-escape "{1 2 3}")))
1384 (should (equal '(1 2 3)
1385 (org-babel-script-escape "(1 2 3)")))
1386 ;; Delimited lists of double-quoted strings
1387 (should (equal '("foo" "bar")
1388 (org-babel-script-escape "(\"foo\" \"bar\")")))
1389 (should (equal '("foo" "bar")
1390 (org-babel-script-escape "[\"foo\" \"bar\"]")))
1391 (should (equal '("foo" "bar")
1392 (org-babel-script-escape "{\"foo\" \"bar\"}")))
1394 (should (equal '("foo" "bar")
1395 (org-babel-script-escape "(\"foo\", \"bar\")")))
1396 (should (equal '("foo" "bar")
1397 (org-babel-script-escape "[\"foo\", \"bar\"]")))
1398 (should (equal '("foo" "bar")
1399 (org-babel-script-escape "{\"foo\", \"bar\"}")))
1400 ;; Delimited lists of single-quoted strings
1401 (should (equal '("foo" "bar")
1402 (org-babel-script-escape "('foo' 'bar')")))
1403 (should (equal '("foo" "bar")
1404 (org-babel-script-escape "['foo' 'bar']")))
1405 (should (equal '("foo" "bar")
1406 (org-babel-script-escape "{'foo' 'bar'}")))
1408 (should (equal '("foo" "bar")
1409 (org-babel-script-escape "('foo', 'bar')")))
1410 (should (equal '("foo" "bar")
1411 (org-babel-script-escape "['foo', 'bar']")))
1412 (should (equal '("foo" "bar")
1413 (org-babel-script-escape "{'foo', 'bar'}")))
1414 ;; Single quoted strings
1415 (should (equal "foo"
1416 (org-babel-script-escape "'foo'")))
1417 ;; ... with internal double quote
1418 (should (equal "foo\"bar"
1419 (org-babel-script-escape "'foo\"bar'")))
1420 ;; ... with internal backslash
1421 (should (equal "foo\\bar"
1422 (org-babel-script-escape "'foo\\bar'")))
1423 ;; ... with internal escaped backslash
1424 (should (equal "foo\\bar"
1425 (org-babel-script-escape "'foo\\\\bar'")))
1426 ;; ... with internal backslash-double quote
1427 (should (equal "foo\\\"bar"
1428 (org-babel-script-escape "'foo\\\"bar'")))
1429 ;; ... with internal escaped backslash-double quote
1430 (should (equal "foo\\\"bar"
1431 (org-babel-script-escape "'foo\\\\\"bar'")))
1432 ;; ... with internal escaped single quote
1433 (should (equal "foo'bar"
1434 (org-babel-script-escape "'foo\\'bar'")))
1435 ;; ... with internal escaped backslash-escaped single quote
1436 (should (equal "foo\\'bar"
1437 (org-babel-script-escape "'foo\\\\\\'bar'")))
1438 ;; Double quoted strings
1439 (should (equal "foo"
1440 (org-babel-script-escape "\"foo\"")))
1441 ;; ... with internal single quote
1442 (should (equal "foo'bar"
1443 (org-babel-script-escape "\"foo'bar\"")))
1444 ;; ... with internal backslash
1445 (should (equal "foo\\bar"
1446 (org-babel-script-escape "\"foo\\bar\"")))
1447 ;; ... with internal escaped backslash
1448 (should (equal "foo\\bar"
1449 (org-babel-script-escape "\"foo\\\\bar\"")))
1450 ;; ... with internal backslash-single quote
1451 (should (equal "foo\\'bar"
1452 (org-babel-script-escape "\"foo\\'bar\"")))
1453 ;; ... with internal escaped backslash-single quote
1454 (should (equal "foo\\'bar"
1455 (org-babel-script-escape "\"foo\\\\'bar\"")))
1456 ;; ... with internal escaped double quote
1457 (should (equal "foo\"bar"
1458 (org-babel-script-escape "\"foo\\\"bar\"")))
1459 ;; ... with internal escaped backslash-escaped double quote
1460 (should (equal "foo\\\"bar"
1461 (org-babel-script-escape "\"foo\\\\\\\"bar\""))))
1465 ;;; test-ob ends here