~clint-fewbar/ubuntu/precise/erlang/merge-15b

« back to all changes in this revision

Viewing changes to lib/dialyzer/test/small_SUITE_data/src/refine_failing.erl

  • Committer: Package Import Robot
  • Author(s): Sergei Golovan
  • Date: 2011-12-15 19:20:10 UTC
  • mfrom: (1.1.18) (3.5.15 sid)
  • mto: (3.5.16 sid)
  • mto: This revision was merged to the branch mainline in revision 33.
  • Revision ID: package-import@ubuntu.com-20111215192010-jnxcfe3tbrpp0big
Tags: 1:15.b-dfsg-1
* New upstream release.
* Upload to experimental because this release breaks external drivers
  API along with ABI, so several applications are to be fixed.
* Removed SSL patch because the old SSL implementation is removed from
  the upstream distribution.
* Removed never used patch which added native code to erlang beam files.
* Removed the erlang-docbuilder binary package because the docbuilder
  application was dropped by upstream.
* Documented dropping ${erlang-docbuilder:Depends} substvar in
  erlang-depends(1) manpage.
* Made erlang-base and erlang-base-hipe provide virtual package
  erlang-abi-15.b (the number means the first erlang version, which
  provides current ABI).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
%% This testcase shows why it's a bad idea to block refinement (by forwarding
 
2
%% any() to all arguments) when a failing call is encountered. The initial
 
3
%% success typing for update_one allows anything to be an element of the list in
 
4
%% the second argument. This will be refined during dataflow by the result from
 
5
%% add_counters to just a list of tuples. This will cause the call in the second
 
6
%% clause of update_one to fail correctly and identify the discrepancy. It could
 
7
%% be a better idea to refuse to add the failing calls but this may lead to a
 
8
%% ton of unused functions,
 
9
%%
 
10
%% by Stavros Aronis<aronisstav@gmail.com>
 
11
 
 
12
-module(refine_failing).
 
13
 
 
14
-export([foo/2]).
 
15
 
 
16
foo(A, B) -> update_all(add_counters(A, []), B).
 
17
 
 
18
add_counters(   [], Acc) -> Acc;
 
19
add_counters([H|T], Acc) -> add_counters(T, [{H, 0}|Acc]).
 
20
 
 
21
update_all(Ds,     []) -> Ds;
 
22
update_all(Ds, [F|Fs]) -> update_all(update_one(F, Ds, []), Fs).
 
23
 
 
24
update_one(_F,           [], Acc) -> Acc;
 
25
update_one( F, [{F, Cr},Ds], Acc) -> update_one(F, Ds, [{F,Cr+1}|Acc]);
 
26
update_one( F, [      D|Ds], Acc) -> update_one(F, Ds, [       D|Acc]).