Add tests for C-a' and C-e'

* testing/lisp/test-org.el (test-org/beginning-of-line):
(test-org/end-of-line): Add tests.

Tests are for bug fixed in e4d4c6e1bc.
This commit is contained in:
Nicolas Goaziou 2016-10-18 09:30:50 +02:00
parent e4d4c6e1bc
commit a2b1be7461

View file

@ -2507,14 +2507,24 @@ http://article.gmane.org/gmane.emacs.orgmode/21459/"
(should (should
(org-test-with-temp-text "* TODO Headline<point>" (org-test-with-temp-text "* TODO Headline<point>"
(let ((org-special-ctrl-a/e t)) (let ((org-special-ctrl-a/e t))
(and (progn (org-beginning-of-line) (looking-at "Headline")) (and (progn (org-beginning-of-line) (looking-at-p "Headline"))
(progn (org-beginning-of-line) (bolp)) (progn (org-beginning-of-line) (bolp))
(progn (org-beginning-of-line) (looking-at "Headline")))))) (progn (org-beginning-of-line) (looking-at-p "Headline"))))))
(should (should
(org-test-with-temp-text "* TODO [#A] Headline<point>" (org-test-with-temp-text "* TODO [#A] Headline<point>"
(let ((org-special-ctrl-a/e t)) (let ((org-special-ctrl-a/e t))
(org-beginning-of-line) (org-beginning-of-line)
(looking-at "Headline")))) (looking-at "Headline"))))
(should
(org-test-with-temp-text "* TODO [#A] Headline<point>"
(let ((org-special-ctrl-a/e '(t . nil)))
(org-beginning-of-line)
(looking-at "Headline"))))
(should-not
(org-test-with-temp-text "* TODO [#A] Headline<point>"
(let ((org-special-ctrl-a/e '(nil . nil)))
(org-beginning-of-line)
(looking-at "Headline"))))
;; At an headline with reversed movement, first move to beginning of ;; At an headline with reversed movement, first move to beginning of
;; line, then to the beginning of title. ;; line, then to the beginning of title.
(should (should
@ -2522,15 +2532,27 @@ http://article.gmane.org/gmane.emacs.orgmode/21459/"
(let ((org-special-ctrl-a/e 'reversed) (let ((org-special-ctrl-a/e 'reversed)
(this-command last-command)) (this-command last-command))
(and (progn (org-beginning-of-line) (bolp)) (and (progn (org-beginning-of-line) (bolp))
(progn (org-beginning-of-line) (looking-at "Headline")))))) (progn (org-beginning-of-line) (looking-at-p "Headline"))))))
(should
(org-test-with-temp-text "* TODO Headline<point>"
(let ((org-special-ctrl-a/e '(reversed . nil))
(this-command last-command))
(and (progn (org-beginning-of-line) (bolp))
(progn (org-beginning-of-line) (looking-at-p "Headline"))))))
(should-not
(org-test-with-temp-text "* TODO Headline<point>"
(let ((org-special-ctrl-a/e '(t . nil))
(this-command last-command))
(and (progn (org-beginning-of-line) (bolp))
(progn (org-beginning-of-line) (looking-at-p "Headline"))))))
;; At an item with special movement, first move after to beginning ;; At an item with special movement, first move after to beginning
;; of title, then to the beginning of line, rinse, repeat. ;; of title, then to the beginning of line, rinse, repeat.
(should (should
(org-test-with-temp-text "- [ ] Item<point>" (org-test-with-temp-text "- [ ] Item<point>"
(let ((org-special-ctrl-a/e t)) (let ((org-special-ctrl-a/e t))
(and (progn (org-beginning-of-line) (looking-at "Item")) (and (progn (org-beginning-of-line) (looking-at-p "Item"))
(progn (org-beginning-of-line) (bolp)) (progn (org-beginning-of-line) (bolp))
(progn (org-beginning-of-line) (looking-at "Item")))))) (progn (org-beginning-of-line) (looking-at-p "Item"))))))
;; At an item with reversed movement, first move to beginning of ;; At an item with reversed movement, first move to beginning of
;; line, then to the beginning of title. ;; line, then to the beginning of title.
(should (should
@ -2538,7 +2560,7 @@ http://article.gmane.org/gmane.emacs.orgmode/21459/"
(let ((org-special-ctrl-a/e 'reversed) (let ((org-special-ctrl-a/e 'reversed)
(this-command last-command)) (this-command last-command))
(and (progn (org-beginning-of-line) (bolp)) (and (progn (org-beginning-of-line) (bolp))
(progn (org-beginning-of-line) (looking-at "Item")))))) (progn (org-beginning-of-line) (looking-at-p "Item"))))))
;; Leave point before invisible characters at column 0. ;; Leave point before invisible characters at column 0.
(should (should
(org-test-with-temp-text "[[http://orgmode.org]]<point>" (org-test-with-temp-text "[[http://orgmode.org]]<point>"
@ -2569,7 +2591,8 @@ http://article.gmane.org/gmane.emacs.orgmode/21459/"
;; Standard test. ;; Standard test.
(should (should
(org-test-with-temp-text "Some text\nSome other text" (org-test-with-temp-text "Some text\nSome other text"
(progn (org-end-of-line) (eolp)))) (org-end-of-line)
(eolp)))
;; With `visual-line-mode' active, move to end of visible line. ;; With `visual-line-mode' active, move to end of visible line.
;; However, never go past ellipsis. ;; However, never go past ellipsis.
(should-not (should-not
@ -2608,6 +2631,11 @@ http://article.gmane.org/gmane.emacs.orgmode/21459/"
(let ((org-special-ctrl-a/e nil)) (let ((org-special-ctrl-a/e nil))
(and (progn (org-end-of-line) (eolp)) (and (progn (org-end-of-line) (eolp))
(progn (org-end-of-line) (eolp)))))) (progn (org-end-of-line) (eolp))))))
(should
(org-test-with-temp-text "* Headline2b :tag:\n"
(let ((org-special-ctrl-a/e '(t . nil)))
(and (progn (org-end-of-line) (eolp))
(progn (org-end-of-line) (eolp))))))
(should (should
(org-test-with-temp-text "* Headline2a :tag:\n** Sub" (org-test-with-temp-text "* Headline2a :tag:\n** Sub"
(org-overview) (org-overview)
@ -2620,9 +2648,21 @@ http://article.gmane.org/gmane.emacs.orgmode/21459/"
(should (should
(org-test-with-temp-text "* Headline1 :tag:\n" (org-test-with-temp-text "* Headline1 :tag:\n"
(let ((org-special-ctrl-a/e t)) (let ((org-special-ctrl-a/e t))
(and (progn (org-end-of-line) (looking-at " :tag:")) (and (progn (org-end-of-line) (looking-at-p " :tag:"))
(progn (org-end-of-line) (eolp)) (progn (org-end-of-line) (eolp))
(progn (org-end-of-line) (looking-at " :tag:")))))) (progn (org-end-of-line) (looking-at-p " :tag:"))))))
(should
(org-test-with-temp-text "* Headline1 :tag:\n"
(let ((org-special-ctrl-a/e '(nil . t)))
(and (progn (org-end-of-line) (looking-at-p " :tag:"))
(progn (org-end-of-line) (eolp))
(progn (org-end-of-line) (looking-at-p " :tag:"))))))
(should-not
(org-test-with-temp-text "* Headline1 :tag:\n"
(let ((org-special-ctrl-a/e '(nil . nil)))
(and (progn (org-end-of-line) (looking-at-p " :tag:"))
(progn (org-end-of-line) (eolp))
(progn (org-end-of-line) (looking-at-p " :tag:"))))))
(should (should
(org-test-with-temp-text "* Headline2a :tag:\n** Sub" (org-test-with-temp-text "* Headline2a :tag:\n** Sub"
(org-overview) (org-overview)
@ -2637,7 +2677,19 @@ http://article.gmane.org/gmane.emacs.orgmode/21459/"
(let ((org-special-ctrl-a/e 'reversed) (let ((org-special-ctrl-a/e 'reversed)
(this-command last-command)) (this-command last-command))
(and (progn (org-end-of-line) (eolp)) (and (progn (org-end-of-line) (eolp))
(progn (org-end-of-line) (looking-at " :tag:")))))) (progn (org-end-of-line) (looking-at-p " :tag:"))))))
(should
(org-test-with-temp-text "* Headline3 :tag:\n"
(let ((org-special-ctrl-a/e '(nil . reversed))
(this-command last-command))
(and (progn (org-end-of-line) (eolp))
(progn (org-end-of-line) (looking-at-p " :tag:"))))))
(should-not
(org-test-with-temp-text "* Headline3 :tag:\n"
(let ((org-special-ctrl-a/e '(nil . t))
(this-command last-command))
(and (progn (org-end-of-line) (eolp))
(progn (org-end-of-line) (looking-at-p " :tag:"))))))
(should (should
(org-test-with-temp-text "* Headline2a :tag:\n** Sub" (org-test-with-temp-text "* Headline2a :tag:\n** Sub"
(org-overview) (org-overview)