A little minor formatting cleanup
This commit is contained in:
parent
07a54bb518
commit
8dda138814
4 changed files with 29 additions and 22 deletions
|
@ -243,7 +243,6 @@ remove_recursive(Path, Options) ->
|
||||||
tmp() ->
|
tmp() ->
|
||||||
case erlang:system_info(system_architecture) of
|
case erlang:system_info(system_architecture) of
|
||||||
"win32" ->
|
"win32" ->
|
||||||
% XXX TODO better tmp dir for windows perhaps :)
|
|
||||||
"./tmp";
|
"./tmp";
|
||||||
_SysArch ->
|
_SysArch ->
|
||||||
"/tmp"
|
"/tmp"
|
||||||
|
|
|
@ -38,7 +38,7 @@ map(Fun, List, Timeout) ->
|
||||||
%% All application level results are wrapped in a tuple with the tag
|
%% All application level results are wrapped in a tuple with the tag
|
||||||
%% 'value'. Exceptions will come through as they are and timeouts will
|
%% 'value'. Exceptions will come through as they are and timeouts will
|
||||||
%% return as the atom timeout.
|
%% 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>
|
%% <pre>
|
||||||
%% 2> ftmap(fun(N) -> factorial(N) end, [1, 2, 1000000, "not num"], 100)
|
%% 2> ftmap(fun(N) -> factorial(N) end, [1, 2, 1000000, "not num"], 100)
|
||||||
%% [{value, 1}, {value, 2}, timeout, {badmatch, ...}]
|
%% [{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()].
|
-spec run_list_fun_in_parallel(atom(), fun(), [any()], integer()) -> [any()].
|
||||||
run_list_fun_in_parallel(ListFun, Fun, List, Timeout) ->
|
run_list_fun_in_parallel(ListFun, Fun, List, Timeout) ->
|
||||||
LocalPid = self(),
|
LocalPid = self(),
|
||||||
Pids = lists:map(fun(E) ->
|
Pids =
|
||||||
Pid = proc_lib:spawn(fun() ->
|
lists:map(fun(E) ->
|
||||||
wait(LocalPid, Fun, E, Timeout)
|
Pid =
|
||||||
end),
|
proc_lib:spawn(fun() ->
|
||||||
{Pid, E}
|
wait(LocalPid, Fun,
|
||||||
end, List),
|
E, Timeout)
|
||||||
|
end),
|
||||||
|
{Pid, E}
|
||||||
|
end, List),
|
||||||
gather(ListFun, Pids).
|
gather(ListFun, Pids).
|
||||||
|
|
||||||
-spec wait(pid(), fun(), any(), integer()) -> any().
|
-spec wait(pid(), fun(), any(), integer()) -> any().
|
||||||
|
@ -113,7 +116,7 @@ map_gather([{Pid, _E} | Rest]) ->
|
||||||
% is easier with the exception. Thoughts?
|
% is easier with the exception. Thoughts?
|
||||||
{Pid, Exception} ->
|
{Pid, Exception} ->
|
||||||
killall(Rest),
|
killall(Rest),
|
||||||
throw(Exception)
|
throw(Exception)
|
||||||
end;
|
end;
|
||||||
map_gather([]) ->
|
map_gather([]) ->
|
||||||
[].
|
[].
|
||||||
|
@ -196,7 +199,7 @@ filter_good_test() ->
|
||||||
|
|
||||||
map_timeout_test() ->
|
map_timeout_test() ->
|
||||||
Results =
|
Results =
|
||||||
try
|
try
|
||||||
map(fun(T) ->
|
map(fun(T) ->
|
||||||
timer:sleep(T),
|
timer:sleep(T),
|
||||||
T
|
T
|
||||||
|
@ -217,7 +220,7 @@ ftmap_timeout_test() ->
|
||||||
|
|
||||||
filter_timeout_test() ->
|
filter_timeout_test() ->
|
||||||
Results =
|
Results =
|
||||||
try
|
try
|
||||||
filter(fun(T) ->
|
filter(fun(T) ->
|
||||||
timer:sleep(T),
|
timer:sleep(T),
|
||||||
T == 1
|
T == 1
|
||||||
|
@ -230,7 +233,7 @@ filter_timeout_test() ->
|
||||||
|
|
||||||
map_bad_test() ->
|
map_bad_test() ->
|
||||||
Results =
|
Results =
|
||||||
try
|
try
|
||||||
map(fun(_) ->
|
map(fun(_) ->
|
||||||
throw(test_exception)
|
throw(test_exception)
|
||||||
end,
|
end,
|
||||||
|
@ -244,10 +247,11 @@ ftmap_bad_test() ->
|
||||||
Results =
|
Results =
|
||||||
ftmap(fun(2) ->
|
ftmap(fun(2) ->
|
||||||
throw(test_exception);
|
throw(test_exception);
|
||||||
(N) ->
|
(N) ->
|
||||||
N
|
N
|
||||||
end,
|
end,
|
||||||
lists:seq(1, 5), infinity),
|
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.
|
-endif.
|
||||||
|
|
|
@ -40,6 +40,7 @@ compare(VsnA, VsnB) ->
|
||||||
%%%===================================================================
|
%%%===================================================================
|
||||||
%%% Internal Functions
|
%%% Internal Functions
|
||||||
%%%===================================================================
|
%%%===================================================================
|
||||||
|
|
||||||
-spec tokens(semvar()) -> parsed_semvar().
|
-spec tokens(semvar()) -> parsed_semvar().
|
||||||
tokens(Vsn) ->
|
tokens(Vsn) ->
|
||||||
[MajorVsn, MinorVsn, RawPatch] = string: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}).
|
{to_int(MajB), to_int(MinB), to_int(PVB), PSB}).
|
||||||
|
|
||||||
-spec compare_toks2(parsed_semvar(), parsed_semvar()) -> boolean().
|
-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;
|
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;
|
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;
|
true;
|
||||||
compare_toks2({_Maj, _Min, _PV, ""}, {_Maj, _Min, _PV, PSB}) when PSB /= ""->
|
compare_toks2({_Maj, _Min, _PV, ""}, {_Maj, _Min, _PV, PSB}) when PSB /= ""->
|
||||||
true;
|
true;
|
||||||
|
@ -91,7 +95,6 @@ to_int(String) ->
|
||||||
throw(invalid_semver_string)
|
throw(invalid_semver_string)
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
|
||||||
%%%===================================================================
|
%%%===================================================================
|
||||||
%%% Test Functions
|
%%% Test Functions
|
||||||
%%%===================================================================
|
%%%===================================================================
|
||||||
|
|
|
@ -62,9 +62,11 @@ compare_against_nothing(Str) ->
|
||||||
-spec fine_compare({string(), string()}, string(),
|
-spec fine_compare({string(), string()}, string(),
|
||||||
{string(), string()}, string()) ->
|
{string(), string()}, string()) ->
|
||||||
boolean().
|
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);
|
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);
|
throw(invalid_version_string);
|
||||||
fine_compare({"", _StrA}, _TA, {StrDigB, _StrB}, _TB) when StrDigB /= "" ->
|
fine_compare({"", _StrA}, _TA, {StrDigB, _StrB}, _TB) when StrDigB /= "" ->
|
||||||
false;
|
false;
|
||||||
|
@ -98,7 +100,6 @@ split_numeric_alpha([Dig|T], {PatchVsn, PatchStr})
|
||||||
split_numeric_alpha(PatchStr, {PatchVsn, ""}) ->
|
split_numeric_alpha(PatchStr, {PatchVsn, ""}) ->
|
||||||
{PatchVsn, PatchStr}.
|
{PatchVsn, PatchStr}.
|
||||||
|
|
||||||
|
|
||||||
%%%===================================================================
|
%%%===================================================================
|
||||||
%%% Test Functions
|
%%% Test Functions
|
||||||
%%%===================================================================
|
%%%===================================================================
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue