diff options
| author | Matthew Sackman <matthew@lshift.net> | 2009-08-19 12:13:02 +0100 |
|---|---|---|
| committer | Matthew Sackman <matthew@lshift.net> | 2009-08-19 12:13:02 +0100 |
| commit | 9966edcaf16691ebf7b22b0e39f11bfa186cd676 (patch) | |
| tree | b97b7849cf6ce93944885915573bfc4984f11701 | |
| parent | afe4be9eea994d2bb376af42f8b118d330854526 (diff) | |
| parent | c1c9fdde82ab9b07769e0fdb1e4a9f8abf2eaaf4 (diff) | |
| download | rabbitmq-server-git-9966edcaf16691ebf7b22b0e39f11bfa186cd676.tar.gz | |
merging in bug21428
| -rw-r--r-- | src/rabbit_misc.erl | 19 | ||||
| -rw-r--r-- | src/rabbit_tests.erl | 9 |
2 files changed, 10 insertions, 18 deletions
diff --git a/src/rabbit_misc.erl b/src/rabbit_misc.erl index c840434a9f..ed8b4165d2 100644 --- a/src/rabbit_misc.erl +++ b/src/rabbit_misc.erl @@ -53,7 +53,7 @@ -export([append_file/2, ensure_parent_dirs_exist/1]). -export([format_stderr/2]). -export([start_applications/1, stop_applications/1]). --export([unfold/2, ceil/1, keygets/2]). +-export([unfold/2, ceil/1]). -import(mnesia). -import(lists). @@ -119,8 +119,6 @@ -spec(stop_applications/1 :: ([atom()]) -> 'ok'). -spec(unfold/2 :: (fun ((A) -> ({'true', B, A} | 'false')), A) -> {[B], A}). -spec(ceil/1 :: (number()) -> number()). --spec(keygets/2 :: ([({K, V} | {K, non_neg_integer(), V})], [any()]) -> - [({K, V} | any())]). -endif. @@ -466,18 +464,3 @@ ceil(N) -> 0 -> N; _ -> 1 + T end. - -keygets(Keys, KeyList) -> - lists:reverse( - lists:foldl( - fun({Key, Pos, Default}, Acc) -> - case lists:keysearch(Key, Pos, KeyList) of - false -> [{Key, Default} | Acc]; - {value, T} -> [T | Acc] - end; - ({Key, Default}, Acc) -> - case lists:keysearch(Key, 1, KeyList) of - false -> [{Key, Default} | Acc]; - {value, T} -> [T | Acc] - end - end, [], Keys)). diff --git a/src/rabbit_tests.erl b/src/rabbit_tests.erl index f6d42e7c3f..ffd675a0b7 100644 --- a/src/rabbit_tests.erl +++ b/src/rabbit_tests.erl @@ -52,6 +52,7 @@ test_content_prop_roundtrip(Datum, Binary) -> all_tests() -> passed = test_disk_queue(), passed = test_priority_queue(), + passed = test_unfold(), passed = test_parsing(), passed = test_topic_matching(), passed = test_log_management(), @@ -155,6 +156,14 @@ test_simple_n_element_queue(N) -> {true, false, N, ToListRes, Items} = test_priority_queue(Q), passed. +test_unfold() -> + {[], test} = rabbit_misc:unfold(fun (V) -> false end, test), + List = lists:seq(2,20,2), + {List, 0} = rabbit_misc:unfold(fun (0) -> false; + (N) -> {true, N*2, N-1} + end, 10), + passed. + test_parsing() -> passed = test_content_properties(), passed. |
