aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/test/map_SUITE.erl
diff options
context:
space:
mode:
authorBjörn-Egil Dahlberg <[email protected]>2014-02-27 17:50:58 +0100
committerBjörn-Egil Dahlberg <[email protected]>2014-02-27 18:39:07 +0100
commit615e41b3810cecc7a30668193ce1fb0207cc42c7 (patch)
tree681b4ee32a3a603bca9d0a04c2373f9e542f2850 /erts/emulator/test/map_SUITE.erl
parent2202a8880f5472ce4bf65afdb967c70a12f35703 (diff)
downloadotp-615e41b3810cecc7a30668193ce1fb0207cc42c7.tar.gz
otp-615e41b3810cecc7a30668193ce1fb0207cc42c7.tar.bz2
otp-615e41b3810cecc7a30668193ce1fb0207cc42c7.zip
erts: Fix Map cmp exact equal of an empty map
The expression, #{} =:= M where M was any Map, would always result in 'true'. This commit fixes this issue by first comparing sizes for both terms and then checking for size zero.
Diffstat (limited to 'erts/emulator/test/map_SUITE.erl')
-rw-r--r--erts/emulator/test/map_SUITE.erl19
1 files changed, 19 insertions, 0 deletions
diff --git a/erts/emulator/test/map_SUITE.erl b/erts/emulator/test/map_SUITE.erl
index 8cc5621181..753d6f7727 100644
--- a/erts/emulator/test/map_SUITE.erl
+++ b/erts/emulator/test/map_SUITE.erl
@@ -29,6 +29,7 @@
t_guard_receive/1, t_guard_fun/1,
t_list_comprehension/1,
t_map_sort_literals/1,
+ t_map_equal/1,
%t_size/1,
t_map_size/1,
@@ -74,6 +75,7 @@ all() -> [
t_update_assoc,t_update_exact,
t_guard_bifs, t_guard_sequence, t_guard_update,
t_guard_receive,t_guard_fun, t_list_comprehension,
+ t_map_equal,
t_map_sort_literals,
%% Specific Map BIFs
@@ -450,6 +452,23 @@ t_map_sort_literals(Config) when is_list(Config) ->
ok.
+t_map_equal(Config) when is_list(Config) ->
+ true = id(#{}) =:= id(#{}),
+ false = id(#{}) =:= id(#{a=>1}),
+ false = id(#{a=>1}) =:= id(#{}),
+ true = id(#{ "a" => "hi", b => 134 }) =:= id(#{ b => 134,"a" => "hi"}),
+
+ false = id(#{ a => 1 }) =:= id(#{ a => 2}),
+ false = id(#{ a => 2 }) =:= id(#{ a => 1}),
+ false = id(#{ a => 2, b => 1 }) =:= id(#{ a => 1, b => 3}),
+ false = id(#{ a => 1, b => 1 }) =:= id(#{ a => 1, b => 3}),
+
+ true = id(#{ a => 1 }) =:= id(#{ a => 1}),
+ true = id(#{ "a" => 2 }) =:= id(#{ "a" => 2}),
+ true = id(#{ "a" => 2, b => 3 }) =:= id(#{ "a" => 2, b => 3}),
+ true = id(#{ a => 1, b => 3, c => <<"wat">> }) =:= id(#{ a => 1, b => 3, c=><<"wat">>}),
+ ok.
+
%% BIFs
t_bif_map_get(Config) when is_list(Config) ->