branch: externals/org
commit fbeb59c5c7b01a45759578db4d4e8f67a9203ec4
Author: Morgan Smith <[email protected]>
Commit: Ihor Radchenko <[email protected]>
test-org/move-subtree: Test for error more precisely
* testing/lisp/test-org.el (test-org/move-subtree): Test for the
error in the specific location we expect it to occur (the function
call to `org-metaup' or `org-metadown'. Also ensure the error is of
type `user-error'.
---
testing/lisp/test-org.el | 60 ++++++++++++++++++++++++++----------------------
1 file changed, 32 insertions(+), 28 deletions(-)
diff --git a/testing/lisp/test-org.el b/testing/lisp/test-org.el
index 155a99d963..54ba2036bc 100644
--- a/testing/lisp/test-org.el
+++ b/testing/lisp/test-org.el
@@ -5891,34 +5891,40 @@ Text.
(cl-flet*
((test-move-subtree (direction
initial-text
- &optional expected selection)
+ expected &optional selection)
(org-test-with-temp-text initial-text
(when selection
(set-mark (point))
(search-forward selection))
- (cl-ecase direction
- (up (org-metaup))
- (down (org-metadown)))
- (should (equal expected
- (buffer-string))))))
+ (let ((func
+ (cl-ecase direction
+ (up #'org-metaup)
+ (down #'org-metadown))))
+ (if (eq expected 'error)
+ (should-error
+ (funcall func)
+ :type 'user-error)
+ (funcall func)
+ (should (equal expected
+ (buffer-string))))))))
(test-move-subtree 'down
"* H1<point>\n* H2\n"
"* H2\n* H1\n")
(test-move-subtree 'up
"* H1\n* H2<point>\n"
"* H2\n* H1\n")
- (should-error
- (test-move-subtree 'down
- "* H1\n* H2<point>\n"))
- (should-error
- (test-move-subtree 'up
- "* H1<point>\n* H2\n"))
- (should-error
- (test-move-subtree 'down
- "* H1\n** H1.2<point>\n* H2"))
- (should-error
- (test-move-subtree 'up
- "* H1\n** H1.2<point>\n"))
+ (test-move-subtree 'down
+ "* H1\n* H2<point>\n"
+ 'error)
+ (test-move-subtree 'up
+ "* H1<point>\n* H2\n"
+ 'error)
+ (test-move-subtree 'down
+ "* H1\n** H1.2<point>\n* H2"
+ 'error)
+ (test-move-subtree 'up
+ "* H1\n** H1.2<point>\n"
+ 'error)
;; With selection
(test-move-subtree 'down
"* T\n** <point>H1\n** H2\n** H3\n"
@@ -5928,16 +5934,14 @@ Text.
"* T\n** H0\n** <point>H1\n** H2\n** H3\n"
"* T\n** H1\n** H2\n** H0\n** H3\n"
"H2")
- (should-error
- (test-move-subtree 'down
- "* T\n** <point>H1\n** H2\n* T2\n"
- nil
- "H2"))
- (should-error
- (test-move-subtree 'up
- "* T\n** <point>H1\n** H2\n* T2\n"
- nil
- "H2"))))
+ (test-move-subtree 'down
+ "* T\n** <point>H1\n** H2\n* T2\n"
+ 'error
+ "H2")
+ (test-move-subtree 'up
+ "* T\n** <point>H1\n** H2\n* T2\n"
+ 'error
+ "H2")))
(ert-deftest test-org/demote ()
"Test `org-demote' specifications."