Clean up try_coerce slightly
This commit is contained in:
parent
4e71d3215b
commit
36a9b17b78
20
src/hz.erl
20
src/hz.erl
@ -2210,19 +2210,23 @@ eu(N, Size) ->
|
|||||||
|
|
||||||
%%% Simple coerce/3 tests
|
%%% Simple coerce/3 tests
|
||||||
|
|
||||||
|
% Round trip coerce run for the eunit tests below. If these results don't match
|
||||||
|
% then the test should fail.
|
||||||
try_coerce(Type, Sophia, Fate) ->
|
try_coerce(Type, Sophia, Fate) ->
|
||||||
FateActual = coerce(Type, Sophia, to_fate),
|
% Run both first, to see if they fail to produce any result.
|
||||||
SophiaActual = coerce(Type, Fate, from_fate),
|
{ok, FateActual} = coerce(Type, Sophia, to_fate),
|
||||||
case {ok, Fate} == FateActual of
|
{ok, SophiaActual} = coerce(Type, Fate, from_fate),
|
||||||
true ->
|
% Now check that the results were what we expected.
|
||||||
|
case FateActual of
|
||||||
|
Fate ->
|
||||||
ok;
|
ok;
|
||||||
false ->
|
_ ->
|
||||||
erlang:error({to_fate_failed, Fate, FateActual})
|
erlang:error({to_fate_failed, Fate, FateActual})
|
||||||
end,
|
end,
|
||||||
case {ok, Sophia} == SophiaActual of
|
case SophiaActual of
|
||||||
true ->
|
Sophia ->
|
||||||
ok;
|
ok;
|
||||||
false ->
|
_ ->
|
||||||
erlang:error({from_fate_failed, Sophia, SophiaActual})
|
erlang:error({from_fate_failed, Sophia, SophiaActual})
|
||||||
end,
|
end,
|
||||||
ok.
|
ok.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user