1. ExUnit compares lists by value (only the value not matching is highlighted)
code: assert [1, 1] = [1, 2]
left: [1, 1]
- (red highlight)
right: [1, 2]
Binaries are treated as one value (the whole binary is highlighted)
code: assert <<1, 1>> = <<1, 2>>
left: <<1, 1>>
-------- (red)
right: <<1, 2>>
(this especially confusing when using module attributes in the match.)
would it be possible to write a custom assertion that only highlights the byte not matching?
code: assert <<1, 1>> = <<1, 2>>
left: <<1, 1>>
-
right: <<1, 2>>
2. binaries are always displayed as base-10 …
assert <<0xBE, 0xEF>> = <<0xBE, 0xED>>
...
code: assert <<190, 239>> = <<190, 237>>
left: <<190, 239>>
right: <<190, 237>>
… or even worse as strings (if it happens to be all-printable)
assert <<0xBE::16>> = <<66, 69>>
code: assert <<190::16>> = <<66, 69>>
left: <<190::16>>
right: "BE"
Is there a way to set the base for assertions? (like in inspect(x, base: :hex)
)
3. what I dream about at night
the ideal would be if ExUnit would layout the right-side binary like the left side, so if I have this assertion:
assert <<1::1, 0::1, 3::2, 15::4>> = <some expression that results in a binary>
instead of
left: <<1::1, 0::1, 3::2, 15::4>>
--------------------------- (red)
right: "?"
I’d get
left: <<1::1, 0::1, 3::2, 15::4>>
----
right: <<0::1, 0::1, 3::2, 15::4>>