Add highlighting tests

This commit is contained in:
Jonatan Kłosko 2021-09-29 19:32:23 +02:00
parent 30128092d4
commit 7357885bbc
8 changed files with 1096 additions and 0 deletions

View File

@ -0,0 +1,66 @@
fn x, y, z ->
# <- keyword
# ^ variable
# ^ punctuation.delimiter
# ^ variable
# ^ punctuation.delimiter
# ^ variable
# ^ operator
fn(a, b, c) ->
# <- keyword
# ^ punctuation.bracket
# ^ variable
# ^ punctuation.delimiter
# ^ variable
# ^ punctuation.delimiter
# ^ variable
# ^ punctuation.bracket
# ^ operator
&(x + y - z * a / &1 + b + div(&2, c))
#<- operator
#^ punctuation.bracket
# ^ variable
# ^ operator
# ^ variable
# ^ operator
# ^ variable
# ^ operator
# ^ variable
# ^ operator
# ^ operator
# ^ operator
# ^ variable
# ^ operator
# ^ function
# ^ punctuation.bracket
# ^ operator
# ^ punctuation.delimiter
# ^ variable
# ^ punctuation.bracket
# ^ punctuation.bracket
end
end
&Set.put(&1, &2)
# <- operator
# ^ type
# ^ operator
# ^ function
# ^ punctuation.bracket
# ^ operator
# ^ punctuation.delimiter
# ^ operator
# ^ punctuation.bracket
&( Set.put(&1, &1) )
#<- operator
#^ punctuation.bracket
# ^ type
# ^ operator
# ^ function
# ^ punctuation.bracket
# ^ operator
# ^ punctuation.delimiter
# ^ operator
# ^ punctuation.bracket
# ^ punctuation.bracket

81
test/highlight/calls.ex Normal file
View File

@ -0,0 +1,81 @@
Path.expand("..", __DIR__)
# ^ type
# ^ operator
# ^ function
# ^ punctuation.bracket
# ^ string
# ^ punctuation.delimiter
# ^ constant.builtin
# ^ punctuation.bracket
func.(1)
# ^ variable
# ^ operator
# ^ punctuation.bracket
# ^ number
# ^ punctuation.bracket
arg |> func
# ^ variable
# ^ operator
# ^ function
func 1
# ^ function
# ^ number
hd([1,2])
# <- function
# ^ punctuation.bracket
# ^ punctuation.bracket
# ^ number
# ^ punctuation.delimiter
# ^ number
# ^ punctuation.bracket
# ^ punctuation.bracket
Kernel.spawn(fn -> :ok end)
# ^ type
# ^ operator
# ^ function
# ^ punctuation.bracket
# ^ keyword
# ^ operator
# ^ string.special.symbol
# ^ keyword
# ^ punctuation.bracket
IO.ANSI.black
# ^ type
# ^ operator
# ^ function
Kernel.-(number)
# ^ type
# ^ operator
# ^ operator
# ^ punctuation.bracket
# ^ variable
# ^ punctuation.bracket
Enum.map([1, 2], fn x ->
# ^ type
# ^ operator
# ^ function
# ^ punctuation.bracket
# ^ punctuation.bracket
# ^ number
# ^ punctuation.delimiter
# ^ number
# ^ punctuation.bracket
# ^ punctuation.delimiter
# ^ keyword
# ^ variable
# ^ operator
x * 2
# <- variable
# ^ operator
# ^ number
end)
# <- keyword
# ^ punctuation.bracket

View File

