Browse Source

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.
Ihor Radchenko 3 years ago
parent
commit
3f59ea981c
1 changed files with 15 additions and 0 deletions
  1. 15 0
      testing/lisp/test-org-element.el

+ 15 - 0
testing/lisp/test-org-element.el

@@ -3889,6 +3889,21 @@ Text
 	    :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)