Test against binary, not iodata in doctests

pull/162/head
Luke Imhoff 7 years ago
parent 0f3cd3f6a0
commit 053c317af1
  1. 61
      apps/explorer/lib/explorer/chain.ex
  2. 61
      apps/explorer/lib/explorer/chain/hash.ex

@ -368,65 +368,24 @@ defmodule Explorer.Chain do
@doc """
Converts the `t:t/0` to string representation shown to users.
iex> Explorer.Chain.hash_to_iodata(
...> %Explorer.Chain.Hash{
iex> %Explorer.Chain.Hash{
...> byte_count: 32,
...> bytes: <<0x9fc76417374aa880d4449a1f7f31ec597f00b1f6f3dd2d66f4c9c6c445836d8b ::
...> big-integer-size(32)-unit(8)>>
...> }
...> )
[
"0x",
['9fc76417374aa880d4449a1f7f31ec597f00b1f6f3dd2d66f4c9c6c445836d8b']
]
...> } |>
...> Explorer.Chain.hash_to_iodata() |>
...> IO.iodata_to_binary()
"0x9fc76417374aa880d4449a1f7f31ec597f00b1f6f3dd2d66f4c9c6c445836d8b"
Always pads number, so that it is a valid format for casting.
iex> Explorer.Chain.hash_to_iodata(
...> %Explorer.Chain.Hash{
iex> %Explorer.Chain.Hash{
...> byte_count: 32,
...> bytes: <<0x1234567890abcdef :: big-integer-size(32)-unit(8)>>
...> }
...> )
[
"0x",
[
[
[
[
[['000', 48, 48, 48], '000', 48, 48, 48],
['000', 48, 48, 48],
'000',
48,
48,
48
],
[['000', 48, 48, 48], '000', 48, 48, 48],
['000', 48, 48, 48],
'000',
48,
48,
48
],
49,
50,
51,
52,
53,
54,
55,
56,
57,
48,
97,
98,
99,
100,
101,
102
]
]
]
...> } |>
...> Explorer.Chain.hash_to_iodata() |>
...> IO.iodata_to_binary()
"0x0000000000000000000000000000000000000000000000001234567890abcdef"
"""
@spec hash_to_iodata(Hash.t()) :: iodata()

@ -125,65 +125,24 @@ defmodule Explorer.Chain.Hash do
@doc """
Converts the `t:t/0` to string representation shown to users.
iex> Explorer.Chain.Hash.to_iodata(
...> %Explorer.Chain.Hash{
iex> %Explorer.Chain.Hash{
...> byte_count: 32,
...> bytes: <<0x9fc76417374aa880d4449a1f7f31ec597f00b1f6f3dd2d66f4c9c6c445836d8b ::
...> big-integer-size(32)-unit(8)>>
...> }
...> )
[
"0x",
['9fc76417374aa880d4449a1f7f31ec597f00b1f6f3dd2d66f4c9c6c445836d8b']
]
...> } |>
...> Explorer.Chain.Hash.to_iodata() |>
...> IO.iodata_to_binary()
"0x9fc76417374aa880d4449a1f7f31ec597f00b1f6f3dd2d66f4c9c6c445836d8b"
Always pads number, so that it is a valid format for casting.
iex> Explorer.Chain.Hash.to_iodata(
...> %Explorer.Chain.Hash{
iex> %Explorer.Chain.Hash{
...> byte_count: 32,
...> bytes: <<0x1234567890abcdef :: big-integer-size(32)-unit(8)>>
...> }
...> )
[
"0x",
[
[
[
[
[['000', 48, 48, 48], '000', 48, 48, 48],
['000', 48, 48, 48],
'000',
48,
48,
48
],
[['000', 48, 48, 48], '000', 48, 48, 48],
['000', 48, 48, 48],
'000',
48,
48,
48
],
49,
50,
51,
52,
53,
54,
55,
56,
57,
48,
97,
98,
99,
100,
101,
102
]
]
]
...> } |>
...> Explorer.Chain.Hash.to_iodata() |>
...> IO.iodata_to_binary()
"0x0000000000000000000000000000000000000000000000001234567890abcdef"
"""
@spec to_iodata(t) :: iodata()

Loading…
Cancel
Save