4
%% Copyright Ericsson AB 1997-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
21
-module(erl_format_SUITE).
23
-include_lib("test_server/include/test_server.hrl").
24
-include("erl_format_SUITE_data/format_test_cases.hrl").
26
-export([all/0, suite/0,groups/0,init_per_suite/1, end_per_suite/1,
27
init_per_group/2,end_per_group/2, atoms/1, tuples/1, lists/1]).
29
-import(runner, [get_term/1]).
31
%% This test suite test the erl_format() function.
32
%% It uses the port program "format_test".
34
suite() -> [{ct_hooks,[ts_install_cth]}].
37
[atoms, tuples, lists].
42
init_per_suite(Config) ->
45
end_per_suite(_Config) ->
48
init_per_group(_GroupName, Config) ->
51
end_per_group(_GroupName, Config) ->
55
%% Tests formatting various atoms.
58
atoms(Config) when is_list(Config) ->
59
?line P = runner:start(?atoms),
61
?line {term, ''} = get_term(P),
62
?line {term, 'a'} = get_term(P),
63
?line {term, 'A'} = get_term(P),
64
?line {term, 'abc'} = get_term(P),
65
?line {term, 'Abc'} = get_term(P),
66
?line {term, 'ab@c'} = get_term(P),
67
?line {term, 'The rain in Spain stays mainly in the plains'} =
70
?line {term, a} = get_term(P),
71
?line {term, ab} = get_term(P),
72
?line {term, abc} = get_term(P),
73
?line {term, ab@c} = get_term(P),
74
?line {term, abcdefghijklmnopq} = get_term(P),
76
?line {term, ''} = get_term(P),
77
?line {term, 'a'} = get_term(P),
78
?line {term, 'A'} = get_term(P),
79
?line {term, 'abc'} = get_term(P),
80
?line {term, 'Abc'} = get_term(P),
81
?line {term, 'ab@c'} = get_term(P),
82
?line {term, 'The rain in Spain stays mainly in the plains'} =
85
?line {term, a} = get_term(P),
86
?line {term, ab} = get_term(P),
87
?line {term, abc} = get_term(P),
88
?line {term, ab@c} = get_term(P),
89
?line {term, ' abcdefghijklmnopq '} = get_term(P),
91
?line runner:recv_eot(P),
96
%% Tests formatting various tuples
99
tuples(Config) when is_list(Config) ->
100
?line P = runner:start(?tuples),
102
?line {term, {}} = get_term(P),
103
?line {term, {a}} = get_term(P),
104
?line {term, {a, b}} = get_term(P),
105
?line {term, {a, b, c}} = get_term(P),
106
?line {term, {1}} = get_term(P),
107
?line {term, {[]}} = get_term(P),
108
?line {term, {[], []}} = get_term(P),
109
?line {term, {[], a, b, c}} = get_term(P),
110
?line {term, {[], a, [], b, c}} = get_term(P),
111
?line {term, {[], a, '', b, c}} = get_term(P),
113
?line runner:recv_eot(P),
118
%% Tests formatting various lists
121
lists(Config) when is_list(Config) ->
122
?line P = runner:start(?lists),
124
?line {term, []} = get_term(P),
125
?line {term, [a]} = get_term(P),
126
?line {term, [a, b]} = get_term(P),
127
?line {term, [a, b, c]} = get_term(P),
128
?line {term, [1]} = get_term(P),
129
?line {term, [[]]} = get_term(P),
130
?line {term, [[], []]} = get_term(P),
131
?line {term, [[], a, b, c]} = get_term(P),
132
?line {term, [[], a, [], b, c]} = get_term(P),
133
?line {term, [[], a, '', b, c]} = get_term(P),
135
?line {term, [{name, 'Madonna'}, {age, 21}, {data, [{addr, "E-street", 42}]}]} =
139
?line {term, [{pi, _}, {'cos(70)', _}]} = get_term(P),
140
?line {term, [[pi, _], ['cos(70)', _]]} = get_term(P),
141
?line {term, [[pi, _], [], ["cos(70)", _]]} =
144
?line {term, [{pi, 3.1415}, {'cos(70)', 0.34202}]} = get_term(P),
145
?line {term, [[pi, 3.1415], ['cos(70)', 0.34202]]} = get_term(P),
146
?line {term, [[pi, 3.1415], [], ["cos(70)", 0.34202]]} =
150
?line {term, [-1]} = get_term(P),
152
?line runner:recv_eot(P),