aboutsummaryrefslogtreecommitdiffstats
path: root/lib/dialyzer/test/small_SUITE_data/src
diff options
context:
space:
mode:
authorBjörn-Egil Dahlberg <[email protected]>2015-04-30 17:36:35 +0200
committerBjörn-Egil Dahlberg <[email protected]>2015-04-30 17:36:35 +0200
commite0693a525481ac2af86830a5ec82520b62c217da (patch)
tree41d4fe09f1cfb90201120fec5f5ac06076835298 /lib/dialyzer/test/small_SUITE_data/src
parent147e8b9bd0b36315f0d8bd38e39c51d93cd9f509 (diff)
downloadotp-e0693a525481ac2af86830a5ec82520b62c217da.tar.gz
otp-e0693a525481ac2af86830a5ec82520b62c217da.tar.bz2
otp-e0693a525481ac2af86830a5ec82520b62c217da.zip
dialyzer: Strengthen maps tests
Diffstat (limited to 'lib/dialyzer/test/small_SUITE_data/src')
-rw-r--r--lib/dialyzer/test/small_SUITE_data/src/maps_sum.erl31
1 files changed, 31 insertions, 0 deletions
diff --git a/lib/dialyzer/test/small_SUITE_data/src/maps_sum.erl b/lib/dialyzer/test/small_SUITE_data/src/maps_sum.erl
new file mode 100644
index 0000000000..a73ac555c9
--- /dev/null
+++ b/lib/dialyzer/test/small_SUITE_data/src/maps_sum.erl
@@ -0,0 +1,31 @@
+-module(maps_sum).
+-export([correct1/1,
+ wrong1/1,
+ wrong2/1]).
+
+-spec correct1(#{atom() => term()}) -> integer().
+
+correct1(Data) ->
+ maps:fold(fun (_Key, Value, Acc) when is_integer(Value) ->
+ Acc + Value;
+ (_Key, _Value, Acc) ->
+ Acc
+ end, 0, Data).
+
+-spec wrong1([{atom(),term()}]) -> integer().
+
+wrong1(Data) ->
+ maps:fold(fun (_Key, Value, Acc) when is_integer(Value) ->
+ Acc + Value;
+ (_Key, _Value, Acc) ->
+ Acc
+ end, 0, Data).
+
+-spec wrong2(#{atom() => term()}) -> integer().
+
+wrong2(Data) ->
+ lists:foldl(fun (_Key, Value, Acc) when is_integer(Value) ->
+ Acc + Value;
+ (_Key, _Value, Acc) ->
+ Acc
+ end, 0, Data).