aboutsummaryrefslogtreecommitdiffstats
path: root/lib/dialyzer/test/small_SUITE_data/src/fun_arity.erl
blob: 850d2fd3314a3af6731d5678442a2f392a715102 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
%%--------------------------------------------------------------------------
%% Module which contains calls to funs of different arity.
%%--------------------------------------------------------------------------
-module(fun_arity).

-export([f_0_ok/0, f_0_ko/0]).
-export([f_1_ok/0, f_1_ko/0]).

-export([fa_0_ok/0, fa_0_ko/0]).
-export([fa_1_ok/0, fa_1_ko/0]).

-export([mfa_0_ok/0, mfa_0_ko/0, mf/0]).
-export([mfa_1_ok/0, mfa_1_ko/0, mf/1]).

-export([mfa_ne_0_ok/0, mfa_ne_0_ko/0]).
-export([mfa_ne_1_ok/0, mfa_ne_1_ko/0]).

-export([mfa_nd_0_ok/0, mfa_nd_0_ko/0]).
-export([mfa_nd_1_ok/0, mfa_nd_1_ko/0]).

-export(['Mfa_0_ok'/1, 'Mfa_0_ko'/1]).
-export(['Mfa_1_ok'/1, 'Mfa_1_ko'/1]).

-export(['mFa_0_ok'/1, 'mFa_0_ko'/1]).
-export(['mFa_1_ok'/1, 'mFa_1_ko'/1]).

-export(['MFa_0_ok'/2, 'MFa_0_ko'/2]).
-export(['MFa_1_ok'/2, 'MFa_1_ko'/2]).

%%--------------------------------------------------------------------------

%% Funs like "fun(...) -> ... end".

f_0_ok() -> (fun_f_0())().
f_0_ko() -> (fun_f_0())(1).
fun_f_0() -> fun() -> ok end.

f_1_ok() -> (fun_f_1())(1).
f_1_ko() -> (fun_f_1())().
fun_f_1() -> fun(_) -> ok end .

%%--------------------------------------------------------------------------

%% Funs like "fun F/A" when F is literal atom and A is literal
%% non-negative integer.

fa_0_ok() -> (fun_fa_0())().
fa_0_ko() -> (fun_fa_0())(1).
fun_fa_0() -> fun f/0.
f() -> ok.

fa_1_ok() -> (fun_fa_1())(1).
fa_1_ko() -> (fun_fa_1())().
fun_fa_1() -> fun f/1.
f(_) -> ok.

%%--------------------------------------------------------------------------

%% Funs like "fun M:F/A" when M and F are literal atoms, A is literal
%% non-negative integer and function is (defined and) exported.

mfa_0_ok() -> (fun_mfa_0())().
mfa_0_ko() -> (fun_mfa_0())(1).
fun_mfa_0() -> fun ?MODULE:mf/0.
mf() -> ok.

mfa_1_ok() -> (fun_mfa_1())(1).
mfa_1_ko() -> (fun_mfa_1())().
fun_mfa_1() -> fun ?MODULE:mf/1.
mf(_) -> ok.

%% Funs like "fun M:F/A" when M and F are literal atoms, A is literal
%% non-negative integer and function is defined but not exported.

mfa_ne_0_ok() -> (fun_mfa_ne_0())().
mfa_ne_0_ko() -> (fun_mfa_ne_0())(1).
fun_mfa_ne_0() -> fun ?MODULE:mf_ne/0.
mf_ne() -> ok.

mfa_ne_1_ok() -> (fun_mfa_ne_1())(1).
mfa_ne_1_ko() -> (fun_mfa_ne_1())().
fun_mfa_ne_1() -> fun ?MODULE:mf_ne/1.
mf_ne(_) -> ok.

%% Funs like "fun M:F/A" when M and F are literal atoms, A is literal
%% non-negative integer and function is not defined.

mfa_nd_0_ok() -> (fun_mfa_nd_0())().
mfa_nd_0_ko() -> (fun_mfa_nd_0())(1).
fun_mfa_nd_0() -> fun ?MODULE:mf_nd/0.

mfa_nd_1_ok() -> (fun_mfa_nd_1())(1).
mfa_nd_1_ko() -> (fun_mfa_nd_1())().
fun_mfa_nd_1() -> fun ?MODULE:mf_nd/1.

%% Funs like "fun M:F/A" when M is variable, F is literal atoms and A
%% is literal non-negative integer.

'Mfa_0_ok'(M) -> ('fun_Mfa_0'(M))().
'Mfa_0_ko'(M) -> ('fun_Mfa_0'(M))(1).
'fun_Mfa_0'(M) -> fun M:f/0.

'Mfa_1_ok'(M) -> ('fun_Mfa_1'(M))(1).
'Mfa_1_ko'(M) -> ('fun_Mfa_1'(M))().
'fun_Mfa_1'(M) -> fun M:f/1.

%% Funs like "fun M:F/A" when M is literal atom, F is variable and A
%% is literal non-negative integer.

'mFa_0_ok'(F) -> ('fun_mFa_0'(F))().
'mFa_0_ko'(F) -> ('fun_mFa_0'(F))(1).
'fun_mFa_0'(F) -> fun ?MODULE:F/0.

'mFa_1_ok'(F) -> ('fun_mFa_1'(F))(1).
'mFa_1_ko'(F) -> ('fun_mFa_1'(F))().
'fun_mFa_1'(F) -> fun ?MODULE:F/1.

%% Funs like "fun M:F/A" when M and F are variables and A is literal
%% non-negative integer.

'MFa_0_ok'(M, F) -> ('fun_MFa_0'(M, F))().
'MFa_0_ko'(M, F) -> ('fun_MFa_0'(M, F))(1).
'fun_MFa_0'(M, F) -> fun M:F/0.

'MFa_1_ok'(M, F) -> ('fun_MFa_1'(M, F))(1).
'MFa_1_ko'(M, F) -> ('fun_MFa_1'(M, F))().
'fun_MFa_1'(M, F) -> fun M:F/1.