diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-11-28 14:08:35 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-11-28 14:08:35 +0000 |
commit | 4471d4a3e53b8d4171d62db8c6d84c20f9964519 (patch) | |
tree | adaf9b4d62805790d248909222b3d7f0eb2690b7 /test/ruby/test_time_tz.rb | |
parent | 2d0833e1017fbf5654425fe55e396fc5acc01f6b (diff) |
time.c: rescue find_timezone when loading
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66080 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby/test_time_tz.rb')
-rw-r--r-- | test/ruby/test_time_tz.rb | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/test/ruby/test_time_tz.rb b/test/ruby/test_time_tz.rb index ae655d98c0..8e60cf44c5 100644 --- a/test/ruby/test_time_tz.rb +++ b/test/ruby/test_time_tz.rb @@ -565,6 +565,26 @@ module TestTimeTZ::WithTZ assert_instance_of(t.zone.class, t2.zone) end + def test_invalid_zone + make_timezone("INVALID", "INV", 0) + rescue => e + assert_kind_of(StandardError, e) + else + assert false, "ArgumentError expected but nothing was raised." + end + + def nametest_marshal_compatibility(time_class, tzname, abbr, utc_offset) + data = [ + "\x04\x08Iu:".b, Marshal.dump(time_class)[3..-1], + "\x0d""\xEF\xA7\x1D\x80\x00\x00\x00\x00".b, + Marshal.dump({offset: utc_offset, zone: abbr})[3..-1], + ].join('') + t = Marshal.load(data) + assert_equal(utc_offset, t.utc_offset) + assert_equal(utc_offset, (t+1).utc_offset) + # t.zone may be a mere String or timezone object. + end + ZONES = { "Asia/Tokyo" => ["JST", +9*3600], "America/Los_Angeles" => ["PDT", -7*3600], @@ -586,6 +606,16 @@ module TestTimeTZ::WithTZ end end end + + instance_methods(false).grep(/\Aname(?=test_)/) do |subtest| + test = $' + ZONES.each_pair do |tzname, (abbr, utc_offset)| + define_method("#{test}@#{tzname}") do + time_class = self.class::TIME_CLASS + __send__(subtest, time_class, tzname, abbr, utc_offset) + end + end + end end class TestTimeTZ::DummyTZ < Test::Unit::TestCase @@ -632,7 +662,7 @@ else class TIME_CLASS < ::Time def self.find_timezone(name) - Timezone[name] + Timezone.fetch(name) end end |