| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872 | 
							- ;;; test-org-list.el --- Tests for org-list.el
 
- ;; Copyright (C) 2012, 2013, 2014  Nicolas Goaziou
 
- ;; Author: Nicolas Goaziou <n.goaziou at gmail dot com>
 
- ;; This program is free software; you can redistribute it and/or modify
 
- ;; it under the terms of the GNU General Public License as published by
 
- ;; the Free Software Foundation, either version 3 of the License, or
 
- ;; (at your option) any later version.
 
- ;; This program is distributed in the hope that it will be useful,
 
- ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
 
- ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
- ;; GNU General Public License for more details.
 
- ;; You should have received a copy of the GNU General Public License
 
- ;; along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
- ;;; Code:
 
- (ert-deftest test-org-list/list-ending ()
 
-   "Test if lists end at the right place."
 
-   ;; With two blank lines.
 
-   (org-test-with-temp-text "- item\n\n\n  Text"
 
-     (goto-line 4)
 
-     (should-not (org-in-item-p)))
 
-   ;; With text less indented than top items.
 
-   (org-test-with-temp-text "- item\nText"
 
-     (goto-line 2)
 
-     (should-not (org-in-item-p)))
 
-   ;; Though, blank lines and text indentation is ignored in blocks.
 
-   (org-test-with-temp-text
 
-       "- item\n  #+begin_quote\n\n\nText at column 0\n  #+end_quote\n Text"
 
-     (goto-line 7)
 
-     (should (org-in-item-p))))
 
- (ert-deftest test-org-list/list-navigation ()
 
-   "Test list navigation specifications."
 
-   (org-test-with-temp-text "
 
- - item A
 
- - item B
 
- - item 1
 
-   - item 1.1
 
-   - item 1.2
 
-   - item 1.3
 
- - item 2
 
- - item X
 
- - item Y"
 
-     (let ((org-list-use-circular-motion nil))
 
-       ;; 1. Test `org-next-item'.
 
-       ;;
 
-       ;; 1.1. Should return an error if at last item in
 
-       ;;      a list/sub-list, unless `org-list-use-circular-motion'
 
-       ;;      is non-nil.
 
-       (goto-line 9)
 
-       (should-error (org-next-item))
 
-       (let ((org-list-use-circular-motion t))
 
- 	(should (progn (org-next-item) t)))
 
-       (goto-line 14)
 
-       (should-error (org-next-item))
 
-       (let ((org-list-use-circular-motion t))
 
- 	(should (progn (org-next-item) t)))
 
-       ;; 1.2. Should jump over sub-lists.
 
-       (goto-line 6)
 
-       (org-next-item)
 
-       (should (looking-at "- item 2"))
 
-       ;; 1.3. Shouldn't move to another list.
 
-       (goto-line 3)
 
-       (should-error (org-next-item))
 
-       (should-not (looking-at "- item 1"))
 
-       ;; 1.4. Should move to the list/sub-list first item when
 
-       ;;     `org-list-use-circular-motion' is non-nil.
 
-       (let ((org-list-use-circular-motion t))
 
- 	(goto-line 10)
 
- 	(org-next-item)
 
- 	(should (looking-at "- item 1"))
 
- 	(goto-line 9)
 
- 	(org-next-item)
 
- 	(should (looking-at "  - item 1.1")))
 
-       ;; 2. Test `org-previous-item'.
 
-       ;;
 
-       ;; 2.1. Should return an error if at first item in
 
-       ;;      a list/sub-list, unless `org-list-use-circular-motion is
 
-       ;;      non-nil.
 
-       (goto-line 7)
 
-       (should-error (org-previous-item))
 
-       (let ((org-list-use-circular-motion t))
 
- 	(should (progn (org-previous-item) t)))
 
-       (goto-line 13)
 
-       (should-error (org-previous-item))
 
-       (let ((org-list-use-circular-motion t))
 
- 	(should (progn (org-previous-item) t)))
 
-       ;; 2.2. Should ignore sub-lists.
 
-       (goto-line 10)
 
-       (org-previous-item)
 
-       (should (looking-at "- item 1"))
 
-       ;; 2.3. Shouldn't move to another list.
 
-       (goto-line 6)
 
-       (should-error (org-previous-item))
 
-       (should-not (looking-at "- item B"))
 
-       ;; 2.4. Should move to the list/sub-list last item when
 
-       ;;      `org-list-use-circular-motion' is non-nil.
 
-       (let ((org-list-use-circular-motion t))
 
- 	(goto-line 6)
 
- 	(org-previous-item)
 
- 	(should (looking-at "- item 2"))
 
- 	(goto-line 7)
 
- 	(org-previous-item)
 
- 	(should (looking-at "  - item 1.3"))))))
 
