aboutsummaryrefslogtreecommitdiffstats
path: root/erts
diff options
context:
space:
mode:
Diffstat (limited to 'erts')
-rw-r--r--erts/emulator/beam/bif.tab24
-rw-r--r--erts/emulator/beam/erl_map.c82
-rw-r--r--erts/emulator/test/map_SUITE.erl248
3 files changed, 177 insertions, 177 deletions
diff --git a/erts/emulator/beam/bif.tab b/erts/emulator/beam/bif.tab
index 306861a4c5..b623e47b9a 100644
--- a/erts/emulator/beam/bif.tab
+++ b/erts/emulator/beam/bif.tab
@@ -580,18 +580,18 @@ bif re:inspect/2
ubif erlang:is_map/1
ubif erlang:map_size/1
-bif map:to_list/1
-bif map:find/2
-bif map:get/2
-bif map:from_list/1
-bif map:is_key/2
-bif map:keys/1
-bif map:merge/2
-bif map:new/0
-bif map:put/3
-bif map:remove/2
-bif map:update/3
-bif map:values/1
+bif maps:to_list/1
+bif maps:find/2
+bif maps:get/2
+bif maps:from_list/1
+bif maps:is_key/2
+bif maps:keys/1
+bif maps:merge/2
+bif maps:new/0
+bif maps:put/3
+bif maps:remove/2
+bif maps:update/3
+bif maps:values/1
#
# Obsolete
diff --git a/erts/emulator/beam/erl_map.c b/erts/emulator/beam/erl_map.c
index 6fd60f0689..27734276f9 100644
--- a/erts/emulator/beam/erl_map.c
+++ b/erts/emulator/beam/erl_map.c
@@ -38,25 +38,25 @@
* - erlang:is_map/1
* - erlang:map_size/1
*
- * - map:find/2
- * - map:from_list/1
- * - map:get/2
- * - map:is_key/2
- * - map:keys/1
- * - map:merge/2
- * - map:new/0
- * - map:put/3
- * - map:remove/2
- * - map:to_list/1
- * - map:update/3
- * - map:values/1
+ * - maps:find/2
+ * - maps:from_list/1
+ * - maps:get/2
+ * - maps:is_key/2
+ * - maps:keys/1
+ * - maps:merge/2
+ * - maps:new/0
+ * - maps:put/3
+ * - maps:remove/2
+ * - maps:to_list/1
+ * - maps:update/3
+ * - maps:values/1
*
* TODO:
- * - map:foldl/3
- * - map:foldr/3
- * - map:map/3
- * - map:size/1
- * - map:without/2
+ * - maps:foldl/3
+ * - maps:foldr/3
+ * - maps:map/3
+ * - maps:size/1
+ * - maps:without/2
*
*/
@@ -80,10 +80,10 @@ BIF_RETTYPE map_size_1(BIF_ALIST_1) {
BIF_ERROR(BIF_P, BADARG);
}
-/* map:to_list/1
+/* maps:to_list/1
*/
-BIF_RETTYPE map_to_list_1(BIF_ALIST_1) {
+BIF_RETTYPE maps_to_list_1(BIF_ALIST_1) {
if (is_map(BIF_ARG_1)) {
Uint n;
Eterm* hp;
@@ -107,11 +107,11 @@ BIF_RETTYPE map_to_list_1(BIF_ALIST_1) {
BIF_ERROR(BIF_P, BADARG);
}
-/* map:find/2
+/* maps:find/2
* return value if key *equals* a key in the map
*/
-BIF_RETTYPE map_find_2(BIF_ALIST_2) {
+BIF_RETTYPE maps_find_2(BIF_ALIST_2) {
if (is_map(BIF_ARG_2)) {
Eterm *hp, *ks,*vs, key, res;
map_t *mp;
@@ -137,12 +137,12 @@ BIF_RETTYPE map_find_2(BIF_ALIST_2) {
}
BIF_ERROR(BIF_P, BADARG);
}
-/* map:get/2
+/* maps:get/2
* return value if key *matches* a key in the map
* exception bad_key if none matches
*/
-BIF_RETTYPE map_get_2(BIF_ALIST_2) {
+BIF_RETTYPE maps_get_2(BIF_ALIST_2) {
if (is_map(BIF_ARG_2)) {
Eterm *hp, *ks,*vs, key, error;
map_t *mp;
@@ -184,11 +184,11 @@ error:
BIF_ERROR(BIF_P, BADARG);
}
-/* map:from_list/1
+/* maps:from_list/1
* List may be unsorted [{K,V}]
*/
-BIF_RETTYPE map_from_list_1(BIF_ALIST_1) {
+BIF_RETTYPE maps_from_list_1(BIF_ALIST_1) {
Eterm *kv, item = BIF_ARG_1;
Eterm *hp, *thp,*vs, *ks, keys, res;
map_t *mp;
@@ -305,10 +305,10 @@ error:
BIF_ERROR(BIF_P, BADARG);
}
-/* map:is_key/2
+/* maps:is_key/2
*/
-BIF_RETTYPE map_is_key_2(BIF_ALIST_2) {
+BIF_RETTYPE maps_is_key_2(BIF_ALIST_2) {
if (is_map(BIF_ARG_2)) {
Eterm *ks, key;
map_t *mp;
@@ -340,10 +340,10 @@ BIF_RETTYPE map_is_key_2(BIF_ALIST_2) {
BIF_ERROR(BIF_P, BADARG);
}
-/* map:keys/1
+/* maps:keys/1
*/
-BIF_RETTYPE map_keys_1(BIF_ALIST_1) {
+BIF_RETTYPE maps_keys_1(BIF_ALIST_1) {
if (is_map(BIF_ARG_1)) {
Eterm *hp, *ks, res = NIL;
map_t *mp;
@@ -366,10 +366,10 @@ BIF_RETTYPE map_keys_1(BIF_ALIST_1) {
}
BIF_ERROR(BIF_P, BADARG);
}
-/* map:merge/2
+/* maps:merge/2
*/
-BIF_RETTYPE map_merge_2(BIF_ALIST_2) {
+BIF_RETTYPE maps_merge_2(BIF_ALIST_2) {
if (is_map(BIF_ARG_1) && is_map(BIF_ARG_2)) {
Eterm *hp,*thp;
Eterm tup;
@@ -452,10 +452,10 @@ BIF_RETTYPE map_merge_2(BIF_ALIST_2) {
}
BIF_ERROR(BIF_P, BADARG);
}
-/* map:new/2
+/* maps:new/2
*/
-BIF_RETTYPE map_new_0(BIF_ALIST_0) {
+BIF_RETTYPE maps_new_0(BIF_ALIST_0) {
Eterm* hp;
Eterm tup;
map_t *mp;
@@ -472,10 +472,10 @@ BIF_RETTYPE map_new_0(BIF_ALIST_0) {
BIF_RET(make_map(mp));
}
-/* map:put/3
+/* maps:put/3
*/
-BIF_RETTYPE map_put_3(BIF_ALIST_3) {
+BIF_RETTYPE maps_put_3(BIF_ALIST_3) {
if (is_map(BIF_ARG_3)) {
Sint n,i;
Sint c = 0;
@@ -582,10 +582,10 @@ BIF_RETTYPE map_put_3(BIF_ALIST_3) {
BIF_ERROR(BIF_P, BADARG);
}
-/* map:remove/3
+/* maps:remove/3
*/
-BIF_RETTYPE map_remove_2(BIF_ALIST_2) {
+BIF_RETTYPE maps_remove_2(BIF_ALIST_2) {
if (is_map(BIF_ARG_2)) {
Sint n;
Sint found = 0;
@@ -656,10 +656,10 @@ BIF_RETTYPE map_remove_2(BIF_ALIST_2) {
BIF_ERROR(BIF_P, BADARG);
}
-/* map:update/3
+/* maps:update/3
*/
-BIF_RETTYPE map_update_3(BIF_ALIST_3) {
+BIF_RETTYPE maps_update_3(BIF_ALIST_3) {
if (is_map(BIF_ARG_3)) {
Sint n,i;
Sint found = 0;
@@ -719,10 +719,10 @@ BIF_RETTYPE map_update_3(BIF_ALIST_3) {
}
-/* map:values/1
+/* maps:values/1
*/
-BIF_RETTYPE map_values_1(BIF_ALIST_1) {
+BIF_RETTYPE maps_values_1(BIF_ALIST_1) {
if (is_map(BIF_ARG_1)) {
Eterm *hp, *vs, res = NIL;
map_t *mp;
diff --git a/erts/emulator/test/map_SUITE.erl b/erts/emulator/test/map_SUITE.erl
index 69b68c4b67..59fdb82f50 100644
--- a/erts/emulator/test/map_SUITE.erl
+++ b/erts/emulator/test/map_SUITE.erl
@@ -412,182 +412,182 @@ t_map_sort_literals(Config) when is_list(Config) ->
%% BIFs
t_bif_map_get(Config) when is_list(Config) ->
- 1 = map:get(a, #{ a=> 1}),
- 2 = map:get(b, #{ a=> 1, b => 2}),
- "hi" = map:get("hello", #{ a=>1, "hello" => "hi"}),
- "tuple hi" = map:get({1,1.0}, #{ a=>a, {1,1.0} => "tuple hi"}),
+ 1 = maps:get(a, #{ a=> 1}),
+ 2 = maps:get(b, #{ a=> 1, b => 2}),
+ "hi" = maps:get("hello", #{ a=>1, "hello" => "hi"}),
+ "tuple hi" = maps:get({1,1.0}, #{ a=>a, {1,1.0} => "tuple hi"}),
M = id(#{ k1=>"v1", <<"k2">> => <<"v3">> }),
- "v4" = map:get(<<"k2">>, M#{ <<"k2">> => "v4" }),
+ "v4" = maps:get(<<"k2">>, M#{ <<"k2">> => "v4" }),
%% error case
- {'EXIT',{badarg,[{map,get,_,_}|_]}} = (catch map:get(a,[])),
- {'EXIT',{badarg,[{map,get,_,_}|_]}} = (catch map:get(a,<<>>)),
- {'EXIT',{bad_key,[{map,get,_,_}|_]}} = (catch map:get({1,1}, #{{1,1.0} => "tuple"})),
- {'EXIT',{bad_key,[{map,get,_,_}|_]}} = (catch map:get(a,#{})),
- {'EXIT',{bad_key,[{map,get,_,_}|_]}} = (catch map:get(a,#{ b=>1, c=>2})),
+ {'EXIT',{badarg, [{maps,get,_,_}|_]}} = (catch maps:get(a,[])),
+ {'EXIT',{badarg, [{maps,get,_,_}|_]}} = (catch maps:get(a,<<>>)),
+ {'EXIT',{bad_key,[{maps,get,_,_}|_]}} = (catch maps:get({1,1}, #{{1,1.0} => "tuple"})),
+ {'EXIT',{bad_key,[{maps,get,_,_}|_]}} = (catch maps:get(a,#{})),
+ {'EXIT',{bad_key,[{maps,get,_,_}|_]}} = (catch maps:get(a,#{ b=>1, c=>2})),
ok.
t_bif_map_find(Config) when is_list(Config) ->
- {ok, 1} = map:find(a, #{ a=> 1}),
- {ok, 2} = map:find(b, #{ a=> 1, b => 2}),
- {ok, "int"} = map:find(1, #{ 1 => "int"}),
- {ok, "int"} = map:find(1.0, #{ 1 => "int"}),
- {ok, "float"} = map:find(1, #{ 1.0 => "float"}),
- {ok, "float"} = map:find(1.0, #{ 1.0=> "float"}),
+ {ok, 1} = maps:find(a, #{ a=> 1}),
+ {ok, 2} = maps:find(b, #{ a=> 1, b => 2}),
+ {ok, "int"} = maps:find(1, #{ 1 => "int"}),
+ {ok, "int"} = maps:find(1.0, #{ 1 => "int"}),
+ {ok, "float"} = maps:find(1, #{ 1.0 => "float"}),
+ {ok, "float"} = maps:find(1.0, #{ 1.0=> "float"}),
- {ok, "hi"} = map:find("hello", #{ a=>1, "hello" => "hi"}),
- {ok, "tuple hi"} = map:find({1.0,1}, #{ a=>a, {1,1.0} => "tuple hi"}), % reverse types in tuple key
+ {ok, "hi"} = maps:find("hello", #{ a=>1, "hello" => "hi"}),
+ {ok, "tuple hi"} = maps:find({1.0,1}, #{ a=>a, {1,1.0} => "tuple hi"}), % reverse types in tuple key
M = id(#{ k1=>"v1", <<"k2">> => <<"v3">> }),
- {ok, "v4"} = map:find(<<"k2">>, M#{ <<"k2">> => "v4" }),
+ {ok, "v4"} = maps:find(<<"k2">>, M#{ <<"k2">> => "v4" }),
%% error case
- error = map:find(a,#{}),
- error = map:find(a,#{b=>1, c=>2}),
+ error = maps:find(a,#{}),
+ error = maps:find(a,#{b=>1, c=>2}),
- {'EXIT',{badarg,[{map,find,_,_}|_]}} = (catch map:find(a,[])),
- {'EXIT',{badarg,[{map,find,_,_}|_]}} = (catch map:find(a,<<>>)),
+ {'EXIT',{badarg,[{maps,find,_,_}|_]}} = (catch maps:find(a,[])),
+ {'EXIT',{badarg,[{maps,find,_,_}|_]}} = (catch maps:find(a,<<>>)),
ok.
t_bif_map_is_key(Config) when is_list(Config) ->
M1 = #{ "hi" => "hello", int => 3, <<"key">> => <<"value">>, 4 => number},
- true = map:is_key("hi", M1),
- true = map:is_key(int, M1),
- true = map:is_key(<<"key">>, M1),
- true = map:is_key(4, M1),
-
- false = map:is_key(5, M1),
- false = map:is_key(<<"key2">>, M1),
- false = map:is_key("h", M1),
- false = map:is_key("hello", M1),
- false = map:is_key(atom, M1),
-
- false = map:is_key("hi", map:remove("hi", M1)),
- true = map:is_key("hi", M1),
- true = map:is_key(1, map:put(1, "number", M1)),
- false = map:is_key(1.0, map:put(1, "number", M1)),
+ true = maps:is_key("hi", M1),
+ true = maps:is_key(int, M1),
+ true = maps:is_key(<<"key">>, M1),
+ true = maps:is_key(4, M1),
+
+ false = maps:is_key(5, M1),
+ false = maps:is_key(<<"key2">>, M1),
+ false = maps:is_key("h", M1),
+ false = maps:is_key("hello", M1),
+ false = maps:is_key(atom, M1),
+
+ false = maps:is_key("hi", maps:remove("hi", M1)),
+ true = maps:is_key("hi", M1),
+ true = maps:is_key(1, maps:put(1, "number", M1)),
+ false = maps:is_key(1.0, maps:put(1, "number", M1)),
ok.
t_bif_map_keys(Config) when is_list(Config) ->
- [] = map:keys(#{}),
+ [] = maps:keys(#{}),
- [1,2,3,4,5] = map:keys(#{ 1 => a, 2 => b, 3 => c, 4 => d, 5 => e}),
- [1,2,3,4,5] = map:keys(#{ 4 => d, 5 => e, 1 => a, 2 => b, 3 => c}),
+ [1,2,3,4,5] = maps:keys(#{ 1 => a, 2 => b, 3 => c, 4 => d, 5 => e}),
+ [1,2,3,4,5] = maps:keys(#{ 4 => d, 5 => e, 1 => a, 2 => b, 3 => c}),
% values in key order: [4,int,"hi",<<"key">>]
M1 = #{ "hi" => "hello", int => 3, <<"key">> => <<"value">>, 4 => number},
- [4,int,"hi",<<"key">>] = map:keys(M1),
+ [4,int,"hi",<<"key">>] = maps:keys(M1),
%% error case
- {'EXIT',{badarg,[{map,keys,_,_}|_]}} = (catch map:keys(1 bsl 65 + 3)),
- {'EXIT',{badarg,[{map,keys,_,_}|_]}} = (catch map:keys(154)),
- {'EXIT',{badarg,[{map,keys,_,_}|_]}} = (catch map:keys(atom)),
- {'EXIT',{badarg,[{map,keys,_,_}|_]}} = (catch map:keys([])),
- {'EXIT',{badarg,[{map,keys,_,_}|_]}} = (catch map:keys(<<>>)),
+ {'EXIT',{badarg,[{maps,keys,_,_}|_]}} = (catch maps:keys(1 bsl 65 + 3)),
+ {'EXIT',{badarg,[{maps,keys,_,_}|_]}} = (catch maps:keys(154)),
+ {'EXIT',{badarg,[{maps,keys,_,_}|_]}} = (catch maps:keys(atom)),
+ {'EXIT',{badarg,[{maps,keys,_,_}|_]}} = (catch maps:keys([])),
+ {'EXIT',{badarg,[{maps,keys,_,_}|_]}} = (catch maps:keys(<<>>)),
ok.
t_bif_map_new(Config) when is_list(Config) ->
- #{} = map:new(),
- 0 = erlang:map_size(map:new()),
+ #{} = maps:new(),
+ 0 = erlang:map_size(maps:new()),
ok.
t_bif_map_put(Config) when is_list(Config) ->
M0 = #{ "hi" => "hello", int => 3, <<"key">> => <<"value">>,
4 => number, 18446744073709551629 => wat},
- M1 = #{ "hi" := "hello"} = map:put("hi", "hello", #{}),
+ M1 = #{ "hi" := "hello"} = maps:put("hi", "hello", #{}),
- ["hi"] = map:keys(M1),
- ["hello"] = map:values(M1),
+ ["hi"] = maps:keys(M1),
+ ["hello"] = maps:values(M1),
- M2 = #{ int := 3 } = map:put(int, 3, M1),
+ M2 = #{ int := 3 } = maps:put(int, 3, M1),
- [int,"hi"] = map:keys(M2),
- [3,"hello"] = map:values(M2),
+ [int,"hi"] = maps:keys(M2),
+ [3,"hello"] = maps:values(M2),
- M3 = #{ <<"key">> := <<"value">> } = map:put(<<"key">>, <<"value">>, M2),
+ M3 = #{ <<"key">> := <<"value">> } = maps:put(<<"key">>, <<"value">>, M2),
- [int,"hi",<<"key">>] = map:keys(M3),
- [3,"hello",<<"value">>] = map:values(M3),
+ [int,"hi",<<"key">>] = maps:keys(M3),
+ [3,"hello",<<"value">>] = maps:values(M3),
- M4 = #{ 18446744073709551629 := wat } = map:put(18446744073709551629, wat, M3),
+ M4 = #{ 18446744073709551629 := wat } = maps:put(18446744073709551629, wat, M3),
- [18446744073709551629,int,"hi",<<"key">>] = map:keys(M4),
- [wat,3,"hello",<<"value">>] = map:values(M4),
+ [18446744073709551629,int,"hi",<<"key">>] = maps:keys(M4),
+ [wat,3,"hello",<<"value">>] = maps:values(M4),
- M0 = #{ 4 := number } = M5 = map:put(4, number, M4),
+ M0 = #{ 4 := number } = M5 = maps:put(4, number, M4),
- [4,18446744073709551629,int,"hi",<<"key">>] = map:keys(M5),
- [number,wat,3,"hello",<<"value">>] = map:values(M5),
+ [4,18446744073709551629,int,"hi",<<"key">>] = maps:keys(M5),
+ [number,wat,3,"hello",<<"value">>] = maps:values(M5),
%% error case
- {'EXIT',{badarg,[{map,put,_,_}|_]}} = (catch map:put(1,a,1 bsl 65 + 3)),
- {'EXIT',{badarg,[{map,put,_,_}|_]}} = (catch map:put(1,a,154)),
- {'EXIT',{badarg,[{map,put,_,_}|_]}} = (catch map:put(1,a,atom)),
- {'EXIT',{badarg,[{map,put,_,_}|_]}} = (catch map:put(1,a,[])),
- {'EXIT',{badarg,[{map,put,_,_}|_]}} = (catch map:put(1,a,<<>>)),
+ {'EXIT',{badarg,[{maps,put,_,_}|_]}} = (catch maps:put(1,a,1 bsl 65 + 3)),
+ {'EXIT',{badarg,[{maps,put,_,_}|_]}} = (catch maps:put(1,a,154)),
+ {'EXIT',{badarg,[{maps,put,_,_}|_]}} = (catch maps:put(1,a,atom)),
+ {'EXIT',{badarg,[{maps,put,_,_}|_]}} = (catch maps:put(1,a,[])),
+ {'EXIT',{badarg,[{maps,put,_,_}|_]}} = (catch maps:put(1,a,<<>>)),
ok.
t_bif_map_remove(Config) when is_list(Config) ->
M0 = #{ "hi" => "hello", int => 3, <<"key">> => <<"value">>,
4 => number, 18446744073709551629 => wat},
- M1 = map:remove("hi", M0),
- [4,18446744073709551629,int,<<"key">>] = map:keys(M1),
- [number,wat,3,<<"value">>] = map:values(M1),
+ M1 = maps:remove("hi", M0),
+ [4,18446744073709551629,int,<<"key">>] = maps:keys(M1),
+ [number,wat,3,<<"value">>] = maps:values(M1),
- M2 = map:remove(int, M1),
- [4,18446744073709551629,<<"key">>] = map:keys(M2),
- [number,wat,<<"value">>] = map:values(M2),
+ M2 = maps:remove(int, M1),
+ [4,18446744073709551629,<<"key">>] = maps:keys(M2),
+ [number,wat,<<"value">>] = maps:values(M2),
- M3 = map:remove(<<"key">>, M2),
- [4,18446744073709551629] = map:keys(M3),
- [number,wat] = map:values(M3),
+ M3 = maps:remove(<<"key">>, M2),
+ [4,18446744073709551629] = maps:keys(M3),
+ [number,wat] = maps:values(M3),
- M4 = map:remove(18446744073709551629, M3),
- [4] = map:keys(M4),
- [number] = map:values(M4),
+ M4 = maps:remove(18446744073709551629, M3),
+ [4] = maps:keys(M4),
+ [number] = maps:values(M4),
- M5 = map:remove(4, M4),
- [] = map:keys(M5),
- [] = map:values(M5),
+ M5 = maps:remove(4, M4),
+ [] = maps:keys(M5),
+ [] = maps:values(M5),
- M0 = map:remove(5,M0),
- M0 = map:remove("hi there",M0),
+ M0 = maps:remove(5,M0),
+ M0 = maps:remove("hi there",M0),
- #{ "hi" := "hello", int := 3, 4 := number} = map:remove(18446744073709551629,map:remove(<<"key">>,M0)),
+ #{ "hi" := "hello", int := 3, 4 := number} = maps:remove(18446744073709551629,maps:remove(<<"key">>,M0)),
%% error case
- {'EXIT',{badarg,[{map,remove,_,_}|_]}} = (catch map:remove(a,1 bsl 65 + 3)),
- {'EXIT',{badarg,[{map,remove,_,_}|_]}} = (catch map:remove(1,154)),
- {'EXIT',{badarg,[{map,remove,_,_}|_]}} = (catch map:remove(a,atom)),
- {'EXIT',{badarg,[{map,remove,_,_}|_]}} = (catch map:remove(1,[])),
- {'EXIT',{badarg,[{map,remove,_,_}|_]}} = (catch map:remove(a,<<>>)),
+ {'EXIT',{badarg,[{maps,remove,_,_}|_]}} = (catch maps:remove(a,1 bsl 65 + 3)),
+ {'EXIT',{badarg,[{maps,remove,_,_}|_]}} = (catch maps:remove(1,154)),
+ {'EXIT',{badarg,[{maps,remove,_,_}|_]}} = (catch maps:remove(a,atom)),
+ {'EXIT',{badarg,[{maps,remove,_,_}|_]}} = (catch maps:remove(1,[])),
+ {'EXIT',{badarg,[{maps,remove,_,_}|_]}} = (catch maps:remove(a,<<>>)),
ok.
t_bif_map_values(Config) when is_list(Config) ->
- [] = map:values(#{}),
+ [] = maps:values(#{}),
- [a,b,c,d,e] = map:values(#{ 1 => a, 2 => b, 3 => c, 4 => d, 5 => e}),
- [a,b,c,d,e] = map:values(#{ 4 => d, 5 => e, 1 => a, 2 => b, 3 => c}),
+ [a,b,c,d,e] = maps:values(#{ 1 => a, 2 => b, 3 => c, 4 => d, 5 => e}),
+ [a,b,c,d,e] = maps:values(#{ 4 => d, 5 => e, 1 => a, 2 => b, 3 => c}),
% values in key order: [4,int,"hi",<<"key">>]
M1 = #{ "hi" => "hello", int => 3, <<"key">> => <<"value">>, 4 => number},
M2 = M1#{ "hi" => "hello2", <<"key">> => <<"value2">> },
- [number,3,"hello2",<<"value2">>] = map:values(M2),
- [number,3,"hello",<<"value">>] = map:values(M1),
+ [number,3,"hello2",<<"value2">>] = maps:values(M2),
+ [number,3,"hello",<<"value">>] = maps:values(M1),
%% error case
- {'EXIT',{badarg,[{map,values,_,_}|_]}} = (catch map:values(1 bsl 65 + 3)),
- {'EXIT',{badarg,[{map,values,_,_}|_]}} = (catch map:values(atom)),
- {'EXIT',{badarg,[{map,values,_,_}|_]}} = (catch map:values([])),
- {'EXIT',{badarg,[{map,values,_,_}|_]}} = (catch map:values(<<>>)),
+ {'EXIT',{badarg,[{maps,values,_,_}|_]}} = (catch maps:values(1 bsl 65 + 3)),
+ {'EXIT',{badarg,[{maps,values,_,_}|_]}} = (catch maps:values(atom)),
+ {'EXIT',{badarg,[{maps,values,_,_}|_]}} = (catch maps:values([])),
+ {'EXIT',{badarg,[{maps,values,_,_}|_]}} = (catch maps:values(<<>>)),
ok.
t_erlang_hash(Config) when is_list(Config) ->
@@ -610,7 +610,7 @@ t_bif_erlang_phash2() ->
44049159 = erlang:phash2(#{<<>> => {}}),
M0 = #{ a => 1, "key" => <<"value">> },
- M1 = map:remove("key",M0),
+ M1 = maps:remove("key",M0),
M2 = M1#{ "key" => <<"value">> },
118679416 = erlang:phash2(M0),
@@ -630,7 +630,7 @@ t_bif_erlang_phash() ->
1578050717 = erlang:phash(#{<<>> => {}},Sz), % yep, broken
M0 = #{ a => 1, "key" => <<"value">> },
- M1 = map:remove("key",M0),
+ M1 = maps:remove("key",M0),
M2 = M1#{ "key" => <<"value">> },
3590546636 = erlang:phash(M0,Sz),
@@ -650,7 +650,7 @@ t_bif_erlang_hash() ->
101655720 = erlang:hash(#{<<>> => {}},Sz), % yep, broken
M0 = #{ a => 1, "key" => <<"value">> },
- M1 = map:remove("key",M0),
+ M1 = maps:remove("key",M0),
M2 = M1#{ "key" => <<"value">> },
38260486 = erlang:hash(M0,Sz),
@@ -706,7 +706,7 @@ t_map_encode_decode(Config) when is_list(Config) ->
ok.
map_encode_decode_and_match([{K,V}|Pairs], EncodedPairs, M0) ->
- M1 = map:put(K,V,M0),
+ M1 = maps:put(K,V,M0),
B0 = erlang:term_to_binary(M1),
Ls = lists:sort([{K, erlang:term_to_binary(K), erlang:term_to_binary(V)}|EncodedPairs]),
%% sort Ks and Vs according to term spec, then match it
@@ -729,45 +729,45 @@ match_encoded_map(Bin,[<<131,Item/binary>>|Items]) ->
t_bif_map_to_list(Config) when is_list(Config) ->
- [] = map:to_list(#{}),
- [{a,1},{b,2}] = map:to_list(#{a=>1,b=>2}),
- [{a,1},{b,2},{c,3}] = map:to_list(#{c=>3,a=>1,b=>2}),
- [{a,1},{b,2},{g,3}] = map:to_list(#{g=>3,a=>1,b=>2}),
- [{a,1},{b,2},{g,3},{"c",4}] = map:to_list(#{g=>3,a=>1,b=>2,"c"=>4}),
- [{3,v2},{hi,v4},{{hi,3},v5},{"hi",v3},{<<"hi">>,v1}] = map:to_list(#{
+ [] = maps:to_list(#{}),
+ [{a,1},{b,2}] = maps:to_list(#{a=>1,b=>2}),
+ [{a,1},{b,2},{c,3}] = maps:to_list(#{c=>3,a=>1,b=>2}),
+ [{a,1},{b,2},{g,3}] = maps:to_list(#{g=>3,a=>1,b=>2}),
+ [{a,1},{b,2},{g,3},{"c",4}] = maps:to_list(#{g=>3,a=>1,b=>2,"c"=>4}),
+ [{3,v2},{hi,v4},{{hi,3},v5},{"hi",v3},{<<"hi">>,v1}] = maps:to_list(#{
<<"hi">>=>v1,3=>v2,"hi"=>v3,hi=>v4,{hi,3}=>v5}),
- [{3,v7},{hi,v9},{{hi,3},v10},{"hi",v8},{<<"hi">>,v6}] = map:to_list(#{
+ [{3,v7},{hi,v9},{{hi,3},v10},{"hi",v8},{<<"hi">>,v6}] = maps:to_list(#{
<<"hi">>=>v1,3=>v2,"hi"=>v3,hi=>v4,{hi,3}=>v5,
<<"hi">>=>v6,3=>v7,"hi"=>v8,hi=>v9,{hi,3}=>v10}),
%% error cases
- {'EXIT', {badarg,_}} = (catch map:to_list(id(a))),
- {'EXIT', {badarg,_}} = (catch map:to_list(id(42))),
+ {'EXIT', {badarg,_}} = (catch maps:to_list(id(a))),
+ {'EXIT', {badarg,_}} = (catch maps:to_list(id(42))),
ok.
t_bif_map_from_list(Config) when is_list(Config) ->
- #{} = map:from_list([]),
- A = map:from_list([]),
+ #{} = maps:from_list([]),
+ A = maps:from_list([]),
0 = erlang:map_size(A),
- #{a:=1,b:=2} = map:from_list([{a,1},{b,2}]),
- #{c:=3,a:=1,b:=2} = map:from_list([{a,1},{b,2},{c,3}]),
- #{g:=3,a:=1,b:=2} = map:from_list([{a,1},{b,2},{g,3}]),
+ #{a:=1,b:=2} = maps:from_list([{a,1},{b,2}]),
+ #{c:=3,a:=1,b:=2} = maps:from_list([{a,1},{b,2},{c,3}]),
+ #{g:=3,a:=1,b:=2} = maps:from_list([{a,1},{b,2},{g,3}]),
- #{a:=2} = map:from_list([{a,1},{a,3},{a,2}]),
+ #{a:=2} = maps:from_list([{a,1},{a,3},{a,2}]),
#{ <<"hi">>:=v1,3:=v3,"hi":=v6,hi:=v4,{hi,3}:=v5} =
- map:from_list([{3,v3},{"hi",v6},{hi,v4},{{hi,3},v5},{<<"hi">>,v1}]),
+ maps:from_list([{3,v3},{"hi",v6},{hi,v4},{{hi,3},v5},{<<"hi">>,v1}]),
#{<<"hi">>:=v6,3:=v8,"hi":=v11,hi:=v9,{hi,3}:=v10} =
- map:from_list([ {{hi,3},v3}, {"hi",v0},{3,v1}, {<<"hi">>,v4}, {hi,v2},
+ maps:from_list([ {{hi,3},v3}, {"hi",v0},{3,v1}, {<<"hi">>,v4}, {hi,v2},
{<<"hi">>,v6}, {{hi,3},v10},{"hi",v11}, {hi,v9}, {3,v8}]),
%% error cases
- {'EXIT', {badarg,_}} = (catch map:from_list(id(a))),
- {'EXIT', {badarg,_}} = (catch map:from_list(id(42))),
+ {'EXIT', {badarg,_}} = (catch maps:from_list(id(a))),
+ {'EXIT', {badarg,_}} = (catch maps:from_list(id(42))),
ok.
%% MISC