From 73f8fedcbeb53293ba0cca2153d5acac9484e2e5 Mon Sep 17 00:00:00 2001 From: Andrew Bennett Date: Tue, 14 Nov 2023 13:33:07 -0600 Subject: [PATCH] Fix more eqWAlizer errors. --- apps/argo_test/src/proper_argo.erl | 51 ++++++++++++++----- .../src/property_test/argo_value_prop.erl | 7 +-- 2 files changed, 42 insertions(+), 16 deletions(-) diff --git a/apps/argo_test/src/proper_argo.erl b/apps/argo_test/src/proper_argo.erl index bccce8e..acc9515 100644 --- a/apps/argo_test/src/proper_argo.erl +++ b/apps/argo_test/src/proper_argo.erl @@ -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) -> @@ -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). %%%============================================================================= @@ -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 + } ). %%%============================================================================= diff --git a/apps/argo_test/src/property_test/argo_value_prop.erl b/apps/argo_test/src/property_test/argo_value_prop.erl index 065213d..c6edc1f 100644 --- a/apps/argo_test/src/property_test/argo_value_prop.erl +++ b/apps/argo_test/src/property_test/argo_value_prop.erl @@ -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 ). @@ -93,5 +93,6 @@ prop_to_wire_type(_Config) -> %%%----------------------------------------------------------------------------- %% @private +-compile({inline, [dynamic_cast/1]}). -spec dynamic_cast(term()) -> dynamic(). dynamic_cast(X) -> X.