Skip to content

Commit 69990a5

Browse files
committed
Fix regression when diffing nested improper lists (elixir-lang#14292)
Close elixir-lang#14291
1 parent 930ec69 commit 69990a5

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
lines changed

lib/ex_unit/lib/ex_unit/diff.ex

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1156,6 +1156,7 @@ defmodule ExUnit.Diff do
11561156
else
11571157
other
11581158
|> Map.to_list()
1159+
|> Enum.map(&escape_pair/1)
11591160
|> build_map_or_struct(struct)
11601161
end
11611162
end

lib/ex_unit/test/ex_unit/diff_test.exs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,8 @@ defmodule ExUnit.DiffTest do
330330
"[[[[], \"Hello-,- \"] | \"world\"] | \"!\"]",
331331
"[[[[], \"Hello \"] | \"world\"] | \"!\"]"
332332
)
333+
334+
refute_diff(:foo = %{bar: [:a | :b]}, "", "")
333335
end
334336

335337
test "proper lists" do

lib/ex_unit/test/ex_unit/formatter_test.exs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -503,6 +503,17 @@ defmodule ExUnit.FormatterTest do
503503
"""
504504
end
505505

506+
test "formats assertions with nested improper list diffing" do
507+
failure = [{:error, catch_assertion(assert :foo = %{bar: [1 | 2]}), []}]
508+
509+
assert format_test_all_failure(test_module(), failure, 1, :infinity, &diff_formatter/2) =~ """
510+
match (=) failed
511+
code: assert :foo = %{bar: [1 | 2]}
512+
left: :foo
513+
right: %{bar: [1 | 2]}
514+
"""
515+
end
516+
506517
defmodule BadInspect do
507518
defstruct key: 0
508519

0 commit comments

Comments
 (0)