Skip to content

Commit 40da7e8

Browse files
committed
Fix ExUnit crash when diffing bitstring specifiers (#14161)
1 parent ac910c1 commit 40da7e8

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

lib/ex_unit/lib/ex_unit/diff.ex

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -878,7 +878,8 @@ defmodule ExUnit.Diff do
878878
end
879879

880880
defp rebuild_split_strings(%{contents: contents, delimiter: delimiter}, right) do
881-
%{contents: contents ++ [{false, right}], delimiter: delimiter}
881+
{new_right, diff} = extract_diff_meta(right)
882+
%{contents: contents ++ [{diff, new_right}], delimiter: delimiter}
882883
end
883884

884885
defp rebuild_concat_string(literal, nil, []) do

lib/ex_unit/test/ex_unit/diff_test.exs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1133,6 +1133,12 @@ defmodule ExUnit.DiffTest do
11331133
"-<<trap::binary-size(3)>> <> \"baz\"-",
11341134
"+\"foobar\"+"
11351135
)
1136+
1137+
refute_diff(
1138+
"hello " <> <<_::binary-size(6)>> = "hello world",
1139+
"\"hello \" <> -<<_::binary-size(6)>>-",
1140+
"\"hello +world+\""
1141+
)
11361142
end
11371143

11381144
test "underscore" do

0 commit comments

Comments
 (0)