properly export config type

This commit is contained in:
alisdair sullivan 2014-02-10 06:39:15 +00:00
parent 1049d69f3e
commit e1599574ff
3 changed files with 18 additions and 16 deletions

View file

@ -31,6 +31,7 @@
-export_type([json_term/0, json_text/0, token/0]).
-export_type([encoder/0, decoder/0, parser/0, internal_state/0]).
-export_type([config/0]).
-ifdef(TEST).
@ -53,6 +54,8 @@
-type json_text() :: binary().
-type config() :: jsx_config:config().
-spec encode(Source::json_term()) -> json_text() | {incomplete, encoder()}.
-spec encode(Source::json_term(), Config::jsx_to_json:config()) -> json_text() | {incomplete, encoder()}.

View file

@ -46,8 +46,11 @@
-type handler() :: handler_type(handler()).
-export_type([handler/0]).
-type config() :: #config{}.
-export_type([config/0]).
%% parsing of jsx config
-spec parse_config(Config::proplists:proplist()) -> jsx:config().
-spec parse_config(Config::proplists:proplist()) -> config().
parse_config(Config) -> parse_config(Config, #config{}).
@ -97,7 +100,7 @@ parse_strict(_Strict, _Rest, _Config) ->
-spec config_to_list(Config::jsx:config()) -> proplists:proplist().
-spec config_to_list(Config::config()) -> proplists:proplist().
config_to_list(Config) ->
reduce_config(lists:map(
@ -226,8 +229,8 @@ config_test_() ->
{"two error_handlers defined", ?_assertError(
badarg,
parse_config([
{error_handler, fun(_) -> true end},
{error_handler, fun(_) -> false end}
{error_handler, fun(_, _, _) -> true end},
{error_handler, fun(_, _, _) -> false end}
])
)},
{"incomplete_handler flag", ?_assertEqual(
@ -237,8 +240,8 @@ config_test_() ->
{"two incomplete_handlers defined", ?_assertError(
badarg,
parse_config([
{incomplete_handler, fun(_) -> true end},
{incomplete_handler, fun(_) -> false end}
{incomplete_handler, fun(_, _, _) -> true end},
{incomplete_handler, fun(_, _, _) -> false end}
])
)},
{"bad option flag", ?_assertError(badarg, parse_config([this_flag_does_not_exist]))}

View file

@ -1633,17 +1633,13 @@ incomplete_test_() ->
badarg,
decode(<<"{">>)
)},
{"stream true", ?_assert(
case decode(<<"{">>, [stream]) of
{incomplete, _} -> true;
_ -> false
end
{"stream true", ?_assertMatch(
{incomplete, _},
decode(<<"{">>, [stream])
)},
{"complete input", ?_assert(
case decode(<<"{}">>, [stream]) of
{incomplete, _} -> true;
_ -> false
end
{"complete input", ?_assertMatch(
{incomplete, _},
decode(<<"{}">>, [stream])
)}
].