aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/test
diff options
context:
space:
mode:
authorBjörn-Egil Dahlberg <[email protected]>2013-10-30 16:09:29 +0100
committerBjörn-Egil Dahlberg <[email protected]>2014-01-28 17:06:42 +0100
commit7e42aefdecae6cc91bdaaef21924b4e7cb75861c (patch)
tree184f6f4b262dd445f4d7012a4ddb79deba8a6811 /erts/emulator/test
parent6fdad74f41803089a0f9026c98f319daecda9a50 (diff)
downloadotp-7e42aefdecae6cc91bdaaef21924b4e7cb75861c.tar.gz
otp-7e42aefdecae6cc91bdaaef21924b4e7cb75861c.tar.bz2
otp-7e42aefdecae6cc91bdaaef21924b4e7cb75861c.zip
erts: Add tests for non BIFs in Maps module
* maps:without/2 * maps:foldl/3 * maps:foldr/3 * maps:map/2 * maps:size/1
Diffstat (limited to 'erts/emulator/test')
-rw-r--r--erts/emulator/test/map_SUITE.erl55
1 files changed, 54 insertions, 1 deletions
diff --git a/erts/emulator/test/map_SUITE.erl b/erts/emulator/test/map_SUITE.erl
index 59fdb82f50..b6cfd668f1 100644
--- a/erts/emulator/test/map_SUITE.erl
+++ b/erts/emulator/test/map_SUITE.erl
@@ -47,6 +47,12 @@
t_erlang_hash/1,
t_map_encode_decode/1,
+ %% maps module not bifs
+ t_maps_fold/1,
+ t_maps_map/1,
+ t_maps_size/1,
+ t_maps_without/1,
+
%% misc
t_pdict/1,
t_ets/1,
@@ -74,9 +80,13 @@ all() -> [
%% erlang
t_erlang_hash, t_map_encode_decode,
- %t_size,
t_map_size,
+ %% maps module
+ t_maps_fold, t_maps_map,
+ t_maps_size, t_maps_without,
+
+
%% Other functions
t_pdict,
t_ets,
@@ -770,6 +780,49 @@ t_bif_map_from_list(Config) when is_list(Config) ->
{'EXIT', {badarg,_}} = (catch maps:from_list(id(42))),
ok.
+%% Maps module, not BIFs
+t_maps_fold(_Config) ->
+
+ Vs = lists:seq(1,100),
+ Rs = lists:reverse(Vs),
+ M = maps:from_list([{{k,I},{v,I}}||I<-Vs]),
+
+ %% foldl
+ 5050 = maps:foldl(fun({k,_},{v,V},A) -> V + A end, 0, M),
+ Rs = maps:foldl(fun({k,_},{v,V},A) -> [V|A] end, [], M),
+
+ %% foldr
+ 5050 = maps:foldr(fun({k,_},{v,V},A) -> V + A end, 0, M),
+ Vs = maps:foldr(fun({k,_},{v,V},A) -> [V|A] end, [], M),
+
+ ok.
+
+t_maps_map(_Config) ->
+ Vs = lists:seq(1,100),
+ M1 = maps:from_list([{I,I}||I<-Vs]),
+ M2 = maps:from_list([{I,{token,I}}||I<-Vs]),
+
+ M2 = maps:map(fun(_K,V) -> {token,V} end, M1),
+ ok.
+
+t_maps_size(_Config) ->
+ Vs = lists:seq(1,100),
+ lists:foldl(fun(I,M) ->
+ M1 = maps:put(I,I,M),
+ I = maps:size(M1),
+ M1
+ end, #{}, Vs),
+ ok.
+
+
+t_maps_without(_Config) ->
+ Ki = [11,22,33,44,55,66,77,88,99],
+ M0 = maps:from_list([{{k,I},{v,I}}||I<-lists:seq(1,100)]),
+ M1 = maps:from_list([{{k,I},{v,I}}||I<-lists:seq(1,100) -- Ki]),
+ M1 = maps:without([{k,I}||I <- Ki],M0),
+ ok.
+
+
%% MISC
t_pdict(_Config) ->