aboutsummaryrefslogtreecommitdiffstats
path: root/lib/dialyzer/test/map_SUITE_data/src/map_in_guard2.erl
diff options
context:
space:
mode:
authorMagnus Lång <[email protected]>2016-02-27 23:29:43 +0100
committerHans Bolinder <[email protected]>2016-04-28 16:16:09 +0200
commit92a672ff8159741ebbc9f3eb11e8a81d7067d2c7 (patch)
tree24268f010ffdc6def5cb658df4698471832e26f6 /lib/dialyzer/test/map_SUITE_data/src/map_in_guard2.erl
parenta13d4a750dfdf9a2a96d1e7ec0054644187afa59 (diff)
downloadotp-92a672ff8159741ebbc9f3eb11e8a81d7067d2c7.tar.gz
otp-92a672ff8159741ebbc9f3eb11e8a81d7067d2c7.tar.bz2
otp-92a672ff8159741ebbc9f3eb11e8a81d7067d2c7.zip
dialyzer_typesig: Add map support
Diffstat (limited to 'lib/dialyzer/test/map_SUITE_data/src/map_in_guard2.erl')
-rw-r--r--lib/dialyzer/test/map_SUITE_data/src/map_in_guard2.erl27
1 files changed, 27 insertions, 0 deletions
diff --git a/lib/dialyzer/test/map_SUITE_data/src/map_in_guard2.erl b/lib/dialyzer/test/map_SUITE_data/src/map_in_guard2.erl
new file mode 100644
index 0000000000..ac2205e8fa
--- /dev/null
+++ b/lib/dialyzer/test/map_SUITE_data/src/map_in_guard2.erl
@@ -0,0 +1,27 @@
+-module(map_in_guard2).
+
+-export([test/0]).
+
+test() ->
+ false = assoc_guard(not_a_map),
+ {'EXIT', {{badmap, not_a_map}, [{?MODULE, assoc_update, 1, _}|_]}}
+ = (catch assoc_update(not_a_map)),
+ {'EXIT', {function_clause, [{?MODULE, assoc_guard_clause, _, _}|_]}}
+ = (catch assoc_guard_clause(not_a_map)),
+ {'EXIT', {function_clause, [{?MODULE, assoc_guard_clause, _, _}|_]}}
+ = (catch (begin true = exact_guard(#{}) end)),
+ {'EXIT', {function_clause, [{?MODULE, exact_guard_clause, _, _}|_]}}
+ = (catch exact_guard_clause(#{})),
+ ok.
+
+assoc_guard(M) when is_map(M#{a => b}) -> true;
+assoc_guard(_) -> false.
+
+assoc_update(M) -> M#{a => true}.
+
+assoc_guard_clause(M) when is_map(M#{a => 3}) -> ok.
+
+exact_guard(M) when (false =/= M#{a := b}) -> true;
+exact_guard(_) -> false.
+
+exact_guard_clause(M) when (false =/= M#{a := b}) -> ok.