@ -0,0 +1,200 @@
<<1, 2, 3>>
# <- punctuation.bracket
# ^ number
# ^ punctuation.delimiter
# ^ number
# ^ punctuation.delimiter
# ^ number
# ^ punctuation.bracket
<< header :: size(8), data :: binary >>
# <- punctuation.bracket
# ^ variable
# ^ operator
# ^ function
# ^ punctuation.bracket
# ^ number
# ^ punctuation.bracket
# ^ punctuation.delimiter
# ^ variable
# ^ operator
# ^ variable
# ^ punctuation.bracket
<<"hello"::binary, c :: utf8, x::[4, unit(2)]>> = "hello™1"
# <- punctuation.bracket
# ^ string
# ^ operator
# ^ variable
# ^ punctuation.delimiter
# ^ variable
# ^ operator
# ^ variable
# ^ punctuation.delimiter
# ^ variable
# ^ operator
# ^ punctuation.bracket
# ^ number
# ^ punctuation.delimiter
# ^ function
# ^ punctuation.bracket
# ^ number
# ^ punctuation.bracket
# ^ punctuation.bracket
# ^ punctuation.bracket
# ^ operator
# ^ string
[1, :a, 'hello'] ++ [2, 3]
# <- punctuation.bracket
# ^ punctuation.delimiter
# ^ string.special.symbol
# ^ punctuation.delimiter
# ^ string
# ^ punctuation.bracket
# ^ operator
# ^ punctuation.bracket
# ^ number
# ^ punctuation.delimiter
# ^ number
# ^ punctuation.bracket
[:head | [?t, ?a]]
# <- punctuation.bracket
# ^ string.special.symbol
# ^ operator
# ^ punctuation.bracket
# ^ constant
# ^ punctuation.delimiter
# ^ constant
# ^ punctuation.bracket
# ^ punctuation.bracket
{:one, 2.0, "three"}
# <- punctuation.bracket
# ^ string.special.symbol
# ^ punctuation.delimiter
# ^ number
# ^ punctuation.delimiter
# ^ string
# ^ punctuation.bracket
[option: "value", key: :word]
# <- punctuation.bracket
# ^ string.special.symbol
# ^ string
# ^ punctuation.delimiter
# ^ string.special.symbol
# ^ string.special.symbol
# ^ punctuation.bracket
[++: "operator", ~~~: :&&&]
# <- punctuation.bracket
# ^ string.special.symbol
# ^ string
# ^ punctuation.delimiter
# ^ string.special.symbol
# ^ string.special.symbol
# ^ punctuation.bracket
[...: 1, <<>>: 2, %{}: 3, %: 4, {}: 5]
# <- punctuation.bracket
# ^ string.special.symbol
# ^ number
# ^ punctuation.delimiter
# ^ string.special.symbol
# ^ number
# ^ punctuation.delimiter
# ^ string.special.symbol
# ^ number
# ^ punctuation.delimiter
# ^ string.special.symbol
# ^ number
# ^ punctuation.delimiter
# ^ string.special.symbol
# ^ number
# ^ punctuation.bracket
["this is an atom too": 1, "so is #{1} this": 2]
# <- punctuation.bracket
# ^ string.special.symbol
# ^ number
# ^ punctuation.delimiter
# ^ string.special.symbol
# ^ punctuation.special
# ^ number
# ^ punctuation.special
# ^ number
# ^ punctuation.bracket
%{shortcut: "syntax"}
#<- punctuation
#^ punctuation.bracket
# ^ string.special.symbol
# ^ string
# ^ punctuation.bracket
%{map | "update" => "me"}
#<- punctuation
#^ punctuation.bracket
# ^ variable
# ^ operator
# ^ string
# ^ operator
# ^ string
# ^ punctuation.bracket
%{ 12 => 13, :weird => ['thing'] }
#<- punctuation
#^ punctuation.bracket
# ^ number
# ^ operator
# ^ number
# ^ punctuation.delimiter
# ^ string.special.symbol
# ^ operator
# ^ punctuation.bracket
# ^ string
# ^ punctuation.bracket
# ^ punctuation.bracket
%Long.Module.Name{name: "Silly"}
# <- punctuation
# ^ type
# ^ type
# ^ punctuation.bracket
# ^ string.special.symbol
# ^ string
# ^ punctuation.bracket
%Long.Module.Name{s | height: {192, :cm}}
# <- punctuation
# ^ type
# ^ punctuation.bracket
# ^ variable
# ^ operator
# ^ string.special.symbol
# ^ punctuation.bracket
# ^ number
# ^ punctuation.delimiter
# ^ string.special.symbol
# ^ punctuation.bracket
# ^ punctuation.bracket
".. #{%Long.Module.Name{s | height: {192, :cm}}} .."
# ^ string
# ^ punctuation.special
# ^ punctuation
# ^ type
# ^ punctuation.bracket
# ^ variable
# ^ operator
# ^ string.special.symbol
# ^ punctuation.bracket
# ^ number
# ^ punctuation.delimiter
# ^ string.special.symbol
# ^ punctuation.bracket
# ^ punctuation.bracket
# ^ punctuation.special
# ^ string

View File

@ -0,0 +1,15 @@
abc_123
# ^ variable
_018OP
# ^ comment.unused
A__0
# ^ type
__MODULE__ ; __STACKTRACE__
# ^ constant.builtin
# ^ constant.builtin
__OTHER__
# ^ comment.unused

175
test/highlight/kernel.ex Normal file
View File

@ -0,0 +1,175 @@
for x <- 1..10, x < 5, do: {x, x}
# <- keyword
# ^ variable
# ^ operator
# ^ number
# ^ operator
# ^ number
# ^ punctuation.delimiter
# ^ variable
# ^ operator
# ^ number
# ^ punctuation.delimiter
# ^ string.special.symbol
# ^ punctuation.bracket
# ^ variable
# ^ punctuation.delimiter
# ^ variable
# ^ punctuation.bracket
for << <<r::4, g::4, b::4, a::size(4)>> <- pixels >> do
# <- keyword
# ^ punctuation.bracket
# ^ punctuation.bracket
# ^ variable
# ^ operator
# ^ number
# ^ punctuation.delimiter
# ^ variable
# ^ operator
# ^ number
# ^ punctuation.delimiter
# ^ variable
# ^ operator
# ^ number
# ^ punctuation.delimiter
# ^ variable
# ^ operator
# ^ function
# ^ punctuation.bracket
# ^ number
# ^ punctuation.bracket
# ^ punctuation.bracket
# ^ operator
# ^ variable
# ^ punctuation.bracket
# ^ keyword
end
# <- keyword
if :this do
# <- keyword
# ^ string.special.symbol
# ^ keyword
:that
# ^ string.special.symbol
else
# <- keyword
:otherwise
# ^ string.special.symbol
end
# <- keyword
receive do
# ^ keyword
# ^ keyword
{:EXIT, _} -> :done
# <- punctuation.bracket
# ^ string.special.symbol
# ^ punctuation.delimiter
# ^ comment.unused
# ^ punctuation.bracket
# ^ operator
# ^ string.special.symbol
{ ^pid, :_ } -> nil
# <- punctuation.bracket
# ^ operator
# ^ variable
# ^ punctuation.delimiter
# ^ string.special.symbol
# ^ punctuation.bracket
# ^ operator
# ^ constant
after 100 -> :no_luck
# ^ keyword
# ^ number
# ^ operator
# ^ string.special.symbol
end
# <- keyword
case __ENV__.line do
# ^ keyword
# ^ constant.builtin
# ^ operator
# ^ function
# ^ keyword
x when is_integer(x) -> x
# <- variable
# ^ keyword
# ^ function
# ^ punctuation.bracket
# ^ variable
# ^ punctuation.bracket
# ^ operator
# ^ variable
x when x in 1..12 -> -x
# <- variable
# ^ keyword
# ^ variable
# ^ keyword
# ^ number
# ^ operator
# ^ number
# ^ operator
# ^ operator
# ^ variable
end
# <- keyword
cond do
# <- keyword
# ^ keyword
false -> "too bad"
# ^ constant
# ^ operator
# ^ string
4 > 5 -> "oops"
# <- number
# ^ operator
# ^ number
# ^ operator
# ^ string
true -> nil
# ^ constant
# ^ operator
# ^ constant
end
# <- keyword
raise RuntimeError, message: "This is not an error"
# ^ keyword
# ^ type
# ^ punctuation.delimiter
# ^ string.special.symbol
# ^ string
import Kernel, except: [spawn: 1, +: 2, /: 2, Unless: 2]
# ^ keyword
# ^ type
# ^ punctuation.delimiter
# ^ string.special.symbol
# ^ punctuation.bracket
# ^ string.special.symbol
# ^ number
# ^ punctuation.delimiter
# ^ string.special.symbol
# ^ number
# ^ punctuation.delimiter
# ^ string.special.symbol
# ^ number
# ^ punctuation.delimiter
# ^ string.special.symbol
# ^ number
# ^ punctuation.bracket
alias Long.Module.Name, as: N0men123_and4
# ^ keyword
# ^ type
# ^ punctuation.delimiter
# ^ string.special.symbol
# ^ type
use Bitwise
# ^ keyword
# ^ type

