From 699629ecdd396f7bb88f2cb0e7adf4d7c31ad744 Mon Sep 17 00:00:00 2001 From: Michael Davis Date: Fri, 25 Feb 2022 05:46:30 -0600 Subject: [PATCH] add unit testing documentation for tags queries --- docs/section-8-code-navigation-systems.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/docs/section-8-code-navigation-systems.md b/docs/section-8-code-navigation-systems.md index eb1c7dde..a1b6a280 100644 --- a/docs/section-8-code-navigation-systems.md +++ b/docs/section-8-code-navigation-systems.md @@ -101,3 +101,20 @@ Invoking `tree-sitter tags test.rb` produces the following console output, repre ``` It is expected that tag queries for a given language are located at `queries/tags.scm` in that language's repository. + +## Unit Testing + +Tags queries may be tested with `tree-sitter test`. Files under `test/tags/` are checked using the same comment system as [highlights queries](https://tree-sitter.github.io/tree-sitter/syntax-highlighting#unit-testing). For example, the above Ruby tags can be tested with these comments: + +```ruby +module Foo + # ^ definition.module + class Bar + # ^ definition.class + + def baz + # ^ definition.method + end + end +end +```