diff options
author | Björn-Egil Dahlberg <[email protected]> | 2014-03-03 10:51:25 +0100 |
---|---|---|
committer | Björn-Egil Dahlberg <[email protected]> | 2014-03-03 10:51:25 +0100 |
commit | 69dbcf7808a2ac3391bb20828e882fa1011ee2f9 (patch) | |
tree | 0694e895d346fcffa9c24268cda1857b68c97919 | |
parent | cd191dbd618cfc9231fdf60a7feb9f68a9c68ab1 (diff) | |
parent | 615e41b3810cecc7a30668193ce1fb0207cc42c7 (diff) | |
download | otp-69dbcf7808a2ac3391bb20828e882fa1011ee2f9.tar.gz otp-69dbcf7808a2ac3391bb20828e882fa1011ee2f9.tar.bz2 otp-69dbcf7808a2ac3391bb20828e882fa1011ee2f9.zip |
Merge branch 'egil/fix-maps-eq'
* egil/fix-maps-eq:
erts: Fix Map cmp exact equal of an empty map
-rw-r--r-- | erts/emulator/beam/utils.c | 6 | ||||
-rw-r--r-- | erts/emulator/test/map_SUITE.erl | 19 |
2 files changed, 24 insertions, 1 deletions
diff --git a/erts/emulator/beam/utils.c b/erts/emulator/beam/utils.c index 5b43d25e3c..738f793020 100644 --- a/erts/emulator/beam/utils.c +++ b/erts/emulator/beam/utils.c @@ -2125,7 +2125,11 @@ tailrecur_ne: if (!is_boxed(b) || *boxed_val_rel(b,b_base) != *aa) goto not_equal; bb = map_val_rel(b,b_base); - if ((sz = map_get_size((map_t*)aa)) == 0) goto pop_next; + sz = map_get_size((map_t*)aa); + + if (sz != map_get_size((map_t*)bb)) goto not_equal; + if (sz == 0) goto pop_next; + aa += 2; bb += 2; sz += 1; /* increment for tuple-keys */ 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) -> |