19
19
%
20
20
21
21
-module (test_fun_info ).
22
+
22
23
-export ([start /0 , get_fun /1 ]).
23
24
24
- -define (SUCCESS , ( 0 ) ).
25
- -define (ERROR , ( 1 ) ).
25
+ -define (SUCCESS , 0 ).
26
+ -define (ERROR , 1 ).
26
27
27
28
start () ->
28
29
try test_funs () of
29
- ok -> ? SUCCESS
30
+ ok ->
31
+ ? SUCCESS
30
32
catch
31
33
_ :E :S ->
32
34
erlang :display ({E , S }),
33
35
? ERROR
34
36
end .
35
37
36
- f (_X , _Y , _Z ) -> ok .
38
+ f (_X , _Y , _Z ) ->
39
+ ok .
37
40
38
- get_fun (local ) -> fun (B ) -> not B end ;
39
- get_fun (local_ref ) -> fun f /3 ;
40
- get_fun (external_ref ) -> fun erlang :apply /2 ;
41
- get_fun (not_existing_ref ) -> fun erlang :undef /8 .
41
+ get_fun (local ) ->
42
+ fun (B ) -> not B end ;
43
+ get_fun (local_ref ) ->
44
+ fun f /3 ;
45
+ get_fun (external_ref ) ->
46
+ fun erlang :apply /2 ;
47
+ get_fun (not_existing_ref ) ->
48
+ fun erlang :undef /8 .
42
49
43
50
test_funs () ->
44
51
LocalFun = ? MODULE :get_fun (local ),
@@ -52,6 +59,8 @@ test_funs() ->
52
59
true = atom_contains (LocalFunName , " get_fun" ),
53
60
{arity , 1 } = erlang :fun_info (LocalFun , arity ),
54
61
{type , local } = erlang :fun_info (LocalFun , type ),
62
+ % TODO: implement env: env is mocked here and always return []
63
+ {env , []} = erlang :fun_info (LocalFun , env ),
55
64
56
65
{module , test_fun_info } = erlang :fun_info (LocalFunRef , module ),
57
66
{name , LocalFunRefName } = erlang :fun_info (LocalFunRef , name ),
@@ -62,25 +71,32 @@ test_funs() ->
62
71
true = Format1 or Format2 or Format3 ,
63
72
{arity , 3 } = erlang :fun_info (LocalFunRef , arity ),
64
73
{type , local } = erlang :fun_info (LocalFunRef , type ),
74
+ % TODO: implement env: env is mocked here and always return []
75
+ {env , []} = erlang :fun_info (LocalFunRef , env ),
65
76
66
77
{module , erlang } = erlang :fun_info (ExternalFunRef , module ),
67
78
{name , apply } = erlang :fun_info (ExternalFunRef , name ),
68
79
{arity , 2 } = erlang :fun_info (ExternalFunRef , arity ),
69
80
{type , external } = erlang :fun_info (ExternalFunRef , type ),
81
+ {env , []} = erlang :fun_info (ExternalFunRef , env ),
70
82
71
83
{module , erlang } = erlang :fun_info (NotExistingFunRef , module ),
72
84
{name , undef } = erlang :fun_info (NotExistingFunRef , name ),
73
85
{arity , 8 } = erlang :fun_info (NotExistingFunRef , arity ),
74
86
{type , external } = erlang :fun_info (NotExistingFunRef , type ),
87
+ % TODO: implement env: env is mocked here and always return []
88
+ {env , []} = erlang :fun_info (NotExistingFunRef , env ),
75
89
76
90
ok .
77
91
78
92
atom_contains (Atom , Pattern ) when is_atom (Atom ) ->
79
93
atom_contains (atom_to_list (Atom ), Pattern );
80
94
atom_contains ([_C | Rest ] = String , Pattern ) ->
81
95
case prefix_match (String , Pattern ) of
82
- true -> true ;
83
- false -> atom_contains (Rest , Pattern )
96
+ true ->
97
+ true ;
98
+ false ->
99
+ atom_contains (Rest , Pattern )
84
100
end ;
85
101
atom_contains ([], _Pattern ) ->
86
102
false .
0 commit comments