aboutsummaryrefslogtreecommitdiffstats
path: root/test/src
diff options
context:
space:
mode:
Diffstat (limited to 'test/src')
-rw-r--r--test/src/treesit-tests.el45
1 files changed, 45 insertions, 0 deletions
diff --git a/test/src/treesit-tests.el b/test/src/treesit-tests.el
index caacb74315d..11d5e1b2c8c 100644
--- a/test/src/treesit-tests.el
+++ b/test/src/treesit-tests.el
@@ -224,6 +224,51 @@
224 (kill-buffer base) 224 (kill-buffer base)
225 (kill-buffer indirect)))) 225 (kill-buffer indirect))))
226 226
227;;; Linecol
228
229(ert-deftest treesit-linecol-basic ()
230 "Tests for basic lincol synchronization."
231 (with-temp-buffer
232 (should (equal (treesit--linecol-cache)
233 '(:line 1 :col 0 :pos 1 :bytepos 1)))
234 (should (equal (treesit--linecol-at (point))
235 '(1 . 0)))
236 (insert "\n")
237 ;; Buffer content: a single newline.
238 (should (equal (treesit--linecol-at (point))
239 '(2 . 0)))
240
241 (treesit--linecol-cache-set 2 0 2 2)
242 (should (equal (treesit--linecol-cache)
243 '(:line 2 :col 0 :pos 2 :bytepos 2)))
244
245 (goto-char (point-min))
246 (should (equal (treesit--linecol-at (point))
247 '(1 . 0)))
248
249 (insert "0123456789")
250 ;; Buffer content: ten chars followed by a newline.
251 (treesit--linecol-cache-set 1 0 1 1)
252 (should (equal (treesit--linecol-at (point))
253 '(1 . 10)))
254
255 (goto-char (point-max))
256 (should (equal (treesit--linecol-at (point))
257 '(2 . 0)))
258
259 (treesit--linecol-cache-set 1 5 6 6)
260 (should (equal (treesit--linecol-at (point))
261 '(2 . 0)))
262
263 (treesit--linecol-cache-set 2 0 12 12)
264 ;; Position 6 is in the middle of the first line.
265 (should (equal (treesit--linecol-at 6)
266 '(1 . 5)))
267 ;; Position 11 is at the end of the line.
268 (should (equal (treesit--linecol-at 11)
269 '(1 . 10)))
270 ))
271
227;;; Tree traversal 272;;; Tree traversal
228 273
229(ert-deftest treesit-search-subtree () 274(ert-deftest treesit-search-subtree ()