mirror of
https://github.com/stevearc/aerial.nvim
synced 2024-09-16 14:34:08 +02:00
Merge pull request #218 from emmanueltouzery/elixir_exunit
support for elixir exunit tests
This commit is contained in:
commit
a467e9a06a
4 changed files with 87 additions and 0 deletions
|
@ -82,6 +82,10 @@ M.elixir = {
|
|||
local protocol = (utils.get_at_path(match, "protocol") or {}).node
|
||||
local protocol_name = vim.treesitter.query.get_node_text(protocol, bufnr) or "<parse error>"
|
||||
item.name = string.format("%s > %s", item.name, protocol_name)
|
||||
elseif name == "test" then
|
||||
item.name = string.format("test %s", item.name)
|
||||
elseif name == "describe" then
|
||||
item.name = string.format("describe %s", item.name)
|
||||
end
|
||||
elseif item.kind == "Constant" then
|
||||
item.name = string.format("@%s", item.name)
|
||||
|
|
|
@ -57,3 +57,18 @@
|
|||
target: (identifier) @identifier (#eq? @identifier "defstruct")) @type
|
||||
(#set! "kind" "Function")
|
||||
) @start
|
||||
|
||||
; exunit unit test
|
||||
(call
|
||||
target: (identifier) @identifier (#any-of? @identifier "describe" "test")
|
||||
(arguments [(string (quoted_content) @name)])
|
||||
(#set! "kind" "Function")
|
||||
) @type
|
||||
|
||||
; exunit test setup
|
||||
(do_block
|
||||
(call
|
||||
target: (identifier) @identifier @name (#eq? @identifier "setup")) @type
|
||||
(#set! "kind" "Function")
|
||||
) @type
|
||||
|
||||
|
|
|
@ -175,6 +175,55 @@ describe("treesitter elixir", function()
|
|||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
kind = "Module",
|
||||
name = "StringTest",
|
||||
level = 0,
|
||||
lnum = 43,
|
||||
col = 0,
|
||||
end_lnum = 59,
|
||||
end_col = 3,
|
||||
children = {
|
||||
{
|
||||
kind = "Function",
|
||||
name = "describe String.capitalize/1",
|
||||
level = 1,
|
||||
lnum = 46,
|
||||
col = 2,
|
||||
end_lnum = 58,
|
||||
end_col = 5,
|
||||
children = {
|
||||
{
|
||||
kind = "Function",
|
||||
name = "setup",
|
||||
level = 2,
|
||||
lnum = 47,
|
||||
col = 4,
|
||||
end_lnum = 49,
|
||||
end_col = 7,
|
||||
},
|
||||
{
|
||||
kind = "Function",
|
||||
name = "test first grapheme is in uppercase",
|
||||
level = 2,
|
||||
lnum = 51,
|
||||
col = 4,
|
||||
end_lnum = 53,
|
||||
end_col = 7,
|
||||
},
|
||||
{
|
||||
kind = "Function",
|
||||
name = "test converts remaining graphemes to lowercase",
|
||||
level = 2,
|
||||
lnum = 55,
|
||||
col = 4,
|
||||
end_lnum = 57,
|
||||
end_col = 7,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
end)
|
||||
end)
|
||||
|
|
|
@ -38,3 +38,22 @@ defimpl Example.Protocol, for: Map do
|
|||
true
|
||||
end
|
||||
end
|
||||
|
||||
# https://hexdocs.pm/ex_unit/ExUnit.Case.html#describe/2-examples
|
||||
defmodule StringTest do
|
||||
use ExUnit.Case, async: true
|
||||
|
||||
describe "String.capitalize/1" do
|
||||
setup do
|
||||
# setup code
|
||||
end
|
||||
|
||||
test "first grapheme is in uppercase" do
|
||||
assert String.capitalize("hello") == "Hello"
|
||||
end
|
||||
|
||||
test "converts remaining graphemes to lowercase" do
|
||||
assert String.capitalize("HELLO") == "Hello"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue