aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorBjörn-Egil Dahlberg <[email protected]>2014-01-17 17:29:16 +0100
committerBjörn-Egil Dahlberg <[email protected]>2014-01-29 11:08:49 +0100
commitfa92c876756032bc7f824ed81bb9ba4667f14805 (patch)
tree5439ac3809964cb82b401cb8e2d2fbed7b489d6a /lib
parentb7b79aaf0453995ef2145647c5c50acc5fae811b (diff)
downloadotp-fa92c876756032bc7f824ed81bb9ba4667f14805.tar.gz
otp-fa92c876756032bc7f824ed81bb9ba4667f14805.tar.bz2
otp-fa92c876756032bc7f824ed81bb9ba4667f14805.zip
dialyzer: Add maps tests
Diffstat (limited to 'lib')
-rw-r--r--lib/dialyzer/test/small_SUITE_data/src/maps1.erl41
1 files changed, 41 insertions, 0 deletions
diff --git a/lib/dialyzer/test/small_SUITE_data/src/maps1.erl b/lib/dialyzer/test/small_SUITE_data/src/maps1.erl
new file mode 100644
index 0000000000..06ced5b69e
--- /dev/null
+++ b/lib/dialyzer/test/small_SUITE_data/src/maps1.erl
@@ -0,0 +1,41 @@
+%%
+%% File: maps1.erl
+%% Author: Björn-Egil Dahlberg
+%% Created: 2014-01-17
+%%
+
+-module(maps1).
+
+-compile([export_all]).
+
+
+-export([recv/3, decode/1]).
+
+%-record(can_pkt, {id, data :: binary(), timestamp}).
+
+-type can_pkt() :: #{ id => term(), data => binary(), timestamp => term() }.
+-type channel() :: atom() | pid() | {atom(),_}.
+
+-spec recv(<<_:64,_:_*8>>, fun((can_pkt()) -> R), channel()) -> R.
+recv(Packet, Fun, Chan) ->
+ #{id := Can_id, data := Can_data} = P = decode(Packet),
+ Fun(P).
+
+-spec decode(<<_:64,_:_*8>>) -> #{id => <<_:11>>,timestamp => char()}.
+decode(<<_:12, Len:4, Timestamp:16, 0:3, Id:11/bitstring, 0:18,
+ Data:Len/binary, _/binary>>) ->
+ #{id => Id, data => Data, timestamp => Timestamp}.
+
+
+
+t1() ->
+ #{bar=>fun t2/0}.
+
+t2() -> ok.
+
+-type map_state() :: #{ id => integer(), val => term() }.
+
+-spec update(map_state(), term()) -> map_state().
+
+update(#{ id := Id, val := Val } = M, X) when is_integer(Id) ->
+ M#{ val := [Val,X] }.