testing.ex (697B)
1 defmodule Makeup.Lexers.ElixirLexer.Testing do 2 @moduledoc false 3 # The tests need to be checked manually!!! (remove this line when they've been checked) 4 alias Makeup.Lexers.ElixirLexer 5 alias Makeup.Lexer.Postprocess 6 7 # This function has two purposes: 8 # 1. Ensure deterministic lexer output (no random prefix) 9 # 2. Convert the token values into binaries so that the output 10 # is more obvious on visual inspection 11 # (iolists are hard to parse by a human) 12 def lex(text) do 13 text 14 |> ElixirLexer.lex(group_prefix: "group") 15 |> Postprocess.token_values_to_binaries() 16 |> Enum.map(fn {ttype, meta, value} -> {ttype, Map.delete(meta, :language), value} end) 17 end 18 end