aboutsummaryrefslogtreecommitdiffstats
path: root/test/src
diff options
context:
space:
mode:
authorMattias EngdegÄrd2023-06-16 12:37:07 +0200
committerMattias EngdegÄrd2023-06-16 12:58:57 +0200
commit8657afac774f36777d0fdd368e0bec64beca22ae (patch)
treebe7d0013e0a0732b2849c14f920d8c98a2fafb58 /test/src
parentf2aae8b879baa4986b69af7ee54fe4eb987b99d6 (diff)
downloademacs-8657afac774f36777d0fdd368e0bec64beca22ae.tar.gz
emacs-8657afac774f36777d0fdd368e0bec64beca22ae.zip
Correct conversion of strings to tree-sitter query syntax
The treesitter query syntax for string literals differs from that of Elisp so we cannot just use the Lisp printer (bug#64017). * src/treesit.c (treesit_query_string_string): New function. (Ftreesit_pattern_expand): Use it. * test/src/treesit-tests.el (treesit-query-api): Add test case.
Diffstat (limited to 'test/src')
-rw-r--r--test/src/treesit-tests.el7
1 files changed, 6 insertions, 1 deletions
diff --git a/test/src/treesit-tests.el b/test/src/treesit-tests.el
index 7a8e53924eb..04aa91ddca6 100644
--- a/test/src/treesit-tests.el
+++ b/test/src/treesit-tests.el
@@ -461,7 +461,12 @@ BODY is the test body."
461 "(type field: (_) @capture .) ? * + \"return\"" 461 "(type field: (_) @capture .) ? * + \"return\""
462 (treesit-query-expand 462 (treesit-query-expand
463 '((type field: (_) @capture :anchor) 463 '((type field: (_) @capture :anchor)
464 :? :* :+ "return"))))))) 464 :? :* :+ "return"))))
465
466 ;; Test string conversion in `treesit-pattern-expand'.
467 (should (equal
468 (treesit-pattern-expand "a\nb\rc\td\0e\"f\1g")
469 "\"a\\nb\\rc\\td\\0e\\\"f\1g\"")))))
465 470
466;;; Narrow 471;;; Narrow
467 472