Skip to content

Commit

Permalink
Make sure several pmap iterators can be chained and not affect each o…
Browse files Browse the repository at this point in the history
…ther
  • Loading branch information
seriyps committed Sep 16, 2024
1 parent 1f024b2 commit 3c878c0
Showing 1 changed file with 39 additions and 1 deletion.
40 changes: 39 additions & 1 deletion test/prop_pmap.erl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
-export([
prop_order_is_preserved/0,
prop_vs_lists/0,
prop_interrupted/0
prop_interrupted/0,
prop_chained/0
]).

-include_lib("proper/include/proper.hrl").
Expand Down Expand Up @@ -118,6 +119,43 @@ prop_interrupted() ->
end
).

%% @doc Make sure several pmap's can be chained.
prop_chained() ->
Gen = {
proper_types:list(proper_types:integer()),
proper_types:pos_integer(),
proper_types:pos_integer()
},
?FORALL(
{List, C1, C2},
Gen,
begin
F1 = fun(X) -> X + 1 end,
F2 = fun(X) -> X * 2 end,
ListIter = iterator:from_list(List),
Links0 = links(),
Pmap1Iter =
iterator_pmap:pmap(
F1,
ListIter,
#{concurrency => C1}
),
Pmap2Iter =
iterator_pmap:pmap(
F2,
Pmap1Iter,
#{concurrency => C2}
),
?assertEqual(
lists:map(F2, lists:map(F1, List)),
iterator:to_list(Pmap2Iter)
),
?assertEqual([], iterator_pmap:flush()),
assert_links(Links0),
true
end
).

links() ->
{links, L} = process_info(self(), links),
lists:sort(L).
Expand Down

0 comments on commit 3c878c0

Please sign in to comment.