Skip to content

Commit b3cc618

Browse files
authored
Fix regression when diffing nested improper lists (#14292)
Close #14291
1 parent 41a0f0c commit b3cc618

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
lines changed

lib/ex_unit/lib/ex_unit/diff.ex

+1
Original file line numberDiff line numberDiff line change
@@ -1162,6 +1162,7 @@ defmodule ExUnit.Diff do
11621162
else
11631163
other
11641164
|> Map.to_list()
1165+
|> Enum.map(&escape_pair/1)
11651166
|> build_map_or_struct(struct)
11661167
end
11671168
end

lib/ex_unit/test/ex_unit/diff_test.exs

+2
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,8 @@ defmodule ExUnit.DiffTest do
335335
"[[[[], \"Hello-,- \"] | \"world\"] | \"!\"]",
336336
"[[[[], \"Hello \"] | \"world\"] | \"!\"]"
337337
)
338+
339+
refute_diff(:foo = %{bar: [:a | :b]}, "", "")
338340
end
339341

340342
test "proper lists" do

lib/ex_unit/test/ex_unit/formatter_test.exs

+11
Original file line numberDiff line numberDiff line change
@@ -510,6 +510,17 @@ defmodule ExUnit.FormatterTest do
510510
"""
511511
end
512512

513+
test "formats assertions with nested improper list diffing" do
514+
failure = [{:error, catch_assertion(assert :foo = %{bar: [1 | 2]}), []}]
515+
516+
assert format_test_all_failure(test_module(), failure, 1, :infinity, &diff_formatter/2) =~ """
517+
match (=) failed
518+
code: assert :foo = %{bar: [1 | 2]}
519+
left: :foo
520+
right: %{bar: [1 | 2]}
521+
"""
522+
end
523+
513524
defmodule BadInspect do
514525
defstruct key: 0
515526

0 commit comments

Comments
 (0)