aboutsummaryrefslogtreecommitdiffstats
path: root/lib/dialyzer/test/map_SUITE_data/src/map_size.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_size.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_size.erl')
-rw-r--r--lib/dialyzer/test/map_SUITE_data/src/map_size.erl36
1 files changed, 36 insertions, 0 deletions
diff --git a/lib/dialyzer/test/map_SUITE_data/src/map_size.erl b/lib/dialyzer/test/map_SUITE_data/src/map_size.erl
new file mode 100644
index 0000000000..2da4f6904e
--- /dev/null
+++ b/lib/dialyzer/test/map_SUITE_data/src/map_size.erl
@@ -0,0 +1,36 @@
+-module(map_size).
+
+-export([t1/0, e1/0, t2/0, t3/0, t4/0, t5/1, t6/1, t7/1]).
+
+t1() ->
+ 0 = maps:size(#{}),
+ 1 = maps:size(#{}).
+
+e1() ->
+ 0 = map_size(#{}),
+ 1 = map_size(#{}).
+
+t2() -> p(#{a=>x}).
+
+p(M) when map_size(M) =:= 0 -> ok.
+
+t3() ->
+ 1 = map_size(cio()),
+ 2 = map_size(cio()),
+ 3 = map_size(cio()),
+ 4 = map_size(cio()).
+
+t4() ->
+ 0 = map_size(cio()).
+
+t5(M) when map_size(M) =:= 0 ->
+ #{a := _} = M. %% Only t5 has no local return; want better message
+
+t6(M) when map_size(M) =:= 0 ->
+ #{} = M.
+
+t7(M=#{a := _}) when map_size(M) =:= 1 ->
+ #{b := _} = M. %% We should warn here too
+
+-spec cio() -> #{3 := ok, 9 => _, 11 => x}.
+cio() -> binary_to_term(<<131,116,0,0,0,2,97,3,100,0,2,111,107,97,9,97,6>>).