diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-09-08 08:03:21 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-09-08 08:03:21 +0000 |
commit | 7a666d95f79e2a96e9e117c05f54ae7f85b10b9d (patch) | |
tree | eaabe594a9405463510722acd03f9f520cd9568e | |
parent | 2a0cca3c89f55912e7baea5137f550617e505c68 (diff) | |
download | ruby-7a666d95f79e2a96e9e117c05f54ae7f85b10b9d.tar.gz |
test_time_tz.rb: right timezone
* test/ruby/test_time_tz.rb (has_right_tz): check if right
timezones are installed.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47451 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | test/ruby/test_time_tz.rb | 33 |
1 files changed, 21 insertions, 12 deletions
diff --git a/test/ruby/test_time_tz.rb b/test/ruby/test_time_tz.rb index 87d68b9b69..70bacb15cd 100644 --- a/test/ruby/test_time_tz.rb +++ b/test/ruby/test_time_tz.rb @@ -6,33 +6,39 @@ class TestTimeTZ < Test::Unit::TestCase force_tz_test = ENV["RUBY_FORCE_TIME_TZ_TEST"] == "yes" case RUBY_PLATFORM when /linux/ - # has_right_tz = false force_tz_test = true when /darwin|freebsd/ - has_right_tz = false has_lisbon_tz = false force_tz_test = true end if force_tz_test - def with_tz(tz) - old = ENV["TZ"] - begin - ENV["TZ"] = tz - yield - ensure - ENV["TZ"] = old + module Util + def with_tz(tz) + old = ENV["TZ"] + begin + ENV["TZ"] = tz + yield + ensure + ENV["TZ"] = old + end end end else - def with_tz(tz) - if ENV["TZ"] == tz - yield + module Util + def with_tz(tz) + if ENV["TZ"] == tz + yield + end end end end module Util + def have_tz_offset(tz) + with_tz(tz) {!Time.now.utc_offset.zero?} + end + def format_gmtoff(gmtoff, colon=false) if gmtoff < 0 expected = "-" @@ -75,6 +81,9 @@ class TestTimeTZ < Test::Unit::TestCase include Util extend Util + has_right_tz &&= have_tz_offset("right/America/Los_Angeles") + has_lisbon_tz &&= have_tz_offset("Europe/Lisbon") + def time_to_s(t) t.to_s end |