Test result improvements: color

This commit is contained in:
bluepython508
2023-12-02 19:25:19 +00:00
parent 2784245b2d
commit c086fc1773

View File

@@ -128,32 +128,24 @@ defmodule Mix.Tasks.Aoc do
|> Enum.map(fn {test, input, p1e, p2e} ->
parsed = mod.parse(input)
p1 = mod.part1(parsed)
if p1e do
if stringify(p1) != p1e do
IO.puts("Failed at #{test}.1: expected #{p1e}, got:")
dbg(p1)
else
IO.puts("Test #{test}.1 succeeded")
end
else
IO.puts("Test #{test}.1")
dbg(p1)
end
p2 = mod.part2(parsed)
if p2e do
if stringify(p2) != p2e do
IO.puts("Failed at #{test}.2: expected #{p2e}, got:")
dbg(p2)
result = fn (part, got, expected) ->
if expected do
if stringify(got) != expected do
IO.puts(IO.ANSI.format [:red, "Test #{test}.#{part} failed: expected #{expected}"])
dbg(got)
else
IO.puts(IO.ANSI.format [:green, "Test #{test}.#{part} succeeded"])
end
else
IO.puts("Test #{test}.2 succeeded")
IO.puts("Test #{test}.#{part}:")
dbg(got)
end
else
IO.puts("Test #{test}.2")
dbg(p2)
end
result.(1, p1, p1e)
result.(2, p2, p2e)
end)
end