[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] Fix test-org-element/cache
From: |
Ihor Radchenko |
Subject: |
Re: [PATCH] Fix test-org-element/cache |
Date: |
Sat, 15 May 2021 20:31:19 +0800 |
Bastien <bzg@gnu.org> writes:
> Applied in maint, thanks!
The patch also revealed an idea for another test. The new test is
revealing existing bug on master. Attached is the patch adding the test
with ":expected-result :failed".
>From d3a5a606c64ed1da0d1880f503c2461839dbfec9 Mon Sep 17 00:00:00 2001
Message-Id:
<d3a5a606c64ed1da0d1880f503c2461839dbfec9.1621081760.git.yantar92@gmail.com>
From: Ihor Radchenko <yantar92@gmail.com>
Date: Sat, 15 May 2021 20:27:20 +0800
Subject: [PATCH] Add a test for known bug in org-element-cache
* testing/lisp/test-org-element.el (test-org-element/cache-bugs): A
new test documenting a known bug:
1. Create initial file like:
P0
P1
| a | b |
<point>| c | d |
Note that second line of the table is not indented. Now,
org-element-at-point returns table-row.
2. Modify the file to test org-element-cache
P0
- item
P1
| a | b |
<point>| c | d |
Now, the first (indented) row of the table belongs to item. The
second row should be an individual table and org-element-at-point
returns table.
---
testing/lisp/test-org-element.el | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/testing/lisp/test-org-element.el b/testing/lisp/test-org-element.el
index 28e9ecd12..18991b5bc 100644
--- a/testing/lisp/test-org-element.el
+++ b/testing/lisp/test-org-element.el
@@ -3889,6 +3889,21 @@ (ert-deftest test-org-element/cache ()
:end (org-element-property :parent (org-element-at-point)))
(+ parent-end 3))))))
+(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"
+ (save-excursion (search-forward "| c |") (org-element-at-point))
+ (insert "- item")
+ (search-forward "| c |")
+ (beginning-of-line)
+ (org-element-type (org-element-at-point)))))))
(provide 'test-org-element)
--
2.26.3