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