aboutsummaryrefslogtreecommitdiffstats
path: root/lib/dialyzer/test/opaque_SUITE_data/src/simple/simple2_api.erl
blob: c86f6fd0b5edbaea3c3fac6210f4aa56131ffa57 (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
-module(simple2_api).

-export([c1/2, c2/0, c3/0, c4/1, c5/1, c6/0, c6_b/0, c7/0, c7_b/0,
         c7_c/0, c8/0, c9/0, c10/0, c11/0, c12/0, c13/0, c14/0, c15/0,
         c16/0, c17/0, c18/0, c19/0, c20/0, c21/0, c22/0, c23/0,
         c24/0, c25/0, c26/0]).

-spec c1(simple1_adt:d1(), simple1_adt:d2()) -> boolean().

c1(A, B) ->
    {A} =< {B}. % succ type of A and B is any()

c2() ->
    A = simple1_adt:d1(),
    erlang:make_tuple(1, A). % ok

c3() ->
    A = simple1_adt:d1(),
    setelement(1, {A}, A). % ok

c4(_) ->
    A = simple1_adt:d1(),
    halt(A). % ok (BIF fails...)

c5(_) ->
    A = simple1_adt:d1(),
    [A] -- [A]. % ok

c6() ->
    A = simple1_adt:d1(),
    A ! foo. % opaque term

c6_b() ->
    A = simple1_adt:d1(),
    erlang:send(A, foo). % opaque term

c7() ->
    A = simple1_adt:d1(),
    foo ! A. % ok

c7_b() ->
    A = simple1_adt:d1(),
    erlang:send(foo, A). % ok

c7_c() ->
    A = simple1_adt:d1(),
    erlang:send(foo, A, []). % ok

c8() ->
    A = simple1_adt:d1(),
    A < 3. % opaque term

c9() ->
    A = simple1_adt:d1(),
    lists:keysearch(A, 1, []). % ok

c10() ->
    A = simple1_adt:d1(),
    lists:keysearch(1, A, []). % opaque term 2

c11() ->
    A = simple1_adt:tuple(),
    lists:keysearch(key, 1, [A]). % ok

c12() ->
    A = simple1_adt:tuple(),
    lists:keysearch(key, 1, A). % opaque term 3

c13() ->
    A = simple1_adt:tuple(),
    lists:keysearch(key, 1, [{A,2}]). % ok

c14() ->
    A = simple1_adt:tuple(),
    lists:keysearch(key, 1, [{2,A}]). % ok

c15() ->
    A = simple1_adt:d1(),
    lists:keysearch(key, 1, [A]). % ok

c16() ->
    A = simple1_adt:tuple(),
    erlang:send(foo, A). % ok

c17() ->
    A = simple1_adt:tuple(),
    lists:reverse([A]). % ok

c18() ->
    A = simple1_adt:tuple(),
    lists:keyreplace(a, 1, [A], {1,2}). % ok

c19() ->
    A = simple1_adt:tuple(),
    %% Problem. The spec says argument 4 is a tuple(). Fix that!
    lists:keyreplace(a, 1, [{1,2}], A). % opaque term 4

c20() ->
    A = simple1_adt:tuple(),
    lists:flatten(A). % opaque term 1

c21() ->
    A = simple1_adt:tuple(),
    lists:flatten([[{A}]]). % ok

c22() ->
    A = simple1_adt:tuple(),
    lists:flatten([[A]]). % ok

c23() ->
    A = simple1_adt:tuple(),
    lists:flatten([A]). % ok

c24() ->
    A = simple1_adt:tuple(),
    lists:flatten({A}). % will never return

c25() ->
    A = simple1_adt:d1(),
    B = simple1_adt:tuple(),
    if {A,3} > {A,B} -> true end. % opaque 2nd argument

c26() ->
    B = simple1_adt:tuple(),
    tuple_to_list(B). % opaque term 1