[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/org 60c927f 17/29: Add new element parser and cache tes
From: |
ELPA Syncer |
Subject: |
[elpa] externals/org 60c927f 17/29: Add new element parser and cache tests |
Date: |
Sun, 17 Oct 2021 02:57:28 -0400 (EDT) |
branch: externals/org
commit 60c927f8b8da12d07056373e3af98e1666b5637e
Author: Ihor Radchenko <yantar92@gmail.com>
Commit: Ihor Radchenko <yantar92@gmail.com>
Add new element parser and cache tests
---
testing/lisp/test-org-element.el | 173 +++++++++++++++++++++++++++++++++++++--
1 file changed, 168 insertions(+), 5 deletions(-)
diff --git a/testing/lisp/test-org-element.el b/testing/lisp/test-org-element.el
index 94f100f..560ba59 100644
--- a/testing/lisp/test-org-element.el
+++ b/testing/lisp/test-org-element.el
@@ -2165,8 +2165,13 @@ e^{i\\pi}+1=0
;; Handle non-empty blank line at the end of buffer.
(should
(org-test-with-temp-text "#+BEGIN_CENTER\nC\n#+END_CENTER\n "
- (= (org-element-property :end (org-element-at-point)) (point-max)))))
-
+ (= (org-element-property :end (org-element-at-point)) (point-max))))
+ (should
+ (org-test-with-temp-text "#+BEGIN_CENTER\n<point>C\n#+END_CENTER\n "
+ (= (org-element-property :end (org-element-at-point))
+ (save-excursion
+ (search-forward "END")
+ (line-beginning-position))))))
;;;; Plain List
@@ -2204,7 +2209,11 @@ Outside list"
;; beginning.
(should
(org-test-with-temp-text "- list\n \n "
- (= (org-element-property :end (org-element-at-point)) (point-max)))))
+ (= (org-element-property :end (org-element-at-point)) (point-max))))
+ ;; Correctly compute list ending when list is before first headline.
+ (dolist (org-element-use-cache '(t nil))
+ (org-test-with-temp-text "- list\n* Headline\n"
+ (should (= (org-element-property :end (org-element-at-point)) 8)))))
;;;; Planning
@@ -3732,6 +3741,14 @@ Text
(org-test-with-temp-text "- Para1\n- Para2\n\nPara3"
(progn (forward-line 2)
(org-element-type (org-element-at-point))))))
+ ;; Special case: at the last blank line in a plain list at the end of
+ ;; a headline, return the plain list, not the last item, and not the
+ ;; headline.
+ (should
+ (eq 'plain-list
+ (org-test-with-temp-text "* Headline\n- Para1\n- Para2\n\nPara3\n*
Another headline"
+ (progn (forward-line 3)
+ (org-element-type (org-element-at-point))))))
;; Special case: when a list ends at the end of buffer and there's
;; no final newline, return last element in last item.
(should
@@ -4063,20 +4080,166 @@ Text
(ert-deftest test-org-element/cache-bugs ()
"Test basic expectations and common pitfalls for cache."
- :expected-result :failed
;; Unindented second row of the table should not be re-parented by
;; inserted item.
(should
(eq 'table
(let ((org-element-use-cache t))
(org-test-with-temp-text
- "#+begin_center\nP0\n\n<point>\n\n P1\n | a | b |\n| c | d
|\n#+end_center"
+ "#+begin_center
+P0
+
+<point>
+
+ P1
+ | a | b |
+| c | d |
+#+end_center"
(save-excursion (search-forward "| c |") (org-element-at-point))
(insert "- item")
(search-forward "| c |")
(beginning-of-line)
+ (org-element-type (org-element-at-point))))))
+ (should
+ (eq 'table
+ (let ((org-element-use-cache t))
+ (org-test-with-temp-text
+ "
+- item 1
+
+<point>
+ | a | b |
+| c | d |
+#+end_center"
+ (save-excursion (search-forward "| c |") (org-element-at-point))
+ (delete-char 1)
+ (search-forward "| c |")
+ (beginning-of-line)
+ (org-element-type (org-element-at-point))))))
+ (should
+ (eq 'table-row
+ (let ((org-element-use-cache t))
+ (org-test-with-temp-text
+ "
+- item 1
+<point>
+ | a | b |
+| c | d |
+#+end_center"
+ (save-excursion (search-forward "| c |") (org-element-at-point))
+ (insert "\n")
+ (search-forward "| c |")
+ (beginning-of-line)
(org-element-type (org-element-at-point)))))))
+(ert-deftest test-org-element/cache-headline ()
+ "Test basic expectations and common pitfalls for cached headings."
+ ;; Appending to final headline in a subtree.
+ (org-test-with-temp-text
+ "
+* Heading
+Aliquam erat volutpat.
+
+*** Subheading
+** Another
+** Final
+:PROPERTIES:
+:ID: some
+<point>:END:
+* Heading 2
+** End
+"
+ (let ((org-element-use-cache t))
+ (org-element-at-point)
+ (save-excursion
+ (goto-char (point-max))
+ (org-element-at-point))
+ (insert ":CATEOGORY: cat\n")
+ (search-backward "* Heading")
+ (should
+ (eq (org-element-property :end (org-element-at-point))
+ (save-excursion
+ (search-forward "* Heading 2")
+ (line-beginning-position))))
+ (search-forward "* Heading 2")
+ (beginning-of-line)
+ (insert "\n\n")
+ (search-backward "* Heading")
+ (should
+ (eq (org-element-property :end (org-element-at-point))
+ (save-excursion
+ (search-forward "* Heading 2")
+ (line-beginning-position))))))
+ ;; Appending at eob.
+ (org-test-with-temp-text
+ "
+* Heading
+*** Sub-heading
+** Another
+*** 1
+***** 2
+** 3
+ Aenean in sem ac leo mollis blandit.
+
+
+<point>"
+ (let ((org-element-use-cache t))
+ (org-element-at-point (point-max))
+ (insert "\n\nTest\n")
+ (search-backward "* Heading")
+ (should
+ (eq (point-max)
+ (org-element-property :end (org-element-at-point))))))
+ ;; Breaking headline at eob.
+ (org-test-with-temp-text
+ "
+* Heading
+*** Sub-heading
+<point>"
+ (let ((org-element-use-cache t))
+ (org-element-at-point (point-max))
+ (insert "* heading 2")
+ (beginning-of-line)
+ (should
+ (eq (point-max)
+ (org-element-property :end (org-element-at-point))))
+ (delete-char 1)
+ (search-backward "* Heading")
+ (should
+ (eq (point-max)
+ (org-element-property :end (org-element-at-point))))))
+ ;; Inserting low-level headline in-between.
+ (org-test-with-temp-text
+ "
+* Heading
+*** Sub-heading
+<point>
+*** Sub-heading 2
+*** Sub-heading 3
+"
+ (let ((org-element-use-cache t))
+ (org-element-at-point (point-max))
+ (insert "** heading 2")
+ (search-forward "*** Sub-heading 2")
+ (should
+ (equal (org-element-property :parent (org-element-at-point))
+ (progn
+ (search-backward "** heading 2")
+ (org-element-at-point))))))
+ ;; Test when `org-element--cache-for-removal' modifies common parent
+ ;; (`org-data' in this case) around changed region.
+ (org-test-with-temp-text
+ "blah
+:DRAWER:
+<point>test
+:END:
+paragraph
+* headline"
+ (let ((org-element-use-cache t))
+ (org-element-at-point (point-max))
+ (delete-region (point) (point-max))
+ (should (eq 'paragraph (org-element-type (org-element-at-point)))))))
+
(provide 'test-org-element)
;;; test-org-element.el ends here
- [elpa] externals/org 5d162b7 10/29: org.el/org-back-to-heading: Handle inlinetasks correctly, (continued)
- [elpa] externals/org 5d162b7 10/29: org.el/org-back-to-heading: Handle inlinetasks correctly, ELPA Syncer, 2021/10/17
- [elpa] externals/org f4bcc0c 29/29: Merge branch 'main' into feature/org-element-cache-new, ELPA Syncer, 2021/10/17
- [elpa] externals/org fede258 15/29: org.el/org-in-archived-heading-p: Support cache and passing element arg, ELPA Syncer, 2021/10/17
- [elpa] externals/org 07ca988 24/29: Fix compatibility with Emacs 27, ELPA Syncer, 2021/10/17
- [elpa] externals/org eeb0450 26/29: Use XDG cache dir as default dir for cache persistance, ELPA Syncer, 2021/10/17
- [elpa] externals/org 8ceb9e7 27/29: Add NEWS entry for new element cache, ELPA Syncer, 2021/10/17
- [elpa] externals/org 85e0a69 20/29: Avoid frequent cache updates in some functions, ELPA Syncer, 2021/10/17
- [elpa] externals/org 7b83168 08/29: org.el/org--property-local-values: Support cache and passing element arg, ELPA Syncer, 2021/10/17
- [elpa] externals/org ec73755 12/29: org.el/org-end-of-subtree: Support cache and passing element arg, ELPA Syncer, 2021/10/17
- [elpa] externals/org fe6cefd 16/29: ox.el: Support cache during export, ELPA Syncer, 2021/10/17
- [elpa] externals/org 60c927f 17/29: Add new element parser and cache tests,
ELPA Syncer <=
- [elpa] externals/org 3c4290e 21/29: org.el/org-scan-tags: Make use of fast `org-element-cache-map', ELPA Syncer, 2021/10/17
- [elpa] externals/org 004ac14 28/29: Fix compatibility with Emacs 26, ELPA Syncer, 2021/10/17
- [elpa] externals/org d437817 11/29: org.el/org-goto-first-child: Support cache and passing element arg, ELPA Syncer, 2021/10/17
- [elpa] externals/org 399a29c 13/29: org.el/org-up-heading-safe: Add cache support, ELPA Syncer, 2021/10/17
- [elpa] externals/org 86345df 14/29: org.el/org-in-commented-heading-p: Support cache and passing element arg, ELPA Syncer, 2021/10/17
- [elpa] externals/org 5aeeb4f 19/29: Use `org-element-at-point-no-context' in performance-critical places, ELPA Syncer, 2021/10/17
- [elpa] externals/org e70a8aa 18/29: Use org-element-cache in place of text property cache in agenda, ELPA Syncer, 2021/10/17
- [elpa] externals/org 885808f 22/29: Fix incorrectly written test, ELPA Syncer, 2021/10/17
- [elpa] externals/org 85712d6 25/29: Add comments documenting cache diagnostics, ELPA Syncer, 2021/10/17
- [elpa] externals/org abe7222 23/29: Add declares to suppress compiler warnings, ELPA Syncer, 2021/10/17