~ubuntu-branches/ubuntu/trusty/erlang/trusty

« back to all changes in this revision

Viewing changes to lib/stdlib/test/calendar_SUITE.erl

  • Committer: Bazaar Package Importer
  • Author(s): Clint Byrum
  • Date: 2011-05-05 15:48:43 UTC
  • mfrom: (3.5.13 sid)
  • Revision ID: james.westby@ubuntu.com-20110505154843-0om6ekzg6m7ugj27
Tags: 1:14.b.2-dfsg-3ubuntu1
* Merge from debian unstable.  Remaining changes:
  - Drop libwxgtk2.8-dev build dependency. Wx isn't in main, and not
    supposed to.
  - Drop erlang-wx binary.
  - Drop erlang-wx dependency from -megaco, -common-test, and -reltool, they
    do not really need wx. Also drop it from -debugger; the GUI needs wx,
    but it apparently has CLI bits as well, and is also needed by -megaco,
    so let's keep the package for now.
  - debian/patches/series: Do what I meant, and enable build-options.patch
    instead.
* Additional changes:
  - Drop erlang-wx from -et
* Dropped Changes:
  - patches/pcre-crash.patch: CVE-2008-2371: outer level option with
    alternatives caused crash. (Applied Upstream)
  - fix for ssl certificate verification in newSSL: 
    ssl_cacertfile_fix.patch (Applied Upstream)
  - debian/patches/series: Enable native.patch again, to get stripped beam
    files and reduce the package size again. (build-options is what
    actually accomplished this)
  - Remove build-options.patch on advice from upstream and because it caused
    odd build failures.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
%%
2
2
%% %CopyrightBegin%
3
 
%% 
4
 
%% Copyright Ericsson AB 1997-2009. All Rights Reserved.
5
 
%% 
 
3
%%
 
4
%% Copyright Ericsson AB 1997-2010. All Rights Reserved.
 
5
%%
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/.
11
 
%% 
 
11
%%
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.
16
 
%% 
 
16
%%
17
17
%% %CopyrightEnd%
18
18
%%
19
19
-module(calendar_SUITE).
20
20
 
21
 
-include("test_server.hrl").
 
21
-include_lib("test_server/include/test_server.hrl").
22
22
 
23
 
-export([all/1, 
 
23
-export([all/0, suite/0,groups/0,init_per_suite/1, end_per_suite/1, 
 
24
         init_per_group/2,end_per_group/2, 
24
25
         gregorian_days/1,
25
26
         gregorian_seconds/1,
26
27
         day_of_the_week/1,
27
28
         day_of_the_week_calibrate/1,
28
29
         leap_years/1,
29
30
         last_day_of_the_month/1,
30
 
         local_time_to_universal_time_dst/1]).
 
31
         local_time_to_universal_time_dst/1,
 
32
         iso_week_number/1]).
31
33
 
32
34
-define(START_YEAR, 1947).                      
33
35
-define(END_YEAR, 2012).
34
36
 
35
 
all(suite) -> [gregorian_days,
36
 
               gregorian_seconds,
37
 
               day_of_the_week,
38
 
               day_of_the_week_calibrate,
39
 
               leap_years,
40
 
               last_day_of_the_month,
41
 
               local_time_to_universal_time_dst];
42
 
 
43
 
all(doc) -> "This is the test suite for calendar.erl".
 
37
suite() -> [{ct_hooks,[ts_install_cth]}].
 
38
 
 
39
all() -> 
 
40
    [gregorian_days, gregorian_seconds, day_of_the_week,
 
41
     day_of_the_week_calibrate, leap_years,
 
42
     last_day_of_the_month, local_time_to_universal_time_dst, iso_week_number].
 
43
 
 
44
groups() -> 
 
45
    [].
 
46
 
 
47
init_per_suite(Config) ->
 
48
    Config.
 
49
 
 
50
end_per_suite(_Config) ->
 
51
    ok.
 
52
 
 
53
init_per_group(_GroupName, Config) ->
 
54
    Config.
 
55
 
 
56
end_per_group(_GroupName, Config) ->
 
57
    Config.
44
58
 
45
59
gregorian_days(doc) ->
46
60
    "Tests that date_to_gregorian_days and gregorian_days_to_date "
48
62
    "At the same time valid_date is tested.";
49
63
gregorian_days(suite) ->
50
64
    [];
51
 
gregorian_days(Config) when list(Config) ->
 
65
gregorian_days(Config) when is_list(Config) ->
52
66
    ?line Days = calendar:date_to_gregorian_days({?START_YEAR, 1, 1}),
53
67
    ?line MaxDays = calendar:date_to_gregorian_days({?END_YEAR, 1, 1}),
