From 835a80dcc48c9c9d90709dcadbedb9afd6ded48c Mon Sep 17 00:00:00 2001 From: Yuan Fu Date: Mon, 26 Dec 2022 17:15:37 -0800 Subject: [PATCH] ; Fix tree-sitter defun tests * test/src/treesit-tests.el (treesit--ert-test-defun-navigation): Change treesit--navigate-defun to treesit--navigate-thing. --- test/src/treesit-tests.el | 64 +++++++++++++++++++++------------------ 1 file changed, 34 insertions(+), 30 deletions(-) diff --git a/test/src/treesit-tests.el b/test/src/treesit-tests.el index 48b61cf3dc3..3fe59a78d07 100644 --- a/test/src/treesit-tests.el +++ b/test/src/treesit-tests.el @@ -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 -- 2.39.2