add unit tests for tags.scm queries (#27)

This commit is contained in:
Michael Davis 2022-03-04 09:38:31 -06:00 committed by GitHub
parent 1344bb095f
commit 6702d11ec4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 60 additions and 8 deletions

14
package-lock.json generated
View File

@ -13,7 +13,7 @@
}, },
"devDependencies": { "devDependencies": {
"prettier": "^2.3.2", "prettier": "^2.3.2",
"tree-sitter-cli": "^0.20.1" "tree-sitter-cli": "^0.20.6"
} }
}, },
"node_modules/nan": { "node_modules/nan": {
@ -34,9 +34,9 @@
} }
}, },
"node_modules/tree-sitter-cli": { "node_modules/tree-sitter-cli": {
"version": "0.20.1", "version": "0.20.6",
"resolved": "https://registry.npmjs.org/tree-sitter-cli/-/tree-sitter-cli-0.20.1.tgz", "resolved": "https://registry.npmjs.org/tree-sitter-cli/-/tree-sitter-cli-0.20.6.tgz",
"integrity": "sha512-I0Gp4ThRp39TDnBAaZKiogvoE85MSeL6/ILZMXbzeEo8hUsudpVhEHRE4CU+Bk5QUaiMiDkD+ZIL3gT2zZ++wg==", "integrity": "sha512-tjbAeuGSMhco/EnsThjWkQbDIYMDmdkWsTPsa/NJAW7bjaki9P7oM9TkLxfdlnm4LXd1wR5wVSM2/RTLtZbm6A==",
"dev": true, "dev": true,
"hasInstallScript": true, "hasInstallScript": true,
"bin": { "bin": {
@ -57,9 +57,9 @@
"dev": true "dev": true
}, },
"tree-sitter-cli": { "tree-sitter-cli": {
"version": "0.20.1", "version": "0.20.6",
"resolved": "https://registry.npmjs.org/tree-sitter-cli/-/tree-sitter-cli-0.20.1.tgz", "resolved": "https://registry.npmjs.org/tree-sitter-cli/-/tree-sitter-cli-0.20.6.tgz",
"integrity": "sha512-I0Gp4ThRp39TDnBAaZKiogvoE85MSeL6/ILZMXbzeEo8hUsudpVhEHRE4CU+Bk5QUaiMiDkD+ZIL3gT2zZ++wg==", "integrity": "sha512-tjbAeuGSMhco/EnsThjWkQbDIYMDmdkWsTPsa/NJAW7bjaki9P7oM9TkLxfdlnm4LXd1wR5wVSM2/RTLtZbm6A==",
"dev": true "dev": true
} }
} }

View File

@ -20,7 +20,7 @@
}, },
"devDependencies": { "devDependencies": {
"prettier": "^2.3.2", "prettier": "^2.3.2",
"tree-sitter-cli": "^0.20.1" "tree-sitter-cli": "^0.20.6"
}, },
"tree-sitter": [ "tree-sitter": [
{ {

31
test/tags/module.ex Normal file
View File

@ -0,0 +1,31 @@
defmodule Foo.Bar.Baz do
# ^ definition.module
# ^ definition.module
# ^ definition.module
def init(arg) do
# ^ definition.function
state =
arg
|> map(&(&1 * 2))
# ^ reference.call
|> map(&(&1 + 1))
# ^ reference.call
{:ok, arg}
end
def map(list, fun, acc \\ [])
# ^ definition.function
def map([head | rest], fun, acc) do
# ^ definition.function
map(rest, fun, [fun.(head) | acc])
# <- reference.call
end
def map([], _fun, acc), do: Enum.reverse(acc)
# ^ definition.function
# ^ reference.module
# ^ reference.call
end

21
test/tags/protocol.ex Normal file
View File

@ -0,0 +1,21 @@
defprotocol Countable do
# ^ definition.module
def count(data)
# ^ definition.function
end
defimpl Countable, for: Binary do
# ^ reference.module
# ^ reference.module
def count(binary), do: byte_size(binary)
# ^ definition.function
# ^ reference.call
end
defimpl Countable, for: List do
# ^ reference.module
# ^ reference.module
def count(list), do: length(list)
# ^ definition.function
# ^ reference.call
end