Document static, make anyint standard
Gajumaru Serialization Tests / tests (push) Successful in 49m9s
Gajumaru Serialization Tests / tests (push) Successful in 49m9s
This commit is contained in:
+12
-8
@@ -86,7 +86,8 @@ decode_tag_and_vsn([TagBin, VsnBin, Fields]) ->
|
||||
dynamic_types() ->
|
||||
#{ vsn => ?VSN
|
||||
, codes =>
|
||||
#{ 247 => negint
|
||||
#{ 246 => anyint
|
||||
, 247 => negint
|
||||
, 248 => int
|
||||
, 249 => binary
|
||||
, 250 => bool
|
||||
@@ -96,7 +97,8 @@ dynamic_types() ->
|
||||
, 254 => id
|
||||
, 255 => label}
|
||||
, rev =>
|
||||
#{ negint => 247
|
||||
#{ anyint => 246
|
||||
, negint => 247
|
||||
, int => 248
|
||||
, binary => 249
|
||||
, bool => 250
|
||||
@@ -108,7 +110,8 @@ dynamic_types() ->
|
||||
, labels => #{}
|
||||
, rev_labels => #{}
|
||||
, templates =>
|
||||
#{ negint => negint
|
||||
#{ anyint => #{alt => [negint, int]}
|
||||
, negint => negint
|
||||
, int => int
|
||||
, binary => binary
|
||||
, bool => bool
|
||||
@@ -197,11 +200,6 @@ encode_typed_(Tag, Term, E, Vsn, #{templates := Ts, rev := Rev} = Types)
|
||||
encode_typed_(MaybeTemplate, Term, _, Vsn, Types) ->
|
||||
encode_maybe_template(MaybeTemplate, Term, Vsn, Types).
|
||||
|
||||
maybe_emit(E, Code, Enc) when E > 0 ->
|
||||
[encode_basic(int, Code), Enc];
|
||||
maybe_emit(0, _, Enc) ->
|
||||
Enc.
|
||||
|
||||
encode_maybe_template(#{items := _} = Type, Term, Vsn, Types) ->
|
||||
case is_map(Term) of
|
||||
true ->
|
||||
@@ -631,6 +629,7 @@ dynamic_types_test_() ->
|
||||
[ ?_test(revert_to_default_types())
|
||||
, ?_test(t_typed_map())
|
||||
, ?_test(t_alts())
|
||||
, ?_test(t_anyints())
|
||||
].
|
||||
|
||||
t_round_trip(T) ->
|
||||
@@ -734,4 +733,9 @@ t_alts() ->
|
||||
t_round_trip_typed(#{alt => [negint, int]}, 4),
|
||||
ok.
|
||||
|
||||
t_anyints() ->
|
||||
t_round_trip_typed(anyint, -5),
|
||||
t_round_trip_typed(anyint, 5),
|
||||
ok.
|
||||
|
||||
-endif.
|
||||
|
||||
Reference in New Issue
Block a user