tree-sitter-elixir/test/corpus/integration/spec.txt

246 lines
5.0 KiB
Plaintext
Raw Normal View History

2021-09-01 14:59:04 +00:00
=====================================
without type parentheses
=====================================
@spec fun(atom, integer, keyword) :: string
---
(source
(unary_operator
(call
(identifier)
(arguments
(binary_operator
(call
(identifier)
(arguments
(identifier)
(identifier)
(identifier)))
(identifier))))))
=====================================
with type parentheses
=====================================
@spec fun(atom(), integer(), keyword()) :: string()
---
(source
(unary_operator
(call
(identifier)
(arguments
(binary_operator
(call
(identifier)
(arguments
(call
2021-09-25 00:23:37 +00:00
(identifier)
(arguments))
2021-09-01 14:59:04 +00:00
(call
2021-09-25 00:23:37 +00:00
(identifier)
(arguments))
2021-09-01 14:59:04 +00:00
(call
2021-09-25 00:23:37 +00:00
(identifier)
(arguments))))
2021-09-01 14:59:04 +00:00
(call
2021-09-25 00:23:37 +00:00
(identifier)
(arguments)))))))
2021-09-01 14:59:04 +00:00
=====================================
with literals
=====================================
@spec fun(%{key: atom}) :: {:ok, atom} | {:error, binary}
---
(source
(unary_operator
(call
(identifier)
(arguments
(binary_operator
(call
(identifier)
(arguments
(map
(map_content
(keywords
(pair
2021-09-28 14:00:35 +00:00
(keyword)
2021-09-25 00:23:37 +00:00
(identifier)))))))
2021-09-01 14:59:04 +00:00
(binary_operator
(tuple
2021-09-28 14:00:35 +00:00
(atom)
2021-09-01 14:59:04 +00:00
(identifier))
(tuple
2021-09-28 14:00:35 +00:00
(atom)
2021-09-01 14:59:04 +00:00
(identifier))))))))
=====================================
with function reference
=====================================
@spec fun((-> atom), (atom -> integer)) :: integer
---
(source
(unary_operator
(call
(identifier)
(arguments
(binary_operator
(call
(identifier)
(arguments
2021-09-25 00:23:37 +00:00
(block
(stab_clause
(body
(identifier))))
(block
(stab_clause
(arguments
(identifier))
(body
(identifier))))))
2021-09-01 14:59:04 +00:00
(identifier))))))
=====================================
with remote type
=====================================
@spec fun(Keyword.t()) :: String.t()
---
(source
(unary_operator
(call
(identifier)
(arguments
(binary_operator
(call
(identifier)
(arguments
(call
(dot
(alias)
2021-09-25 00:23:37 +00:00
(identifier))
(arguments))))
2021-09-01 14:59:04 +00:00
(call
(dot
(alias)
2021-09-25 00:23:37 +00:00
(identifier))
(arguments)))))))
2021-09-01 14:59:04 +00:00
=====================================
with type guard
=====================================
@spec fun(arg1, arg2) :: {arg1, arg2} when arg1: atom, arg2: integer
---
(source
(unary_operator
(call
(identifier)
(arguments
(binary_operator
(binary_operator
(call
(identifier)
(arguments
(identifier)
(identifier)))
(tuple
(identifier)
(identifier)))
(keywords
(pair
2021-09-28 14:00:35 +00:00
(keyword)
2021-09-01 14:59:04 +00:00
(identifier))
(pair
2021-09-28 14:00:35 +00:00
(keyword)
2021-09-01 14:59:04 +00:00
(identifier))))))))
=====================================
with named arguments
=====================================
@spec days_since_epoch(year :: integer, month :: integer, day :: integer) :: integer
---
(source
(unary_operator
(call
(identifier)
(arguments
(binary_operator
(call
(identifier)
(arguments
(binary_operator
(identifier)
(identifier))
(binary_operator
(identifier)
(identifier))
(binary_operator
(identifier)
(identifier))))
(identifier))))))
=====================================
nonempty list
=====================================
@spec fun() :: [integer, ...]
---
(source
(unary_operator
(call
(identifier)
(arguments
(binary_operator
2021-09-25 00:23:37 +00:00
(call
(identifier)
(arguments))
2021-09-01 14:59:04 +00:00
(list
2021-09-25 00:23:37 +00:00
(identifier)
2021-09-01 14:59:04 +00:00
(identifier)))))))
=====================================
[error] type guard cannot end with keyword separator
=====================================
@spec fun(arg) :: arg when arg: atom,
---
(source
(unary_operator
(call
(identifier)
(arguments
(binary_operator
(binary_operator
(call
(identifier)
(arguments
(identifier)))
(identifier))
(keywords
(pair
2021-09-28 14:00:35 +00:00
(keyword)
2021-09-01 14:59:04 +00:00
(identifier)))))))
(ERROR))