mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
split tests.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28257 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
094ca0281e
commit
9c2a968855
1 changed files with 64 additions and 38 deletions
|
@ -17,6 +17,7 @@ class TestTimeTZ < Test::Unit::TestCase
|
|||
end
|
||||
end
|
||||
|
||||
module Util
|
||||
def format_gmtoff(gmtoff)
|
||||
if gmtoff < 0
|
||||
expected = "-"
|
||||
|
@ -28,6 +29,10 @@ class TestTimeTZ < Test::Unit::TestCase
|
|||
expected << "%02d%02d" % [gmtoff / 60, gmtoff % 60]
|
||||
expected
|
||||
end
|
||||
end
|
||||
|
||||
include Util
|
||||
extend Util
|
||||
|
||||
def time_to_s(t)
|
||||
if RUBY_VERSION < "1.9"
|
||||
|
@ -120,7 +125,13 @@ class TestTimeTZ < Test::Unit::TestCase
|
|||
"Jul" => 7, "Aug" => 8, "Sep" => 9, "Oct" => 10, "Nov" => 11, "Dec" => 12
|
||||
}
|
||||
|
||||
def test_zdump
|
||||
GENTESTNAME = "test_gen_0"
|
||||
def self.gen_test_name(hint)
|
||||
GENTESTNAME.succ!
|
||||
GENTESTNAME.sub(/gen_/) { "gen" + "_#{hint}_".gsub(/[^0-9A-Za-z]+/, '_') }
|
||||
end
|
||||
|
||||
def self.gen_zdump_test
|
||||
sample = []
|
||||
ZDUMP_SAMPLE.each_line {|line|
|
||||
next if /\A\#/ =~ line || /\A\s*\z/ =~ line
|
||||
|
@ -151,39 +162,53 @@ class TestTimeTZ < Test::Unit::TestCase
|
|||
gmtoff]
|
||||
}
|
||||
sample.each {|tz, u, l, gmtoff|
|
||||
with_tz(tz) {
|
||||
expected = "%04d-%02d-%02d %02d:%02d:%02d %s" % (l+[format_gmtoff(gmtoff)])
|
||||
mesg = "TZ=#{tz} Time.utc(#{u.map(&:inspect).join(', ')}).localtime"
|
||||
define_method(gen_test_name(tz)) {
|
||||
with_tz(tz) {
|
||||
t = nil
|
||||
assert_nothing_raised(mesg) { t = Time.utc(*u).localtime }
|
||||
assert_equal(expected, time_to_s(t), mesg)
|
||||
assert_equal(gmtoff, t.gmtoff)
|
||||
}
|
||||
}
|
||||
}
|
||||
sample.group_by {|tz, _, _, _| tz }.each {|tz, a|
|
||||
with_tz(tz) {
|
||||
a.each_with_index {|(_, u, l, gmtoff), i|
|
||||
expected = "%04d-%02d-%02d %02d:%02d:%02d %s" % (l+[format_gmtoff(gmtoff)])
|
||||
monotonic_to_past = i == 0 || (a[i-1][2] <=> l) < 0
|
||||
monotonic_to_future = i == a.length-1 || (l <=> a[i+1][2]) < 0
|
||||
if monotonic_to_past && monotonic_to_future
|
||||
define_method(gen_test_name(tz)) {
|
||||
with_tz(tz) {
|
||||
assert_time_constructor(tz, expected, :local, l)
|
||||
assert_time_constructor(tz, expected, :local, l.reverse+[nil, nil, false, nil])
|
||||
assert_time_constructor(tz, expected, :local, l.reverse+[nil, nil, true, nil])
|
||||
assert_time_constructor(tz, expected, :new, l)
|
||||
assert_time_constructor(tz, expected, :new, l+[:std])
|
||||
assert_time_constructor(tz, expected, :new, l+[:dst])
|
||||
}
|
||||
}
|
||||
elsif monotonic_to_past && !monotonic_to_future
|
||||
define_method(gen_test_name(tz)) {
|
||||
with_tz(tz) {
|
||||
assert_time_constructor(tz, expected, :local, l.reverse+[nil, nil, true, nil])
|
||||
assert_time_constructor(tz, expected, :new, l+[:dst])
|
||||
}
|
||||
}
|
||||
elsif !monotonic_to_past && monotonic_to_future
|
||||
define_method(gen_test_name(tz)) {
|
||||
with_tz(tz) {
|
||||
assert_time_constructor(tz, expected, :local, l.reverse+[nil, nil, false, nil])
|
||||
assert_time_constructor(tz, expected, :new, l+[:std])
|
||||
else
|
||||
flunk("time in reverse order: TZ=#{tz} #{expected}")
|
||||
end
|
||||
}
|
||||
}
|
||||
else
|
||||
define_method(gen_test_name(tz)) {
|
||||
flunk("time in reverse order: TZ=#{tz} #{expected}")
|
||||
}
|
||||
end
|
||||
}
|
||||
}
|
||||
end
|
||||
|
||||
|
@ -246,4 +271,5 @@ right/America/Los_Angeles Wed Dec 31 23:59:60 2008 UTC = Wed Dec 31 15:59:60 20
|
|||
right/Europe/Paris Fri Jun 30 23:59:60 1972 UTC = Sat Jul 1 00:59:60 1972 CET isdst=0 gmtoff=3600
|
||||
right/Europe/Paris Wed Dec 31 23:59:60 2008 UTC = Thu Jan 1 00:59:60 2009 CET isdst=0 gmtoff=3600
|
||||
End
|
||||
gen_zdump_test
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue