|
| 1 | +defmodule Gradient.AstData do |
| 2 | + require Gradient.Debug |
| 3 | + import Gradient.Debug, only: [elixir_to_ast: 1] |
| 4 | + import Gradient.TestHelpers |
| 5 | + alias Gradient.Types |
| 6 | + |
| 7 | + @tokens __ENV__.file |> load_tokens() |
| 8 | + |
| 9 | + defp pipe do |
| 10 | + {__ENV__.function, |
| 11 | + {__ENV__.line, |
| 12 | + elixir_to_ast do |
| 13 | + 1 |
| 14 | + |> is_atom() |
| 15 | + |
| 16 | + '1' |
| 17 | + |> is_atom() |
| 18 | + |
| 19 | + :ok |
| 20 | + |> is_atom() |
| 21 | + |
| 22 | + [1, 2, 3] |
| 23 | + |> is_atom() |
| 24 | + |
| 25 | + {1, 2, 3} |
| 26 | + |> is_atom() |
| 27 | + |
| 28 | + "a" |
| 29 | + |> is_atom() |
| 30 | + end, __ENV__.line}, |
| 31 | + {:block, 11, |
| 32 | + [ |
| 33 | + {:call, 14, {:remote, 14, {:atom, 14, :erlang}, {:atom, 14, :is_atom}}, |
| 34 | + [{:integer, 13, 1}]}, |
| 35 | + {:call, 17, {:remote, 17, {:atom, 17, :erlang}, {:atom, 17, :is_atom}}, |
| 36 | + [{:cons, 16, {:integer, 16, 49}, {nil, 16}}]}, |
| 37 | + {:call, 20, {:remote, 20, {:atom, 20, :erlang}, {:atom, 20, :is_atom}}, |
| 38 | + [{:atom, 19, :ok}]}, |
| 39 | + {:call, 23, {:remote, 23, {:atom, 23, :erlang}, {:atom, 23, :is_atom}}, |
| 40 | + [ |
| 41 | + {:cons, 22, {:integer, 22, 1}, |
| 42 | + {:cons, 22, {:integer, 22, 2}, {:cons, 22, {:integer, 22, 3}, {nil, 22}}}} |
| 43 | + ]}, |
| 44 | + {:call, 26, {:remote, 26, {:atom, 26, :erlang}, {:atom, 26, :is_atom}}, |
| 45 | + [{:tuple, 25, [{:integer, 25, 1}, {:integer, 25, 2}, {:integer, 25, 3}]}]}, |
| 46 | + {:call, 29, {:remote, 29, {:atom, 29, :erlang}, {:atom, 29, :is_atom}}, |
| 47 | + [{:bin, 28, [{:bin_element, 28, {:string, 28, 'a'}, :default, :default}]}]} |
| 48 | + ]}} |
| 49 | + end |
| 50 | + |
| 51 | + @spec ast_data() :: [{Types.abstract_expr(), Types.tokens(), Types.options()}] |
| 52 | + def ast_data do |
| 53 | + [pipe()] |
| 54 | + |> Enum.map(fn {{name, _}, {start_line, ast, end_line}, expected} -> |
| 55 | + tokens = Gradient.Tokens.drop_tokens_to_line(@tokens, start_line) |
| 56 | + {name, {ast, tokens, [line: start_line, end_line: end_line]}, expected} |
| 57 | + end) |
| 58 | + end |
| 59 | +end |
0 commit comments