4
%% Copyright Ericsson AB 2010-2011. All Rights Reserved.
6
%% The contents of this file are subject to the Erlang Public License,
7
%% Version 1.1, (the "License"); you may not use this file except in
8
%% compliance with the License. You should have received a copy of the
9
%% Erlang Public License along with this software. If not, it can be
10
%% retrieved online at http://www.erlang.org/.
12
%% Software distributed under the License is distributed on an "AS IS"
13
%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
14
%% the License for the specific language governing rights and limitations
19
-module(edlin_expand_SUITE).
20
-export([all/0, suite/0,groups/0,init_per_suite/1, end_per_suite/1,
21
init_per_group/2,end_per_group/2]).
23
-export([normal/1, quoted_fun/1, quoted_module/1, quoted_both/1]).
25
-export([init_per_testcase/2, end_per_testcase/2]).
27
-include_lib("test_server/include/test_server.hrl").
29
% Default timetrap timeout (set in init_per_testcase).
30
-define(default_timeout, ?t:minutes(1)).
32
init_per_testcase(_Case, Config) ->
33
?line Dog = ?t:timetrap(?default_timeout),
34
[{watchdog, Dog} | Config].
35
end_per_testcase(_Case, Config) ->
36
Dog = ?config(watchdog, Config),
37
test_server:timetrap_cancel(Dog),
40
suite() -> [{ct_hooks,[ts_install_cth]}].
43
[normal, quoted_fun, quoted_module, quoted_both].
48
init_per_suite(Config) ->
49
true = code:delete(expand_test),
50
true = code:delete(expand_test1),
51
true = code:delete('ExpandTestCaps'),
52
true = code:delete('ExpandTestCaps1'),
55
end_per_suite(_Config) ->
58
init_per_group(_GroupName, Config) ->
61
end_per_group(_GroupName, Config) ->
69
normal(Config) when is_list(Config) ->
70
?line {module,expand_test} = c:l(expand_test),
71
% These tests might fail if another module with the prefix "expand_" happens
73
?line {yes, "test:", []} = edlin_expand:expand(lists:reverse("expand_")),
74
?line {no, [], []} = edlin_expand:expand(lists:reverse("expandXX_")),
77
{"a_less_fun_name",1},
78
{"b_comes_after_a",1},
80
{"module_info",1}]} = edlin_expand:expand(lists:reverse("expand_test:")),
81
?line {yes,[],[{"a_fun_name",1},
82
{"a_less_fun_name",1}]} = edlin_expand:expand(
83
lists:reverse("expand_test:a_")),
87
["Normal module name, some function names using quoted atoms"];
90
quoted_fun(Config) when is_list(Config) ->
91
?line {module,expand_test} = c:l(expand_test),
92
?line {module,expand_test1} = c:l(expand_test1),
93
%% should be no colon after test this time
94
?line {yes, "test", []} = edlin_expand:expand(lists:reverse("expand_")),
95
?line {no, [], []} = edlin_expand:expand(lists:reverse("expandXX_")),
96
?line {no,[],[{"'#weird-fun-name'",0},
97
{"'Quoted_fun_name'",0},
98
{"'Quoted_fun_too'",0},
100
{"a_less_fun_name",1},
101
{"b_comes_after_a",1},
103
{"module_info",1}]} = edlin_expand:expand(
104
lists:reverse("expand_test1:")),
105
?line {yes,"_",[]} = edlin_expand:expand(
106
lists:reverse("expand_test1:a")),
107
?line {yes,[],[{"a_fun_name",1},
108
{"a_less_fun_name",1}]} = edlin_expand:expand(
109
lists:reverse("expand_test1:a_")),
111
[{"'#weird-fun-name'",0},
112
{"'Quoted_fun_name'",0},
113
{"'Quoted_fun_too'",0}]} = edlin_expand:expand(
114
lists:reverse("expand_test1:'")),
115
?line {yes,"uoted_fun_",[]} = edlin_expand:expand(
116
lists:reverse("expand_test1:'Q")),
118
[{"'Quoted_fun_name'",0},
119
{"'Quoted_fun_too'",0}]} = edlin_expand:expand(
120
lists:reverse("expand_test1:'Quoted_fun_")),
121
?line {yes,"weird-fun-name'(",[]} = edlin_expand:expand(
122
lists:reverse("expand_test1:'#")),
125
quoted_module(doc) ->
127
quoted_module(suite) ->
129
quoted_module(Config) when is_list(Config) ->
130
?line {module,'ExpandTestCaps'} = c:l('ExpandTestCaps'),
131
?line {yes, "Caps':", []} = edlin_expand:expand(lists:reverse("'ExpandTest")),
134
{"a_less_fun_name",1},
135
{"b_comes_after_a",1},
137
{"module_info",1}]} = edlin_expand:expand(lists:reverse("'ExpandTestCaps':")),
138
?line {yes,[],[{"a_fun_name",1},
139
{"a_less_fun_name",1}]} = edlin_expand:expand(
140
lists:reverse("'ExpandTestCaps':a_")),
143
quoted_both(suite) ->
145
quoted_both(Config) when is_list(Config) ->
146
?line {module,'ExpandTestCaps'} = c:l('ExpandTestCaps'),
147
?line {module,'ExpandTestCaps1'} = c:l('ExpandTestCaps1'),
148
%% should be no colon (or quote) after test this time
149
?line {yes, "Caps", []} = edlin_expand:expand(lists:reverse("'ExpandTest")),
150
?line {no,[],[{"'#weird-fun-name'",0},
151
{"'Quoted_fun_name'",0},
152
{"'Quoted_fun_too'",0},
154
{"a_less_fun_name",1},
155
{"b_comes_after_a",1},
157
{"module_info",1}]} = edlin_expand:expand(
158
lists:reverse("'ExpandTestCaps1':")),
159
?line {yes,"_",[]} = edlin_expand:expand(
160
lists:reverse("'ExpandTestCaps1':a")),
161
?line {yes,[],[{"a_fun_name",1},
162
{"a_less_fun_name",1}]} = edlin_expand:expand(
163
lists:reverse("'ExpandTestCaps1':a_")),
165
[{"'#weird-fun-name'",0},
166
{"'Quoted_fun_name'",0},
167
{"'Quoted_fun_too'",0}]} = edlin_expand:expand(
168
lists:reverse("'ExpandTestCaps1':'")),
169
?line {yes,"uoted_fun_",[]} = edlin_expand:expand(
170
lists:reverse("'ExpandTestCaps1':'Q")),
172
[{"'Quoted_fun_name'",0},
173
{"'Quoted_fun_too'",0}]} = edlin_expand:expand(
174
lists:reverse("'ExpandTestCaps1':'Quoted_fun_")),
175
?line {yes,"weird-fun-name'(",[]} = edlin_expand:expand(
176
lists:reverse("'ExpandTestCaps1':'#")),