diff options
author | Björn Gustavsson <[email protected]> | 2016-03-10 09:57:37 +0100 |
---|---|---|
committer | Björn Gustavsson <[email protected]> | 2016-03-10 09:57:37 +0100 |
commit | e42208ce5d5e76056f9c199d52512275c98b50c1 (patch) | |
tree | 016d43ebe0fa7f0fb7dd2bcab9398dc418a4b665 /lib/stdlib/test/y2k_SUITE.erl | |
parent | 104cca3be8852070cb3c6d5b12ea74fe1591ba9b (diff) | |
parent | 25e64aaf1df1ea5c712075a9236367de4cc81359 (diff) | |
download | otp-e42208ce5d5e76056f9c199d52512275c98b50c1.tar.gz otp-e42208ce5d5e76056f9c199d52512275c98b50c1.tar.bz2 otp-e42208ce5d5e76056f9c199d52512275c98b50c1.zip |
Merge branch 'bjorn/stdlib/modernize-tests'
* bjorn/stdlib/modernize-tests:
Eliminate use of ?config() macro
Remove ?line macros
Replace "%" with "%%" at the beginning of a line
Eliminate 'suite' and 'doc' clauses
gen_server_SUITE: Eliminate use of test_server:timecall/3
Use 'test_server' instead of ?t macro
Eliminate use of test_server:messages_get/0
sys_SUITE: Replace test_server:capture*/0 with ct:capture*/0
sys_SUITE: Mend test cases that didn't test what they should
Replace calls to test_server:sleep/1 with ct:sleep/1 or timer:sleep/1
Eliminate use of test_server:do_times()
Replace use of test_server:format/2 with io:format/2
Eliminate use of test_server:fail/0,1
Modernize use of timetraps
Diffstat (limited to 'lib/stdlib/test/y2k_SUITE.erl')
-rw-r--r-- | lib/stdlib/test/y2k_SUITE.erl | 155 |
1 files changed, 64 insertions, 91 deletions
diff --git a/lib/stdlib/test/y2k_SUITE.erl b/lib/stdlib/test/y2k_SUITE.erl index d80dd10631..7828eb26ed 100644 --- a/lib/stdlib/test/y2k_SUITE.erl +++ b/lib/stdlib/test/y2k_SUITE.erl @@ -55,104 +55,80 @@ end_per_group(_GroupName, Config) -> Config. -date_1999_01_01(doc) -> - "#1 : 1999-01-01: test roll-over from 1998-12-31 to 1999-01-01."; -date_1999_01_01(suite) -> - []; +%% #1 : 1999-01-01: test roll-over from 1998-12-31 to 1999-01-01. date_1999_01_01(Config) when is_list(Config) -> - ?line Date = {1998, 12, 31}, NextDate = {1999, 1, 1}, - ?line match(next_date(Date), NextDate), + Date = {1998, 12, 31}, NextDate = {1999, 1, 1}, + match(next_date(Date), NextDate), TZD = tzd(Date), if TZD > 0 -> - ?line Time = {24 - TZD, 0, 0}, - ?line {NDate, _NTime} = + Time = {24 - TZD, 0, 0}, + {NDate, _NTime} = erlang:localtime_to_universaltime({Date, Time}), - ?line match(NDate, NextDate); + match(NDate, NextDate); TZD < 0 -> - ?line Time = {24 + TZD, 0, 0}, - ?line {NDate, _NTime} = + Time = {24 + TZD, 0, 0}, + {NDate, _NTime} = erlang:universaltime_to_localtime({Date, Time}), - ?line match(NDate, NextDate); + match(NDate, NextDate); true -> ok end. - -date_1999_02_28(doc) -> - "#2 : 1999-02-28: test roll-over from 1999-02-28 to 1999-03-01."; -date_1999_02_28(suite) -> - []; + +%% #2 : 1999-02-28: test roll-over from 1999-02-28 to 1999-03-01. date_1999_02_28(Config) when is_list(Config) -> - ?line Date = {1999, 2, 28}, NextDate = {1999, 3, 1}, - ?line match(next_date(Date), NextDate), - ?line match(tz_next_date(Date), NextDate). - -date_1999_09_09(doc) -> - "#3 : 1999-09-09: test roll-over from 1999-09-08 to 1999-09-09."; -date_1999_09_09(suite) -> - []; + Date = {1999, 2, 28}, NextDate = {1999, 3, 1}, + match(next_date(Date), NextDate), + match(tz_next_date(Date), NextDate). + +%% #3 : 1999-09-09: test roll-over from 1999-09-08 to 1999-09-09. date_1999_09_09(Config) when is_list(Config) -> - ?line Date = {1999, 9, 8}, NextDate = {1999, 9, 9}, - ?line match(next_date(Date), NextDate), - ?line match(tz_next_date(Date), NextDate). - -date_2000_01_01(doc) -> - "#4 : 2000-01-01: test roll-over from 1999-12-31 to 2000-01-01 to " - "2000-01-02."; -date_2000_01_01(suite) -> - []; + Date = {1999, 9, 8}, NextDate = {1999, 9, 9}, + match(next_date(Date), NextDate), + match(tz_next_date(Date), NextDate). + +%% #4 : 2000-01-01: test roll-over from 1999-12-31 to 2000-01-01 to +%% 2000-01-02.; date_2000_01_01(Config) when is_list(Config) -> - ?line Date = {1999, 12, 31}, NextDate = {2000, 1, 1}, - ?line match(next_date(Date), NextDate), - ?line match(tz_next_date(Date), NextDate), - ?line NextDate1 = {2000, 1, 2}, - ?line match(next_date(NextDate), NextDate1), - ?line match(tz_next_date(NextDate), NextDate1). - -date_2000_02_29(doc) -> - "#5 : 2000-02-29: test roll-over from 2000-02-28 to 2000-02-29 to " - "2000-03-01."; -date_2000_02_29(suite) -> - []; + Date = {1999, 12, 31}, NextDate = {2000, 1, 1}, + match(next_date(Date), NextDate), + match(tz_next_date(Date), NextDate), + NextDate1 = {2000, 1, 2}, + match(next_date(NextDate), NextDate1), + match(tz_next_date(NextDate), NextDate1). + +%% #5 : 2000-02-29: test roll-over from 2000-02-28 to 2000-02-29 to +%% 2000-03-01. date_2000_02_29(Config) when is_list(Config) -> - ?line Date = {2000, 2, 28}, NextDate = {2000, 2, 29}, - ?line match(next_date(Date), NextDate), - ?line match(tz_next_date(Date), NextDate), - ?line NextDate1 = {2000, 3, 1}, - ?line match(next_date(NextDate), NextDate1), - ?line match(tz_next_date(NextDate), NextDate1). - -date_2001_01_01(doc) -> - "#6 : 2001-01-01: test roll-over from 2000-12-31 to 2001-01-01."; -date_2001_01_01(suite) -> - []; + Date = {2000, 2, 28}, NextDate = {2000, 2, 29}, + match(next_date(Date), NextDate), + match(tz_next_date(Date), NextDate), + NextDate1 = {2000, 3, 1}, + match(next_date(NextDate), NextDate1), + match(tz_next_date(NextDate), NextDate1). + +%% #6 : 2001-01-01: test roll-over from 2000-12-31 to 2001-01-01. date_2001_01_01(Config) when is_list(Config) -> - ?line Date = {2000, 12, 31}, NextDate = {2001, 1, 1}, - ?line match(next_date(Date), NextDate), - ?line match(tz_next_date(Date), NextDate). - -date_2001_02_29(doc) -> - "#7 : 2001-02-29: test roll-over from 2001-02-28 to 2001-03-01."; -date_2001_02_29(suite) -> - []; + Date = {2000, 12, 31}, NextDate = {2001, 1, 1}, + match(next_date(Date), NextDate), + match(tz_next_date(Date), NextDate). + +%% #7 : 2001-02-29: test roll-over from 2001-02-28 to 2001-03-01. date_2001_02_29(Config) when is_list(Config) -> - ?line Date = {2001, 2, 28}, NextDate = {2001, 3, 1}, - ?line match(next_date(Date), NextDate), - ?line match(tz_next_date(Date), NextDate). - -date_2004_02_29(doc) -> - "#8 : 2004-02-29: test roll-over from 2004-02-28 to 2004-02-29 to " - "2004-03-01."; -date_2004_02_29(suite) -> - []; + Date = {2001, 2, 28}, NextDate = {2001, 3, 1}, + match(next_date(Date), NextDate), + match(tz_next_date(Date), NextDate). + +%% #8 : 2004-02-29: test roll-over from 2004-02-28 to 2004-02-29 to +%% 2004-03-01. date_2004_02_29(Config) when is_list(Config) -> - ?line Date = {2004, 2, 28}, NextDate = {2004, 2, 29}, - ?line match(next_date(Date), NextDate), - ?line match(tz_next_date(Date), NextDate), - ?line NextDate1 = {2004, 3, 1}, - ?line match(next_date(NextDate), NextDate1), - ?line match(tz_next_date(NextDate), NextDate1). - + Date = {2004, 2, 28}, NextDate = {2004, 2, 29}, + match(next_date(Date), NextDate), + match(tz_next_date(Date), NextDate), + NextDate1 = {2004, 3, 1}, + match(next_date(NextDate), NextDate1), + match(tz_next_date(NextDate), NextDate1). + %% %% Local functions %% @@ -162,7 +138,7 @@ next_date(Date) -> %% timezonediff %% tzd(Date) -> - ?line {_LDate, {LH, _LM, _LS}} = + {_LDate, {LH, _LM, _LS}} = erlang:universaltime_to_localtime({Date, {12, 0, 0}}), 12 - LH. @@ -170,15 +146,15 @@ tz_next_date(Date) -> TZD = tzd(Date), if TZD > 0 -> - ?line Time = {24 - TZD, 0, 0}, - ?line {NDate, _NTime} = + Time = {24 - TZD, 0, 0}, + {NDate, _NTime} = erlang:localtime_to_universaltime({Date, Time}), - ?line NDate; + NDate; TZD < 0 -> - ?line Time = {24 + TZD, 0, 0}, - ?line {NDate, _NTime} = + Time = {24 + TZD, 0, 0}, + {NDate, _NTime} = erlang:universaltime_to_localtime({Date, Time}), - ?line NDate; + NDate; true -> Date end. @@ -189,6 +165,3 @@ tz_next_date(Date) -> match(X, X) -> ok. - - - |