; * test/src/treesit-tests.el (treesit-node-check): New test.

This commit is contained in:
Yuan Fu 2022-11-14 00:54:54 -08:00
parent 3a0c94ac0b
commit 7e9c2e2952
No known key found for this signature in database
GPG key ID: 56E19BC57664A442

View file

@ -505,6 +505,24 @@ visible_end.)"
(treesit-node-at (point)))
"]"))))
(ert-deftest treesit-node-check ()
"Test `treesit-node-check'."
(skip-unless (treesit-language-available-p 'json))
(let (parser root-node array-node comment-node)
(progn
(insert "/* comment */ [1, 2, 3,4 ")
(setq parser (treesit-parser-create 'json))
(setq root-node (treesit-parser-root-node
parser))
(setq comment-node (treesit-node-child root-node 0))
(setq array-node (treesit-node-child root-node 1)))
(should (treesit-node-check comment-node 'extra))
(should (treesit-node-check array-node 'has-error))
(should-error (treesit-node-check array-node 'xxx))
;; TODO: Test for `missing'.
))
(ert-deftest treesit-misc ()
"Misc helper functions."
(let ((settings '((t 0 t)