1 ;;; test-org-element.el --- Tests for org-element.el
3 ;; Copyright (C) 2012 Nicolas Goaziou
5 ;; Author: Nicolas Goaziou <n.goaziou at gmail dot com>
7 ;; This program is free software; you can redistribute it and/or modify
8 ;; it under the terms of the GNU General Public License as published by
9 ;; the Free Software Foundation, either version 3 of the License, or
10 ;; (at your option) any later version.
12 ;; This program is distributed in the hope that it will be useful,
13 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
14 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 ;; GNU General Public License for more details.
17 ;; You should have received a copy of the GNU General Public License
18 ;; along with this program. If not, see <http://www.gnu.org/licenses/>.
24 (unless (featurep 'org-element
)
25 (signal 'missing-test-dependency
"org-element"))
27 (defun org-test-parse-and-interpret (text)
28 "Parse TEXT as Org syntax and interpret it.
29 Return interpreted string."
33 (org-element-interpret-data (org-element-parse-buffer))))
41 (ert-deftest test-org-element
/babel-call-parser
()
42 "Test `babel-call' parsing."
45 (org-test-with-temp-text "#+CALL: test()"
46 (org-element-map (org-element-parse-buffer) 'babel-call
'identity nil t
))
47 '(babel-call (:begin
1 :end
15 :info
("test()" nil
0) :post-blank
0)))))
52 (ert-deftest test-org-element
/bold-parser
()
57 (org-test-with-temp-text "*bold*"
58 (org-element-map (org-element-parse-buffer) 'bold
'identity nil t
))
59 '(bold (:begin
1 :end
7 :contents-begin
2 :contents-end
6 :post-blank
0)
64 (org-test-with-temp-text "*first line\nsecond line*"
65 (org-element-map (org-element-parse-buffer) 'bold
'identity nil t
))
66 '(bold (:begin
1 :end
25 :contents-begin
2 :contents-end
24 :post-blank
0)
67 "first line\nsecond line"))))
72 (ert-deftest test-org-element
/center-block-parser
()
73 "Test `center-block' parser."
77 (org-test-with-temp-text "#+BEGIN_CENTER\nText\n#+END_CENTER"
79 (org-element-parse-buffer) 'center-block
'identity nil t
))
81 (:begin
1 :end
33 :hiddenp nil
:contents-begin
16 :contents-end
21
84 (:begin
16 :end
21 :contents-begin
16 :contents-end
20 :post-blank
0)
87 (org-test-with-temp-text "#+BEGIN_CENTER\nText\n#+END_CENTER"
93 (org-element-parse-buffer) 'center-block
'identity nil t
))))
94 ;; Ignore incomplete block.
96 (org-test-with-temp-text "#+BEGIN_CENTER"
98 (org-element-parse-buffer) 'center-block
'identity nil t
))))
103 (ert-deftest test-org-element
/clock-parser
()
104 "Test `clock' parser."
108 (let ((org-clock-string "CLOCK:"))
109 (org-test-with-temp-text "CLOCK: [2012-01-01 sun. 00:01]"
111 (org-element-parse-buffer) 'clock
'identity nil t
)))
113 (:status running
:value
"[2012-01-01 sun. 00:01]" :time nil
:begin
1
114 :end
31 :post-blank
0))))
118 (let ((org-clock-string "CLOCK:"))
119 (org-test-with-temp-text "
120 CLOCK: [2012-01-01 sun. 00:01]--[2012-01-01 sun. 00:02] => 0:01"
122 (org-element-parse-buffer) 'clock
'identity nil t
)))
125 :value
"[2012-01-01 sun. 00:01]--[2012-01-01 sun. 00:02]"
126 :time
"0:01" :begin
2 :end
66 :post-blank
0)))))
131 (ert-deftest test-org-element
/code-parser
()
132 "Test `code' parser."
136 (org-test-with-temp-text "~code~"
137 (org-element-map (org-element-parse-buffer) 'code
'identity nil t
))
138 '(code (:value
"code" :begin
1 :end
7 :post-blank
0))))
139 ;; Multi-line markup.
142 (org-test-with-temp-text "~first line\nsecond line~"
143 (org-element-map (org-element-parse-buffer) 'code
'identity nil t
))
144 '(code (:value
"first line\nsecond line" :begin
1 :end
25 :post-blank
0)))))
149 (ert-deftest test-org-element
/comment-parser
()
150 "Test `comment' parser."
154 (org-test-with-temp-text "# Comment"
155 (org-element-map (org-element-parse-buffer) 'comment
'identity nil t
))
156 '(comment (:begin
1 :end
10 :value
"Comment\n" :post-blank
0))))
160 (org-test-with-temp-text "#+ Comment"
161 (org-element-map (org-element-parse-buffer) 'comment
'identity nil t
))
162 '(comment (:begin
1 :end
11 :value
"Comment\n" :post-blank
0))))
163 ;; Preserve indentation.
166 (org-test-with-temp-text "#+ No blank\n#+ One blank"
167 (org-element-map (org-element-parse-buffer) 'comment
'identity nil t
))
168 '(comment (:begin
1 :end
26 :value
"No blank\n One blank\n" :post-blank
0))))
169 ;; Comment with blank lines.
172 (org-test-with-temp-text "#+ First part\n#+ \n#+\n#+ Second part"
173 (org-element-map (org-element-parse-buffer) 'comment
'identity nil t
))
175 (:begin
1 :end
36 :value
"First part\n\n\nSecond part\n"
181 (ert-deftest test-org-element
/comment-block-parser
()
182 "Test `comment-block' parser."
186 (org-test-with-temp-text "#+BEGIN_COMMENT\nText\n#+END_COMMENT"
188 (org-element-parse-buffer) 'comment-block
'identity nil t
))
189 '(comment-block (:begin
1 :end
35 :value
"Text\n" :hiddenp nil
191 ;; Test folded block.
192 (org-test-with-temp-text "#+BEGIN_COMMENT\nText\n#+END_COMMENT"
195 (org-element-property
198 (org-element-parse-buffer) 'comment-block
'identity nil t
))))
199 ;; Ignore incomplete block.
201 (org-test-with-temp-text "#+BEGIN_COMMENT"
203 (org-element-parse-buffer) 'comment-block
'identity nil t
))))
208 (ert-deftest test-org-element
/drawer-parser
()
209 "Test `drawer' parser."
213 (let ((org-drawers '("TEST")))
214 (org-test-with-temp-text ":TEST:\nText\n:END:"
215 (org-element-map (org-element-parse-buffer) 'drawer
'identity nil t
)))
217 (:begin
1 :end
18 :drawer-name
"TEST" :hiddenp nil
:contents-begin
8
218 :contents-end
13 :post-blank
0)
220 (:begin
8 :end
13 :contents-begin
8 :contents-end
12 :post-blank
0)
222 ;; Do not mix regular drawers and property drawers.
224 (let ((org-drawers '("PROPERTIES")))
225 (org-test-with-temp-text ":PROPERTIES:\n:prop: value\n:END:"
227 (org-element-parse-buffer) 'drawer
'identity nil t
))))
228 ;; Ignore incomplete drawer.
230 (let ((org-drawers '("TEST")))
231 (org-test-with-temp-text ":TEST:"
233 (org-element-parse-buffer) 'drawer
'identity nil t
)))))
238 (ert-deftest test-org-element
/dynamic-block-parser
()
239 "Test `dynamic-block' parser."
243 (org-test-with-temp-text
244 "#+BEGIN: myblock :param1 val1 :param2 val2\nText\n#+END:"
246 (org-element-parse-buffer) 'dynamic-block
'identity nil t
))
248 (:begin
1 :end
55 :block-name
"myblock"
249 :arguments
":param1 val1 :param2 val2" :hiddenp nil
250 :contents-begin
44 :contents-end
49 :post-blank
0)
252 (:begin
44 :end
49 :contents-begin
44 :contents-end
48 :post-blank
0)
255 (org-test-with-temp-text
256 "#+BEGIN: myblock :param1 val1 :param2 val2\nText\n#+END:"
259 (org-element-property
262 (org-element-parse-buffer) 'dynamic-block
'identity nil t
))))
263 ;; Ignore incomplete block.
265 (org-test-with-temp-text "#+BEGIN: myblock :param1 val1 :param2 val2"
267 (org-element-parse-buffer) 'dynamic-block
'identity nil t
))))
272 (ert-deftest test-org-element
/entity-parser
()
273 "Test `entity' parser."
277 (org-test-with-temp-text "\\sin"
278 (org-element-map (org-element-parse-buffer) 'entity
'identity nil t
))
280 (:name
"sin" :latex
"\\sin" :latex-math-p t
:html
"sin"
281 :ascii
"sin" :latin1
"sin" :utf-8
"sin" :begin
1 :end
5
282 :use-brackets-p nil
:post-blank
0))))
285 (org-element-property
287 (org-test-with-temp-text "\\alpha{}text"
288 (org-element-map (org-element-parse-buffer) 'entity
'identity nil t
))))
289 ;; User-defined entity.
292 (org-element-property
294 (let ((org-entities-user
295 '(("test" "test" nil
"test" "test" "test" "test"))))
296 (org-test-with-temp-text "\\test"
297 (org-element-map (org-element-parse-buffer) 'entity
'identity nil t
))))
303 (ert-deftest test-org-element
/example-block-parser
()
304 "Test `example-block' parser."
308 (org-test-with-temp-text "#+BEGIN_EXAMPLE\nText\n#+END_EXAMPLE"
310 (org-element-parse-buffer) 'example-block
'identity nil t
))
312 (:begin
1 :end
35 :value
"Text\n" :switches nil
313 :number-lines nil
:preserve-indent nil
:retain-labels t
314 :use-labels t
:label-fmt nil
:hiddenp nil
:post-blank
0))))
315 ;; Test folded block.
316 (org-test-with-temp-text "#+BEGIN_EXAMPLE\nText\n#+END_EXAMPLE"
319 (org-element-property
322 (org-element-parse-buffer) 'example-block
'identity nil t
))))
323 ;; Ignore incomplete block.
325 (org-test-with-temp-text "#+BEGIN_EXAMPLE"
327 (org-element-parse-buffer) 'example-block
'identity nil t
))))
329 (ert-deftest test-org-element
/block-switches
()
330 "Test `example-block' and `src-block' switches parsing."
331 (let ((org-coderef-label-format "(ref:%s)"))
332 ;; 1. Test "-i" switch.
333 (org-test-with-temp-text "#+BEGIN_SRC emacs-lisp\n(+ 1 1)\n#+END_SRC"
334 (let ((element (org-element-current-element)))
335 (should-not (org-element-property :preserve-indent element
))))
336 (org-test-with-temp-text "#+BEGIN_SRC emacs-lisp -i\n(+ 1 1)\n#+END_SRC"
337 (let ((element (org-element-current-element)))
338 (should (org-element-property :preserve-indent element
))))
339 (org-test-with-temp-text "#+BEGIN_EXAMPLE\nText.\n#+END_EXAMPLE"
340 (let ((element (org-element-current-element)))
341 (should-not (org-element-property :preserve-indent element
))))
342 (org-test-with-temp-text "#+BEGIN_EXAMPLE -i\nText.\n#+END_EXAMPLE"
343 (let ((element (org-element-current-element)))
344 (should (org-element-property :preserve-indent element
))))
345 ;; 2. "-n -r -k" combination should number lines, retain labels but
346 ;; not use them in coderefs.
347 (org-test-with-temp-text "#+BEGIN_EXAMPLE -n -r -k\nText.\n#+END_EXAMPLE"
348 (let ((element (org-element-current-element)))
349 (should (and (org-element-property :number-lines element
)
350 (org-element-property :retain-labels element
)
351 (not (org-element-property :use-labels element
))))))
352 (org-test-with-temp-text
353 "#+BEGIN_SRC emacs-lisp -n -r -k\n(+ 1 1)\n#+END_SRC"
354 (let ((element (org-element-current-element)))
355 (should (and (org-element-property :number-lines element
)
356 (org-element-property :retain-labels element
)
357 (not (org-element-property :use-labels element
))))))
358 ;; 3. "-n -r" combination should number-lines remove labels and not
359 ;; use them in coderefs.
360 (org-test-with-temp-text "#+BEGIN_EXAMPLE -n -r\nText.\n#+END_EXAMPLE"
361 (let ((element (org-element-current-element)))
362 (should (and (org-element-property :number-lines element
)
363 (not (org-element-property :retain-labels element
))
364 (not (org-element-property :use-labels element
))))))
365 (org-test-with-temp-text "#+BEGIN_SRC emacs-lisp -n -r\n(+ 1 1)\n#+END_SRC"
366 (let ((element (org-element-current-element)))
367 (should (and (org-element-property :number-lines element
)
368 (not (org-element-property :retain-labels element
))
369 (not (org-element-property :use-labels element
))))))
370 ;; 4. "-n" or "+n" should number lines, retain labels and use them
372 (org-test-with-temp-text "#+BEGIN_EXAMPLE -n\nText.\n#+END_EXAMPLE"
373 (let ((element (org-element-current-element)))
374 (should (and (org-element-property :number-lines element
)
375 (org-element-property :retain-labels element
)
376 (org-element-property :use-labels element
)))))
377 (org-test-with-temp-text "#+BEGIN_SRC emacs-lisp -n\n(+ 1 1)\n#+END_SRC"
378 (let ((element (org-element-current-element)))
379 (should (and (org-element-property :number-lines element
)
380 (org-element-property :retain-labels element
)
381 (org-element-property :use-labels element
)))))
382 (org-test-with-temp-text "#+BEGIN_EXAMPLE +n\nText.\n#+END_EXAMPLE"
383 (let ((element (org-element-current-element)))
384 (should (and (org-element-property :number-lines element
)
385 (org-element-property :retain-labels element
)
386 (org-element-property :use-labels element
)))))
387 (org-test-with-temp-text "#+BEGIN_SRC emacs-lisp +n\n(+ 1 1)\n#+END_SRC"
388 (let ((element (org-element-current-element)))
389 (should (and (org-element-property :number-lines element
)
390 (org-element-property :retain-labels element
)
391 (org-element-property :use-labels element
)))))
392 ;; 5. No switch should not number lines, but retain labels and use
394 (org-test-with-temp-text "#+BEGIN_EXAMPLE\nText.\n#+END_EXAMPLE"
395 (let ((element (org-element-current-element)))
396 (should (and (not (org-element-property :number-lines element
))
397 (org-element-property :retain-labels element
)
398 (org-element-property :use-labels element
)))))
399 (org-test-with-temp-text "#+BEGIN_SRC emacs-lisp\n(+ 1 1)\n#+END_SRC"
400 (let ((element (org-element-current-element)))
401 (should (and (not (org-element-property :number-lines element
))
402 (org-element-property :retain-labels element
)
403 (org-element-property :use-labels element
)))))
404 ;; 6. "-r" switch only: do not number lines, remove labels, and
405 ;; don't use labels in coderefs.
406 (org-test-with-temp-text "#+BEGIN_EXAMPLE -r\nText.\n#+END_EXAMPLE"
407 (let ((element (org-element-current-element)))
408 (should (and (not (org-element-property :number-lines element
))
409 (not (org-element-property :retain-labels element
))
410 (not (org-element-property :use-labels element
))))))
411 (org-test-with-temp-text "#+BEGIN_SRC emacs-lisp -r\n(+ 1 1)\n#+END_SRC"
412 (let ((element (org-element-current-element)))
413 (should (and (not (org-element-property :number-lines element
))
414 (not (org-element-property :retain-labels element
))
415 (not (org-element-property :use-labels element
))))))
416 ;; 7. Recognize coderefs with user-defined syntax.
417 (org-test-with-temp-text
418 "#+BEGIN_EXAMPLE -l \"[ref:%s]\"\nText [ref:text]\n#+END_EXAMPLE"
419 (let ((element (org-element-current-element)))
421 (equal (org-element-property :label-fmt element
) "[ref:%s]"))))
422 (org-test-with-temp-text
423 "#+BEGIN_SRC emacs-lisp -l \"[ref:%s]\"\n(+ 1 1) [ref:text]\n#+END_SRC"
424 (let ((element (org-element-current-element)))
426 (equal (org-element-property :label-fmt element
) "[ref:%s]"))))))
431 (ert-deftest test-org-element
/export-block-parser
()
432 "Test `export-block' parser."
436 (org-test-with-temp-text "#+BEGIN_LATEX\nText\n#+END_LATEX"
438 (org-element-parse-buffer) 'export-block
'identity nil t
))
440 (:begin
1 :end
31 :type
"LATEX" :value
"Text\n" :hiddenp nil
442 ;; Test folded block.
443 (org-test-with-temp-text "#+BEGIN_LATEX\nText\n#+END_LATEX"
446 (org-element-property
449 (org-element-parse-buffer) 'export-block
'identity nil t
))))
450 ;; Ignore incomplete block.
452 (org-test-with-temp-text "#+BEGIN_LATEX"
454 (org-element-parse-buffer) 'export-block
'identity nil t
))))
459 (ert-deftest test-org-element
/export-snippet-parser
()
460 "Test `export-snippet' parser."
463 (org-test-with-temp-text "<back-end@contents>"
465 (org-element-parse-buffer) 'export-snippet
'identity nil t
))
467 (:back-end
"back-end"
468 :value
"contents" :begin
1 :end
20 :post-blank
0)))))
473 (ert-deftest test-org-element
/fixed-width
()
474 "Test fixed-width area parsing."
475 ;; Preserve indentation.
478 (org-test-with-temp-text ": no blank\n: one blank"
479 (org-element-map (org-element-parse-buffer) 'fixed-width
'identity nil t
))
481 (:begin
1 :end
24 :value
"no blank\n one blank\n" :post-blank
0))))
482 ;; Fixed-width with empty lines.
485 (org-test-with-temp-text ": first part\n:\n: \n: second part"
486 (org-element-map (org-element-parse-buffer) 'fixed-width
'identity nil t
))
488 (:begin
1 :end
32 :value
"first part\n\n\nsecond part\n" :post-blank
0))))
489 ;; Parse indented fixed-width markers.
492 (org-test-with-temp-text "Text\n : no blank\n : one blank"
493 (org-element-map (org-element-parse-buffer) 'fixed-width
'identity nil t
))
495 (:begin
6 :end
33 :value
"no blank\n one blank\n" :post-blank
0))))
496 ;; Distinguish fixed-width areas within a list and outside of it.
500 (org-test-with-temp-text "
503 : fixed-width outside"
505 (org-element-parse-buffer) 'fixed-width
'identity
))))))
508 ;;;; Footnote Definition.
510 (ert-deftest test-org-element
/footnote-definition-parser
()
511 "Test `footnote-definition' parser."
514 (org-test-with-temp-text "[fn:1] Definition"
516 (org-element-parse-buffer) 'footnote-definition
'identity nil t
))
517 '(footnote-definition
518 (:label
"fn:1" :begin
1 :end
18 :contents-begin
8 :contents-end
18
521 (:begin
8 :end
18 :contents-begin
8 :contents-end
18 :post-blank
0)
525 ;;;; Footnotes Reference
527 (ert-deftest test-org-element
/footnote-reference-parser
()
528 "Test `footnote-reference' parser."
529 ;; 1. Parse a standard reference.
530 (org-test-with-temp-text "[fn:label]"
531 (should (equal (org-element-footnote-reference-parser)
533 (:label
"fn:label" :type standard
:inline-definition nil
534 :begin
1 :end
11 :post-blank
0)))))
535 ;; 2. Parse a normalized reference.
536 (org-test-with-temp-text "[1]"
537 (should (equal (org-element-footnote-reference-parser)
539 (:label
"1" :type standard
:inline-definition nil
540 :begin
1 :end
4 :post-blank
0)))))
541 ;; 3. Parse an inline reference.
542 (org-test-with-temp-text "[fn:test:def]"
543 (should (equal (org-element-footnote-reference-parser)
545 (:label
"fn:test" :type inline
:inline-definition
("def")
546 :begin
1 :end
14 :post-blank
0)))))
547 ;; 4. Parse an anonymous reference.
548 (org-test-with-temp-text "[fn::def]"
549 (should (equal (org-element-footnote-reference-parser)
551 (:label nil
:type inline
:inline-definition
("def")
552 :begin
1 :end
10 :post-blank
0)))))
553 ;; 5. Parse nested footnotes.
554 (org-test-with-temp-text "[fn::def [fn:label]]"
557 (org-element-footnote-reference-parser)
559 (:label nil
:type inline
563 (:label
"fn:label" :type standard
:inline-definition nil
564 :begin
5 :end
15 :post-blank
0)))
565 :begin
1 :end
21 :post-blank
0)))))
566 ;; 6. Parse adjacent footnotes.
567 (org-test-with-temp-text "[fn:label1][fn:label2]"
570 (org-element-footnote-reference-parser)
572 (:label
"fn:label1" :type standard
:inline-definition nil
:begin
1
573 :end
12 :post-blank
0)))))
574 ;; 7. Only properly closed footnotes are recognized as such.
575 (org-test-with-temp-text "Text [fn:label"
578 (org-element-parse-buffer) 'footnote-reference
'identity
))))
583 (ert-deftest test-org-element
/headline-quote-keyword
()
584 "Test QUOTE keyword recognition."
586 (org-test-with-temp-text "* Headline"
587 (let ((org-quote-string "QUOTE"))
588 (should-not (org-element-property :quotedp
(org-element-at-point)))))
589 ;; Standard position.
590 (org-test-with-temp-text "* QUOTE Headline"
591 (let ((org-quote-string "QUOTE"))
592 (let ((headline (org-element-at-point)))
593 (should (org-element-property :quotedp headline
))
594 ;; Test removal from raw value.
595 (should (equal (org-element-property :raw-value headline
) "Headline"))))
597 (let ((org-quote-string "Quote"))
598 (should-not (org-element-property :quotedp
(org-element-at-point)))))
599 ;; With another keyword.
600 (org-test-with-temp-text "* TODO QUOTE Headline"
601 (let ((org-quote-string "QUOTE")
602 (org-todo-keywords '((sequence "TODO" "DONE"))))
603 (should (org-element-property :quotedp
(org-element-at-point))))))
605 (ert-deftest test-org-element
/headline-comment-keyword
()
606 "Test COMMENT keyword recognition."
608 (org-test-with-temp-text "* Headline"
609 (let ((org-comment-string "COMMENT"))
610 (should-not (org-element-property :commentedp
(org-element-at-point)))))
611 ;; Standard position.
612 (org-test-with-temp-text "* COMMENT Headline"
613 (let ((org-comment-string "COMMENT"))
614 (let ((headline (org-element-at-point)))
615 (should (org-element-property :commentedp headline
))
616 ;; Test removal from raw value.
617 (should (equal (org-element-property :raw-value headline
) "Headline"))))
619 (let ((org-comment-string "Comment"))
620 (should-not (org-element-property :commentedp
(org-element-at-point)))))
621 ;; With another keyword.
622 (org-test-with-temp-text "* TODO COMMENT Headline"
623 (let ((org-comment-string "COMMENT")
624 (org-todo-keywords '((sequence "TODO" "DONE"))))
625 (should (org-element-property :commentedp
(org-element-at-point))))))
627 (ert-deftest test-org-element
/headline-archive-tag
()
628 "Test ARCHIVE tag recognition."
630 (org-test-with-temp-text "* Headline"
631 (let ((org-archive-tag "ARCHIVE"))
632 (should-not (org-element-property :archivedp
(org-element-at-point)))))
634 (org-test-with-temp-text "* Headline :ARCHIVE:"
635 (let ((org-archive-tag "ARCHIVE"))
636 (let ((headline (org-element-at-point)))
637 (should (org-element-property :archivedp headline
))
639 (should-not (org-element-property :tags headline
))))
640 (let ((org-archive-tag "Archive"))
641 (should-not (org-element-property :archivedp
(org-element-at-point)))))
643 (org-test-with-temp-text "* Headline :test:ARCHIVE:"
644 (let ((org-archive-tag "ARCHIVE"))
645 (let ((headline (org-element-at-point)))
646 (should (org-element-property :archivedp headline
))
648 (should (equal (org-element-property :tags headline
) '("test")))))))
653 (ert-deftest test-org-element
/inlinetask-parser
()
654 "Test `inlinetask' parser."
655 (when (featurep 'org-inlinetask
)
656 (let ((org-inlinetask-min-level 15))
657 ;; 1. Regular inlinetask.
660 (org-test-with-temp-text
661 "*************** Task\nTest\n*************** END"
663 (org-element-parse-buffer) 'inlinetask
'identity nil t
))
665 (:title
("Task") :begin
1 :end
46 :hiddenp nil
:contents-begin
22
666 :contents-end
27 :level
15 :priority nil
:tags nil
667 :todo-keyword nil
:todo-type nil
:scheduled nil
:deadline nil
668 :timestamp nil
:clock nil
:post-blank
0 :category
"???")
670 (:begin
22 :end
27 :contents-begin
22 :contents-end
26 :post-blank
0)
672 ;; 2. Degenerate inlinetask.
675 (org-test-with-temp-text
676 "*************** Task"
678 (org-element-parse-buffer) 'inlinetask
'identity nil t
))
680 (:title
("Task") :begin
1 :end
21 :hiddenp nil
:contents-begin
21
681 :contents-end
21 :level
15 :priority nil
:tags nil
682 :todo-keyword nil
:todo-type nil
:scheduled nil
:deadline nil
683 :timestamp nil
:clock nil
:post-blank
0 :category nil
))))
688 (let ((org-todo-keywords '((sequence "TODO" "DONE"))))
689 (org-test-with-temp-text "*************** TODO Task"
690 (org-element-property
693 (org-element-parse-buffer) 'inlinetask
'identity nil t
))))))
698 (org-test-with-temp-text "
700 DEADLINE: <2012-03-29 thu.>"
701 (org-element-property
704 (org-element-parse-buffer) 'inlinetask
'identity nil t
)))))
709 (org-test-with-temp-text "
710 *************** [#A] Task"
711 (org-element-property
714 (org-element-parse-buffer) 'inlinetask
'identity nil t
)))))
719 (org-test-with-temp-text "
720 *************** Task :test:"
721 (org-element-property
724 (org-element-parse-buffer) 'inlinetask
'identity nil t
))))))))
729 (ert-deftest test-org-element
/item-parser
()
730 "Test `item' parser."
734 (org-test-with-temp-text "- item"
735 (org-element-map (org-element-parse-buffer) 'item
'identity nil t
))
737 (:bullet
"- " :begin
1 :end
7 :contents-begin
3 :contents-end
7
738 :checkbox nil
:counter nil
:tag nil
:hiddenp nil
739 :structure
((1 0 "- " nil nil nil
7))
742 (:begin
3 :end
7 :contents-begin
3 :contents-end
7 :post-blank
0)
747 (org-element-property
749 (org-test-with-temp-text "6. [@6] item"
750 (org-element-map (org-element-parse-buffer) 'item
'identity nil t
)))))
755 (org-element-property
757 (org-test-with-temp-text "- tag :: description"
758 (org-element-map (org-element-parse-buffer) 'item
'identity nil t
)))))
763 (org-test-with-temp-text "
768 (org-element-parse-buffer) 'item
769 (lambda (item) (org-element-property :checkbox item
))))))
771 (org-test-with-temp-text "* Headline
776 (let ((org-cycle-include-plain-lists t
)) (org-cycle))
778 (org-element-property
780 (org-element-map (org-element-parse-buffer) 'item
'identity nil t
)))))
785 (ert-deftest test-org-element
/link-parser
()
786 "Test `link' parser."
789 (equal (org-test-with-temp-text "A radio link"
791 (let ((org-target-link-regexp "radio")) (org-element-parse-buffer))
792 'link
'identity nil t
))
793 '(link (:type
"radio" :path
"radio" :raw-link
"radio" :begin
3 :end
9
794 :contents-begin nil
:contents-end nil
:post-blank
1))))
797 ;; 2.1. With description.
799 (equal (org-test-with-temp-text "[[http://orgmode.org][Orgmode.org]]"
800 (org-element-map (org-element-parse-buffer) 'link
'identity nil t
))
801 '(link (:type
"http" :path
"//orgmode.org"
802 :raw-link
"http://orgmode.org" :begin
1 :end
36
803 :contents-begin
23 :contents-end
34 :post-blank
0)
805 ;; 2.2. Without description.
807 (equal (org-test-with-temp-text "[[http://orgmode.org]]"
808 (org-element-map (org-element-parse-buffer) 'link
'identity nil t
))
809 '(link (:type
"http" :path
"//orgmode.org"
810 :raw-link
"http://orgmode.org" :begin
1 :end
23
811 :contents-begin nil
:contents-end nil
:post-blank
0))))
812 ;; 2.3. With expansion.
814 (equal (org-test-with-temp-text "[[Org:worg]]"
815 (let ((org-link-abbrev-alist '(("Org" .
"http://orgmode.org/"))))
817 (org-element-parse-buffer) 'link
'identity nil t
)))
818 '(link (:type
"http" :path
"//orgmode.org/worg" :raw-link
"Org:worg"
819 :begin
1 :end
13 :contents-begin nil
:contents-end nil
821 ;; 2.4. With translation.
823 (equal (org-test-with-temp-text "[[http://orgmode.org]]"
824 (flet ((link-translate (type path
) (cons type
"127.0.0.1")))
825 (let ((org-link-translation-function 'link-translate
))
827 (org-element-parse-buffer) 'link
'identity nil t
))))
828 '(link (:type
"http" :path
"127.0.0.1" :raw-link
"http://orgmode.org"
829 :begin
1 :end
23 :contents-begin nil
:contents-end nil
833 (equal (org-test-with-temp-text "[[id:aaaa]]"
834 (org-element-map (org-element-parse-buffer) 'link
'identity nil t
))
835 '(link (:type
"id" :path
"aaaa" :raw-link
"id:aaaa" :begin
1 :end
12
836 :contents-begin nil
:contents-end nil
:post-blank
0))))
837 ;; 2.6. Custom-id link.
839 (equal (org-test-with-temp-text "[[#some-id]]"
840 (org-element-map (org-element-parse-buffer) 'link
'identity nil t
))
841 '(link (:type
"custom-id" :path
"some-id" :raw-link
"#some-id"
842 :begin
1 :end
13 :contents-begin nil
:contents-end nil
846 (equal (org-test-with-temp-text "[[(reference)]]"
847 (org-element-map (org-element-parse-buffer) 'link
'identity nil t
))
848 '(link (:type
"coderef" :path
"reference" :raw-link
"(reference)"
849 :begin
1 :end
16 :contents-begin nil
:contents-end nil
853 (equal (org-test-with-temp-text "[[target-or-title]]"
854 (org-element-map (org-element-parse-buffer) 'link
'identity nil t
))
855 '(link (:type
"fuzzy" :path
"target-or-title"
856 :raw-link
"target-or-title" :begin
1 :end
20
857 :contents-begin nil
:contents-end nil
:post-blank
0))))
860 (equal (org-test-with-temp-text "A link: http://orgmode.org"
861 (org-element-map (org-element-parse-buffer) 'link
'identity nil t
))
862 '(link (:type
"http" :path
"//orgmode.org"
863 :raw-link
"http://orgmode.org" :begin
9 :end
27
864 :contents-begin nil
:contents-end nil
:post-blank
0))))
867 (equal (org-test-with-temp-text "A link: <http://orgmode.org>"
868 (org-element-map (org-element-parse-buffer) 'link
'identity nil t
))
869 '(link (:type
"http" :path
"//orgmode.org"
870 :raw-link
"http://orgmode.org" :begin
9 :end
29
871 :contents-begin nil
:contents-end nil
:post-blank
0)))))
876 (ert-deftest test-org-element
/plain-list-parser
()
877 "Test `plain-list' parser."
880 (org-test-with-temp-text "- item"
881 (org-element-map (org-element-parse-buffer) 'plain-list
'identity nil t
))
883 (:type unordered
:begin
1 :end
7 :contents-begin
1 :contents-end
7
884 :structure
((1 0 "- " nil nil nil
7)) :post-blank
0)
886 (:bullet
"- " :begin
1 :end
7 :contents-begin
3 :contents-end
7
887 :checkbox nil
:counter nil
:tag nil
:hiddenp nil
888 :structure
((1 0 "- " nil nil nil
7)) :post-blank
0)
890 (:begin
3 :end
7 :contents-begin
3 :contents-end
7 :post-blank
0)
892 ;; Blank lines after the list only belong to outer plain list.
893 (org-test-with-temp-text "
898 (let ((endings (org-element-map
899 (org-element-parse-buffer) 'plain-list
900 (lambda (pl) (org-element-property :end pl
)))))
901 ;; Move to ending of outer list.
902 (goto-char (car endings
))
903 (should (looking-at "Outside list"))
904 ;; Move to ending of inner list.
905 (goto-char (nth 1 endings
))
906 (should (looking-at "^$")))))
911 (ert-deftest test-org-element
/src-block-parser
()
912 "Test `src-block' parser."
916 (org-test-with-temp-text "#+BEGIN_SRC\nText\n#+END_SRC"
918 (org-element-parse-buffer) 'src-block
'identity nil t
))
920 (:language nil
:switches nil
:parameters nil
:begin
1 :end
27
921 :number-lines nil
:preserve-indent nil
:retain-labels t
922 :use-labels t
:label-fmt nil
:hiddenp nil
:value
"Text\n"
924 ;; Test folded block.
925 (org-test-with-temp-text "#+BEGIN_SRC\nText\n#+END_SRC"
928 (org-element-property
931 (org-element-parse-buffer) 'src-block
'identity nil t
))))
932 ;; Ignore incomplete block.
934 (org-test-with-temp-text "#+BEGIN_SRC"
936 (org-element-parse-buffer) 'src-block
'identity nil t
))))
941 (ert-deftest test-org-element
/quote-block-parser
()
942 "Test `quote-block' parser."
946 (org-test-with-temp-text "#+BEGIN_QUOTE\nText\n#+END_QUOTE"
948 (org-element-parse-buffer) 'quote-block
'identity nil t
))
950 (:begin
1 :end
31 :hiddenp nil
:contents-begin
15 :contents-end
20
953 (:begin
15 :end
20 :contents-begin
15 :contents-end
19 :post-blank
0)
955 ;; Test folded block.
956 (org-test-with-temp-text "#+BEGIN_QUOTE\nText\n#+END_QUOTE"
959 (org-element-property
962 (org-element-parse-buffer) 'quote-block
'identity nil t
))))
963 ;; Ignore incomplete block.
965 (org-test-with-temp-text "#+BEGIN_QUOTE"
967 (org-element-parse-buffer) 'quote-block
'identity nil t
))))
972 (ert-deftest test-org-element
/section-parser
()
973 "Test `section' parser."
977 (org-test-with-temp-text "* Headline\nText"
978 (org-element-map (org-element-parse-buffer) 'section
'identity nil t
))
980 (:begin
12 :end
16 :contents-begin
12 :contents-end
16 :post-blank
0)
982 (:begin
12 :end
16 :contents-begin
12 :contents-end
16 :post-blank
0)
984 ;; There's a section before the first headline.
986 (org-test-with-temp-text "Text"
987 (org-element-map (org-element-parse-buffer) 'section
'identity
)))
988 ;; A section cannot be empty.
990 (org-test-with-temp-text "* Headline 1\n* Headline 2"
991 (org-element-map (org-element-parse-buffer) 'section
'identity
))))
996 (ert-deftest test-org-element
/special-block-parser
()
997 "Test `special-block' parser."
1001 (org-test-with-temp-text "#+BEGIN_SPECIAL\nText\n#+END_SPECIAL"
1003 (org-element-parse-buffer) 'special-block
'identity nil t
))
1005 (:type
"SPECIAL" :begin
1 :end
35 :hiddenp nil
:contents-begin
17
1006 :contents-end
22 :post-blank
0)
1008 (:begin
17 :end
22 :contents-begin
17 :contents-end
21 :post-blank
0)
1010 ;; Test folded block.
1011 (org-test-with-temp-text "#+BEGIN_SPECIAL\nText\n#+END_SPECIAL"
1014 (org-element-property
1017 (org-element-parse-buffer) 'special-block
'identity nil t
))))
1018 ;; Ignore incomplete block.
1020 (org-test-with-temp-text "#+BEGIN_SPECIAL"
1022 (org-element-parse-buffer) 'special-block
'identity nil t
))))
1027 (ert-deftest test-org-element
/verse-block-parser
()
1028 "Test `verse-block' parser."
1030 (org-test-with-temp-text "#+BEGIN_VERSE\nVerse block\n#+END_VERSE"
1033 (org-element-map (org-element-parse-buffer) 'verse-block
'identity nil t
)
1035 (:begin
1 :end
38 :contents-begin
15 :contents-end
27 :hiddenp nil
1039 (org-test-with-temp-text "#+begin_verse\nVerse block\n#+end_verse"
1042 (org-element-map (org-element-parse-buffer) 'verse-block
'identity nil t
)
1044 (:begin
1 :end
38 :contents-begin
15 :contents-end
27 :hiddenp nil
1048 (org-test-with-temp-text "#+BEGIN_VERSE\nVerse block\n#+END_VERSE"
1049 (org-hide-block-all)
1052 (org-element-map (org-element-parse-buffer) 'verse-block
'identity nil t
)
1054 (:begin
1 :end
38 :contents-begin
15 :contents-end
27
1055 :hiddenp org-hide-block
:post-blank
0)
1057 ;; Parse objects in verse blocks.
1058 (org-test-with-temp-text "#+BEGIN_VERSE\nVerse \\alpha\n#+END_VERSE"
1059 (should (org-element-map (org-element-parse-buffer) 'entity
'identity
)))
1060 ;; Ignore incomplete verse block.
1062 (org-test-with-temp-text "#+BEGIN_VERSE"
1064 (org-element-parse-buffer) 'verse-block
'identity nil t
))))
1068 ;;; Test Interpreters.
1070 (ert-deftest test-org-element
/interpret-affiliated-keywords
()
1071 "Test if affiliated keywords are correctly interpreted."
1072 ;; Interpret simple keywords.
1075 (org-element-interpret-data
1076 '(org-data nil
(paragraph (:name
"para") "Paragraph")))
1077 "#+NAME: para\nParagraph\n"))
1078 ;; Interpret multiple keywords.
1081 (org-element-interpret-data
1082 '(org-data nil
(paragraph (:attr_ascii
("line1" "line2")) "Paragraph")))
1083 "#+ATTR_ASCII: line1\n#+ATTR_ASCII: line2\nParagraph\n"))
1084 ;; Interpret parsed keywords.
1087 (org-element-interpret-data
1088 '(org-data nil
(paragraph (:caption
("caption")) "Paragraph")))
1089 "#+CAPTION: caption\nParagraph\n"))
1090 ;; Interpret dual keywords.
1093 (org-element-interpret-data
1094 '(org-data nil
(paragraph (:caption
(("long") "short")) "Paragraph")))
1095 "#+CAPTION[short]: long\nParagraph\n")))
1097 (ert-deftest test-org-element
/center-block-interpreter
()
1098 "Test center block interpreter."
1100 (equal (org-test-parse-and-interpret "#+BEGIN_CENTER\nTest\n#+END_CENTER")
1101 "#+BEGIN_CENTER\nTest\n#+END_CENTER\n")))
1103 (ert-deftest test-org-element
/drawer-interpreter
()
1104 "Test drawer interpreter."
1106 (equal (let ((org-drawers '("TEST")))
1107 (org-test-parse-and-interpret ":TEST:\nTest\n:END:"))
1108 ":TEST:\nTest\n:END:\n")))
1110 (ert-deftest test-org-element
/dynamic-block-interpreter
()
1111 "Test dynamic block interpreter."
1113 (equal (org-test-parse-and-interpret
1114 "#+BEGIN: myblock :parameter value1\nTest\n#+END:")
1115 "#+BEGIN: myblock :parameter value1\nTest\n#+END:\n")))
1117 (ert-deftest test-org-element
/footnote-definition-interpreter
()
1118 "Test footnote definition interpreter."
1119 (should (equal (org-test-parse-and-interpret "[fn:1] Test") "[fn:1] Test\n")))
1121 (ert-deftest test-org-element
/headline-interpreter
()
1122 "Test headline and section interpreters."
1123 ;; 1. Standard test.
1124 (should (equal (org-test-parse-and-interpret "* Headline") "* Headline\n"))
1125 ;; 2. With TODO keywords.
1127 (equal (let ((org-todo-keywords '((sequence "TODO" "DONE"))))
1128 (org-test-parse-and-interpret "* TODO Headline"))
1129 "* TODO Headline\n"))
1132 ;; 3.1. ... and a positive `org-tags-column' value.
1134 (equal (let ((org-tags-column 20))
1135 (org-test-parse-and-interpret "* Headline :tag:"))
1136 "* Headline :tag:\n"))
1137 ;; 3.2. ... and a negative `org-tags-column' value.
1139 (equal (let ((org-tags-column -
20))
1140 (org-test-parse-and-interpret "* Headline :tag:"))
1141 "* Headline :tag:\n"))
1142 ;; 3.3. ... and a null `org-tags-column' value.
1144 (equal (let ((org-tags-column 0))
1145 (org-test-parse-and-interpret "* Headline :tag:"))
1146 "* Headline :tag:\n"))
1147 ;; 4. With priority cookie.
1149 (equal (org-test-parse-and-interpret "* [#B] Headline")
1150 "* [#B] Headline\n"))
1151 ;; 5. With comment keyword.
1153 (equal (let ((org-comment-string "COMMENT"))
1154 (org-test-parse-and-interpret "* COMMENT Headline"))
1155 "* COMMENT Headline\n"))
1156 ;; 6. With quote section.
1158 (equal (let ((org-quote-string "QUOTE"))
1159 (org-test-parse-and-interpret "* QUOTE Headline"))
1160 "* QUOTE Headline\n"))
1161 ;; 7. Keep same number of blank lines before body.
1163 (equal (org-test-parse-and-interpret
1164 "* Headline\n\n\nText after two blank lines.")
1165 "* Headline\n\n\nText after two blank lines.\n")))
1167 (ert-deftest test-org-element
/inlinetask-interpreter
()
1168 "Test inlinetask interpretation."
1169 (when (featurep 'org-inlinetask
)
1170 (let ((org-inlinetask-min-level 15))
1171 ;; 1. Regular inlinetask.
1172 (should (equal (org-test-parse-and-interpret
1173 "*************** Task\nTest\n*************** END")
1174 "*************** Task\nTest\n*************** END\n"))
1175 ;; 2. Degenerate inlinetask.
1176 (should (equal (org-test-parse-and-interpret "*************** Task")
1177 "*************** Task\n"))
1178 ;; 3. Prefer degenerate form when there are no contents.
1179 (should (equal (org-test-parse-and-interpret
1180 "*************** Task\n*************** END")
1181 "*************** Task\n"))
1182 ;; 4. With TODO keywords.
1184 (equal (let ((org-todo-keywords '((sequence "TODO" "DONE"))))
1185 (org-test-parse-and-interpret "*************** TODO Task"))
1186 "*************** TODO Task\n"))
1189 ;; 5.1. ... and a positive `org-tags-column' value.
1191 (equal (let ((org-tags-column 30))
1192 (org-test-parse-and-interpret "*************** Task :tag:"))
1193 "*************** Task :tag:\n"))
1194 ;; 5.2. ... and a negative `org-tags-column' value.
1196 (equal (let ((org-tags-column -
30))
1197 (org-test-parse-and-interpret "*************** Task :tag:"))
1198 "*************** Task :tag:\n"))
1199 ;; 5.3. ... and a null `org-tags-column' value.
1201 (equal (let ((org-tags-column 0))
1202 (org-test-parse-and-interpret "*************** Task :tag:"))
1203 "*************** Task :tag:\n"))
1204 ;; 6. With priority cookie.
1206 (equal (org-test-parse-and-interpret "*************** [#B] Task")
1207 "*************** [#B] Task\n")))))
1209 (ert-deftest test-org-element
/plain-list-interpreter
()
1210 "Test plain-list and item interpreters."
1211 ;; 1. Unordered list.
1212 (should (equal (org-test-parse-and-interpret "- item 1") "- item 1\n"))
1213 ;; 2. Description list.
1215 (equal (org-test-parse-and-interpret "- tag :: desc") "- tag :: desc\n"))
1218 (equal (let ((org-plain-list-ordered-item-terminator t
))
1219 (org-test-parse-and-interpret "1. Item"))
1221 ;; 4. Ordered list with counter.
1223 (equal (let ((org-plain-list-ordered-item-terminator t
))
1224 (org-test-parse-and-interpret "1. [@5] Item"))
1226 ;; 5. List with check-boxes.
1228 (equal (org-test-parse-and-interpret
1229 "- [-] Item 1\n - [X] Item 2\n - [ ] Item 3")
1230 "- [-] Item 1\n - [X] Item 2\n - [ ] Item 3\n")))
1232 (ert-deftest test-org-element
/quote-block-interpreter
()
1233 "Test quote block interpreter."
1234 (should (equal (org-test-parse-and-interpret
1235 "#+BEGIN_QUOTE\nTest\n#+END_QUOTE")
1236 "#+BEGIN_QUOTE\nTest\n#+END_QUOTE\n")))
1238 (ert-deftest test-org-element
/special-block-interpreter
()
1239 "Test special block interpreter."
1240 (should (equal (org-test-parse-and-interpret
1241 "#+BEGIN_SPECIAL\nTest\n#+END_SPECIAL")
1242 "#+BEGIN_SPECIAL\nTest\n#+END_SPECIAL\n")))
1244 (ert-deftest test-org-element
/babel-call-interpreter
()
1245 "Test babel call interpreter."
1246 ;; 1. Without argument.
1247 (should (equal (org-test-parse-and-interpret "#+CALL: test()")
1248 "#+CALL: test()\n"))
1249 ;; 2. With argument.
1250 (should (equal (org-test-parse-and-interpret "#+CALL: test(x=2)")
1251 "#+CALL: test(x=2)\n"))
1252 ;; 3. With header arguments.
1253 (should (equal (org-test-parse-and-interpret
1254 "#+CALL: test[:results output]()[:results html]")
1255 "#+CALL: test[:results output]()[:results html]\n")))
1257 (ert-deftest test-org-element
/clock-interpreter
()
1258 "Test clock interpreter."
1261 (equal (let ((org-clock-string "CLOCK:"))
1262 (org-test-parse-and-interpret "CLOCK: [2012-01-01 sun. 00:01]"))
1263 "CLOCK: [2012-01-01 sun. 00:01]\n"))
1267 (let ((org-clock-string "CLOCK:"))
1268 (org-test-parse-and-interpret "
1269 CLOCK: [2012-01-01 sun. 00:01]--[2012-01-01 sun. 00:02] => 0:01"))
1270 "CLOCK: [2012-01-01 sun. 00:01]--[2012-01-01 sun. 00:02] => 0:01\n")))
1272 (ert-deftest test-org-element
/comment-interpreter
()
1273 "Test comment interpreter."
1275 (should (equal (org-test-parse-and-interpret "#Comment") "#+ Comment\n"))
1277 (should (equal (org-test-parse-and-interpret " #+ Comment")
1279 ;; Preserve indentation.
1280 (should (equal (org-test-parse-and-interpret " #+ No blank\n#+ One blank")
1281 "#+ No blank\n#+ One blank\n")))
1283 (ert-deftest test-org-element
/comment-block-interpreter
()
1284 "Test comment block interpreter."
1285 (should (equal (org-test-parse-and-interpret
1286 "#+BEGIN_COMMENT\nTest\n#+END_COMMENT")
1287 "#+BEGIN_COMMENT\nTest\n#+END_COMMENT\n")))
1289 (ert-deftest test-org-element
/example-block-interpreter
()
1290 "Test example block interpreter."
1291 ;; Without switches.
1292 (should (equal (org-test-parse-and-interpret
1293 "#+BEGIN_EXAMPLE\nTest\n#+END_EXAMPLE")
1294 "#+BEGIN_EXAMPLE\nTest\n#+END_EXAMPLE\n"))
1297 (equal (org-test-parse-and-interpret
1298 "#+BEGIN_EXAMPLE -n -k\n(+ 1 1)\n#+END_EXAMPLE")
1299 "#+BEGIN_EXAMPLE -n -k\n(+ 1 1)\n#+END_EXAMPLE\n")))
1301 (ert-deftest test-org-element
/export-block-interpreter
()
1302 "Test export block interpreter."
1303 (should (equal (org-test-parse-and-interpret
1304 "#+BEGIN_HTML\nTest\n#+END_HTML")
1305 "#+BEGIN_HTML\nTest\n#+END_HTML\n")))
1307 (ert-deftest test-org-element
/fixed-width-interpreter
()
1308 "Test fixed width interpreter."
1310 (should (equal (org-test-parse-and-interpret ": Test") ": Test\n"))
1311 ;; Preserve indentation.
1312 (should (equal (org-test-parse-and-interpret ": 2 blanks\n: 1 blank")
1313 ": 2 blanks\n: 1 blank\n")))
1315 (ert-deftest test-org-element
/horizontal-rule-interpreter
()
1316 "Test horizontal rule interpreter."
1317 (should (equal (org-test-parse-and-interpret "-------") "-----\n")))
1319 (ert-deftest test-org-element
/keyword-interpreter
()
1320 "Test keyword interpreter."
1321 (should (equal (org-test-parse-and-interpret "#+KEYWORD: value")
1322 "#+KEYWORD: value\n")))
1324 (ert-deftest test-org-element
/latex-environment-interpreter
()
1325 "Test latex environment interpreter."
1326 (should (equal (org-test-parse-and-interpret
1327 "\\begin{equation}\n1+1=2\n\\end{equation}")
1328 "\\begin{equation}\n1+1=2\n\\end{equation}\n")))
1330 (ert-deftest test-org-element
/planning-interpreter
()
1331 "Test planning interpreter."
1332 (let ((org-closed-string "CLOSED:")
1333 (org-deadline-string "DEADLINE:")
1334 (org-scheduled-string "SCHEDULED:"))
1337 (org-test-parse-and-interpret
1339 CLOSED: <2012-01-01> DEADLINE: <2012-01-01> SCHEDULED: <2012-01-01>")
1341 CLOSED: <2012-01-01> DEADLINE: <2012-01-01> SCHEDULED: <2012-01-01>\n"))))
1343 (ert-deftest test-org-element
/property-drawer-interpreter
()
1344 "Test property drawer interpreter."
1345 (should (equal (let ((org-property-format "%-10s %s"))
1346 (org-test-parse-and-interpret
1347 ":PROPERTIES:\n:prop: value\n:END:"))
1348 ":PROPERTIES:\n:prop: value\n:END:\n")))
1350 (ert-deftest test-org-element
/src-block-interpreter
()
1351 "Test src block interpreter."
1354 (equal (org-test-parse-and-interpret
1355 "#+BEGIN_SRC emacs-lisp :results silent\n(+ 1 1)\n#+END_SRC")
1356 "#+BEGIN_SRC emacs-lisp :results silent\n(+ 1 1)\n#+END_SRC\n"))
1359 (equal (org-test-parse-and-interpret
1360 "#+BEGIN_SRC emacs-lisp -n -k\n(+ 1 1)\n#+END_SRC")
1361 "#+BEGIN_SRC emacs-lisp -n -k\n(+ 1 1)\n#+END_SRC\n")))
1363 (ert-deftest test-org-element
/table-interpreter
()
1364 "Test table, table-row and table-cell interpreters."
1366 (should (equal (org-test-parse-and-interpret "| a | b |\n| c | d |")
1367 "| a | b |\n| c | d |\n"))
1368 ;; 2. Table with horizontal rules.
1369 (should (equal (org-test-parse-and-interpret
1370 "| a | b |\n|---+---|\n| c | d |")
1371 "| a | b |\n|---+---|\n| c | d |\n"))
1372 ;; 3. Table with meta-data.
1373 (should (equal (org-test-parse-and-interpret "| / | < | > |\n| * | 1 | 2 |")
1374 "| / | < | > |\n| * | 1 | 2 |\n")))
1376 (ert-deftest test-org-element
/verse-block-interpreter
()
1377 "Test verse block interpretation."
1379 (equal (org-test-parse-and-interpret "#+BEGIN_VERSE\nTest\n#+END_VERSE")
1380 "#+BEGIN_VERSE\nTest\n#+END_VERSE\n")))
1382 (ert-deftest test-org-element
/bold-interpreter
()
1383 "Test bold interpreter."
1384 (should (equal (org-test-parse-and-interpret "*text*") "*text*\n")))
1386 (ert-deftest test-org-element
/code-interpreter
()
1387 "Test code interpreter."
1388 (should (equal (org-test-parse-and-interpret "~text~") "~text~\n")))
1390 (ert-deftest test-org-element
/entity-interpreter
()
1391 "Test entity interpreter."
1392 ;; 1. Without brackets.
1394 (equal (org-test-parse-and-interpret "\\alpha text") "\\alpha text\n"))
1395 ;; 2. With brackets.
1397 (equal (org-test-parse-and-interpret "\\alpha{}text") "\\alpha{}text\n")))
1399 (ert-deftest test-org-element
/export-snippet-interpreter
()
1400 "Test export snippet interpreter."
1401 (should (equal (org-test-parse-and-interpret "<back-end@contents>")
1402 "<back-end@contents>\n")))
1404 (ert-deftest test-org-element
/footnote-reference-interpreter
()
1405 "Test footnote reference interpreter."
1406 ;; 1. Regular reference.
1407 (should (equal (org-test-parse-and-interpret "Text[fn:1]") "Text[fn:1]\n"))
1408 ;; 2. Normalized reference.
1409 (should (equal (org-test-parse-and-interpret "Text[1]") "Text[1]\n"))
1410 ;; 3. Named reference.
1411 (should (equal (org-test-parse-and-interpret "Text[fn:label]")
1412 "Text[fn:label]\n"))
1413 ;; 4. Inline reference.
1414 (should (equal (org-test-parse-and-interpret "Text[fn:label:def]")
1415 "Text[fn:label:def]\n"))
1416 ;; 5. Anonymous reference.
1417 (should (equal (org-test-parse-and-interpret "Text[fn::def]")
1418 "Text[fn::def]\n")))
1420 (ert-deftest test-org-element
/inline-babel-call-interpreter
()
1421 "Test inline babel call interpreter."
1422 ;; 1. Without arguments.
1423 (should (equal (org-test-parse-and-interpret "call_test()") "call_test()\n"))
1424 ;; 2. With arguments.
1425 (should (equal (org-test-parse-and-interpret "call_test(x=2)")
1426 "call_test(x=2)\n"))
1427 ;; 3. With header arguments.
1428 (should (equal (org-test-parse-and-interpret
1429 "call_test[:results output]()[:results html]")
1430 "call_test[:results output]()[:results html]\n")))
1432 (ert-deftest test-org-element
/inline-src-block-interpreter
()
1433 "Test inline src block interpreter."
1434 ;; 1. Without header argument.
1435 (should (equal (org-test-parse-and-interpret "src_emacs-lisp{(+ 1 1)}")
1436 "src_emacs-lisp{(+ 1 1)}\n"))
1437 ;; 2. With header arguments.
1438 (should (equal (org-test-parse-and-interpret
1439 "src_emacs-lisp[:results silent]{(+ 1 1)}")
1440 "src_emacs-lisp[:results silent]{(+ 1 1)}\n")))
1442 (ert-deftest test-org-element
/italic-interpreter
()
1443 "Test italic interpreter."
1444 (should (equal (org-test-parse-and-interpret "/text/") "/text/\n")))
1446 (ert-deftest test-org-element
/latex-fragment-interpreter
()
1447 "Test latex fragment interpreter."
1448 (let ((org-latex-regexps
1449 '(("begin" "^[ ]*\\(\\\\begin{\\([a-zA-Z0-9\\*]+\\)[^