summaryrefslogtreecommitdiff
path: root/lib/stdlib/test/maps_SUITE.erl
diff options
context:
space:
mode:
Diffstat (limited to 'lib/stdlib/test/maps_SUITE.erl')
-rw-r--r--lib/stdlib/test/maps_SUITE.erl25
1 files changed, 22 insertions, 3 deletions
diff --git a/lib/stdlib/test/maps_SUITE.erl b/lib/stdlib/test/maps_SUITE.erl
index 28895c4efe..8d479f8211 100644
--- a/lib/stdlib/test/maps_SUITE.erl
+++ b/lib/stdlib/test/maps_SUITE.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 1997-2021. All Rights Reserved.
+%% Copyright Ericsson AB 1997-2022. All Rights Reserved.
%%
%% Licensed under the Apache License, Version 2.0 (the "License");
%% you may not use this file except in compliance with the License.
@@ -42,7 +42,8 @@
t_from_list_check_trapping/1,
t_from_keys_check_trapping/1,
t_keys_trapping/1,
- t_values_trapping/1]).
+ t_values_trapping/1,
+ t_groups_from_list/1]).
-define(badmap(V,F,Args), {'EXIT', {{badmap,V}, [{maps,F,Args,_}|_]}}).
-define(badkey(K,F,Args), {'EXIT', {{badkey,K}, [{maps,F,Args,_}|_]}}).
@@ -68,7 +69,8 @@ all() ->
t_from_list_check_trapping,
t_from_keys_check_trapping,
t_keys_trapping,
- t_values_trapping].
+ t_values_trapping,
+ t_groups_from_list].
t_from_list_kill_process(Config) when is_list(Config) ->
Killer = self(),
@@ -770,6 +772,16 @@ t_size_1(Config) when is_list(Config) ->
{'EXIT', {{badmap,<<>>}, _}} = (catch maps:size(id(<<>>))),
ok.
+t_groups_from_list(_Config) ->
+ #{} = maps:groups_from_list(fun erlang:length/1, []),
+ #{3 := ["tna","tac"], 5 := ["ognid"], 7 := ["olaffub"]} =
+ maps:groups_from_list(
+ fun erlang:length/1,
+ fun lists:reverse/1,
+ ["ant", "buffalo", "cat", "dingo"]
+ ),
+ #{0 := [2], 1 := [1, 3]} = maps:groups_from_list(fun(X) -> X rem 2 end, [1, 2, 3]).
+
error_info(_Config) ->
BadIterator = [-1|#{}],
GoodIterator = maps:iterator(#{}),
@@ -806,6 +818,13 @@ error_info(_Config) ->
{get, [key, {no,map}]},
{get, [key, {no,map}, default]},
+ {groups_from_list, [not_a_fun, []]},
+ {groups_from_list, [fun hd/1, not_a_list]},
+
+ {groups_from_list, [not_a_fun, fun(_) -> ok end, []]},
+ {groups_from_list, [fun(_) -> ok end, not_a_fun, []]},
+ {groups_from_list, [fun(_) -> ok end, fun(_) -> ok end, not_a_list]},
+
{intersect, [#{a => b}, y]},
{intersect, [x, #{a => b}]},
{intersect, [x, y],[{1,".*"},{2,".*"}]},