4
%% Copyright Ericsson AB 2001-2009. All Rights Reserved.
4
%% Copyright Ericsson AB 2001-2011. All Rights Reserved.
6
6
%% The contents of this file are subject to the Erlang Public License,
7
7
%% Version 1.1, (the "License"); you may not use this file except in
8
8
%% compliance with the License. You should have received a copy of the
9
9
%% Erlang Public License along with this software. If not, it can be
10
10
%% retrieved online at http://www.erlang.org/.
12
12
%% Software distributed under the License is distributed on an "AS IS"
13
13
%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
14
14
%% the License for the specific language governing rights and limitations
15
15
%% under the License.
19
19
-module(sofs_SUITE).
26
26
-define(config(X,Y), foo).
27
27
-define(t, test_server).
29
-include("test_server.hrl").
29
-include_lib("test_server/include/test_server.hrl").
30
30
-define(format(S, A), ok).
33
-export([all/0, suite/0,groups/0,init_per_suite/1, end_per_suite/1,
34
init_per_group/2,end_per_group/2]).
35
-export([sofs/1, from_term_1/1, set_1/1, from_sets_1/1, relation_1/1,
36
-export([ from_term_1/1, set_1/1, from_sets_1/1, relation_1/1,
36
37
a_function_1/1, family_1/1, projection/1,
37
38
relation_to_family_1/1, domain_1/1, range_1/1, image/1,
38
39
inverse_image/1, inverse_1/1, converse_1/1, no_elements_1/1,
81
82
union/1, union/2, family_to_digraph/1, family_to_digraph/2,
82
83
digraph_to_family/1, digraph_to_family/2]).
84
-export([init_per_testcase/2, fin_per_testcase/2]).
85
-export([init_per_testcase/2, end_per_testcase/2]).
86
87
-compile({inline,[{eval,2}]}).
89
suite() -> [{ct_hooks,[ts_install_cth]}].
92
[{group, sofs}, {group, sofs_family}].
96
[from_term_1, set_1, from_sets_1, relation_1,
97
a_function_1, family_1, relation_to_family_1, domain_1,
98
range_1, image, inverse_image, inverse_1, converse_1,
99
no_elements_1, substitution, restriction, drestriction,
100
projection, strict_relation_1, extension,
101
weak_relation_1, to_sets_1, specification, union_1,
102
intersection_1, difference, symdiff,
103
symmetric_partition, is_sofs_set_1, is_set_1, is_equal,
104
is_subset, is_a_function_1, is_disjoint, join,
105
canonical, composite_1, relative_product_1,
106
relative_product_2, product_1, partition_1, partition_3,
107
multiple_relative_product, digraph, constant_function,
110
[family_specification, family_domain_1, family_range_1,
111
family_to_relation_1, union_of_family_1,
112
intersection_of_family_1, family_projection,
113
family_difference, family_intersection_1,
114
family_intersection_2, family_union_1, family_union_2,
117
init_per_suite(Config) ->
120
end_per_suite(_Config) ->
123
init_per_group(_GroupName, Config) ->
126
end_per_group(_GroupName, Config) ->
91
130
init_per_testcase(_Case, Config) ->
92
131
Dog=?t:timetrap(?t:minutes(2)),
93
132
[{watchdog, Dog}|Config].
95
fin_per_testcase(_Case, Config) ->
134
end_per_testcase(_Case, Config) ->
96
135
Dog=?config(watchdog, Config),
97
136
test_server:timetrap_cancel(Dog),
100
139
%% [{2,b},{1,a,b}] == lists:sort([{2,b},{1,a,b}])
101
140
%% [{1,a,b},{2,b}] == lists:keysort(1,[{2,b},{1,a,b}])
104
[from_term_1, set_1, from_sets_1, relation_1, a_function_1,
105
family_1, relation_to_family_1, domain_1, range_1, image,
106
inverse_image, inverse_1, converse_1, no_elements_1,
107
substitution, restriction, drestriction, projection,
108
strict_relation_1, extension, weak_relation_1, to_sets_1,
109
specification, union_1, intersection_1, difference, symdiff,
110
symmetric_partition, is_sofs_set_1, is_set_1, is_equal,
111
is_subset, is_a_function_1, is_disjoint, join, canonical,
112
composite_1, relative_product_1, relative_product_2, product_1,
113
partition_1, partition_3, multiple_relative_product, digraph,
114
constant_function, misc].
116
143
from_term_1(suite) -> [];
117
144
from_term_1(doc) -> [""];
118
from_term_1(Conf) when list(Conf) ->
145
from_term_1(Conf) when is_list(Conf) ->
119
146
%% would go wrong: projection(1,from_term([{2,b},{1,a,b}])),
121
148
?line {'EXIT', {badarg, _}} = (catch from_term([], {atom,'_',atom})),
306
333
a_function_1(suite) -> [];
307
334
a_function_1(doc) -> [""];
308
a_function_1(Conf) when list(Conf) ->
335
a_function_1(Conf) when is_list(Conf) ->
310
337
?line eval(a_function([]), from_term([], [{atom,atom}])),
311
338
?line eval(a_function([{a,b},{a,b},{b,c}]), from_term([{a,b},{b,c}])),
989
1016
specification(suite) -> [];
990
1017
specification(doc) -> [""];
991
specification(Conf) when list(Conf) ->
992
Fun = {external, fun(I) when integer(I) -> true; (_) -> false end},
1018
specification(Conf) when is_list(Conf) ->
1019
Fun = {external, fun(I) when is_integer(I) -> true; (_) -> false end},
993
1020
?line [1,2,3] = to_external(specification(Fun, set([a,1,b,2,c,3]))),
995
1022
Fun2 = fun(S) -> is_subset(S, set([1,3,5,7,9])) end,
1934
1961
Fun = fun(S) -> no_elements(S) > 1 end,
1935
1962
family_to_relation(family_specification(Fun, relation_to_family(R))).
1937
sofs_family(suite) ->
1938
[family_specification, family_domain_1, family_range_1,
1939
family_to_relation_1, union_of_family_1, intersection_of_family_1,
1940
family_projection, family_difference,
1941
family_intersection_1, family_intersection_2,
1942
family_union_1, family_union_2, partition_family].
1944
1965
family_specification(suite) -> [];
1945
1966
family_specification(doc) -> [""];
1946
family_specification(Conf) when list(Conf) ->
1967
family_specification(Conf) when is_list(Conf) ->
1947
1968
E = empty_set(),
1949
1970
?line eval(family_specification({sofs, is_set}, E), E),
1963
1984
(catch family_specification(Fun3, F3)),
1966
IsList = {external, fun(L) when list(L) -> true; (_) -> false end},
1987
IsList = {external, fun(L) when is_list(L) -> true; (_) -> false end},
1967
1988
?line eval(family_specification(IsList, E), E),
1968
1989
?line eval(family_specification(IsList, F1), F1),
1969
1990
MF = {external, fun(L) -> lists:member(3, L) end},
1976
1997
family_domain_1(suite) -> [];
1977
1998
family_domain_1(doc) -> [""];
1978
family_domain_1(Conf) when list(Conf) ->
1999
family_domain_1(Conf) when is_list(Conf) ->
1979
2000
?line E = empty_set(),
1980
2001
?line ER = from_term([{a,[]},{b,[]}],[{atom,[{atom,atom}]}]),
1981
2002
?line EF = from_term([{a,[]},{b,[]}],[{atom,[atom]}]),
2002
2023
family_range_1(suite) -> [];
2003
2024
family_range_1(doc) -> [""];
2004
family_range_1(Conf) when list(Conf) ->
2025
family_range_1(Conf) when is_list(Conf) ->
2005
2026
?line E = empty_set(),
2006
2027
?line ER = from_term([{a,[]},{b,[]}],[{atom,[{atom,atom}]}]),
2007
2028
?line EF = from_term([{a,[]},{b,[]}],[{atom,[atom]}]),
2053
2074
intersection_of_family_1(suite) -> [];
2054
2075
intersection_of_family_1(doc) -> [""];
2055
intersection_of_family_1(Conf) when list(Conf) ->
2076
intersection_of_family_1(Conf) when is_list(Conf) ->
2056
2077
?line EF = from_term([{a,[]},{b,[]}],[{atom,[atom]}]),
2057
2078
?line eval(intersection_of_family(EF), set([])),
2058
2079
?line FR = from_term([{a,[1,2,3]},{b,[2,3]},{c,[3,4,5]}]),