diff options
| author | Yuan Fu | 2023-04-13 00:52:17 -0700 |
|---|---|---|
| committer | Yuan Fu | 2023-04-13 15:08:51 -0700 |
| commit | dff254946a72db1d592e6e2f71f85786e5e5bdec (patch) | |
| tree | 31301c906a69ddb06a900beccc3dbc996624e698 /test/src | |
| parent | 80f6c1027fd054d9126599322bcfd1f30f3f1076 (diff) | |
| download | emacs-dff254946a72db1d592e6e2f71f85786e5e5bdec.tar.gz emacs-dff254946a72db1d592e6e2f71f85786e5e5bdec.zip | |
Fix tree-sitter tests
After 2ce27563ecc, treesit--navigate-things takes a TACTIC argument
instead of using treesit-defun-tactic, so the tests need to change
from binding treesit-defun-tactic to passing the tactic argument,
which is what this change does.
* test/src/treesit-tests.el:
(treesit--ert-insert-and-parse-marker): New argument TACTIC.
(treesit-defun-navigation-nested-1)
(treesit-defun-navigation-nested-2)
(treesit-defun-navigation-nested-3)
(treesit-defun-navigation-top-level): Pass TACTIC argument.
Diffstat (limited to 'test/src')
| -rw-r--r-- | test/src/treesit-tests.el | 62 |
1 files changed, 32 insertions, 30 deletions
diff --git a/test/src/treesit-tests.el b/test/src/treesit-tests.el index 468cd221ef9..ac5e6f1e08c 100644 --- a/test/src/treesit-tests.el +++ b/test/src/treesit-tests.el | |||
| @@ -831,7 +831,7 @@ the return value is ((1 3) (1 3))." | |||
| 831 | (funcall fn))))) | 831 | (funcall fn))))) |
| 832 | 832 | ||
| 833 | (defun treesit--ert-test-defun-navigation | 833 | (defun treesit--ert-test-defun-navigation |
| 834 | (init program master &optional opening closing) | 834 | (init program master tactic &optional opening closing) |
| 835 | "Run defun navigation tests on PROGRAM and MASTER. | 835 | "Run defun navigation tests on PROGRAM and MASTER. |
| 836 | 836 | ||
| 837 | INIT is a setup function that runs right after this function | 837 | INIT is a setup function that runs right after this function |
| @@ -843,6 +843,8 @@ starting marker position, and the rest are marker positions the | |||
| 843 | corresponding navigation should stop at (after running | 843 | corresponding navigation should stop at (after running |
| 844 | `treesit-defun-skipper'). | 844 | `treesit-defun-skipper'). |
| 845 | 845 | ||
| 846 | TACTIC is the same as in `treesit--navigate-thing'. | ||
| 847 | |||
| 846 | OPENING and CLOSING are the same as in | 848 | OPENING and CLOSING are the same as in |
| 847 | `treesit--ert-insert-and-parse-marker', by default they are \"[\" | 849 | `treesit--ert-insert-and-parse-marker', by default they are \"[\" |
| 848 | and \"]\"." | 850 | and \"]\"." |
| @@ -873,7 +875,7 @@ and \"]\"." | |||
| 873 | (if-let ((pos (funcall | 875 | (if-let ((pos (funcall |
| 874 | #'treesit--navigate-thing | 876 | #'treesit--navigate-thing |
| 875 | (point) (car conf) (cdr conf) | 877 | (point) (car conf) (cdr conf) |
| 876 | regexp pred))) | 878 | regexp pred tactic))) |
| 877 | (save-excursion | 879 | (save-excursion |
| 878 | (goto-char pos) | 880 | (goto-char pos) |
| 879 | (funcall treesit-defun-skipper) | 881 | (funcall treesit-defun-skipper) |
| @@ -1025,43 +1027,42 @@ the prev-beg, now point should be at marker 103\", etc.") | |||
| 1025 | "Test defun navigation." | 1027 | "Test defun navigation." |
| 1026 | (skip-unless (treesit-language-available-p 'python)) | 1028 | (skip-unless (treesit-language-available-p 'python)) |
| 1027 | ;; Nested defun navigation | 1029 | ;; Nested defun navigation |
| 1028 | (let ((treesit-defun-tactic 'nested)) | 1030 | (require 'python) |
| 1029 | (require 'python) | 1031 | (treesit--ert-test-defun-navigation |
| 1030 | (treesit--ert-test-defun-navigation | 1032 | 'python-ts-mode |
| 1031 | 'python-ts-mode | 1033 | treesit--ert-defun-navigation-python-program |
| 1032 | treesit--ert-defun-navigation-python-program | 1034 | treesit--ert-defun-navigation-nested-master |
| 1033 | treesit--ert-defun-navigation-nested-master))) | 1035 | 'nested)) |
| 1034 | 1036 | ||
| 1035 | (ert-deftest treesit-defun-navigation-nested-2 () | 1037 | (ert-deftest treesit-defun-navigation-nested-2 () |
| 1036 | "Test defun navigation using `js-ts-mode'." | 1038 | "Test defun navigation using `js-ts-mode'." |
| 1037 | (skip-unless (treesit-language-available-p 'javascript)) | 1039 | (skip-unless (treesit-language-available-p 'javascript)) |
| 1038 | ;; Nested defun navigation | 1040 | ;; Nested defun navigation |
| 1039 | (let ((treesit-defun-tactic 'nested)) | 1041 | (require 'js) |
| 1040 | (require 'js) | 1042 | (treesit--ert-test-defun-navigation |
| 1041 | (treesit--ert-test-defun-navigation | 1043 | 'js-ts-mode |
| 1042 | 'js-ts-mode | 1044 | treesit--ert-defun-navigation-js-program |
| 1043 | treesit--ert-defun-navigation-js-program | 1045 | treesit--ert-defun-navigation-nested-master |
| 1044 | treesit--ert-defun-navigation-nested-master))) | 1046 | 'nested)) |
| 1045 | 1047 | ||
| 1046 | (ert-deftest treesit-defun-navigation-nested-3 () | 1048 | (ert-deftest treesit-defun-navigation-nested-3 () |
| 1047 | "Test defun navigation using `bash-ts-mode'." | 1049 | "Test defun navigation using `bash-ts-mode'." |
| 1048 | (skip-unless (treesit-language-available-p 'bash)) | 1050 | (skip-unless (treesit-language-available-p 'bash)) |
| 1049 | ;; Nested defun navigation | 1051 | ;; Nested defun navigation |
| 1050 | (let ((treesit-defun-tactic 'nested)) | 1052 | (treesit--ert-test-defun-navigation |
| 1051 | (treesit--ert-test-defun-navigation | 1053 | (lambda () |
| 1052 | (lambda () | 1054 | (treesit-parser-create 'bash) |
| 1053 | (treesit-parser-create 'bash) | 1055 | (setq-local treesit-defun-type-regexp "function_definition")) |
| 1054 | (setq-local treesit-defun-type-regexp "function_definition")) | 1056 | treesit--ert-defun-navigation-bash-program |
| 1055 | treesit--ert-defun-navigation-bash-program | 1057 | treesit--ert-defun-navigation-nested-master |
| 1056 | treesit--ert-defun-navigation-nested-master))) | 1058 | 'nested)) |
| 1057 | 1059 | ||
| 1058 | (ert-deftest treesit-defun-navigation-nested-4 () | 1060 | (ert-deftest treesit-defun-navigation-nested-4 () |
| 1059 | "Test defun navigation using Elixir. | 1061 | "Test defun navigation using Elixir. |
| 1060 | This tests bug#60355." | 1062 | This tests bug#60355." |
| 1061 | (skip-unless (treesit-language-available-p 'elixir)) | 1063 | (skip-unless (treesit-language-available-p 'elixir)) |
| 1062 | ;; Nested defun navigation | 1064 | ;; Nested defun navigation |
| 1063 | (let ((treesit-defun-tactic 'nested) | 1065 | (let ((pred (lambda (node) |
| 1064 | (pred (lambda (node) | ||
| 1065 | (member (treesit-node-text | 1066 | (member (treesit-node-text |
| 1066 | (treesit-node-child-by-field-name node "target")) | 1067 | (treesit-node-child-by-field-name node "target")) |
| 1067 | '("def" "defmodule"))))) | 1068 | '("def" "defmodule"))))) |
| @@ -1070,18 +1071,19 @@ This tests bug#60355." | |||
| 1070 | (treesit-parser-create 'elixir) | 1071 | (treesit-parser-create 'elixir) |
| 1071 | (setq-local treesit-defun-type-regexp `("call" . ,pred))) | 1072 | (setq-local treesit-defun-type-regexp `("call" . ,pred))) |
| 1072 | treesit--ert-defun-navigation-elixir-program | 1073 | treesit--ert-defun-navigation-elixir-program |
| 1073 | treesit--ert-defun-navigation-nested-master))) | 1074 | treesit--ert-defun-navigation-nested-master |
| 1075 | 'nested))) | ||
| 1074 | 1076 | ||
| 1075 | (ert-deftest treesit-defun-navigation-top-level () | 1077 | (ert-deftest treesit-defun-navigation-top-level () |
| 1076 | "Test top-level only defun navigation." | 1078 | "Test top-level only defun navigation." |
| 1077 | (skip-unless (treesit-language-available-p 'python)) | 1079 | (skip-unless (treesit-language-available-p 'python)) |
| 1078 | ;; Nested defun navigation | 1080 | ;; Nested defun navigation |
| 1079 | (let ((treesit-defun-tactic 'top-level)) | 1081 | (require 'python) |
| 1080 | (require 'python) | 1082 | (treesit--ert-test-defun-navigation |
| 1081 | (treesit--ert-test-defun-navigation | 1083 | 'python-ts-mode |
| 1082 | 'python-ts-mode | 1084 | treesit--ert-defun-navigation-python-program |
| 1083 | treesit--ert-defun-navigation-python-program | 1085 | treesit--ert-defun-navigation-top-level-master |
| 1084 | treesit--ert-defun-navigation-top-level-master))) | 1086 | 'top-level)) |
| 1085 | 1087 | ||
| 1086 | ;; TODO | 1088 | ;; TODO |
| 1087 | ;; - Functions in treesit.el | 1089 | ;; - Functions in treesit.el |