54
68
    ?line check_gregorian_days(Days, MaxDays).
60
74
    "every 2 days + 1 second.";
61
75
gregorian_seconds(suite) ->
62
76
    [];
63
 
gregorian_seconds(Config) when list(Config) ->
 
77
gregorian_seconds(Config) when is_list(Config) ->
64
78
    ?line Secs = calendar:datetime_to_gregorian_seconds({{?START_YEAR, 1, 1},
65
79
                                                         {0, 0, 0}}),
66
80
    ?line MaxSecs = calendar:datetime_to_gregorian_seconds({{?END_YEAR, 1, 1},
72
86
    "year ?START_YEAR up to ?END_YEAR.";
73
87
day_of_the_week(suite) ->
74
88
    [];
75
 
day_of_the_week(Config) when list(Config) ->
 
89
day_of_the_week(Config) when is_list(Config) ->
76
90
    ?line Days = calendar:date_to_gregorian_days({?START_YEAR, 1, 1}),
77
91
    ?line MaxDays = calendar:date_to_gregorian_days({?END_YEAR, 1, 1}),
78
92
    ?line DayNumber = calendar:day_of_the_week({?START_YEAR, 1, 1}),
82
96
    "Tests that day_of_the_week for 1997-11-11 is Tuesday (2)";
83
97
day_of_the_week_calibrate(suite) ->
84
98
    [];
85
 
day_of_the_week_calibrate(Config) when list(Config) ->
 
99
day_of_the_week_calibrate(Config) when is_list(Config) ->
86
100
    ?line 2 = calendar:day_of_the_week({1997, 11, 11}).
87
101
 
88
102
leap_years(doc) ->
90
104
    "year ?START_YEAR up to ?END_YEAR.";
91
105
leap_years(suite) ->
92
106
    [];
93
 
leap_years(Config) when list(Config) ->
 
107
leap_years(Config) when is_list(Config) ->
94
108
    ?line check_leap_years(?START_YEAR, ?END_YEAR).
95
109
 
96
110
last_day_of_the_month(doc) ->
98
112
    "year ?START_YEAR up to ?END_YEAR.";
99
113
last_day_of_the_month(suite) ->
100
114
    [];
101
 
last_day_of_the_month(Config) when list(Config) ->
 
115
last_day_of_the_month(Config) when is_list(Config) ->
102
116
    ?line check_last_day_of_the_month({?START_YEAR, 1}, {?END_YEAR, 1}).
103
117
 
104
118
local_time_to_universal_time_dst(doc) ->
105
119
    "Tests local_time_to_universal_time_dst for MET";
106
120
local_time_to_universal_time_dst(suite) ->
107
121
    [];
108
 
local_time_to_universal_time_dst(Config) when list(Config) ->
 
122
local_time_to_universal_time_dst(Config) when is_list(Config) ->
109
123
    case os:type() of
110
124
        {unix,_} ->
111
125
            case os:cmd("date '+%Z'") of
117
131
        _ ->
118
132
            local_time_to_universal_time_dst_x(Config)
119
133
    end.
120
 
local_time_to_universal_time_dst_x(Config) when list(Config) ->
 
134
local_time_to_universal_time_dst_x(Config) when is_list(Config) ->
121
135
    %% Assumes MET (UTC+1 / UTC+2(dst)
122
136
    ?line LtW   = {{2003,01,15},{14,00,00}}, % Winter
123
137
    ?line UtW   = {{2003,01,15},{13,00,00}}, % 
156
170
            {comment,"Bug in mktime() in this OS"}
157
171
    end.
158
172
 
 
173
iso_week_number(doc) ->
 
174
        "Test the iso week number calculation for all three possibilities."
 
175
        " When the date falls on the last week of the previous year,"
 
176
        " when the date falls on a week within the given year and finally,"
 
177
        " when the date falls on the first week of the next year.";
 
178
iso_week_number(suite) ->
 
179
        [];
 
180
iso_week_number(Config) when is_list(Config) ->
 
181
        ?line check_iso_week_number().
159
182
 
160
183
%%
161
184
%% LOCAL FUNCTIONS
245
268
check_last_day_of_the_month(_, _) ->
246
269
    ok.
247
270
 
248
 
 
 
271
%% check_iso_week_number
 
272
%%
 
273
check_iso_week_number() ->
 
274
    ?line {2004, 53} = calendar:iso_week_number({2005, 1, 1}),
 
275
    ?line {2007, 1} = calendar:iso_week_number({2007, 1, 1}),
 
276
    ?line {2009, 1} = calendar:iso_week_number({2008, 12, 29}).
249
277
    
250
278
 
251
279