173
test/highlight/literals.ex Normal file
View File

@ -0,0 +1,173 @@
1234 ; 01234
# ^ number
# ^ punctuation.delimiter
# ^ number
1.23 ; 1.23e10 ; 1.23e-10
# ^ number
# ^ number
# ^ number
0xab ; 0o171 ; 0b01001
# ^ number
# ^ number
# ^ number
100_000_000 ; 0b1111_0000
# ^ number
# ^ number
?a ; ?1 ; ?\n ; ?\s ; ?\c ; ? ; ?,
# <- constant
# ^ constant
# ^ constant
# ^ constant
# ^ constant
# ^ constant
# ^ constant
# ^ constant
true ; false ; nil
# ^ constant
# ^ constant
# ^ constant
:this ; :that
# ^ string.special.symbol
# ^ string.special.symbol
:'complex atom'
# ^ string.special.symbol
:"with' \" 'quotes \u0301"
# ^ string.special.symbol
# ^ string.escape
# ^ string.escape
# ^ string.special.symbol
# ^ string.escape
# ^ string.escape
:"with #{1 + 1} interpol"
# ^ punctuation.special
# ^ number
# ^ operator
# ^ number
# ^ punctuation.special
:... ; :<<>> ; :%{} ; :% ; :{}
# ^ string.special.symbol
# ^ string.special.symbol
# ^ string.special.symbol
# ^ string.special.symbol
# ^ string.special.symbol
:++ ; :-- ; :* ; :~~~ ; :::
# ^ string.special.symbol
# ^ string.special.symbol
# ^ string.special.symbol
# ^ string.special.symbol
# ^ string.special.symbol
:% ; :. ; :<-
# <- string.special.symbol
# ^ string.special.symbol
# ^ string.special.symbol
"simple string"
# ^ string
# ^ string
"with \x{ff} code"
# ^ string
# ^ string.escape
# ^ string.escape
# ^ string
"with \7 \016 \t \\s"
# ^ string
# ^ string.escape
# ^ string.escape
# ^ string
# ^ string.escape
# ^ string
# ^ string.escape
# ^ string
"with #{inspect "inner"} interpolation"
# ^ string
# ^ punctuation.special
# ^ function
# ^ string
# ^ punctuation.special
# ^ string
"Multiline
string"
# <- string
# ^ string
"""
Heredoc
"""
# ^ string
'charlist'
# ^ string
~s(string sigil #{1})
# <- string
# ^ string
# ^ string
# ^ number
~S/string #{1}/
# ^ string
~r/x?/iu
# <- string.regex
# ^ string.regex
# ^ string.regex
~R{noescapes\}[a-z]*}
# ^ string.regex
# ^ string.escape
# ^ string.regex
~w(hello #{ ["has" <> "123", '\c\d', "\123 interpol" | []] } world)s
#<- string.special
# ^ string.special
# ^ punctuation.special
# ^ punctuation.bracket
# ^ string
# ^ operator
# ^ string
# ^ punctuation.delimiter
# ^ string
# ^ string.escape
# ^ string.escape
# ^ string
# ^ punctuation.delimiter
# ^ string
# ^ string.escape
# ^ string
# ^ operator
# ^ punctuation.bracket
# ^ punctuation.bracket
# ^ punctuation.bracket
# ^ punctuation.special
# ^ string.special
~w/yoo \\ \/ =)/
# ^ string.special
# ^ string.escape
# ^ string.escape
# ^ string.special
~W/yoo \\ \/ =)/
# ^ string.special
# ^ string.special
# ^ string.escape
# ^ string.special
~D/2020-01-01/d
# ^ string.special

319
test/highlight/module.ex Normal file
View File

