]> git.eshelyaron.com Git - emacs.git/commitdiff
; Fix tree-sitter defun tests
authorYuan Fu <casouri@gmail.com>
Tue, 27 Dec 2022 01:15:37 +0000 (17:15 -0800)
committerYuan Fu <casouri@gmail.com>
Tue, 27 Dec 2022 01:50:14 +0000 (17:50 -0800)
* test/src/treesit-tests.el (treesit--ert-test-defun-navigation):
Change treesit--navigate-defun to treesit--navigate-thing.

test/src/treesit-tests.el

index 48b61cf3dc3296afeeecbd25bbf370a2f6fd6cd0..3fe59a78d070be6dc258c8e0fc406860895af3f6 100644 (file)
@@ -831,36 +831,40 @@ OPENING and CLOSING are the same as in
 and \"]\"."
   (with-temp-buffer
     (funcall init)
-    (let* ((opening (or opening "["))
-           (closing (or closing "]"))
-           ;; Insert program and parse marker positions.
-           (marker-alist (treesit--ert-insert-and-parse-marker
-                             opening closing program))
-           ;; Translate marker positions into buffer positions.
-           (decoded-master
-            (cl-loop for record in master
-                     collect
-                     (cl-loop for pos in record
-                              collect (alist-get pos marker-alist))))
-           ;; Collect positions each function returns.
-           (positions
-            (treesit--ert-collect-positions
-             ;; The first column of DECODED-MASTER.
-             (mapcar #'car decoded-master)
-             ;; Four functions: next-end, prev-beg, next-beg, prev-end.
-             (mapcar (lambda (conf)
-                       (lambda ()
-                         (if-let ((pos (funcall
-                                        #'treesit--navigate-defun
-                                        (point) (car conf) (cdr conf))))
-                             (save-excursion
-                               (goto-char pos)
-                               (funcall treesit-defun-skipper)
-                               (point)))))
-                     '((-1 . beg)
-                       (1 . end)
-                       (-1 . end)
-                       (1 . beg))))))
+    (pcase-let*
+        ((opening (or opening "["))
+         (closing (or closing "]"))
+         ;; Insert program and parse marker positions.
+         (marker-alist (treesit--ert-insert-and-parse-marker
+                           opening closing program))
+         ;; Translate marker positions into buffer positions.
+         (decoded-master
+          (cl-loop for record in master
+                   collect
+                   (cl-loop for pos in record
+                            collect (alist-get pos marker-alist))))
+         (`(,regexp . ,pred) (treesit--thing-unpack-pattern
+                              treesit-defun-type-regexp))
+         ;; Collect positions each function returns.
+         (positions
+          (treesit--ert-collect-positions
+           ;; The first column of DECODED-MASTER.
+           (mapcar #'car decoded-master)
+           ;; Four functions: next-end, prev-beg, next-beg, prev-end.
+           (mapcar (lambda (conf)
+                     (lambda ()
+                       (if-let ((pos (funcall
+                                      #'treesit--navigate-thing
+                                      (point) (car conf) (cdr conf)
+                                      regexp pred)))
+                           (save-excursion
+                             (goto-char pos)
+                             (funcall treesit-defun-skipper)
+                             (point)))))
+                   '((-1 . beg)
+                     (1 . end)
+                     (-1 . end)
+                     (1 . beg))))))
       ;; Verify each position.
       (cl-loop for record in decoded-master
                for orig-record in master