Skip to content

Commit

Permalink
Fix more eqWAlizer errors.
Browse files Browse the repository at this point in the history
  • Loading branch information
potatosalad committed Nov 14, 2023
1 parent 2fcbcb5 commit 73f8fed
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 16 deletions.
51 changes: 38 additions & 13 deletions apps/argo_test/src/proper_argo.erl
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,10 @@

-spec complexity() -> pos_integer().
complexity() ->
max(parameter(?COMPLEXITY, 0), 1).
case parameter(?COMPLEXITY, 0) of
Complexity when is_integer(Complexity) andalso Complexity >= 0 ->
max(Complexity, 1)
end.

-spec mostly(U :: proper_types:type(), T :: proper_types:type()) -> proper_types:type().
mostly(U, T) ->
Expand All @@ -111,7 +114,11 @@ option(T) ->

-spec with_complexity(RawType :: proper_types:type()) -> proper_types:type().
with_complexity(RawType) ->
Complexity = parameter(?COMPLEXITY, 0) + 1,
Complexity =
case parameter(?COMPLEXITY, 0) of
C when is_integer(C) andalso C >= 0 ->
C + 1
end,
with_parameter(?COMPLEXITY, Complexity, RawType).

%%%=============================================================================
Expand Down Expand Up @@ -171,18 +178,36 @@ varint() ->
-spec header() -> proper_types:type().
header() ->
?LET(
Header,
#argo_header{
inline_everything = boolean(),
self_describing = boolean(),
out_of_band_field_errors = exactly(true),
self_describing_errors = boolean(),
null_terminated_strings = boolean(),
no_deduplication = boolean(),
has_user_flags = exactly(false),
user_flags = exactly(undefined)
{
InlineEverything,
SelfDescribing,
OutOfBandFieldErrors,
SelfDescribingErrors,
NullTerminatedStrings,
NoDeduplication,
HasUserFlags,
UserFlags
},
{
boolean(),
boolean(),
exactly(true),
boolean(),
boolean(),
boolean(),
exactly(false),
exactly(undefined)
},
Header
#argo_header{
inline_everything = InlineEverything,
self_describing = SelfDescribing,
out_of_band_field_errors = OutOfBandFieldErrors,
self_describing_errors = SelfDescribingErrors,
null_terminated_strings = NullTerminatedStrings,
no_deduplication = NoDeduplication,
has_user_flags = HasUserFlags,
user_flags = UserFlags
}
).

%%%=============================================================================
Expand Down
7 changes: 4 additions & 3 deletions apps/argo_test/src/property_test/argo_value_prop.erl
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@ prop_roundtrip_json_encoder_and_json_decoder(_Config) ->
{WireType, Value},
?LET(WireType, proper_argo:wire_type(), {WireType, proper_argo:value(WireType)}),
begin
JsonEncoded = jsone:encode(argo_value:to_json(Value)),
JsonDecoded = argo_value:from_json(WireType, jsone:decode(JsonEncoded)),
?EQUALS(JsonEncoded, jsone:encode(argo_value:to_json(JsonDecoded)))
JsonEncoded = jsone:encode(dynamic_cast(argo_value:to_json(Value))),
JsonDecoded = argo_value:from_json(WireType, dynamic_cast(jsone:decode(JsonEncoded))),
?EQUALS(JsonEncoded, jsone:encode(dynamic_cast(argo_value:to_json(JsonDecoded))))
end
).

Expand All @@ -93,5 +93,6 @@ prop_to_wire_type(_Config) ->
%%%-----------------------------------------------------------------------------

%% @private
-compile({inline, [dynamic_cast/1]}).
-spec dynamic_cast(term()) -> dynamic().
dynamic_cast(X) -> X.

0 comments on commit 73f8fed

Please sign in to comment.