@ -0,0 +1,319 @@
defmodule Long.Module.Name do
# ^ keyword
# ^ type
# ^ type
# ^ keyword
@moduledoc "Simple doc"
# <- comment.doc
# ^ comment.doc.__attribute__
# ^ comment.doc
@moduledoc false
# <- comment.doc
# ^ comment.doc.__attribute__
# ^ comment.doc
@moduledoc """
Heredoc doc
"""
# ^ comment.doc
@moduledoc ~S'''
Sigil doc
'''
# ^ comment.doc
@moduledoc "With #{1} interpolation"
# ^ punctuation.special
# ^ number
# ^ punctuation.special
@typedoc "Type doc"
# <- comment.doc
@doc "Type doc"
# <- comment.doc
@doc """
Multiline docstring
"with quotes"
and #{ inspect %{"interpolation" => "in" <> "action"} }
now with #{ {:a, 'tuple'} }
and #{ inspect {
:tuple,
%{ with: "nested #{ inspect %{ :interpolation => %{} } }" }
} }
"""
# <- comment.doc
@spec func(type, integer()) :: :ok | :fail
# <- attribute
# ^ attribute
# ^ function
# ^ punctuation.bracket
# ^ variable
# ^ punctuation.delimiter
# ^ function
# ^ punctuation.bracket
# ^ punctuation.bracket
# ^ punctuation.bracket
# ^ operator
# ^ string.special.symbol
# ^ operator
# ^ string.special.symbol
defstruct items: []
# ^ keyword
# ^ string.special.symbol
# ^ punctuation.bracket
# ^ punctuation.bracket
defexception [:message]
# ^ keyword
# ^ punctuation.bracket
# ^ string.special.symbol
# ^ punctuation.bracket
@type item :: String.t()
# <- attribute
# ^ attribute
# ^ variable
# ^ operator
# ^ type
# ^ operator
# ^ function
# ^ punctuation.bracket
# ^ punctuation.bracket
@attr "value"
# <- attribute
# ^ attribute
# ^ string
@true
# ^ attribute
@nil
# ^ attribute
def f, do: nil
# ^ keyword
# ^ function
# ^ punctuation.delimiter
# ^ string.special.symbol
# ^ constant
def f(x), do: x
# ^ keyword
# ^ function
# ^ punctuation.bracket
# ^ variable
# ^ punctuation.bracket
# ^ punctuation.delimiter
# ^ string.special.symbol
# ^ variable
def f(10), do: nil
# ^ keyword
# ^ function
# ^ punctuation.bracket
# ^ punctuation.bracket
# ^ punctuation.delimiter
# ^ string.special.symbol
# ^ constant
def f(a, b \\ []), do: nil
# <- keyword
# ^ function
# ^ punctuation.bracket
# ^ variable
# ^ punctuation.delimiter
# ^ variable
# ^ operator
# ^ punctuation.bracket
# ^ punctuation.bracket
# ^ punctuation.delimiter
# ^ string.special.symbol
# ^ constant
def __before_compile__(_) do
# <- keyword
# ^ function
# ^ punctuation.bracket
# ^ comment.unused
# ^ punctuation.bracket
# ^ keyword
end
# <- keyword
def with_guard(x) when x == 1 do: nil
# <- keyword
# ^ function
# ^ variable
# ^ keyword
# ^ variable
# ^ operator
# ^ number
# ^ keyword
# <- keyword
def with_guard when is_integer(1), do: nil
# <- keyword
# ^ function
# ^ keyword
# ^ function
# ^ punctuation.bracket
# ^ number
# ^ punctuation.bracket
# ^ punctuation.delimiter
# ^ string.special.symbol
# ^ constant
def x + y, do: nil
# ^ keyword
# ^ variable
# ^ operator
# ^ variable
# ^ punctuation.delimiter
# ^ string.special.symbol
# ^ constant
def x |> y, do: nil
# ^ keyword
# ^ variable
# ^ operator
# ^ variable
# ^ punctuation.delimiter
# ^ string.special.symbol
# ^ constant
def x and y, do: nil
# ^ keyword
# ^ variable
# ^ keyword
# ^ variable
# ^ punctuation.delimiter
# ^ string.special.symbol
# ^ constant
def unquote(f)(x), do: nil
# ^ keyword
# ^ keyword
# ^ punctuation.bracket
# ^ variable
# ^ punctuation.bracket
# ^ punctuation.bracket
# ^ variable
# ^ punctuation.bracket
# ^ punctuation.delimiter
# ^ string.special.symbol
# ^ constant
def unquote(name)(unquote_splicing(args)), do: nil
# ^ keyword
# ^ keyword
# ^ punctuation.bracket
# ^ variable
# ^ punctuation.bracket
# ^ punctuation.bracket
# ^ keyword
# ^ punctuation.bracket
# ^ variable
# ^ punctuation.bracket
# ^ punctuation.bracket
# ^ string.special.symbol
# ^ constant
def(test(x), do: x)
# ^ keyword
# ^ punctuation.bracket
# ^ punctuation.bracket
# ^ variable
# ^ punctuation.bracket
# ^ punctuation.delimiter
# ^ string.special.symbol
# ^ variable
# ^ punctuation.bracket
defguard is_something(one), do: one != nil
# ^ keyword
# ^ function
# ^ punctuation.bracket
# ^ variable
# ^ punctuation.bracket
# ^ punctuation.delimiter
# ^ string.special.symbol
# ^ variable
# ^ operator
# ^ constant
defdelegate empty?(list), to: Enum
# ^ keyword
# ^ function
# ^ punctuation.bracket
# ^ variable
# ^ punctuation.bracket
# ^ punctuation.delimiter
# ^ string.special.symbol
# ^ type
defmacro meta_function(name) do
# ^ keyword
# ^ function
# ^ punctuation.bracket
# ^ variable
# ^ punctuation.bracket
# ^ keyword
quote do
# ^ keyword
# ^ keyword
def unquote(:"#{name}_foo")() do
# ^ keyword
# ^ keyword
# ^ punctuation.bracket
# ^ string.special.symbol
# ^ punctuation.special
# ^ variable
# ^ punctuation.special
# ^ string.special.symbol
# ^ punctuation.bracket
# ^ punctuation.bracket
# ^ punctuation.bracket
# ^ keyword
unquote("yessir")
# ^ keyword
# ^ punctuation.bracket
# ^ string
# ^ punctuation.bracket
end
# <- keyword
end
# <- keyword
end
# <- keyword
end
# <- keyword
defprotocol Useless do
# ^ keyword
# ^ type
# ^ keyword
def func(this)
# ^ keyword
# ^ function
# ^ punctuation.bracket
# ^ variable
# ^ punctuation.bracket
end
# <- keyword
defimpl Useless, for: Atom do
# ^ keyword
# ^ type
# ^ punctuation.delimiter
# ^ string.special.symbol
# ^ type
# ^ keyword
end
# <- keyword

View File

@ -0,0 +1,67 @@
a ~>> b = bind(a, b)
# <- variable
# ^ operator
# ^ variable
# ^ operator
# ^ function
# ^ punctuation.bracket
# ^ variable
# ^ punctuation.delimiter
# ^ variable
# ^ punctuation.bracket
a ~> b
# ^ operator
a + b
# ^ operator
... == !x && y || z
# <- variable
# ^ operator
# ^ operator
# ^ variable
# ^ operator
# ^ variable
# ^ operator
# ^ variable
x = 1 + 2.0 * 3
# <- variable
# ^ operator
# ^ number
# ^ operator
# ^ number
# ^ operator
# ^ number
y = true and false
# <- variable
# ^ operator
# ^ constant
# ^ keyword
# ^ constant
{ ^z, a } = {true, x}
# <- punctuation.bracket
# ^ operator
# ^ variable
# ^ punctuation.delimiter
# ^ variable
# ^ operator
# ^ punctuation.bracket
# ^ constant
# ^ punctuation.delimiter
# ^ variable
# ^ punctuation.bracket
"hello" |> String.upcase |> String.downcase()
# ^ string
# ^ operator
# ^ type
# ^ operator
# ^ function
# ^ operator
# ^ type
# ^ operator
# ^ function