aboutsummaryrefslogtreecommitdiffstats
path: root/lib/hipe/test/maps_SUITE_data/maps_put_map_exact.erl
diff options
context:
space:
mode:
authorKostis Sagonas <[email protected]>2014-04-29 12:14:19 +0200
committerKostis Sagonas <[email protected]>2014-04-29 12:14:19 +0200
commitf6d5234c391a0ba834337c3e92ee5fb377834a32 (patch)
treeb046b684620ca9eab0e3f880a7ee34c1e6397d17 /lib/hipe/test/maps_SUITE_data/maps_put_map_exact.erl
parent5a43eb383bdeb604fd8a891ffe34610c3fe6208b (diff)
downloadotp-f6d5234c391a0ba834337c3e92ee5fb377834a32.tar.gz
otp-f6d5234c391a0ba834337c3e92ee5fb377834a32.tar.bz2
otp-f6d5234c391a0ba834337c3e92ee5fb377834a32.zip
Add five new test files for maps in the HiPE test suite
Diffstat (limited to 'lib/hipe/test/maps_SUITE_data/maps_put_map_exact.erl')
-rw-r--r--lib/hipe/test/maps_SUITE_data/maps_put_map_exact.erl28
1 files changed, 28 insertions, 0 deletions
diff --git a/lib/hipe/test/maps_SUITE_data/maps_put_map_exact.erl b/lib/hipe/test/maps_SUITE_data/maps_put_map_exact.erl
new file mode 100644
index 0000000000..1cfcd80180
--- /dev/null
+++ b/lib/hipe/test/maps_SUITE_data/maps_put_map_exact.erl
@@ -0,0 +1,28 @@
+%% -*- erlang-indent-level: 2 -*-
+%%-------------------------------------------------------------------------
+-module(maps_put_map_exact).
+
+-export([test/0]).
+
+test() ->
+ false = exact_guard(#{b => a}),
+ false = exact_guard(not_a_map),
+ true = exact_guard(#{a => false}),
+ #{a := true} = exact_update(#{a => false}),
+ {'EXIT', {badarg, [{?MODULE, exact_update, 1, _}|_]}}
+ = (catch exact_update(not_a_map)),
+ {'EXIT', {badarg, [{?MODULE, exact_update, 1, _}|_]}}
+ = (catch exact_update(#{})),
+ ok = exact_guard_clause(#{a => yes}),
+ {'EXIT', {function_clause, [{?MODULE, exact_guard_clause, _, _}|_]}}
+ = (catch exact_guard_clause(#{})),
+ {'EXIT', {function_clause, [{?MODULE, exact_guard_clause, _, _}|_]}}
+ = (catch exact_guard_clause(not_a_map)),
+ ok.
+
+exact_guard(M) when is_map(M#{a := b}) -> true;
+exact_guard(_) -> false.
+
+exact_update(M) -> M#{a := true}.
+
+exact_guard_clause(M) when is_map(M#{a := 42}) -> ok.