A little minor formatting cleanup

This commit is contained in:
Eric Merritt 2011-04-22 09:36:29 -05:00 committed by Jordan Wilberding
parent 07a54bb518
commit 8dda138814
4 changed files with 29 additions and 22 deletions

View file

@ -243,7 +243,6 @@ remove_recursive(Path, Options) ->
tmp() ->
case erlang:system_info(system_architecture) of
"win32" ->
% XXX TODO better tmp dir for windows perhaps :)
"./tmp";
_SysArch ->
"/tmp"

View file

@ -38,7 +38,7 @@ map(Fun, List, Timeout) ->
%% All application level results are wrapped in a tuple with the tag
%% 'value'. Exceptions will come through as they are and timeouts will
%% return as the atom timeout.
%% This is useful when the ftmap is being used for side effects.
%% This is useful when the ftmap is being used for side effects.
%% <pre>
%% 2> ftmap(fun(N) -> factorial(N) end, [1, 2, 1000000, "not num"], 100)
%% [{value, 1}, {value, 2}, timeout, {badmatch, ...}]
@ -68,12 +68,15 @@ filter(Fun, List, Timeout) ->
-spec run_list_fun_in_parallel(atom(), fun(), [any()], integer()) -> [any()].
run_list_fun_in_parallel(ListFun, Fun, List, Timeout) ->
LocalPid = self(),
Pids = lists:map(fun(E) ->
Pid = proc_lib:spawn(fun() ->
wait(LocalPid, Fun, E, Timeout)
end),
{Pid, E}
end, List),
Pids =
lists:map(fun(E) ->
Pid =
proc_lib:spawn(fun() ->
wait(LocalPid, Fun,
E, Timeout)
end),
{Pid, E}
end, List),
gather(ListFun, Pids).
-spec wait(pid(), fun(), any(), integer()) -> any().
@ -113,7 +116,7 @@ map_gather([{Pid, _E} | Rest]) ->
% is easier with the exception. Thoughts?
{Pid, Exception} ->
killall(Rest),
throw(Exception)
throw(Exception)
end;
map_gather([]) ->
[].
@ -196,7 +199,7 @@ filter_good_test() ->
map_timeout_test() ->
Results =
try
try
map(fun(T) ->
timer:sleep(T),
T
@ -217,7 +220,7 @@ ftmap_timeout_test() ->
filter_timeout_test() ->
Results =
try
try
filter(fun(T) ->
timer:sleep(T),
T == 1
@ -230,7 +233,7 @@ filter_timeout_test() ->
map_bad_test() ->
Results =
try
try
map(fun(_) ->
throw(test_exception)
end,
@ -244,10 +247,11 @@ ftmap_bad_test() ->
Results =
ftmap(fun(2) ->
throw(test_exception);
(N) ->
N
(N) ->
N
end,
lists:seq(1, 5), infinity),
?assertMatch([{value, 1}, test_exception, {value, 3}, {value, 4}, {value, 5}] , Results).
?assertMatch([{value, 1}, test_exception, {value, 3},
{value, 4}, {value, 5}] , Results).
-endif.

View file

@ -40,6 +40,7 @@ compare(VsnA, VsnB) ->
%%%===================================================================
%%% Internal Functions
%%%===================================================================
-spec tokens(semvar()) -> parsed_semvar().
tokens(Vsn) ->
[MajorVsn, MinorVsn, RawPatch] = string:tokens(Vsn, "."),
@ -67,11 +68,14 @@ compare_toks({MajA, MinA, PVA, PSA}, {MajB, MinB, PVB, PSB}) ->
{to_int(MajB), to_int(MinB), to_int(PVB), PSB}).
-spec compare_toks2(parsed_semvar(), parsed_semvar()) -> boolean().
compare_toks2({MajA, _MinA, _PVA, _PSA}, {MajB, _MinB, _PVB, _PSB}) when MajA > MajB ->
compare_toks2({MajA, _MinA, _PVA, _PSA}, {MajB, _MinB, _PVB, _PSB})
when MajA > MajB ->
true;
compare_toks2({_Maj, MinA, _PVA, _PSA}, {_Maj, MinB, _PVB, _PSB}) when MinA > MinB ->
compare_toks2({_Maj, MinA, _PVA, _PSA}, {_Maj, MinB, _PVB, _PSB})
when MinA > MinB ->
true;
compare_toks2({_Maj, _Min, PVA, _PSA}, {_Maj, _Min, PVB, _PSB}) when PVA > PVB ->
compare_toks2({_Maj, _Min, PVA, _PSA}, {_Maj, _Min, PVB, _PSB})
when PVA > PVB ->
true;
compare_toks2({_Maj, _Min, _PV, ""}, {_Maj, _Min, _PV, PSB}) when PSB /= ""->
true;
@ -91,7 +95,6 @@ to_int(String) ->
throw(invalid_semver_string)
end.
%%%===================================================================
%%% Test Functions
%%%===================================================================

View file

@ -62,9 +62,11 @@ compare_against_nothing(Str) ->
-spec fine_compare({string(), string()}, string(),
{string(), string()}, string()) ->
boolean().
fine_compare({_StrDigA, StrA}, TA, {_StrDigB, _StrB}, _TB) when StrA /= "", TA /= [] ->
fine_compare({_StrDigA, StrA}, TA, {_StrDigB, _StrB}, _TB)
when StrA /= "", TA /= [] ->
throw(invalid_version_string);
fine_compare({_StrDigA, _StrA}, _TA, {_StrDigB, StrB}, TB) when StrB /= "", TB /= [] ->
fine_compare({_StrDigA, _StrA}, _TA, {_StrDigB, StrB}, TB)
when StrB /= "", TB /= [] ->
throw(invalid_version_string);
fine_compare({"", _StrA}, _TA, {StrDigB, _StrB}, _TB) when StrDigB /= "" ->
false;
@ -98,7 +100,6 @@ split_numeric_alpha([Dig|T], {PatchVsn, PatchStr})
split_numeric_alpha(PatchStr, {PatchVsn, ""}) ->
{PatchVsn, PatchStr}.
%%%===================================================================
%%% Test Functions
%%%===================================================================