diff options
author | Björn-Egil Dahlberg <[email protected]> | 2015-05-05 17:17:35 +0200 |
---|---|---|
committer | Björn-Egil Dahlberg <[email protected]> | 2015-05-05 17:17:35 +0200 |
commit | a3fce1683d39d41fd746db42363a6c69aaf37abc (patch) | |
tree | 88b5344e1e6d5c81bd238a60c3944e0fb689d7ca | |
parent | 66260d0606fcbaad3d5179288fea90cfe546cbbe (diff) | |
parent | e0693a525481ac2af86830a5ec82520b62c217da (diff) | |
download | otp-a3fce1683d39d41fd746db42363a6c69aaf37abc.tar.gz otp-a3fce1683d39d41fd746db42363a6c69aaf37abc.tar.bz2 otp-a3fce1683d39d41fd746db42363a6c69aaf37abc.zip |
Merge branch 'egil/strengthen-dialyzer-tests'
* egil/strengthen-dialyzer-tests:
dialyzer: Strengthen maps tests
-rw-r--r-- | lib/dialyzer/test/small_SUITE_data/results/maps_sum | 4 | ||||
-rw-r--r-- | lib/dialyzer/test/small_SUITE_data/src/maps_sum.erl | 31 |
2 files changed, 35 insertions, 0 deletions
diff --git a/lib/dialyzer/test/small_SUITE_data/results/maps_sum b/lib/dialyzer/test/small_SUITE_data/results/maps_sum new file mode 100644 index 0000000000..a19c0bba96 --- /dev/null +++ b/lib/dialyzer/test/small_SUITE_data/results/maps_sum @@ -0,0 +1,4 @@ + +maps_sum.erl:15: Invalid type specification for function maps_sum:wrong1/1. The success typing is (#{}) -> any() +maps_sum.erl:26: Function wrong2/1 has no local return +maps_sum.erl:27: The call lists:foldl(fun((_,_,_) -> any()),0,Data::any()) will never return since it differs in the 1st argument from the success typing arguments: (fun((_,_) -> any()),any(),[any()]) 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). |