aboutsummaryrefslogtreecommitdiffstats
path: root/lib/dialyzer/test/map_SUITE_data/src/map_in_guard2.erl
blob: ac2205e8fa3f6e9fbf36f2a4b755916434cdf688 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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.