aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2015-03-23 11:49:19 +0100
committerBjörn Gustavsson <[email protected]>2015-04-13 12:37:54 +0200
commitfea64943212cd96764b595c91b22da68bc72e999 (patch)
treec3333067cb11b506c75e073853c7926f6f6b56ff /erts/emulator
parent85afb5e3441e78cd0d572dc809d94cfc810d71ff (diff)
downloadotp-fea64943212cd96764b595c91b22da68bc72e999.tar.gz
otp-fea64943212cd96764b595c91b22da68bc72e999.tar.bz2
otp-fea64943212cd96764b595c91b22da68bc72e999.zip
erts/map_SUITE.erl: Add a test case that tests has_map_fields
The has_map_fields instruction was not tested at all by erts/map_SUITE.erl
Diffstat (limited to 'erts/emulator')
-rw-r--r--erts/emulator/test/map_SUITE.erl44
1 files changed, 42 insertions, 2 deletions
diff --git a/erts/emulator/test/map_SUITE.erl b/erts/emulator/test/map_SUITE.erl
index 490dd0c1ad..7b68e91dc5 100644
--- a/erts/emulator/test/map_SUITE.erl
+++ b/erts/emulator/test/map_SUITE.erl
@@ -75,7 +75,10 @@
t_pdict/1,
t_ets/1,
t_dets/1,
- t_tracing/1
+ t_tracing/1,
+
+ %% instruction-level tests
+ t_has_map_fields/1
]).
-include_lib("stdlib/include/ms_transform.hrl").
@@ -132,7 +135,10 @@ all() -> [
t_erts_internal_hash,
t_pdict,
t_ets,
- t_tracing
+ t_tracing,
+
+ %% instruction-level tests
+ t_has_map_fields
].
groups() -> [].
@@ -2715,5 +2721,39 @@ trace_collector(Msg,Parent) ->
Parent ! Msg,
Parent.
+t_has_map_fields(Config) when is_list(Config) ->
+ true = has_map_fields_1(#{one=>1}),
+ true = has_map_fields_1(#{one=>1,two=>2}),
+ false = has_map_fields_1(#{two=>2}),
+ false = has_map_fields_1(#{}),
+
+ true = has_map_fields_2(#{c=>1,b=>2,a=>3}),
+ true = has_map_fields_2(#{c=>1,b=>2,a=>3,x=>42}),
+ false = has_map_fields_2(#{b=>2,c=>1}),
+ false = has_map_fields_2(#{x=>y}),
+ false = has_map_fields_2(#{}),
+
+ true = has_map_fields_3(#{c=>1,b=>2,a=>3}),
+ true = has_map_fields_3(#{c=>1,b=>2,a=>3,[]=>42}),
+ true = has_map_fields_3(#{b=>2,a=>3,[]=>42,42.0=>43}),
+ true = has_map_fields_3(#{a=>3,[]=>42,42.0=>43}),
+ true = has_map_fields_3(#{[]=>42,42.0=>43}),
+ false = has_map_fields_3(#{b=>2,c=>1}),
+ false = has_map_fields_3(#{[]=>y}),
+ false = has_map_fields_3(#{42.0=>x,a=>99}),
+ false = has_map_fields_3(#{}),
+
+ ok.
+
+has_map_fields_1(#{one:=_}) -> true;
+has_map_fields_1(#{}) -> false.
+
+has_map_fields_2(#{a:=_,b:=_,c:=_}) -> true;
+has_map_fields_2(#{}) -> false.
+
+has_map_fields_3(#{a:=_,b:=_}) -> true;
+has_map_fields_3(#{[]:=_,42.0:=_}) -> true;
+has_map_fields_3(#{}) -> false.
+
%% Use this function to avoid compile-time evaluation of an expression.
id(I) -> I.