intermediate commit on way to eunit

This commit is contained in:
alisdair sullivan 2010-08-06 17:55:19 -07:00
parent 57c85a4185
commit ca1d605e95
2 changed files with 6 additions and 4 deletions

View file

@ -243,10 +243,10 @@ load_tests([Test|Rest], Dir, Acc) ->
end. end.
%% if the json, erlang or jsx values are lists, assume they're a path to a file that should %% if the json, eep0018 or jsx values are lists, assume they're a path to a file that should
%% be read with file:read_file/1 %% be read with file:read_file/1
parse_test([{Key, Path}|Rest], Test) when is_list(Path) -> parse_test([{Key, Path}|Rest], Test) when is_list(Path) ->
case lists:member(Key, [json, erlang, jsx]) of case lists:member(Key, [json, eep0018, jsx]) of
true -> true ->
case file:read_file(Path) of case file:read_file(Path) of
{ok, Bin} -> parse_test(Rest, [{Key, Bin}] ++ Test) {ok, Bin} -> parse_test(Rest, [{Key, Bin}] ++ Test)

View file

@ -65,6 +65,7 @@ term_to_events(Term) ->
proplist_to_events([{Key, Term}|Rest], Acc) -> proplist_to_events([{Key, Term}|Rest], Acc) ->
Event = term_to_event(Term), Event = term_to_event(Term),
EncodedKey = key_to_event(Key), EncodedKey = key_to_event(Key),
io:format("~p~n~p~n~n", [EncodedKey, Acc]),
case key_repeats(EncodedKey, Acc) of case key_repeats(EncodedKey, Acc) of
false -> proplist_to_events(Rest, Event ++ EncodedKey ++ Acc) false -> proplist_to_events(Rest, Event ++ EncodedKey ++ Acc)
; true -> erlang:error(badarg) ; true -> erlang:error(badarg)
@ -101,9 +102,10 @@ key_to_event(Key) when is_binary(Key) ->
[{key, json_escape(Key)}]. [{key, json_escape(Key)}].
key_repeats([Key], [Key|_]) -> true; key_repeats([{key, Key}], [{key, Key}|_Rest]) -> true;
key_repeats(Key, [{Key, _Value}|_Rest]) -> true;
key_repeats(Key, [_|Rest]) -> key_repeats(Key, Rest); key_repeats(Key, [_|Rest]) -> key_repeats(Key, Rest);
key_repeats(_, []) -> false. key_repeats(_Key, []) -> false.
%% conversion of floats to 'nice' decimal output. erlang's float implementation is almost %% conversion of floats to 'nice' decimal output. erlang's float implementation is almost