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
/ignore-reference-in-commented-headings
()
608 (org-test-with-temp-text
620 <point>#+BEGIN_SRC emacs-lisp :var x=n
623 (org-babel-execute-src-block)))))
625 (ert-deftest test-ob
/do-not-resolve-to-partial-names-data
()
626 (org-test-with-temp-text "
635 #+begin_src emacs-lisp :var x=base
638 (org-babel-next-src-block 1)
639 (should (equal (org-babel-execute-src-block) '((3) (4))))))
641 (ert-deftest test-ob
/do-not-resolve-to-partial-names-code
()
642 (org-test-with-temp-text "
644 #+begin_src emacs-lisp
649 #+begin_src emacs-lisp
653 #+begin_src emacs-lisp :var x=base
656 (org-babel-next-src-block 3)
657 (should (equal (org-babel-execute-src-block) "foo"))))
659 (ert-deftest test-ob
/allow-spaces-around-
=-in-var-specs
()
660 (org-test-with-temp-text "#+begin_src emacs-lisp :var a = 1 b = 2 c= 3 d =4
664 (should (= 10 (org-babel-execute-src-block)))))
666 (ert-deftest test-ob
/org-babel-update-intermediate
()
667 (org-test-with-temp-text "#+name: foo
668 #+begin_src emacs-lisp
675 #+begin_src emacs-lisp :var it=foo
678 (let ((org-babel-update-intermediate nil
))
679 (goto-char (point-min))
680 (org-babel-next-src-block 2)
681 (should (= 3 (org-babel-execute-src-block)))
682 (goto-char (point-min))
684 (should (looking-at ": 4")))
685 (let ((org-babel-update-intermediate t
))
686 (goto-char (point-min))
687 (org-babel-next-src-block 2)
688 (should (= 3 (org-babel-execute-src-block)))
689 (goto-char (point-min))
691 (should (looking-at ": 2")))))
693 (ert-deftest test-ob
/eval-header-argument
()
694 (flet ((check-eval (eval runp
)
695 (org-test-with-temp-text (format "#+begin_src emacs-lisp :eval %s
698 (let ((foo :not-run
))
700 (progn (should (org-babel-execute-src-block))
701 (should (eq foo
:evald
)))
702 (progn (should-not (org-babel-execute-src-block))
703 (should-not (eq foo
:evald
))))))))
704 (check-eval "never" nil
)
705 (check-eval "no" nil
)
706 (check-eval "never-export" t
)
707 (check-eval "no-export" t
)
708 (let ((org-babel-exp-reference-buffer (current-buffer)))
709 (check-eval "never" nil
)
710 (check-eval "no" nil
)
711 (check-eval "never-export" nil
)
712 (check-eval "no-export" nil
))))
714 (ert-deftest test-ob
/noweb-expansion-1
()
715 (org-test-with-temp-text "#+begin_src sh :results output :tangle yes
723 (should (string= (org-babel-expand-noweb-references) "bar"))))
725 (ert-deftest test-ob
/noweb-expansion-2
()
726 (org-test-with-temp-text "#+begin_src sh :results output :tangle yes
731 #+begin_src sh :noweb-sep \"\"
735 #+begin_src sh :noweb-ref foo :noweb-sep \"\"
738 (should (string= (org-babel-expand-noweb-references) "barbaz"))))
740 (ert-deftest test-ob
/splitting-variable-lists-in-references
()
741 (org-test-with-temp-text ""
742 (should (= 1 (length (org-babel-ref-split-args
743 "a=\"this, no work\""))))
744 (should (= 2 (length (org-babel-ref-split-args
745 "a=\"this, no work\", b=1"))))))
747 (ert-deftest test-ob
/org-babel-balanced-split
()
749 '(":a 1" "b [2 3]" "c (4 :d (5 6))")
750 (org-babel-balanced-split ":a 1 :b [2 3] :c (4 :d (5 6))"
753 (ert-deftest test-ob
/commented-last-block-line-no-var
()
754 (org-test-with-temp-text-in-file "
755 #+begin_src emacs-lisp
758 (org-babel-next-src-block)
759 (org-babel-execute-maybe)
760 (should (re-search-forward "\\#\\+results:" nil t
))
765 (buffer-substring-no-properties (point-at-bol) (point-at-eol)))))
766 (org-test-with-temp-text-in-file "
767 #+begin_src emacs-lisp
770 (org-babel-next-src-block)
771 (org-babel-execute-maybe)
772 (should (re-search-forward "\\#\\+results:" nil t
))
777 (buffer-substring-no-properties (point-at-bol) (point-at-eol))))))
779 (ert-deftest test-ob
/commented-last-block-line-with-var
()
780 (org-test-with-temp-text-in-file "
781 #+begin_src emacs-lisp :var a=1
784 (org-babel-next-src-block)
785 (org-babel-execute-maybe)
786 (re-search-forward "\\#\\+results:" nil t
)
790 (buffer-substring-no-properties (point-at-bol) (point-at-eol)))))
791 (org-test-with-temp-text-in-file "
792 #+begin_src emacs-lisp :var a=2
795 (org-babel-next-src-block)
796 (org-babel-execute-maybe)
797 (re-search-forward "\\#\\+results:" nil t
)
801 (buffer-substring-no-properties (point-at-bol) (point-at-eol))))))
803 (ert-deftest test-ob
/org-babel-insert-result--improper-lists
()
804 "Test `org-babel-insert-result' with improper lists."
805 ;; Do not error when output is an improper list.
807 (org-test-with-temp-text
809 <point>#+BEGIN_SRC emacs-lisp
813 (org-babel-execute-maybe) t
)))
815 (ert-deftest test-ob
/remove-inline-result
()
816 "Test `org-babel-remove-inline-result' honors whitespace."
818 ((inline-sb "src_emacs-lisp{(+ 1 2)}")
819 (inline-res " {{{results(=3=)}}}")
820 (inline-sb-dot (concat inline-sb
"."))
821 (inline-sb-res-dot (concat inline-sb inline-res
".")))
822 (org-test-with-temp-text
823 ;; Insert inline_src_block followed by dot.
825 ;; Insert result before dot.
826 (org-babel-execute-maybe)
827 (should (string= inline-sb-res-dot
828 (buffer-substring-no-properties
829 (point-at-bol) (point-at-eol))))
830 ;; Delete whitespace and result.
831 (org-babel-remove-inline-result)
832 (should (string= inline-sb-dot
833 (buffer-substring-no-properties
834 (point-at-bol) (point-at-eol))))
835 ;; Add whitespace and result before dot.
836 (search-forward inline-sb
)
837 (insert " " inline-res
)
838 (goto-char (point-at-bol))
839 ;; Remove whitespace and result.
840 (org-babel-remove-inline-result)
841 (should (string= inline-sb-dot
842 (buffer-substring-no-properties
843 (point-at-bol) (point-at-eol))))
844 ;; Add whitespace before dot.
845 (search-forward inline-sb
)
847 (goto-char (point-at-bol))
848 ;; Add result before whitespace.
849 (org-babel-execute-maybe)
850 ;; Remove result - leave trailing whitespace and dot.
851 (org-babel-remove-inline-result)
852 (should (string= (concat inline-sb
" .")
853 (buffer-substring-no-properties
854 (point-at-bol) (point-at-eol)))))))
856 (defun test-ob-verify-result-and-removed-result (result buffer-text
)
857 "Test helper function to test `org-babel-remove-result'.
858 A temp buffer is populated with BUFFER-TEXT, the first block is executed,
859 and the result of execution is verified against RESULT.
861 The block is actually executed /twice/ to ensure result
862 replacement happens correctly."
863 (org-test-with-temp-text
865 (org-babel-next-src-block) (org-babel-execute-maybe) (org-babel-execute-maybe)
866 (should (re-search-forward "\\#\\+results:" nil t
))
868 (should (string= result
869 (buffer-substring-no-properties
871 (- (point-max) 16))))
872 (org-babel-previous-src-block) (org-babel-remove-result)
873 (should (string= buffer-text
874 (buffer-substring-no-properties
875 (point-min) (point-max))))))
877 (ert-deftest test-ob
/org-babel-remove-result--results-default
()
878 "Test `org-babel-remove-result' with default :results."
879 (mapcar (lambda (language)
880 (test-ob-verify-result-and-removed-result
883 "* org-babel-remove-result
884 #+begin_src " language
"
888 '("sh" "emacs-lisp")))
890 (ert-deftest test-ob
/org-babel-remove-result--results-list
()
891 "Test `org-babel-remove-result' with :results list."
892 (test-ob-verify-result-and-removed-result
898 "* org-babel-remove-result
899 #+begin_src emacs-lisp :results list
905 (ert-deftest test-ob
/org-babel-results-indented-wrap
()
906 "Ensure that wrapped results are inserted correction when indented.
907 If not inserted correctly then the second evaluation will fail
908 trying to find the :END: marker."
909 (org-test-with-temp-text
911 #+begin_src sh :results file wrap
914 (org-babel-next-src-block 1)
915 (org-babel-execute-src-block)
916 (org-babel-execute-src-block)))
918 (ert-deftest test-ob
/file-desc-header-argument
()
919 "Test that the :file-desc header argument is used."
920 (org-test-with-temp-text "#+begin_src emacs-lisp :results file :file-desc bar
924 #+begin_src emacs-lisp :results file :file-desc
927 (org-babel-execute-src-block)
928 (org-babel-next-src-block 1)
929 (org-babel-execute-src-block)
930 (goto-char (point-min))
931 (should (search-forward "[[file:foo][bar]]" nil t
))
932 (should (search-forward "[[file:foo][foo]]" nil t
))))
934 (ert-deftest test-ob
/org-babel-remove-result--results-pp
()
935 "Test `org-babel-remove-result' with :results pp."
936 (test-ob-verify-result-and-removed-result
937 ": \"I /am/ working!\""
939 "* org-babel-remove-result
940 #+begin_src emacs-lisp :results pp
946 (ert-deftest test-org-babel
/inline-src_blk-preceded-punct-preceded-by-point
()
947 (let ((test-line ".src_emacs-lisp[ :results verbatim ]{ \"x\" }")
948 (org-babel-inline-result-wrap "=%s="))
949 (org-test-with-temp-text
952 (org-babel-execute-maybe)
953 (should (re-search-forward "=\"x\"=" nil t
))
956 (ert-deftest test-ob
/commented-last-block-line-with-var
()
957 (org-test-with-temp-text-in-file "
958 #+begin_src emacs-lisp :var a=1
961 (org-babel-next-src-block)
962 (org-babel-execute-maybe)
963 (re-search-forward "\\#\\+results:" nil t
)
967 (buffer-substring-no-properties (point-at-bol) (point-at-eol)))))
968 (org-test-with-temp-text-in-file "
969 #+begin_src emacs-lisp :var a=2
972 (org-babel-next-src-block)
973 (org-babel-execute-maybe)
974 (re-search-forward "\\#\\+results:" nil t
)
978 (buffer-substring-no-properties (point-at-bol) (point-at-eol))))))
980 (defun test-ob-verify-result-and-removed-result (result buffer-text
)
981 "Test helper function to test `org-babel-remove-result'.
982 A temp buffer is populated with BUFFER-TEXT, the first block is executed,
983 and the result of execution is verified against RESULT.
985 The block is actually executed /twice/ to ensure result
986 replacement happens correctly."
987 (org-test-with-temp-text
989 (org-babel-next-src-block) (org-babel-execute-maybe) (org-babel-execute-maybe)
990 (should (re-search-forward "\\#\\+results:" nil t
))
992 (should (string= result
993 (buffer-substring-no-properties
995 (- (point-max) 16))))
996 (org-babel-previous-src-block) (org-babel-remove-result)
997 (should (string= buffer-text
998 (buffer-substring-no-properties
999 (point-min) (point-max))))))
1001 (ert-deftest test-ob
/org-babel-remove-result--results-default
()
1002 "Test `org-babel-remove-result' with default :results."
1003 (mapcar (lambda (language)
1004 (test-ob-verify-result-and-removed-result
1007 "* org-babel-remove-result
1008 #+begin_src " language
"
1012 '("sh" "emacs-lisp")))
1014 (ert-deftest test-ob
/org-babel-remove-result--results-list
()
1015 "Test `org-babel-remove-result' with :results list."
1016 (test-ob-verify-result-and-removed-result
1022 "* org-babel-remove-result
1023 #+begin_src emacs-lisp :results list
1029 (ert-deftest test-ob
/org-babel-remove-result--results-wrap
()
1030 "Test `org-babel-remove-result' with :results wrap."
1031 (test-ob-verify-result-and-removed-result
1036 "* org-babel-remove-result
1038 #+begin_src emacs-lisp :results wrap
1044 (ert-deftest test-ob
/org-babel-remove-result--results-org
()
1045 "Test `org-babel-remove-result' with :results org."
1046 (test-ob-verify-result-and-removed-result
1053 "* org-babel-remove-result
1054 #+begin_src emacs-lisp :results org
1062 (ert-deftest test-ob
/org-babel-remove-result--results-html
()
1063 "Test `org-babel-remove-result' with :results html."
1064 (test-ob-verify-result-and-removed-result
1066 <head><body></body></head>
1069 "* org-babel-remove-result
1070 #+begin_src emacs-lisp :results html
1071 \"<head><body></body></head>\"
1076 (ert-deftest test-ob
/org-babel-remove-result--results-latex
()
1077 "Test `org-babel-remove-result' with :results latex."
1078 (test-ob-verify-result-and-removed-result
1085 "* org-babel-remove-result
1086 #+begin_src emacs-lisp :results latex
1094 (ert-deftest test-ob
/org-babel-remove-result--results-code
()
1095 "Test `org-babel-remove-result' with :results code."
1097 (test-ob-verify-result-and-removed-result
1098 "#+BEGIN_SRC emacs-lisp
1102 "* org-babel-remove-result
1103 #+begin_src emacs-lisp :results code
1104 (message \"I am working!\")
1109 (ert-deftest test-ob
/org-babel-remove-result--results-pp
()
1110 "Test `org-babel-remove-result' with :results pp."
1111 (test-ob-verify-result-and-removed-result
1112 ": \"I /am/ working!\""
1114 "* org-babel-remove-result
1115 #+begin_src emacs-lisp :results pp
1116 \"I /am/ working!\")
1121 (ert-deftest test-ob
/results-do-not-replace-code-blocks
()
1122 (org-test-with-temp-text "Block two has a space after the name.
1125 #+begin_src emacs-lisp
1130 #+begin_src emacs-lisp
1135 #+begin_src emacs-lisp
1142 (dolist (num '(1 2 3))
1143 ;; execute the block
1144 (goto-char (point-min))
1145 (org-babel-next-src-block num
) (org-babel-execute-src-block)
1146 ;; check the results
1147 (goto-char (point-max))
1148 (move-beginning-of-line 0)
1149 (should (looking-at (format ": %d" num
))))))
1151 (ert-deftest test-ob
/blocks-with-spaces
()
1152 "Test expansion of blocks followed by blank lines."
1154 (equal "#+BEGIN_SRC emacs-lisp
1160 (org-test-with-temp-text "#+BEGIN_SRC emacs-lisp
1163 (let ((org-babel-next-src-block "RESULTS"))
1164 (org-babel-execute-src-block))
1167 (ert-deftest test-ob
/results-in-narrowed-buffer
()
1168 "Test block execution in a narrowed buffer."
1169 ;; If results don't exist, they should be inserted in visible part
1173 "#+BEGIN_SRC emacs-lisp\n(+ 1 2)\n#+END_SRC\n\n#+RESULTS:\n: 3"
1174 (org-test-with-temp-text
1175 "#+BEGIN_SRC emacs-lisp\n(+ 1 2)\n#+END_SRC\n\nParagraph"
1176 (narrow-to-region (point) (save-excursion (forward-line 3) (point)))
1177 (let ((org-babel-results-keyword "RESULTS"))
1178 (org-babel-execute-src-block))
1179 (org-trim (buffer-string)))))
1182 "#+NAME: test\n#+BEGIN_SRC emacs-lisp\n(+ 1 2)\n#+END_SRC\n\n#+RESULTS: test\n: 3"
1183 (org-test-with-temp-text
1184 "#+NAME: test\n#+BEGIN_SRC emacs-lisp\n(+ 1 2)\n#+END_SRC\n\nParagraph"
1185 (narrow-to-region (point) (save-excursion (forward-line 4) (point)))
1186 (let ((org-babel-results-keyword "RESULTS"))
1187 (org-babel-execute-src-block))
1188 (org-trim (buffer-string)))))
1189 ;; Results in visible part of buffer, should be updated here.
1193 #+BEGIN_SRC emacs-lisp
1199 (org-test-with-temp-text
1201 #+BEGIN_SRC emacs-lisp
1209 (narrow-to-region (point) (save-excursion (forward-line 7) (point)))
1210 (let ((org-babel-results-keyword "RESULTS"))
1211 (org-babel-execute-src-block))
1212 (org-trim (buffer-string)))))
1213 ;; Results in invisible part of buffer, should be updated there.
1214 (org-test-with-temp-text
1216 #+BEGIN_SRC emacs-lisp
1224 (narrow-to-region (point) (save-excursion (forward-line 4) (point)))
1225 (let ((org-babel-results-keyword "RESULTS"))
1226 (org-babel-execute-src-block))
1227 (should-not (re-search-forward "^#\\+RESULTS:" nil t
))
1229 (should (should (re-search-forward "^: 3" nil t
)))))
1231 (ert-deftest test-ob
/specific-colnames
()
1232 "Test passing specific column names."
1234 (equal "#+name: input-table
1240 #+begin_src sh :var data=input-table :exports results :colnames '(Rev Author)
1251 (org-test-with-temp-text
1252 "#+name: input-table
1258 #+begin_src sh :var data=input-table :exports results :colnames '(Rev Author)
1262 ;; we should find a code block
1263 (should (re-search-forward org-babel-src-block-regexp nil t
))
1264 (goto-char (match-beginning 0))
1265 ;; now that we've located the code block, it may be evaluated
1266 (let ((org-babel-execute-src-block "RESULTS"))
1267 (org-babel-execute-src-block))
1270 (ert-deftest test-ob
/location-of-header-arg-eval
()
1271 "Test location of header argument evaluation."
1272 (org-test-with-temp-text "
1274 #+begin_src emacs-lisp :var pt=(point)
1278 #+name: bottom-block
1279 #+begin_src emacs-lisp :var pt=top-block()
1283 ;; the value of the second block should be greater than the first
1285 (< (progn (re-search-forward org-babel-src-block-regexp nil t
)
1286 (goto-char (match-beginning 0))
1287 (prog1 (save-match-data (org-babel-execute-src-block))
1288 (goto-char (match-end 0))))
1289 (progn (re-search-forward org-babel-src-block-regexp nil t
)
1290 (goto-char (match-beginning 0))
1291 (org-babel-execute-src-block))))))
1293 (ert-deftest test-ob
/preserve-results-indentation
()
1294 "Preserve indentation when executing a src block."
1298 (org-test-with-temp-text " #+begin_src emacs-lisp\n(+ 1 1)\n #+end_src"
1299 (org-babel-execute-src-block)
1300 (let ((case-fold-search t
)) (search-forward "RESULTS"))
1301 (list (org-get-indentation)
1302 (progn (forward-line) (org-get-indentation))))))
1306 (org-test-with-temp-text
1307 " #+name: block\n #+begin_src emacs-lisp\n(+ 1 1)\n #+end_src"
1308 (org-babel-execute-src-block)
1309 (let ((case-fold-search t
)) (search-forward "RESULTS"))
1310 (list (org-get-indentation)
1311 (progn (forward-line) (org-get-indentation))))))
1312 ;; Don't get fooled by TAB-based indentation.
1316 (org-test-with-temp-text
1317 "\t #+begin_src emacs-lisp\n\t (+ 1 1)\n\t #+end_src"
1319 (org-babel-execute-src-block)
1320 (let ((case-fold-search t
)) (search-forward "RESULTS"))
1321 (list (org-get-indentation)
1322 (progn (forward-line) (org-get-indentation)))))))
1324 (ert-deftest test-ob
/safe-header-args
()
1325 "Detect safe and unsafe header args."
1326 (let ((safe-args '((:cache .
"foo")
1327 (:results .
"output")
1330 (unsafe-args '((:eval .
"yes")
1331 (:results .
"output file")
1333 (malformed-args '((bar .
"foo")
1336 (safe-p (org-babel-header-args-safe-fn org-babel-safe-header-args
)))
1337 (dolist (arg safe-args
)
1338 (should (org-babel-one-header-arg-safe-p arg org-babel-safe-header-args
)))
1339 (dolist (arg unsafe-args
)
1340 (should (not (org-babel-one-header-arg-safe-p arg org-babel-safe-header-args
))))
1341 (dolist (arg malformed-args
)
1342 (should (not (org-babel-one-header-arg-safe-p arg org-babel-safe-header-args
))))
1343 (should (not (funcall safe-p
(append safe-args unsafe-args
))))))
1345 (ert-deftest test-ob
/noweb-expansions-in-cache
()
1346 "Ensure that noweb expansions are expanded before caching."
1347 (let ((noweb-expansions-in-cache-var 0))
1348 (org-test-with-temp-text "
1350 #+begin_src emacs-lisp
1355 #+begin_src emacs-lisp :noweb yes :cache yes
1356 (setq noweb-expansions-in-cache-var
1357 (+ 1 noweb-expansions-in-cache-var))
1358 (concat <<foo>> \" check noweb expansions\")
1361 ;; run the second block to create the cache
1362 (goto-char (point-min))
1363 (re-search-forward (regexp-quote "#+name: bar"))
1364 (should (string= "I said check noweb expansions"
1365 (org-babel-execute-src-block)))
1366 (should (= noweb-expansions-in-cache-var
1))
1367 ;; change the value of the first block
1368 (goto-char (point-min))
1369 (re-search-forward (regexp-quote "said"))
1370 (goto-char (match-beginning 0))
1372 (re-search-forward (regexp-quote "#+name: bar"))
1373 (should (string= "I haven't said check noweb expansions"
1374 (org-babel-execute-src-block)))
1375 (should (= noweb-expansions-in-cache-var
2)))))
1377 (ert-deftest test-org-babel
/file-ext-and-output-dir
()
1378 (org-test-at-id "93573e1d-6486-442e-b6d0-3fedbdc37c9b"
1379 (org-babel-next-src-block)
1380 (should (equal "file-ext-basic.txt"
1381 (cdr (assq :file
(nth 2 (org-babel-get-src-block-info t
))))))
1382 (org-babel-next-src-block)
1383 (should (equal "foo/file-ext-dir-relative.txt"
1384 (cdr (assq :file
(nth 2 (org-babel-get-src-block-info t
))))))
1385 (org-babel-next-src-block)
1386 (should (equal "foo/file-ext-dir-relative-slash.txt"
1387 (cdr (assq :file
(nth 2 (org-babel-get-src-block-info t
))))))
1388 (org-babel-next-src-block)
1389 (should (equal "/tmp/file-ext-dir-absolute.txt"
1390 (cdr (assq :file
(nth 2 (org-babel-get-src-block-info t
))))))
1391 (org-babel-next-src-block)
1392 (should (equal "foo.bar"
1393 (cdr (assq :file
(nth 2 (org-babel-get-src-block-info t
))))))
1394 (org-babel-next-src-block)
1395 (should (equal "xxx/foo.bar"
1396 (cdr (assq :file
(nth 2 (org-babel-get-src-block-info t
))))))
1399 (ert-deftest test-org-babel
/script-escape
()
1400 ;; Delimited lists of numbers
1401 (should (equal '(1 2 3)
1402 (org-babel-script-escape "[1 2 3]")))
1403 (should (equal '(1 2 3)
1404 (org-babel-script-escape "{1 2 3}")))
1405 (should (equal '(1 2 3)
1406 (org-babel-script-escape "(1 2 3)")))
1407 ;; Delimited lists of double-quoted strings
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\"}")))
1415 (should (equal '("foo" "bar")
1416 (org-babel-script-escape "(\"foo\", \"bar\")")))
1417 (should (equal '("foo" "bar")
1418 (org-babel-script-escape "[\"foo\", \"bar\"]")))
1419 (should (equal '("foo" "bar")
1420 (org-babel-script-escape "{\"foo\", \"bar\"}")))
1421 ;; Delimited lists of single-quoted strings
1422 (should (equal '("foo" "bar")
1423 (org-babel-script-escape "('foo' 'bar')")))
1424 (should (equal '("foo" "bar")
1425 (org-babel-script-escape "['foo' 'bar']")))
1426 (should (equal '("foo" "bar")
1427 (org-babel-script-escape "{'foo' 'bar'}")))
1429 (should (equal '("foo" "bar")
1430 (org-babel-script-escape "('foo', 'bar')")))
1431 (should (equal '("foo" "bar")
1432 (org-babel-script-escape "['foo', 'bar']")))
1433 (should (equal '("foo" "bar")
1434 (org-babel-script-escape "{'foo', 'bar'}")))
1435 ;; Single quoted strings
1436 (should (equal "foo"
1437 (org-babel-script-escape "'foo'")))
1438 ;; ... with internal double quote
1439 (should (equal "foo\"bar"
1440 (org-babel-script-escape "'foo\"bar'")))
1441 ;; ... with internal backslash
1442 (should (equal "foo\\bar"
1443 (org-babel-script-escape "'foo\\bar'")))
1444 ;; ... with internal escaped backslash
1445 (should (equal "foo\\bar"
1446 (org-babel-script-escape "'foo\\\\bar'")))
1447 ;; ... with internal backslash-double quote
1448 (should (equal "foo\\\"bar"
1449 (org-babel-script-escape "'foo\\\"bar'")))
1450 ;; ... with internal escaped backslash-double quote
1451 (should (equal "foo\\\"bar"
1452 (org-babel-script-escape "'foo\\\\\"bar'")))
1453 ;; ... with internal escaped single quote
1454 (should (equal "foo'bar"
1455 (org-babel-script-escape "'foo\\'bar'")))
1456 ;; ... with internal escaped backslash-escaped single quote
1457 (should (equal "foo\\'bar"
1458 (org-babel-script-escape "'foo\\\\\\'bar'")))
1459 ;; Double quoted strings
1460 (should (equal "foo"
1461 (org-babel-script-escape "\"foo\"")))
1462 ;; ... with internal single quote
1463 (should (equal "foo'bar"
1464 (org-babel-script-escape "\"foo'bar\"")))
1465 ;; ... with internal backslash
1466 (should (equal "foo\\bar"
1467 (org-babel-script-escape "\"foo\\bar\"")))
1468 ;; ... with internal escaped backslash
1469 (should (equal "foo\\bar"
1470 (org-babel-script-escape "\"foo\\\\bar\"")))
1471 ;; ... with internal backslash-single quote
1472 (should (equal "foo\\'bar"
1473 (org-babel-script-escape "\"foo\\'bar\"")))
1474 ;; ... with internal escaped backslash-single quote
1475 (should (equal "foo\\'bar"
1476 (org-babel-script-escape "\"foo\\\\'bar\"")))
1477 ;; ... with internal escaped double quote
1478 (should (equal "foo\"bar"
1479 (org-babel-script-escape "\"foo\\\"bar\"")))
1480 ;; ... with internal escaped backslash-escaped double quote
1481 (should (equal "foo\\\"bar"
1482 (org-babel-script-escape "\"foo\\\\\\\"bar\""))))
1484 (ert-deftest ob
/process-params-no-duplicates
()
1485 (should (equal (org-babel-process-params '((:colname-names .
1)
1486 (:rowname-names .
1)
1487 (:result-params .
1)
1489 (:var .
"\"foo\"")))
1491 (:colname-names .
1)
1492 (:rowname-names .
1)
1493 (:result-params .
1)
1494 (:result-type . value
)))))
1498 ;;; test-ob ends here