From 87c8901d6915ecdb6d2807d770c13aa41719e875 Mon Sep 17 00:00:00 2001 From: nobu Date: Wed, 23 Jul 2014 07:20:38 +0000 Subject: [PATCH] test_time.rb: encoding of Time#zone * test/ruby/test_time.rb (assert_zone_encoding): encoding of Time#zone is not locale, but the default internal. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46906 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_time.rb | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/test/ruby/test_time.rb b/test/ruby/test_time.rb index cdce37f796..4ed899baf6 100644 --- a/test/ruby/test_time.rb +++ b/test/ruby/test_time.rb @@ -517,8 +517,15 @@ class TestTime < Test::Unit::TestCase assert_equal(Time.at(946684800).getlocal.to_s, Time.at(946684800).to_s) end + def assert_zone_encoding(time) + zone = time.zone + assert_predicate(zone, :valid_encoding?) + enc = Encoding.default_internal || Encoding.find('locale') + assert_equal(enc, zone.encoding) + end + def test_zone - assert_equal(Encoding.find('locale'), Time.now.zone.encoding) + assert_zone_encoding Time.now end def test_plus_minus_succ @@ -567,7 +574,7 @@ class TestTime < Test::Unit::TestCase assert_equal(1, t2000.yday) assert_equal(false, t2000.isdst) assert_equal("UTC", t2000.zone) - assert_equal(Encoding.find("locale"), t2000.zone.encoding) + assert_zone_encoding(t2000) assert_equal(0, t2000.gmt_offset) assert_not_predicate(t2000, :sunday?) assert_not_predicate(t2000, :monday?) @@ -589,7 +596,7 @@ class TestTime < Test::Unit::TestCase assert_equal(t.yday, Time.at(946684800).yday) assert_equal(t.isdst, Time.at(946684800).isdst) assert_equal(t.zone, Time.at(946684800).zone) - assert_equal(Encoding.find("locale"), Time.at(946684800).zone.encoding) + assert_zone_encoding(Time.at(946684800)) assert_equal(t.gmt_offset, Time.at(946684800).gmt_offset) assert_equal(t.sunday?, Time.at(946684800).sunday?) assert_equal(t.monday?, Time.at(946684800).monday?)