- (ert-deftest test-org-list/cycle-bullet ()
 
-   "Test `org-cycle-list-bullet' specifications."
 
-   ;; Error when not at an item.
 
-   (should-error
 
-    (org-test-with-temp-text "Paragraph"
 
-      (org-cycle-list-bullet)))
 
-   ;; Cycle through "-", "+", "*", "1.", "1)".
 
-   (org-test-with-temp-text "  - item"
 
-     (org-cycle-list-bullet)
 
-     (should (looking-at "[ \t]+\\+"))
 
-     (org-cycle-list-bullet)
 
-     (should (looking-at "[ \t]+\\*"))
 
-     (let ((org-plain-list-ordered-item-terminator t))
 
-       (org-cycle-list-bullet))
 
-     (should (looking-at "[ \t]+1\\."))
 
-     (let ((org-plain-list-ordered-item-terminator t))
 
-       (org-cycle-list-bullet))
 
-     (should (looking-at "[ \t]+1)")))
 
-   ;; Argument is a valid bullet: cycle to that bullet directly.
 
-   (should
 
-    (equal "1. item"
 
- 	  (org-test-with-temp-text "- item"
 
- 	    (let ((org-plain-list-ordered-item-terminator t))
 
- 	      (org-cycle-list-bullet "1.")
 
- 	      (buffer-string)))))
 
-   ;; Argument is an integer N: cycle to the Nth allowed bullet.
 
-   (should
 
-    (equal "+ item"
 
- 	  (org-test-with-temp-text "1. item"
 
- 	    (let ((org-plain-list-ordered-item-terminator t))
 
- 	      (org-cycle-list-bullet 1)
 
- 	      (buffer-string)))))
 
-   ;; Argument is `previous': cycle backwards.
 
-   (should
 
-    (equal "- item"
 
- 	  (org-test-with-temp-text "+ item"
 
- 	    (let ((org-plain-list-ordered-item-terminator t))
 
- 	      (org-cycle-list-bullet 'previous)
 
- 	      (buffer-string)))))
 
-   ;; Do not cycle to "*" bullets when item is at column 0.
 
-   (should
 
-    (equal "1. item"
 
- 	  (org-test-with-temp-text "+ item"
 
- 	    (let ((org-plain-list-ordered-item-terminator t))
 
- 	      (org-cycle-list-bullet)
 
- 	      (buffer-string)))))
 
-   ;; Do not cycle to numbered bullets in a description list.
 
-   (should-not
 
-    (equal "1. tag :: item"
 
- 	  (org-test-with-temp-text "+ tag :: item"
 
- 	    (let ((org-plain-list-ordered-item-terminator t))
 
- 	      (org-cycle-list-bullet)
 
- 	      (buffer-string)))))
 
-   ;; Do not cycle to ordered item terminators if they are not allowed
 
-   ;; in `org-plain-list-ordered-item-terminator'.
 
-   (should
 
-    (equal "  1) item"
 
- 	  (org-test-with-temp-text "  * item"
 
- 	    (let ((org-plain-list-ordered-item-terminator 41))
 
- 	      (org-cycle-list-bullet)
 
- 	      (buffer-string)))))
 
-   ;; When `org-list-allow-alphabetical' is non-nil, cycle to alpha bullets.
 
-   (should
 
-    (equal "a. item"
 
- 	  (org-test-with-temp-text "1) item"
 
- 	    (let ((org-plain-list-ordered-item-terminator t)
 
- 		  (org-list-allow-alphabetical t))
 
- 	      (org-cycle-list-bullet)
 
- 	      (buffer-string)))))
 
-   ;; Do not cycle to alpha bullets when list has more than 26
 
-   ;; elements.
 
-   (should-not
 
-    (equal "a. item 1"
 
- 	  (org-test-with-temp-text "1) item 1
 
- 2) item 2
 
- 3) item 3
 
- 4) item 4
 
- 5) item 5
 
- 6) item 6
 
- 7) item 7
 
- 8) item 8
 
- 9) item 9
 
- 10) item 10
 
- 11) item 11
 
- 12) item 12
 
- 13) item 13
 
- 14) item 14
 
- 15) item 15
 
- 16) item 16
 
- 17) item 17
 
- 18) item 18
 
- 19) item 19
 
- 20) item 20
 
- 21) item 21
 
- 22) item 22
 
- 23) item 23
 
- 24) item 24
 
- 25) item 25
 
- 26) item 26
 
- 27) item 27"
 
- 	    (let ((org-plain-list-ordered-item-terminator t)
 
- 		  (org-list-allow-alphabetical t))
 
- 	      (org-cycle-list-bullet)
 
- 	      (buffer-substring (point) (line-end-position)))))))
 
- (ert-deftest test-org-list/indent-item ()
 
-   "Test `org-indent-item' specifications."
 
-   ;; 1. Error when not at an item.
 
-   (org-test-with-temp-text "Paragraph."
 
-     (should-error (org-indent-item)))
 
-   ;; 2. Error when trying to move first item of a list.
 
-   (org-test-with-temp-text "
 
- - Item 1
 
- - Item 2"
 
-     (forward-line)
 
-     (should-error (org-indent-item)))
 
-   ;; 3. Indent a single item, not its children.
 
-   (org-test-with-temp-text "
 
- - Item 1
 
- - Item 2
 
-   - Item 2.1"
 
-     (search-forward "- Item 2")
 
-     (let (org-list-demote-modify-bullet) (org-indent-item))
 
-     (should (equal (buffer-string)
 
- 		   "
 
- - Item 1
 
-   - Item 2
 
-   - Item 2.1")))
 
-   ;; 4. Follow `org-list-demote-modify-bullet' specifications.
 
-   ;;
 
-   ;; 4.1. With unordered lists.
 
-   (org-test-with-temp-text "
 
- - Item 1
 
- - Item 2"
 
-     (search-forward "- Item 2")
 
-     (let ((org-list-demote-modify-bullet '(("-" . "+")))) (org-indent-item))
 
-     (should (equal (buffer-string)
 
- 		   "
 
- - Item 1
 
-   + Item 2")))
 
-   ;; 4.2. and ordered lists.
 
-   (org-test-with-temp-text "
 
- 1. Item 1
 
- 2. Item 2"
 
-     (search-forward "2. Item 2")
 
-     (let ((org-plain-list-ordered-item-terminator t)
 
- 	  (org-list-demote-modify-bullet '(("1." . "+"))))
 
-       (org-indent-item))
 
-     (should (equal (buffer-string)
 
- 		   "
 
- 1. Item 1
 
-    + Item 2")))
 
-   ;; 5. When a region is selected, indent every item within.
 
-   (org-test-with-temp-text "
 
- - Item 1
 
- - Item 2
 
- - Item 3
 
- "
 
-     (search-forward "- Item 2")
 
-     (beginning-of-line)
 
-     (transient-mark-mode 1)
 
-     (push-mark (point) t t)
 
-     (goto-char (point-max))
 
-     (let (org-list-demote-modify-bullet) (org-indent-item))
 
-     (should (equal (buffer-string)
 
- 		   "
 
- - Item 1
 
-   - Item 2
 
-   - Item 3
 
- "))))
 
- (ert-deftest test-org-list/indent-item-tree ()
 
-   "Test `org-indent-item-tree' specifications."
 
-   ;; 1. Error when not at an item.
 
-   (org-test-with-temp-text "Paragraph."
 
-     (should-error (org-indent-item-tree)))
 
-   ;; 2. Indent item along with its children.
 
-   (org-test-with-temp-text "
 
- - Item 1
 
- - Item 2
 
-   - Item 2.1"
 
-     (search-forward "- Item 2")
 
-     (let (org-list-demote-modify-bullet) (org-indent-item-tree))
 
-     (should (equal (buffer-string)
 
- 		   "
 
- - Item 1
 
-   - Item 2
 
-     - Item 2.1")))
 
-   ;; 3. Special case: When indenting top item, move the whole list.
 
-   (org-test-with-temp-text "
 
- - Item 1
 
- - Item 2"
 
-     (search-forward "- Item 1")
 
-     (let (org-list-demote-modify-bullet org-odd-levels-only)
 
-       (org-indent-item-tree))
 
-     (should (equal (buffer-string)
 
- 		   "
 
-  - Item 1
 
-  - Item 2")))
 
-   ;; 4. Follow `org-list-demote-modify-bullet' specifications.
 
-   ;;
 
-   ;; 4.1. With unordered lists.
 
-   (org-test-with-temp-text "
 
- - Item 1
 
- - Item 2
 
-   + Item 2.1"
 
-     (search-forward "- Item 2")
 
-     (let ((org-list-demote-modify-bullet '(("-" . "+") ("+" . "-"))))
 
-       (org-indent-item-tree))
 
-     (should (equal (buffer-string)
 
- 		   "
 
- - Item 1
 
-   + Item 2
 
-     - Item 2.1")))
 
-   ;; 4.2. and ordered lists.
 
-   (org-test-with-temp-text "
 
- 1. Item 1
 
- 2. Item 2
 
-    + Item 2.1"
 
-     (search-forward "2. Item 2")
 
-     (let ((org-plain-list-ordered-item-terminator t)
 
- 	  (org-list-demote-modify-bullet '(("1." . "+") ("+" . "1."))))
 
-       (org-indent-item-tree))
 
-     (should (equal (buffer-string)
 
- 		   "
 
- 1. Item 1
 
-    + Item 2
 
-      1. Item 2.1")))
 
-   ;; 5. When a region is selected, indent every item within.
 
-   (org-test-with-temp-text "
 
- - Item 1
 
- - Item 2
 
-   - Item 2.1
 
- - Item 3
 
-   - Item 3.1
 
- "
 
-     (search-forward "- Item 2")
 
-     (beginning-of-line)
 
-     (transient-mark-mode 1)
 
-     (push-mark (point) t t)
 
-     (goto-char (point-max))
 
-     (let (org-list-demote-modify-bullet) (org-indent-item-tree))
 
-     (should (equal (buffer-string)
 
- 		   "
 
- - Item 1
 
-   - Item 2
 
-     - Item 2.1
 
-   - Item 3
 
-     - Item 3.1
 
- "))))
 
- (ert-deftest test-org-list/outdent-item ()
 
-   "Test `org-outdent-item' specifications."
 
-   ;; 1. Error when not at an item.
 
-   (org-test-with-temp-text "Paragraph."
 
-     (should-error (org-outdent-item)))
 
-   ;; 2. Error when trying to move first item of a list.
 
-   (org-test-with-temp-text "
 
- - Item 1
 
- - Item 2"
 
-     (forward-line)
 
-     (should-error (org-outdent-item)))
 
-   ;; 3. Error when trying to outdent an item without its children.
 
-   (org-test-with-temp-text "
 
- - Item 1
 
-   - Item 1.1
 
-     - Item 1.1.1"
 
-     (search-forward "- Item 1.1")
 
-     (should-error (org-outdent-item)))
 
-   ;; 4. Error when trying to outdent before top item.
 
-   (org-test-with-temp-text "
 
-   - Item 1
 
-   - Item 2"
 
-     (search-forward "- Item 2")
 
-     (should-error (org-outdent-item)))
 
-   ;; 5. When a region is selected, outdent every item within.
 
-   (org-test-with-temp-text "
 
- - Item 1
 
-   - Item 2
 
-   - Item 3
 
- "
 
-     (search-forward "- Item 2")
 
-     (beginning-of-line)
 
-     (transient-mark-mode 1)
 
-     (push-mark (point) t t)
 
-     (goto-char (point-max))
 
-     (let (org-list-demote-modify-bullet) (org-outdent-item))
 
-     (should (equal (buffer-string)
 
- 		   "
 
- - Item 1
 
- - Item 2
 
- - Item 3
 
- "))))
 
- (ert-deftest test-org-list/outdent-item-tree ()
 
-   "Test `org-outdent-item-tree' specifications."
 
-   ;; 1. Error when not at an item.
 
-   (org-test-with-temp-text "Paragraph."
 
-     (should-error (org-outdent-item-tree)))
 
-   ;; 2. Error when trying to outdent before top item.
 
-   (org-test-with-temp-text "
 
-   - Item 1
 
-   - Item 2"
 
-     (search-forward "- Item 2")
 
-     (should-error (org-outdent-item-tree)))
 
-   ;; 3. Outdent item along with its children.
 
-   (org-test-with-temp-text "
 
- - Item 1
 
-   - Item 2
 
-     - Item 2.1"
 
-     (search-forward "- Item 2")
 
-     (org-outdent-item-tree)
 
-     (should (equal (buffer-string)
 
- 		   "
 
- - Item 1
 
- - Item 2
 
-   - Item 2.1")))
 
-   ;; 3. Special case: When outdenting top item, move the whole list.
 
-   (org-test-with-temp-text "
 
-  - Item 1
 
-  - Item 2"
 
-     (search-forward "- Item 1")
 
-     (let (org-odd-levels-only) (org-outdent-item-tree))
 
-     (should (equal (buffer-string)
 
- 		   "
 
- - Item 1
 
- - Item 2")))
 
-   ;; 5. When a region is selected, outdent every item within.
 
-   (org-test-with-temp-text "
 
- - Item 1
 
-   - Item 2
 
-     - Item 2.1
 
-   - Item 3
 
-     - Item 3.1
 
- "
 
-     (search-forward "- Item 2")
 
-     (beginning-of-line)
 
-     (transient-mark-mode 1)
 
-     (push-mark (point) t t)
 
-     (goto-char (point-max))
 
-     (org-outdent-item-tree)
 
-     (should (equal (buffer-string)
 
- 		   "
 
- - Item 1
 
- - Item 2
 
-   - Item 2.1
 
- - Item 3
 
-   - Item 3.1
 
- "))))
 
- (ert-deftest test-org-list/move-item-down ()
 
-   "Test `org-move-item-down' specifications."
 
-   ;; Standard test.
 
-   (org-test-with-temp-text "- item 1\n- item 2"
 
-     (org-move-item-down)
 
-     (should (equal (buffer-string)
 
- 		   "- item 2\n- item 1")))
 
-   ;; Keep same column in item.
 
-   (org-test-with-temp-text "- item 1\n- item 2"
 
-     (forward-char 4)
 
-     (org-move-item-down)
 
-     (should (looking-at "em 1")))
 
-   ;; Move sub-items.
 
-   (org-test-with-temp-text "- item 1\n  - sub-item 1\n- item 2"
 
-     (org-move-item-down)
 
-     (should (equal (buffer-string)
 
- 		   "- item 2\n- item 1\n  - sub-item 1")))
 
-   ;; Preserve blank lines.
 
-   (org-test-with-temp-text "- item 1\n\n- item 2"
 
-     (let ((org-list-empty-line-terminates-plain-lists nil)) (org-move-item-down))
 
-     (should (equal (buffer-string) "- item 2\n\n- item 1")))
 
-   ;; Error when trying to move the last item...
 
-   (org-test-with-temp-text "- item 1\n- item 2"
 
-     (forward-line)
 
-     (should-error (org-move-item-down)))
 
-   ;; ... unless `org-list-use-circular-motion' is non-nil.  In this
 
-   ;; case, move to the first item.
 
-   (org-test-with-temp-text "- item 1\n- item 2\n- item 3"
 
-     (forward-line 2)
 
-     (let ((org-list-use-circular-motion t)) (org-move-item-down))
 
-     (should (equal (buffer-string) "- item 3\n- item 1\n- item 2\n")))
 
-   ;; Preserve item visibility.
 
-   (org-test-with-temp-text "* Headline\n- item 1\n  body 1\n- item 2\n  body 2"
 
-     (let ((org-cycle-include-plain-lists t))
 
-       (search-forward "- item 1")
 
-       (org-cycle)
 
-       (search-forward "- item 2")
 
-       (org-cycle))
 
-     (search-backward "- item 1")
 
-     (org-move-item-down)
 
-     (forward-line)
 
-     (should (org-invisible-p2))
 
-     (search-backward " body 2")
 
-     (should (org-invisible-p2)))
 
-   ;; Preserve children visibility.
 
-   (org-test-with-temp-text "* Headline
 
- - item 1
 
-   - sub-item 1
 
-     sub-body 1
 
- - item 2
 
-   - sub-item 2
 
-     sub-body 2"
 
-     (let ((org-cycle-include-plain-lists t))
 
-       (search-forward "- sub-item 1")
 
-       (org-cycle)
 
-       (search-forward "- sub-item 2")
 
-       (org-cycle))
 
-     (search-backward "- item 1")
 
-     (org-move-item-down)
 
-     (search-forward "sub-body 1")
 
-     (should (org-invisible-p2))
 
-     (search-backward "sub-body 2")
 
-     (should (org-invisible-p2)))
 
-   ;; Preserve contents visibility.
 
-   (org-test-with-temp-text "
 
- - item 1
 
-   #+BEGIN_CENTER
 
-   Text1
 
-   #+END_CENTER
 
- - item 2
 
-   #+BEGIN_CENTER
 
-   Text2
 
-   #+END_CENTER"
 
-     (org-hide-block-all)
 
-     (search-forward "- item 1")
 
-     (org-move-item-down)
 
-     (search-forward "Text1")
 
-     (should (org-invisible-p2))
 
-     (search-backward "Text2")
 
-     (should (org-invisible-p2))))
 
- (ert-deftest test-org-list/move-item-up ()
 
-   "Test `org-move-item-up' specifications."
 
-   ;; Standard test.
 
-   (org-test-with-temp-text "- item 1\n- item 2"
 
-     (forward-line)
 
-     (org-move-item-up)
 
-     (should (equal (buffer-string)
 
- 		   "- item 2\n- item 1")))
 
-   ;; Keep same column in item.
 
-   (org-test-with-temp-text "- item 1\n- item 2"
 
-     (forward-line)
 
-     (forward-char 4)
 
-     (org-move-item-up)
 
-     (should (looking-at "em 2")))
 
-   ;; Move sub-items.
 
-   (org-test-with-temp-text "- item 1\n- item 2\n  - sub-item 2"
 
-     (forward-line)
 
-     (org-move-item-up)
 
-     (should (equal (buffer-string)
 
- 		   "- item 2\n  - sub-item 2\n- item 1")))
 
-   ;; Preserve blank lines.
 
-   (org-test-with-temp-text "- item 1\n\n- item 2"
 
-     (search-forward "- item 2")
 
-     (let ((org-list-empty-line-terminates-plain-lists nil)) (org-move-item-up))
 
-     (should (equal (buffer-string) "- item 2\n\n- item 1")))
 
-   ;; Error when trying to move the first item...
 
-   (org-test-with-temp-text "- item 1\n- item 2"
 
-     (should-error (org-move-item-up)))
 
-   ;; ... unless `org-list-use-circular-motion' is non-nil.  In this
 
-   ;; case, move to the first item.
 
-   (org-test-with-temp-text "- item 1\n- item 2\n- item 3"
 
-     (let ((org-list-use-circular-motion t)) (org-move-item-up))
 
-     (should (equal (buffer-string) "- item 2\n- item 3\n- item 1")))
 
-   ;; Preserve item visibility.
 
-   (org-test-with-temp-text "* Headline\n- item 1\n  body 1\n- item 2\n  body 2"
 
-     (let ((org-cycle-include-plain-lists t))
 
-       (search-forward "- item 1")
 
-       (org-cycle)
 
-       (search-forward "- item 2")
 
-       (org-cycle))
 
-     (org-move-item-up)
 
-     (forward-line)
 
-     (should (org-invisible-p2))
 
-     (search-forward " body 1")
 
-     (should (org-invisible-p2)))
 
-   ;; Preserve children visibility.
 
-   (org-test-with-temp-text "* Headline
 
- - item 1
 
-   - sub-item 1
 
-     sub-body 1
 
- - item 2
 
-   - sub-item 2
 
-     sub-body 2"
 
-     (let ((org-cycle-include-plain-lists t))
 
-       (search-forward "- sub-item 1")
 
-       (org-cycle)
 
-       (search-forward "- sub-item 2")
 
-       (org-cycle))
 
-     (search-backward "- item 2")
 
-     (org-move-item-up)
 
-     (search-forward "sub-body 2")
 
-     (should (org-invisible-p2))
 
-     (search-forward "sub-body 1")
 
-     (should (org-invisible-p2)))
 
-   ;; Preserve contents visibility.
 
-   (org-test-with-temp-text "
 
- - item 1
 
-   #+BEGIN_CENTER
 
-   Text1
 
-   #+END_CENTER
 
- - item 2
 
-   #+BEGIN_CENTER
 
-   Text2
 
-   #+END_CENTER"
 
-     (org-hide-block-all)
 
-     (search-forward "- item 2")
 
-     (org-move-item-up)
 
-     (search-forward "Text2")
 
-     (should (org-invisible-p2))
 
-     (search-forward "Text1")
 
-     (should (org-invisible-p2))))
 
- (ert-deftest test-org-list/insert-item ()
 
-   "Test item insertion."
 
-   ;; Blank lines specifications.
 
-   ;;
 
-   ;; Non-nil `org-blank-before-new-entry': insert a blank line, unless
 
-   ;; `org-list-empty-line-terminates-plain-lists' is non-nil.
 
-   (should
 
-    (org-test-with-temp-text "- a"
 
-      (let ((org-list-empty-line-terminates-plain-lists nil)
 
- 	   (org-blank-before-new-entry '((plain-list-item . t))))
 
-        (end-of-line)
 
-        (org-insert-item)
 
-        (forward-line -1)
 
-        (looking-at "$"))))
 
-   (should-not
 
-    (org-test-with-temp-text "- a"
 
-      (let ((org-list-empty-line-terminates-plain-lists t)
 
- 	   (org-blank-before-new-entry '((plain-list-item . t))))
 
-        (end-of-line)
 
-        (org-insert-item)
 
-        (forward-line -1)
 
-        (looking-at "$"))))
 
-   ;; Nil `org-blank-before-new-entry': do not insert a blank line.
 
-   (should-not
 
-    (org-test-with-temp-text "- a"
 
-      (let ((org-list-empty-line-terminates-plain-lists nil)
 
- 	   (org-blank-before-new-entry '((plain-list-item . nil))))
 
-        (end-of-line)
 
-        (org-insert-item)
 
-        (forward-line -1)
 
-        (looking-at "$"))))
 
-   ;; `org-blank-before-new-entry' set to auto: if there's no blank
 
-   ;; line already in the sole item, do not insert one.
 
-   (should-not
 
-    (org-test-with-temp-text "- a"
 
-      (let ((org-list-empty-line-terminates-plain-lists nil)
 
- 	   (org-blank-before-new-entry '((plain-list-item . auto))))
 
-        (end-of-line)
 
-        (org-insert-item)
 
-        (forward-line -1)
 
-        (looking-at "$"))))
 
-   ;; `org-blank-before-new-entry' set to `auto': if there's a blank
 
-   ;; line in the sole item, insert another one.
 
-   (should
 
-    (org-test-with-temp-text "- a\n\n  b"
 
-      (let ((org-list-empty-line-terminates-plain-lists nil)
 
- 	   (org-blank-before-new-entry '((plain-list-item . auto))))
 
-        (goto-char (point-max))
 
-        (org-insert-item)
 
-        (forward-line -1)
 
-        (looking-at "$"))))
 
-   ;; `org-blank-before-new-entry' set to `auto': if the user specified
 
-   ;; a blank line, preserve it.
 
-   (should
 
-    (org-test-with-temp-text "- a\n\n"
 
-      (let ((org-list-empty-line-terminates-plain-lists nil)
 
- 	   (org-blank-before-new-entry '((plain-list-item . auto))))
 
-        (goto-char (point-max))
 
-        (org-insert-item)
 
-        (forward-line -1)
 
-        (looking-at "$"))))
 
-   ;; `org-blank-before-new-entry' set to `auto': if some items in list
 
-   ;; are already separated by blank lines, insert one.
 
-   (should
 
-    (org-test-with-temp-text "- a\n\n- b"
 
-      (let ((org-list-empty-line-terminates-plain-lists nil)
 
- 	   (org-blank-before-new-entry '((plain-list-item . auto))))
 
-        (goto-char (point-max))
 
-        (org-insert-item)
 
-        (forward-line -1)
 
-        (looking-at "$"))))
 
-   (should
 
-    (org-test-with-temp-text "- a\n\n- b"
 
-      (let ((org-list-empty-line-terminates-plain-lists nil)
 
- 	   (org-blank-before-new-entry '((plain-list-item . auto))))
 
-        (org-insert-item)
 
-        (forward-line)
 
-        (looking-at "$"))))
 
-   (should
 
-    (org-test-with-temp-text "- a\n  #+BEGIN_EXAMPLE\n\n  x\n  #+END_EXAMPLE"
 
-      (let ((org-list-empty-line-terminates-plain-lists nil)
 
- 	   (org-blank-before-new-entry '((plain-list-item . auto))))
 
-        (goto-char (point-max))
 
-        (org-insert-item)
 
-        (forward-line -1)
 
-        (looking-at "$")))))
 
- (ert-deftest test-org-list/repair ()
 
-   "Test `org-list-repair' specifications."
 
-   ;; Repair indentation.
 
-   (should
 
-    (equal "- item\n  - child"
 
- 	  (org-test-with-temp-text "- item\n - child"
 
- 	    (let ((org-list-indent-offset 0)) (org-list-repair))
 
- 	    (buffer-string))))
 
-   ;; Repair bullets and numbering.
 
-   (should
 
-    (equal "- a\n- b"
 
- 	  (org-test-with-temp-text "- a\n+ b"
 
- 	    (let ((org-list-indent-offset 0))
 
- 	      (org-list-repair))
 
- 	    (buffer-string))))
 
-   (should
 
-    (equal "1. a\n2. b"
 
- 	  (org-test-with-temp-text "1. a\n1. b"
 
- 	    (let ((org-list-indent-offset 0)
 
- 		  (org-plain-list-ordered-item-terminator t))
 
- 	      (org-list-repair))
 
- 	    (buffer-string))))
 
-   ;; Repair check-boxes.
 
-   (should
 
-    (equal "- [X] item\n  - [X] child"
 
- 	  (org-test-with-temp-text "- [ ] item\n  - [X] child"
 
- 	    (let ((org-list-indent-offset 0))
 
- 	      (org-list-repair))
 
- 	    (buffer-string))))
 
-   ;; Special case: do not move contents of an item within its child.
 
-   ;; Yet, preserve indentation differences within contents.
 
-   (should
 
-    (equal "- item\n  - child\n  within item"
 
- 	  (org-test-with-temp-text "- item\n    - child\n    within item"
 
- 	    (let ((org-list-indent-offset 0)) (org-list-repair))
 
- 	    (buffer-string))))
 
-   (should
 
-    (equal
 
-     "- item\n  - child\n  within item\n    indented"
 
-     (org-test-with-temp-text
 
- 	"- item\n    - child\n   within item\n     indented"
 
-       (let ((org-list-indent-offset 0)) (org-list-repair))
 
-       (buffer-string)))))
 
- ;;; Radio Lists
 
- (ert-deftest test-org-list/send-list ()
 
-   "Test various checks for `org-list-send-list'."
 
-   ;; Error when not at a list item.
 
-   (should-error
 
-    (org-test-with-temp-text "Not a list item"
 
-      (org-list-send-list)))
 
-   ;; Error when ORGLST line is not provided.
 
-   (should-error
 
-    (org-test-with-temp-text "- item"
 
-      (org-list-send-list)))
 
-   ;; Error when transformation function is unknown.
 
-   (should-error
 
-    (org-test-with-temp-text "@ignore
 
- #+ORGLST: SEND list unknown-function
 
- - item
 
- @end ignore"
 
-      (forward-line 2)
 
-      (org-list-send-list)))
 
-   ;; Error when receiving location is not defined.
 
-   (should-error
 
-    (org-test-with-temp-text "@ignore
 
- #+ORGLST: SEND list org-list-to-texinfo
 
- - item
 
- @end ignore"
 
-      (forward-line 2)
 
-      (org-list-send-list)))
 
-   ;; Error when insertion region is ill-formed.
 
-   (should-error
 
-    (org-test-with-temp-text "@c BEGIN RECEIVE ORGLST list
 
- @ignore
 
- #+ORGLST: SEND list org-list-to-texinfo
 
- - item
 
- @end ignore"
 
-      (forward-line 3)
 
-      (org-list-send-list))))
 
- (ert-deftest test-org-list/to-html ()
 
-   "Test `org-list-to-html' specifications."
 
-   (should
 
-    (equal "<ul class=\"org-ul\">\n<li>a</li>\n</ul>"
 
- 	  (let (org-html-indent)
 
- 	    (with-temp-buffer
 
- 	      (insert "<!-- BEGIN RECEIVE ORGLST name -->
 
- <!-- END RECEIVE ORGLST name -->
 
- <!--
 
- #+ORGLST: SEND name org-list-to-html
 
- - a
 
- -->")
 
- 	      (goto-char (point-min))
 
- 	      (re-search-forward "^- a" nil t)
 
- 	      (beginning-of-line)
 
- 	      (org-list-send-list)
 
- 	      (goto-line 2)
 
- 	      (buffer-substring-no-properties
 
- 	       (point)
 
- 	       (progn (re-search-forward "^<!-- END" nil t)
 
- 		      (beginning-of-line)
 
- 		      (skip-chars-backward " \r\t\n")
 
- 		      (point))))))))
 
- (ert-deftest test-org-list/to-latex ()
 
-   "Test `org-list-to-latex' specifications."
 
-   (should
 
-    (equal "\\begin{itemize}\n\\item a\n\\end{itemize}"
 
- 	  (with-temp-buffer
 
- 	    (insert "% BEGIN RECEIVE ORGLST name
 
- % END RECEIVE ORGLST name
 
- \\begin{comment}
 
- #+ORGLST: SEND name org-list-to-latex
 
- - a
 
- \\end{comment}")
 
- 	    (goto-char (point-min))
 
- 	    (re-search-forward "^- a" nil t)
 
- 	    (beginning-of-line)
 
- 	    (org-list-send-list)
 
- 	    (goto-line 2)
 
- 	    (buffer-substring-no-properties
 
- 	     (point)
 
- 	     (progn (re-search-forward "^% END" nil t)
 
- 		    (beginning-of-line)
 
- 		    (skip-chars-backward " \r\t\n")
 
- 		    (point)))))))
 
- (ert-deftest test-org-list/to-texinfo ()
 
-   "Test `org-list-to-texinfo' specifications."
 
-   (should
 
-    (equal "@itemize\n@item\na\n@end itemize"
 
- 	  (with-temp-buffer
 
- 	    (insert "@c BEGIN RECEIVE ORGLST name
 
- @c END RECEIVE ORGLST name
 
- @ignore
 
- #+ORGLST: SEND name org-list-to-texinfo
 
- - a
 
- @end ignore")
 
- 	    (goto-char (point-min))
 
- 	    (re-search-forward "^- a" nil t)
 
- 	    (beginning-of-line)
 
- 	    (org-list-send-list)
 
- 	    (goto-line 2)
 
- 	    (buffer-substring-no-properties
 
- 	     (point)
 
- 	     (progn (re-search-forward "^@c END" nil t)
 
- 		    (beginning-of-line)
 
- 		    (skip-chars-backward " \r\t\n")
 
- 		    (point)))))))
 
- (provide 'test-org-list)
 
- ;;; test-org-list.el ends here
 
 
  |